From d8f95646cbc3ce8c29373f980b24d9bc131910e5 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Wed, 27 Jul 2022 15:14:12 +0300 Subject: [PATCH] *: use (*VM).IstackLen() where appropriate --- pkg/compiler/vm_test.go | 2 +- pkg/core/interop/contract/call.go | 4 ++-- pkg/core/interop/runtime/engine.go | 2 +- pkg/vm/invocation_tree_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/compiler/vm_test.go b/pkg/compiler/vm_test.go index af908da614..d5b8e738ec 100644 --- a/pkg/compiler/vm_test.go +++ b/pkg/compiler/vm_test.go @@ -57,7 +57,7 @@ func evalWithArgs(t *testing.T, src string, op []byte, args []stackitem.Item, re func assertResult(t *testing.T, vm *vm.VM, result interface{}) { assert.Equal(t, result, vm.PopResult()) - assert.Equal(t, 0, vm.Istack().Len()) + assert.Equal(t, 0, vm.IstackLen()) } func vmAndCompile(t *testing.T, src string) *vm.VM { diff --git a/pkg/core/interop/contract/call.go b/pkg/core/interop/contract/call.go index 3f47fd5ca1..13864bdbe9 100644 --- a/pkg/core/interop/contract/call.go +++ b/pkg/core/interop/contract/call.go @@ -157,12 +157,12 @@ var ErrNativeCall = errors.New("failed native call") // CallFromNative performs synchronous call from native contract. func CallFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contract, method string, args []stackitem.Item, hasReturn bool) error { - startSize := ic.VM.Istack().Len() + startSize := ic.VM.IstackLen() if err := callExFromNative(ic, caller, cs, method, args, callflag.All, hasReturn, false, true); err != nil { return err } - for !ic.VM.HasStopped() && ic.VM.Istack().Len() > startSize { + for !ic.VM.HasStopped() && ic.VM.IstackLen() > startSize { if err := ic.VM.Step(); err != nil { return fmt.Errorf("%w: %v", ErrNativeCall, err) } diff --git a/pkg/core/interop/runtime/engine.go b/pkg/core/interop/runtime/engine.go index 81dae7a2c0..5f4c110d63 100644 --- a/pkg/core/interop/runtime/engine.go +++ b/pkg/core/interop/runtime/engine.go @@ -38,7 +38,7 @@ func GetCallingScriptHash(ic *interop.Context) error { // GetEntryScriptHash returns entry script hash. func GetEntryScriptHash(ic *interop.Context) error { - return ic.VM.PushContextScriptHash(ic.VM.Istack().Len() - 1) + return ic.VM.PushContextScriptHash(ic.VM.IstackLen() - 1) } // GetScriptContainer returns transaction or block that contains the script diff --git a/pkg/vm/invocation_tree_test.go b/pkg/vm/invocation_tree_test.go index b3f3896c71..b3ce8a26cf 100644 --- a/pkg/vm/invocation_tree_test.go +++ b/pkg/vm/invocation_tree_test.go @@ -24,7 +24,7 @@ func TestInvocationTree(t *testing.T) { cnt := 0 v := newTestVM() v.SyscallHandler = func(v *VM, _ uint32) error { - if v.Istack().Len() > 4 { // top -> call -> syscall -> call -> syscall -> ... + if v.IstackLen() > 4 { // top -> call -> syscall -> call -> syscall -> ... v.Estack().PushVal(1) return nil }