From 6e9c770142d6847d886e45ad05ac8924aeff785f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 7 Nov 2023 14:55:02 +0300 Subject: [PATCH] [#50] Drop notaryless deploy parameter Signed-off-by: Evgenii Stratonikov --- alphabet/alphabet_contract.go | 16 +++++----------- audit/audit_contract.go | 8 +------- balance/balance_contract.go | 9 ++------- common/common.go | 15 --------------- container/container_contract.go | 15 +++++---------- frostfs/frostfs_contract.go | 15 +++++---------- frostfsid/frostfsid_contract.go | 9 ++------- netmap/netmap_contract.go | 17 ++++++----------- reputation/reputation_contract.go | 3 --- tests/alphabet_test.go | 13 ++++++------- tests/balance_test.go | 5 ++--- tests/container_test.go | 13 ++++++------- tests/frostfs_test.go | 9 ++++----- tests/frostfsid_test.go | 7 +++---- tests/netmap_test.go | 11 +++++------ tests/reputation_test.go | 5 +---- 16 files changed, 53 insertions(+), 117 deletions(-) diff --git a/alphabet/alphabet_contract.go b/alphabet/alphabet_contract.go index 5a24a71..c8530b3 100644 --- a/alphabet/alphabet_contract.go +++ b/alphabet/alphabet_contract.go @@ -18,8 +18,6 @@ const ( indexKey = "index" totalKey = "threshold" nameKey = "name" - - notaryDisabledKey = "notary" ) // OnNEP17Payment is a callback for NEP-17 compatible native GAS and NEO @@ -34,8 +32,6 @@ func OnNEP17Payment(from interop.Hash160, amount int, data interface{}) { func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -43,13 +39,11 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrNetmap interop.Hash160 - addrProxy interop.Hash160 - name string - index int - total int + addrNetmap interop.Hash160 + addrProxy interop.Hash160 + name string + index int + total int }) if len(args.addrNetmap) != interop.Hash160Len || len(args.addrProxy) != interop.Hash160Len { diff --git a/audit/audit_contract.go b/audit/audit_contract.go index 0dc8b2e..d405195 100644 --- a/audit/audit_contract.go +++ b/audit/audit_contract.go @@ -37,15 +37,11 @@ func (a auditHeader) ID() []byte { const ( netmapContractKey = "netmapScriptHash" - - notaryDisabledKey = "notary" ) func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -53,9 +49,7 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrNetmap interop.Hash160 + addrNetmap interop.Hash160 }) if len(args.addrNetmap) != interop.Hash160Len { diff --git a/balance/balance_contract.go b/balance/balance_contract.go index 2c5e9aa..2a9ba02 100644 --- a/balance/balance_contract.go +++ b/balance/balance_contract.go @@ -47,7 +47,6 @@ const ( netmapContractKey = "netmapScriptHash" containerContractKey = "containerScriptHash" - notaryDisabledKey = "notary" ) var token Token @@ -67,8 +66,6 @@ func init() { func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -76,10 +73,8 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - // TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrNetmap interop.Hash160 - addrContainer interop.Hash160 + addrNetmap interop.Hash160 + addrContainer interop.Hash160 }) if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len { diff --git a/common/common.go b/common/common.go index a8cf9c2..a52f749 100644 --- a/common/common.go +++ b/common/common.go @@ -1,26 +1,11 @@ package common import ( - "github.com/nspcc-dev/neo-go/pkg/interop/storage" "github.com/nspcc-dev/neo-go/pkg/interop/util" ) -const ( - panicMsgForNotaryDisabledEnv = "contract not applicable for notary-disabled environment" -) - // BytesEqual compares two slices of bytes by wrapping them into strings, // which is necessary with new util.Equals interop behaviour, see neo-go#1176. func BytesEqual(a []byte, b []byte) bool { return util.Equals(string(a), string(b)) } - -// RmAndCheckNotaryDisabledKey remove notary disabled key from storage and -// panic in notary disabled environment -func RmAndCheckNotaryDisabledKey(data interface{}, key interface{}) { - //TODO(@acid-ant): #9 remove notaryDisabled from args in future version - storage.Delete(storage.GetContext(), key) - if data.([]interface{})[0].(bool) { - panic(panicMsgForNotaryDisabledEnv) - } -} diff --git a/container/container_contract.go b/container/container_contract.go index f45c1c9..cee3d36 100644 --- a/container/container_contract.go +++ b/container/container_contract.go @@ -50,7 +50,6 @@ const ( nnsContractKey = "nnsScriptHash" nnsRootKey = "nnsRoot" nnsHasAliasKey = "nnsHasAlias" - notaryDisabledKey = "notary" // RegistrationFeeKey is a key in netmap config which contains fee for container registration. RegistrationFeeKey = "ContainerFee" @@ -94,8 +93,6 @@ func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) { func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -123,13 +120,11 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrNetmap interop.Hash160 - addrBalance interop.Hash160 - addrID interop.Hash160 - addrNNS interop.Hash160 - nnsRoot string + addrNetmap interop.Hash160 + addrBalance interop.Hash160 + addrID interop.Hash160 + addrNNS interop.Hash160 + nnsRoot string }) if len(args.addrNetmap) != interop.Hash160Len || diff --git a/frostfs/frostfs_contract.go b/frostfs/frostfs_contract.go index 468ee44..f005794 100644 --- a/frostfs/frostfs_contract.go +++ b/frostfs/frostfs_contract.go @@ -26,9 +26,8 @@ const ( CandidateFeeConfigKey = "InnerRingCandidateFee" withdrawFeeConfigKey = "WithdrawFee" - alphabetKey = "alphabet" - candidatesKey = "candidates" - notaryDisabledKey = "notary" + alphabetKey = "alphabet" + candidatesKey = "candidates" processingContractKey = "processingScriptHash" @@ -47,8 +46,6 @@ var ( func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -56,11 +53,9 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrProc interop.Hash160 - keys []interop.PublicKey - config [][]byte + addrProc interop.Hash160 + keys []interop.PublicKey + config [][]byte }) if len(args.keys) == 0 { diff --git a/frostfsid/frostfsid_contract.go b/frostfsid/frostfsid_contract.go index 6119b06..f3c1d3e 100644 --- a/frostfsid/frostfsid_contract.go +++ b/frostfsid/frostfsid_contract.go @@ -22,15 +22,12 @@ const ( const ( netmapContractKey = "netmapScriptHash" containerContractKey = "containerScriptHash" - notaryDisabledKey = "notary" ownerKeysPrefix = 'o' ) func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) @@ -38,10 +35,8 @@ func _deploy(data interface{}, isUpdate bool) { } args := data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrNetmap interop.Hash160 - addrContainer interop.Hash160 + addrNetmap interop.Hash160 + addrContainer interop.Hash160 }) if len(args.addrNetmap) != interop.Hash160Len || len(args.addrContainer) != interop.Hash160Len { diff --git a/netmap/netmap_contract.go b/netmap/netmap_contract.go index 34afdc6..df8a87a 100644 --- a/netmap/netmap_contract.go +++ b/netmap/netmap_contract.go @@ -43,8 +43,7 @@ type Node struct { } const ( - notaryDisabledKey = "notary" - innerRingKey = "innerring" + innerRingKey = "innerring" // DefaultSnapshotCount contains the number of previous snapshots stored by this contract. // Must be less than 255. @@ -70,16 +69,12 @@ var ( func _deploy(data interface{}, isUpdate bool) { ctx := storage.GetContext() - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - var args = data.(struct { - //TODO(@acid-ant): #9 remove notaryDisabled in future version - notaryDisabled bool - addrBalance interop.Hash160 - addrContainer interop.Hash160 - keys []interop.PublicKey - config [][]byte - version int + addrBalance interop.Hash160 + addrContainer interop.Hash160 + keys []interop.PublicKey + config [][]byte + version int }) ln := len(args.config) diff --git a/reputation/reputation_contract.go b/reputation/reputation_contract.go index 8c9dc1f..3899e0b 100644 --- a/reputation/reputation_contract.go +++ b/reputation/reputation_contract.go @@ -10,14 +10,11 @@ import ( ) const ( - notaryDisabledKey = "notary" reputationValuePrefix = 'r' reputationCountPrefix = 'c' ) func _deploy(data interface{}, isUpdate bool) { - common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey) - if isUpdate { args := data.([]interface{}) common.CheckVersion(args[len(args)-1].(int)) diff --git a/tests/alphabet_test.go b/tests/alphabet_test.go index 3d15a43..5a4ff12 100644 --- a/tests/alphabet_test.go +++ b/tests/alphabet_test.go @@ -21,13 +21,12 @@ const alphabetPath = "../alphabet" func deployAlphabetContract(t *testing.T, e *neotest.Executor, addrNetmap, addrProxy util.Uint160, name string, index, total int64) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml")) - args := make([]interface{}, 6) - args[0] = false - args[1] = addrNetmap - args[2] = addrProxy - args[3] = name - args[4] = index - args[5] = total + args := make([]interface{}, 5) + args[0] = addrNetmap + args[1] = addrProxy + args[2] = name + args[3] = index + args[4] = total e.DeployContract(t, c, args) return c.Hash diff --git a/tests/balance_test.go b/tests/balance_test.go index 03b076e..9ebe169 100644 --- a/tests/balance_test.go +++ b/tests/balance_test.go @@ -15,9 +15,8 @@ func deployBalanceContract(t *testing.T, e *neotest.Executor, addrNetmap, addrCo c := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml")) args := make([]interface{}, 3) - args[0] = false - args[1] = addrNetmap - args[2] = addrContainer + args[0] = addrNetmap + args[1] = addrContainer e.DeployContract(t, c, args) return c.Hash diff --git a/tests/container_test.go b/tests/container_test.go index 9950db6..90af2a6 100644 --- a/tests/container_test.go +++ b/tests/container_test.go @@ -29,13 +29,12 @@ const ( ) func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 { - args := make([]interface{}, 6) - args[0] = int64(0) - args[1] = addrNetmap - args[2] = addrBalance - args[3] = util.Uint160{} // not needed for now - args[4] = addrNNS - args[5] = "frostfs" + args := make([]interface{}, 5) + args[0] = addrNetmap + args[1] = addrBalance + args[2] = util.Uint160{} // not needed for now + args[3] = addrNNS + args[4] = "frostfs" c := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml")) e.DeployContract(t, c, args) diff --git a/tests/frostfs_test.go b/tests/frostfs_test.go index a9b59d2..631c659 100644 --- a/tests/frostfs_test.go +++ b/tests/frostfs_test.go @@ -22,16 +22,15 @@ const frostfsPath = "../frostfs" func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160, pubs keys.PublicKeys, config ...interface{}) util.Uint160 { - args := make([]interface{}, 5) - args[0] = false - args[1] = addrProc + args := make([]interface{}, 3) + args[0] = addrProc arr := make([]interface{}, len(pubs)) for i := range pubs { arr[i] = pubs[i].Bytes() } - args[2] = arr - args[3] = append([]interface{}{}, config...) + args[1] = arr + args[2] = append([]interface{}{}, config...) c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml")) e.DeployContract(t, c, args) diff --git a/tests/frostfsid_test.go b/tests/frostfsid_test.go index 2e25e58..446746d 100644 --- a/tests/frostfsid_test.go +++ b/tests/frostfsid_test.go @@ -17,10 +17,9 @@ import ( const frostfsidPath = "../frostfsid" func deployFrostFSIDContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 { - args := make([]interface{}, 5) - args[0] = false - args[1] = addrNetmap - args[2] = addrContainer + args := make([]interface{}, 2) + args[0] = addrNetmap + args[1] = addrContainer c := neotest.CompileFile(t, e.CommitteeHash, frostfsidPath, path.Join(frostfsidPath, "config.yml")) e.DeployContract(t, c, args) diff --git a/tests/netmap_test.go b/tests/netmap_test.go index 4c08c0f..067a42a 100644 --- a/tests/netmap_test.go +++ b/tests/netmap_test.go @@ -24,12 +24,11 @@ func deployNetmapContract(t *testing.T, e *neotest.Executor, addrBalance, addrCo _, pubs, ok := vm.ParseMultiSigContract(e.Committee.Script()) require.True(t, ok) - args := make([]interface{}, 5) - args[0] = false - args[1] = addrBalance - args[2] = addrContainer - args[3] = []interface{}{pubs[0]} - args[4] = append([]interface{}{}, config...) + args := make([]interface{}, 4) + args[0] = addrBalance + args[1] = addrContainer + args[2] = []interface{}{pubs[0]} + args[3] = append([]interface{}{}, config...) c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml")) e.DeployContract(t, c, args) diff --git a/tests/reputation_test.go b/tests/reputation_test.go index 8b09a25..b8349c3 100644 --- a/tests/reputation_test.go +++ b/tests/reputation_test.go @@ -16,10 +16,7 @@ func deployReputationContract(t *testing.T, e *neotest.Executor) util.Uint160 { c := neotest.CompileFile(t, e.CommitteeHash, reputationPath, path.Join(reputationPath, "config.yml")) - args := make([]interface{}, 1) - args[0] = false - - e.DeployContract(t, c, args) + e.DeployContract(t, c, []interface{}{}) return c.Hash }