core: store precise gas price in interop descriptions

In NEO3 sycalls can have prices less than 10^5, we need to store them
precisely. Adjusting actual prices is to be done in the following tasks.
This commit is contained in:
Evgenii Stratonikov 2020-06-15 11:53:40 +03:00
parent fd2cd291e7
commit 61bba1a39c

View file

@ -6,11 +6,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/vm/opcode" "github.com/nspcc-dev/neo-go/pkg/vm/opcode"
) )
// interopGasRatio is a multiplier by which a number returned from price getter
// and Fixed8 amount of GAS differ. Numbers defined in syscall tables are a multiple
// of 0.001 GAS = Fixed8(10^5).
const interopGasRatio = 100000
// StoragePrice is a price for storing 1 byte of storage. // StoragePrice is a price for storing 1 byte of storage.
const StoragePrice = 100000 const StoragePrice = 100000
@ -21,12 +16,8 @@ func getPrice(v *vm.VM, op opcode.Opcode, parameter []byte) util.Fixed8 {
interopID := vm.GetInteropID(parameter) interopID := vm.GetInteropID(parameter)
ifunc := v.GetInteropByID(interopID) ifunc := v.GetInteropByID(interopID)
if ifunc != nil && ifunc.Price > 0 { if ifunc != nil && ifunc.Price > 0 {
return toFixed8(int64(ifunc.Price)) return util.Fixed8(ifunc.Price)
} }
} }
return opcodePrice(op) return opcodePrice(op)
} }
func toFixed8(n int64) util.Fixed8 {
return util.Fixed8(n * interopGasRatio)
}