From 5514b3f52f77f9727e565ddc0f591af673a005f7 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 9 Jun 2020 16:16:32 +0300 Subject: [PATCH] smartcontract,vm: remove DynamicInvoke feature It doesn't exist in NEO3. --- pkg/core/interop/context.go | 6 +++--- pkg/core/interop_system.go | 2 +- pkg/core/state/contract.go | 5 ----- pkg/smartcontract/parameter.go | 7 +++---- pkg/vm/context.go | 3 --- pkg/vm/vm.go | 10 ---------- 6 files changed, 7 insertions(+), 26 deletions(-) diff --git a/pkg/core/interop/context.go b/pkg/core/interop/context.go index 026045baa..0fdd8cb57 100644 --- a/pkg/core/interop/context.go +++ b/pkg/core/interop/context.go @@ -89,12 +89,12 @@ type ContractMD struct { } // GetContract returns script of the contract with the specified hash. -func (ic *Context) GetContract(h util.Uint160) ([]byte, bool) { +func (ic *Context) GetContract(h util.Uint160) []byte { cs, err := ic.DAO.GetContractState(h) if err != nil { - return nil, false + return nil } - return cs.Script, cs.HasDynamicInvoke() + return cs.Script } // NewContractMD returns Contract with the specified list of methods. diff --git a/pkg/core/interop_system.go b/pkg/core/interop_system.go index 2c4f6335e..5e8435ce1 100644 --- a/pkg/core/interop_system.go +++ b/pkg/core/interop_system.go @@ -484,7 +484,7 @@ func contractCallExInternal(ic *interop.Context, v *vm.VM, h []byte, method stac if err != nil { return errors.New("invalid contract hash") } - script, _ := ic.GetContract(u) + script := ic.GetContract(u) if script == nil { return errors.New("contract not found") } diff --git a/pkg/core/state/contract.go b/pkg/core/state/contract.go index 86e9a231d..227b13ab7 100644 --- a/pkg/core/state/contract.go +++ b/pkg/core/state/contract.go @@ -53,11 +53,6 @@ func (cs *Contract) HasStorage() bool { return (cs.Manifest.Features & smartcontract.HasStorage) != 0 } -// HasDynamicInvoke checks whether the contract has dynamic invoke property set. -func (cs *Contract) HasDynamicInvoke() bool { - return (cs.Manifest.Features & smartcontract.HasDynamicInvoke) != 0 -} - // IsPayable checks whether the contract has payable property set. func (cs *Contract) IsPayable() bool { return (cs.Manifest.Features & smartcontract.IsPayable) != 0 diff --git a/pkg/smartcontract/parameter.go b/pkg/smartcontract/parameter.go index 303d47af8..4242cb08a 100644 --- a/pkg/smartcontract/parameter.go +++ b/pkg/smartcontract/parameter.go @@ -22,10 +22,9 @@ type PropertyState byte // List of supported properties. const ( - HasStorage PropertyState = 1 << iota - HasDynamicInvoke - IsPayable - NoProperties = 0 + HasStorage PropertyState = 1 << iota + IsPayable PropertyState = 1 << 2 + NoProperties = 0 ) // Parameter represents a smart contract parameter. diff --git a/pkg/vm/context.go b/pkg/vm/context.go index a32942893..83e385d19 100644 --- a/pkg/vm/context.go +++ b/pkg/vm/context.go @@ -39,9 +39,6 @@ type Context struct { // Script hash of the prog. scriptHash util.Uint160 - - // Whether it's allowed to make dynamic calls from this context. - hasDynamicInvoke bool } var errNoInstParam = errors.New("failed to read instruction parameter") diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 3f933595f..7503e5869 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -268,16 +268,6 @@ func (v *VM) LoadScript(b []byte) { v.istack.PushVal(ctx) } -// loadScriptWithHash if similar to the LoadScript method, but it also loads -// given script hash directly into the Context to avoid its recalculations. It's -// up to user of this function to make sure the script and hash match each other. -func (v *VM) loadScriptWithHash(b []byte, hash util.Uint160, hasDynamicInvoke bool) { - v.LoadScript(b) - ctx := v.Context() - ctx.scriptHash = hash - ctx.hasDynamicInvoke = hasDynamicInvoke -} - // Context returns the current executed context. Nil if there is no context, // which implies no program is loaded. func (v *VM) Context() *Context {