[#50] Drop notaryless deploy parameter
All checks were successful
DCO action / DCO (pull_request) Successful in 1m20s
Tests / Tests (1.20) (pull_request) Successful in 3m13s
Tests / Tests (1.19) (pull_request) Successful in 4m11s

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-11-07 14:55:02 +03:00
parent 09281e3ef3
commit 6e9c770142
16 changed files with 53 additions and 117 deletions

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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)
}
}

View file

@ -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 ||

View file

@ -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 {

View file

@ -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 {

View file

@ -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)

View file

@ -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))

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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
}