From 765235eca3dcd1d1986e694b04dc877b12588d36 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 19 Nov 2021 17:15:30 +0300 Subject: [PATCH] vm: omit context parameter from Call() It's not used and should not be used to switch from contract to contract. --- pkg/compiler/vm_test.go | 2 +- pkg/core/blockchain.go | 2 +- pkg/core/interop/contract/call.go | 2 +- pkg/vm/cli/cli.go | 2 +- pkg/vm/vm.go | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/compiler/vm_test.go b/pkg/compiler/vm_test.go index 59cdae635..03f8655e0 100644 --- a/pkg/compiler/vm_test.go +++ b/pkg/compiler/vm_test.go @@ -89,7 +89,7 @@ func invokeMethod(t *testing.T, method string, script []byte, v *vm.VM, di *comp v.LoadScriptWithFlags(script, callflag.All) v.Context().Jump(mainOffset) if initOffset >= 0 { - v.Call(v.Context(), initOffset) + v.Call(initOffset) } } diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index c32529dcd..6e8541f73 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -2191,7 +2191,7 @@ func (bc *Blockchain) InitVerificationVM(v *vm.VM, getContract func(util.Uint160 v.Context().Jump(md.Offset) if initMD != nil { - v.Call(v.Context(), initMD.Offset) + v.Call(initMD.Offset) } } if len(witness.InvocationScript) != 0 { diff --git a/pkg/core/interop/contract/call.go b/pkg/core/interop/contract/call.go index f6933c1f9..5da37e97b 100644 --- a/pkg/core/interop/contract/call.go +++ b/pkg/core/interop/contract/call.go @@ -123,7 +123,7 @@ func callExFromNative(ic *interop.Context, caller util.Uint160, cs *state.Contra md = cs.Manifest.ABI.GetMethod(manifest.MethodInit, 0) if md != nil { - ic.VM.Call(ic.VM.Context(), md.Offset) + ic.VM.Call(md.Offset) } return nil diff --git a/pkg/vm/cli/cli.go b/pkg/vm/cli/cli.go index 05db4d4ef..c3b39e02a 100644 --- a/pkg/vm/cli/cli.go +++ b/pkg/vm/cli/cli.go @@ -460,7 +460,7 @@ func handleRun(c *ishell.Context) { } v.Context().Jump(offset) if initMD := m.ABI.GetMethod(manifest.MethodInit, 0); initMD != nil { - v.Call(v.Context(), initMD.Offset) + v.Call(initMD.Offset) } } } diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 84bb6ada0..246e87554 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -1557,8 +1557,8 @@ func (v *VM) throw(item stackitem.Item) { } // Call calls method by offset using new execution context. -func (v *VM) Call(ctx *Context, offset int) { - v.call(ctx, offset) +func (v *VM) Call(offset int) { + v.call(v.Context(), offset) } // call is an internal representation of Call, which does not