From 4587121c7fdf0e732956e6b7b56d8b9384b81be3 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 9 Mar 2020 14:18:00 +0300 Subject: [PATCH 1/2] core: fix error propagation in contract-related interops Obvious bug that hides failed contract deployments. --- pkg/core/interop_neo.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index 7140b1fa2..4696ffdd7 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -515,7 +515,7 @@ func (ic *interopContext) createContractStateFromVM(v *vm.VM) (*state.Contract, func (ic *interopContext) contractCreate(v *vm.VM) error { newcontract, err := ic.createContractStateFromVM(v) if err != nil { - return nil + return err } contract, err := ic.dao.GetContractState(newcontract.ScriptHash()) if err != nil { @@ -555,7 +555,7 @@ func (ic *interopContext) contractIsPayable(v *vm.VM) error { func (ic *interopContext) contractMigrate(v *vm.VM) error { newcontract, err := ic.createContractStateFromVM(v) if err != nil { - return nil + return err } contract, err := ic.dao.GetContractState(newcontract.ScriptHash()) if err != nil { From eb404ceae35cd51615712d6c32e5df775c3b286b Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 9 Mar 2020 14:18:51 +0300 Subject: [PATCH 2/2] core: fix max contract description limit check It differs from other parameters in C# code. Fixes #735. --- pkg/core/interop_neo.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/core/interop_neo.go b/pkg/core/interop_neo.go index 4696ffdd7..9dacb49be 100644 --- a/pkg/core/interop_neo.go +++ b/pkg/core/interop_neo.go @@ -17,6 +17,8 @@ import ( ) const ( + // MaxContractDescriptionLen is the maximum length for contract description. + MaxContractDescriptionLen = 65536 // MaxContractScriptSize is the maximum script size for a contract. MaxContractScriptSize = 1024 * 1024 // MaxContractParametersNum is the maximum number of parameters for a contract. @@ -494,7 +496,7 @@ func (ic *interopContext) createContractStateFromVM(v *vm.VM) (*state.Contract, return nil, errors.New("too big email") } desc := v.Estack().Pop().Bytes() - if len(desc) > MaxContractStringLen { + if len(desc) > MaxContractDescriptionLen { return nil, errors.New("too big description") } contract := &state.Contract{