neo-go/pkg/core/opcode_price.go

202 lines
5.1 KiB
Go
Raw Normal View History

package core
import (
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
)
// opcodePrice returns the deployment prices of specified opcodes
func opcodePrice(opcodes ...opcode.Opcode) int64 {
var result int64
for _, op := range opcodes {
result += prices[op]
}
return result
}
var prices = map[opcode.Opcode]int64{
opcode.PUSHINT8: 30,
opcode.PUSHINT32: 30,
opcode.PUSHINT64: 30,
opcode.PUSHINT16: 30,
opcode.PUSHINT128: 120,
opcode.PUSHINT256: 120,
opcode.PUSHA: 120,
opcode.PUSHNULL: 30,
opcode.PUSHDATA1: 180,
opcode.PUSHDATA2: 13000,
opcode.PUSHDATA4: 110000,
opcode.PUSHM1: 30,
opcode.PUSH0: 30,
opcode.PUSH1: 30,
opcode.PUSH2: 30,
opcode.PUSH3: 30,
opcode.PUSH4: 30,
opcode.PUSH5: 30,
opcode.PUSH6: 30,
opcode.PUSH7: 30,
opcode.PUSH8: 30,
opcode.PUSH9: 30,
opcode.PUSH10: 30,
opcode.PUSH11: 30,
opcode.PUSH12: 30,
opcode.PUSH13: 30,
opcode.PUSH14: 30,
opcode.PUSH15: 30,
opcode.PUSH16: 30,
opcode.NOP: 30,
opcode.JMP: 70,
opcode.JMPL: 70,
opcode.JMPIF: 70,
opcode.JMPIFL: 70,
opcode.JMPIFNOT: 70,
opcode.JMPIFNOTL: 70,
opcode.JMPEQ: 70,
opcode.JMPEQL: 70,
opcode.JMPNE: 70,
opcode.JMPNEL: 70,
opcode.JMPGT: 70,
opcode.JMPGTL: 70,
opcode.JMPGE: 70,
opcode.JMPGEL: 70,
opcode.JMPLT: 70,
opcode.JMPLTL: 70,
opcode.JMPLE: 70,
opcode.JMPLEL: 70,
opcode.CALL: 22000,
opcode.CALLL: 22000,
opcode.CALLA: 22000,
opcode.ABORT: 30,
opcode.ASSERT: 30,
opcode.THROW: 22000,
opcode.TRY: 100,
opcode.TRYL: 100,
opcode.ENDTRY: 100,
opcode.ENDTRYL: 100,
opcode.ENDFINALLY: 100,
opcode.RET: 0,
opcode.SYSCALL: 0,
opcode.DEPTH: 60,
opcode.DROP: 60,
opcode.NIP: 60,
opcode.XDROP: 400,
opcode.CLEAR: 400,
opcode.DUP: 60,
opcode.OVER: 60,
opcode.PICK: 60,
opcode.TUCK: 60,
opcode.SWAP: 60,
opcode.ROT: 60,
opcode.ROLL: 400,
opcode.REVERSE3: 60,
opcode.REVERSE4: 60,
opcode.REVERSEN: 400,
opcode.INITSSLOT: 400,
opcode.INITSLOT: 800,
opcode.LDSFLD0: 60,
opcode.LDSFLD1: 60,
opcode.LDSFLD2: 60,
opcode.LDSFLD3: 60,
opcode.LDSFLD4: 60,
opcode.LDSFLD5: 60,
opcode.LDSFLD6: 60,
opcode.LDSFLD: 60,
opcode.STSFLD0: 60,
opcode.STSFLD1: 60,
opcode.STSFLD2: 60,
opcode.STSFLD3: 60,
opcode.STSFLD4: 60,
opcode.STSFLD5: 60,
opcode.STSFLD6: 60,
opcode.STSFLD: 60,
opcode.LDLOC0: 60,
opcode.LDLOC1: 60,
opcode.LDLOC2: 60,
opcode.LDLOC3: 60,
opcode.LDLOC4: 60,
opcode.LDLOC5: 60,
opcode.LDLOC6: 60,
opcode.LDLOC: 60,
opcode.STLOC0: 60,
opcode.STLOC1: 60,
opcode.STLOC2: 60,
opcode.STLOC3: 60,
opcode.STLOC4: 60,
opcode.STLOC5: 60,
opcode.STLOC6: 60,
opcode.STLOC: 60,
opcode.LDARG0: 60,
opcode.LDARG1: 60,
opcode.LDARG2: 60,
opcode.LDARG3: 60,
opcode.LDARG4: 60,
opcode.LDARG5: 60,
opcode.LDARG6: 60,
opcode.LDARG: 60,
opcode.STARG0: 60,
opcode.STARG1: 60,
opcode.STARG2: 60,
opcode.STARG3: 60,
opcode.STARG4: 60,
opcode.STARG5: 60,
opcode.STARG6: 60,
opcode.STARG: 60,
opcode.NEWBUFFER: 80000,
opcode.MEMCPY: 80000,
opcode.CAT: 80000,
opcode.SUBSTR: 80000,
opcode.LEFT: 80000,
opcode.RIGHT: 80000,
opcode.INVERT: 100,
opcode.AND: 200,
opcode.OR: 200,
opcode.XOR: 200,
opcode.EQUAL: 200,
opcode.NOTEQUAL: 200,
opcode.SIGN: 100,
opcode.ABS: 100,
opcode.NEGATE: 100,
opcode.INC: 100,
opcode.DEC: 100,
opcode.ADD: 200,
opcode.SUB: 200,
opcode.MUL: 300,
opcode.DIV: 300,
opcode.MOD: 300,
opcode.SHL: 300,
opcode.SHR: 300,
opcode.NOT: 100,
opcode.BOOLAND: 200,
opcode.BOOLOR: 200,
opcode.NZ: 100,
opcode.NUMEQUAL: 200,
opcode.NUMNOTEQUAL: 200,
opcode.LT: 200,
opcode.LTE: 200,
opcode.GT: 200,
opcode.GTE: 200,
opcode.MIN: 200,
opcode.MAX: 200,
opcode.WITHIN: 200,
opcode.PACK: 7000,
opcode.UNPACK: 7000,
opcode.NEWARRAY0: 400,
opcode.NEWARRAY: 15000,
opcode.NEWARRAYT: 15000,
opcode.NEWSTRUCT0: 400,
opcode.NEWSTRUCT: 15000,
opcode.NEWMAP: 200,
opcode.SIZE: 150,
opcode.HASKEY: 270000,
opcode.KEYS: 500,
opcode.VALUES: 7000,
opcode.PICKITEM: 270000,
opcode.APPEND: 15000,
opcode.SETITEM: 270000,
opcode.REVERSEITEMS: 500,
opcode.REMOVE: 500,
opcode.CLEARITEMS: 400,
opcode.ISNULL: 60,
opcode.ISTYPE: 60,
opcode.CONVERT: 80000,
}