diff --git a/pkg/core/bench_test.go b/pkg/core/bench_test.go new file mode 100644 index 000000000..24beadb32 --- /dev/null +++ b/pkg/core/bench_test.go @@ -0,0 +1,24 @@ +package core + +import ( + "testing" + + "github.com/nspcc-dev/neo-go/pkg/config/netmode" + "github.com/nspcc-dev/neo-go/pkg/vm/opcode" + "github.com/nspcc-dev/neo-go/pkg/wallet" + "github.com/stretchr/testify/require" +) + +func BenchmarkVerifyWitness(t *testing.B) { + bc := newTestChain(t) + acc, err := wallet.NewAccount() + require.NoError(t, err) + + tx := bc.newTestTx(acc.Contract.ScriptHash(), []byte{byte(opcode.PUSH1)}) + require.NoError(t, acc.SignTx(netmode.UnitTestNet, tx)) + + t.ResetTimer() + for n := 0; n < t.N; n++ { + _ = bc.VerifyWitness(tx.Signers[0].Account, tx, &tx.Scripts[0], 100000000) + } +} diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 00a7f58be..f9e9f3072 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1837,7 +1837,7 @@ func (bc *Blockchain) InitVerificationVM(v *vm.VM, getContract func(util.Uint160 if err != nil { return fmt.Errorf("%w: %v", ErrInvalidVerification, err) } - v.LoadScriptWithFlags(witness.VerificationScript, callflag.ReadOnly) + v.LoadScriptWithHash(witness.VerificationScript, hash, callflag.ReadOnly) } else { cs, err := getContract(hash) if err != nil {