From 762a8da76a7f387adb639d9b4d125e126e322634 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 4 Jul 2023 12:51:41 +0300 Subject: [PATCH 1/2] core: remove contract script check on deploy/update This check is good and was present here since #1729, but it was accidently removed from the reference implementation (see the discussion in https://github.com/neo-project/neo/issues/2848). The removal of this check from the C# node leaded to the T5 testnet state diff since 1670095 heigh which causes inability to process new blocks since 2272533 height (see #3049). This check was added back to the C# node in https://github.com/neo-project/neo/pull/2849, but it is planned to be the part of the upcoming 3.6.0 C# node release. We need to keep our testnet healthy, thus, strict contract script check will be temporary removed from the node code and is planned to be added back to be a part of the next 3.6.0-compatible release. Close #3049. Signed-off-by: Anna Shaleva --- pkg/core/native/management.go | 6 +----- pkg/core/native/native_test/management_test.go | 11 ----------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/pkg/core/native/management.go b/pkg/core/native/management.go index c56159398..889ceab9c 100644 --- a/pkg/core/native/management.go +++ b/pkg/core/native/management.go @@ -23,8 +23,6 @@ import ( "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" "github.com/nspcc-dev/neo-go/pkg/smartcontract/nef" "github.com/nspcc-dev/neo-go/pkg/util" - "github.com/nspcc-dev/neo-go/pkg/util/bitfield" - "github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm/stackitem" ) @@ -719,12 +717,10 @@ func (m *Management) emitNotification(ic *interop.Context, name string, hash uti func checkScriptAndMethods(script []byte, methods []manifest.Method) error { l := len(script) - offsets := bitfield.New(l) for i := range methods { if methods[i].Offset >= l { return fmt.Errorf("method %s/%d: offset is out of the script range", methods[i].Name, len(methods[i].Parameters)) } - offsets.Set(methods[i].Offset) } - return vm.IsScriptCorrect(script, offsets) + return nil } diff --git a/pkg/core/native/native_test/management_test.go b/pkg/core/native/native_test/management_test.go index dd5535cdb..f5af18246 100644 --- a/pkg/core/native/native_test/management_test.go +++ b/pkg/core/native/native_test/management_test.go @@ -143,17 +143,6 @@ func TestManagement_ContractDeploy(t *testing.T) { managementInvoker.InvokeFail(t, "method add/2: offset is out of the script range", "deploy", nefBytes, manifB) }) - t.Run("bad methods in manifest 2", func(t *testing.T) { - var badManifest = cs1.Manifest - badManifest.ABI.Methods = make([]manifest.Method, len(cs1.Manifest.ABI.Methods)) - copy(badManifest.ABI.Methods, cs1.Manifest.ABI.Methods) - badManifest.ABI.Methods[0].Offset = len(cs1.NEF.Script) - 2 // Ends with `CALLT(X,X);RET`. - - manifB, err := json.Marshal(badManifest) - require.NoError(t, err) - - managementInvoker.InvokeFail(t, "some methods point to wrong offsets (not to instruction boundary)", "deploy", nefBytes, manifB) - }) t.Run("duplicated methods in manifest 1", func(t *testing.T) { badManifest := cs1.Manifest badManifest.ABI.Methods = make([]manifest.Method, len(cs1.Manifest.ABI.Methods)) From 146775213a4883871ff8363dee7492686dcb90b2 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Tue, 4 Jul 2023 14:29:08 +0300 Subject: [PATCH 2/2] CHANGELOG: release 0.101.3 Signed-off-by: Anna Shaleva --- CHANGELOG.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51f514767..4e0d49bb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,27 @@ This document outlines major changes between releases. +## 0.101.3 "Yuckiness" (08 Jul 2023) + +Yet another 3.5.0-compatible emergency version that removes scrupulous +instructions check of smart contract's script on contract deployment or update. +Presence of this check leads to the known T5 testnet state incompatibility +(since 1670095) which causes inability to process new blocks (since 2272533). +It should be noted that the corresponding check was accidentally removed from +the reference C# node implementation way back in neo-project/neo#2266 and added +again in neo-project/neo#2849 which is planned to be a part of the upcoming +3.6.0 C# node release. Thus, changes made in the presented 0.101.3 release will +be reverted afterwards and strict contract script check will be present in the +next 3.6.0-compatible version of NeoGo node. + +T5 testnet chain requires a complete resynchronization for this version. Mainnet +chain resynchronization is recommended. + +Bugs fixed: + + * extra strict contract script check on contract deployment or update is + removed (#3052) + ## 0.101.2 "Excavation" (29 Jun 2023) One more (and unexpected one!) 3.5.0-compatible version that fixes a VM bug