From b51eb7f5efc89b9c0cdea177ce4ca10a782a7e19 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Thu, 12 Nov 2020 14:20:26 +0300 Subject: [PATCH] core: update opcodes prices Changes ported from https://github.com/neo-project/neo/pull/2020. --- pkg/core/fee/opcode.go | 16 ++++++++-------- pkg/core/native_contract_test.go | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/core/fee/opcode.go b/pkg/core/fee/opcode.go index 27fa8b745..af8604993 100644 --- a/pkg/core/fee/opcode.go +++ b/pkg/core/fee/opcode.go @@ -89,7 +89,7 @@ var prices = map[opcode.Opcode]int64{ opcode.REVERSE4: 60, opcode.REVERSEN: 400, opcode.INITSSLOT: 400, - opcode.INITSLOT: 800, + opcode.INITSLOT: 1600, opcode.LDSFLD0: 60, opcode.LDSFLD1: 60, opcode.LDSFLD2: 60, @@ -148,8 +148,8 @@ var prices = map[opcode.Opcode]int64{ opcode.AND: 200, opcode.OR: 200, opcode.XOR: 200, - opcode.EQUAL: 200, - opcode.NOTEQUAL: 200, + opcode.EQUAL: 1000, + opcode.NOTEQUAL: 1000, opcode.SIGN: 100, opcode.ABS: 100, opcode.NEGATE: 100, @@ -175,8 +175,8 @@ var prices = map[opcode.Opcode]int64{ opcode.MIN: 200, opcode.MAX: 200, opcode.WITHIN: 200, - opcode.PACK: 7000, - opcode.UNPACK: 7000, + opcode.PACK: 15000, + opcode.UNPACK: 15000, opcode.NEWARRAY0: 400, opcode.NEWARRAY: 15000, opcode.NEWARRAYT: 15000, @@ -186,11 +186,11 @@ var prices = map[opcode.Opcode]int64{ opcode.SIZE: 150, opcode.HASKEY: 270000, opcode.KEYS: 500, - opcode.VALUES: 7000, + opcode.VALUES: 270000, opcode.PICKITEM: 270000, - opcode.APPEND: 15000, + opcode.APPEND: 270000, opcode.SETITEM: 270000, - opcode.REVERSEITEMS: 500, + opcode.REVERSEITEMS: 270000, opcode.REMOVE: 500, opcode.CLEARITEMS: 400, opcode.ISNULL: 60, diff --git a/pkg/core/native_contract_test.go b/pkg/core/native_contract_test.go index 2858bff41..554c74d14 100644 --- a/pkg/core/native_contract_test.go +++ b/pkg/core/native_contract_test.go @@ -175,15 +175,15 @@ func TestNativeContract_Invoke(t *testing.T) { w := io.NewBufBinWriter() emit.AppCallWithOperationAndArgs(w.BinWriter, tn.Metadata().Hash, "sum", int64(14), int64(28)) script := w.Bytes() - // System.Contract.Call + "sum" itself + opcodes for pushing arguments (PACK is 7000) - tx := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2+10000) + // System.Contract.Call + "sum" itself + opcodes for pushing arguments (PACK is 15000) + tx := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2+18000) validUntil := chain.blockHeight + 1 tx.ValidUntilBlock = validUntil addSigners(tx) require.NoError(t, signTx(chain, tx)) // Enough for Call and other opcodes, but not enough for "sum" call. - tx2 := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2) + tx2 := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2+8000) tx2.ValidUntilBlock = chain.blockHeight + 1 addSigners(tx2) require.NoError(t, signTx(chain, tx2)) @@ -290,7 +290,7 @@ func TestNativeContract_InvokeOtherContract(t *testing.T) { emit.AppCallWithOperationAndArgs(w.BinWriter, tn.Metadata().Hash, "callOtherContractWithArg", chain.contracts.Policy.Hash, "setFeePerByte", int64(500)) require.NoError(t, w.Err) script := w.Bytes() - tx := transaction.New(chain.GetConfig().Magic, script, testSumPrice*5+10000) + tx := transaction.New(chain.GetConfig().Magic, script, testSumPrice*5+18000) validUntil := chain.blockHeight + 1 tx.ValidUntilBlock = validUntil addSigners(tx) @@ -368,7 +368,7 @@ func TestAllContractsHaveName(t *testing.T) { emit.AppCallWithOperationAndArgs(w.BinWriter, c.Metadata().Hash, "name") require.NoError(t, w.Err) - tx := transaction.New(netmode.UnitTestNet, w.Bytes(), 1007570) + tx := transaction.New(netmode.UnitTestNet, w.Bytes(), 1015570) tx.ValidUntilBlock = bc.blockHeight + 1 addSigners(tx) require.NoError(t, signTx(bc, tx))