[#50] Drop notaryless deploy parameter

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" indexKey = "index"
totalKey = "threshold" totalKey = "threshold"
nameKey = "name" nameKey = "name"
notaryDisabledKey = "notary"
) )
// OnNEP17Payment is a callback for NEP-17 compatible native GAS and NEO // 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) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -43,8 +39,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrNetmap interop.Hash160 addrNetmap interop.Hash160
addrProxy interop.Hash160 addrProxy interop.Hash160
name string name string

View file

@ -37,15 +37,11 @@ func (a auditHeader) ID() []byte {
const ( const (
netmapContractKey = "netmapScriptHash" netmapContractKey = "netmapScriptHash"
notaryDisabledKey = "notary"
) )
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -53,8 +49,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrNetmap interop.Hash160 addrNetmap interop.Hash160
}) })

View file

@ -47,7 +47,6 @@ const (
netmapContractKey = "netmapScriptHash" netmapContractKey = "netmapScriptHash"
containerContractKey = "containerScriptHash" containerContractKey = "containerScriptHash"
notaryDisabledKey = "notary"
) )
var token Token var token Token
@ -67,8 +66,6 @@ func init() {
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -76,8 +73,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
// TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrNetmap interop.Hash160 addrNetmap interop.Hash160
addrContainer interop.Hash160 addrContainer interop.Hash160
}) })

View file

@ -1,26 +1,11 @@
package common package common
import ( import (
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
"github.com/nspcc-dev/neo-go/pkg/interop/util" "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, // BytesEqual compares two slices of bytes by wrapping them into strings,
// which is necessary with new util.Equals interop behaviour, see neo-go#1176. // which is necessary with new util.Equals interop behaviour, see neo-go#1176.
func BytesEqual(a []byte, b []byte) bool { func BytesEqual(a []byte, b []byte) bool {
return util.Equals(string(a), string(b)) 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" nnsContractKey = "nnsScriptHash"
nnsRootKey = "nnsRoot" nnsRootKey = "nnsRoot"
nnsHasAliasKey = "nnsHasAlias" nnsHasAliasKey = "nnsHasAlias"
notaryDisabledKey = "notary"
// RegistrationFeeKey is a key in netmap config which contains fee for container registration. // RegistrationFeeKey is a key in netmap config which contains fee for container registration.
RegistrationFeeKey = "ContainerFee" RegistrationFeeKey = "ContainerFee"
@ -94,8 +93,6 @@ func OnNEP11Payment(a interop.Hash160, b int, c []byte, d interface{}) {
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -123,8 +120,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrNetmap interop.Hash160 addrNetmap interop.Hash160
addrBalance interop.Hash160 addrBalance interop.Hash160
addrID interop.Hash160 addrID interop.Hash160

View file

@ -28,7 +28,6 @@ const (
alphabetKey = "alphabet" alphabetKey = "alphabet"
candidatesKey = "candidates" candidatesKey = "candidates"
notaryDisabledKey = "notary"
processingContractKey = "processingScriptHash" processingContractKey = "processingScriptHash"
@ -47,8 +46,6 @@ var (
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -56,8 +53,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrProc interop.Hash160 addrProc interop.Hash160
keys []interop.PublicKey keys []interop.PublicKey
config [][]byte config [][]byte

View file

@ -22,15 +22,12 @@ const (
const ( const (
netmapContractKey = "netmapScriptHash" netmapContractKey = "netmapScriptHash"
containerContractKey = "containerScriptHash" containerContractKey = "containerScriptHash"
notaryDisabledKey = "notary"
ownerKeysPrefix = 'o' ownerKeysPrefix = 'o'
) )
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) common.CheckVersion(args[len(args)-1].(int))
@ -38,8 +35,6 @@ func _deploy(data interface{}, isUpdate bool) {
} }
args := data.(struct { args := data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrNetmap interop.Hash160 addrNetmap interop.Hash160
addrContainer interop.Hash160 addrContainer interop.Hash160
}) })

View file

@ -43,7 +43,6 @@ type Node struct {
} }
const ( const (
notaryDisabledKey = "notary"
innerRingKey = "innerring" innerRingKey = "innerring"
// DefaultSnapshotCount contains the number of previous snapshots stored by this contract. // DefaultSnapshotCount contains the number of previous snapshots stored by this contract.
@ -70,11 +69,7 @@ var (
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
ctx := storage.GetContext() ctx := storage.GetContext()
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
var args = data.(struct { var args = data.(struct {
//TODO(@acid-ant): #9 remove notaryDisabled in future version
notaryDisabled bool
addrBalance interop.Hash160 addrBalance interop.Hash160
addrContainer interop.Hash160 addrContainer interop.Hash160
keys []interop.PublicKey keys []interop.PublicKey

View file

@ -10,14 +10,11 @@ import (
) )
const ( const (
notaryDisabledKey = "notary"
reputationValuePrefix = 'r' reputationValuePrefix = 'r'
reputationCountPrefix = 'c' reputationCountPrefix = 'c'
) )
func _deploy(data interface{}, isUpdate bool) { func _deploy(data interface{}, isUpdate bool) {
common.RmAndCheckNotaryDisabledKey(data, notaryDisabledKey)
if isUpdate { if isUpdate {
args := data.([]interface{}) args := data.([]interface{})
common.CheckVersion(args[len(args)-1].(int)) 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 { 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")) c := neotest.CompileFile(t, e.CommitteeHash, alphabetPath, path.Join(alphabetPath, "config.yml"))
args := make([]interface{}, 6) args := make([]interface{}, 5)
args[0] = false args[0] = addrNetmap
args[1] = addrNetmap args[1] = addrProxy
args[2] = addrProxy args[2] = name
args[3] = name args[3] = index
args[4] = index args[4] = total
args[5] = total
e.DeployContract(t, c, args) e.DeployContract(t, c, args)
return c.Hash 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")) c := neotest.CompileFile(t, e.CommitteeHash, balancePath, path.Join(balancePath, "config.yml"))
args := make([]interface{}, 3) args := make([]interface{}, 3)
args[0] = false args[0] = addrNetmap
args[1] = addrNetmap args[1] = addrContainer
args[2] = addrContainer
e.DeployContract(t, c, args) e.DeployContract(t, c, args)
return c.Hash 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 { func deployContainerContract(t *testing.T, e *neotest.Executor, addrNetmap, addrBalance, addrNNS util.Uint160) util.Uint160 {
args := make([]interface{}, 6) args := make([]interface{}, 5)
args[0] = int64(0) args[0] = addrNetmap
args[1] = addrNetmap args[1] = addrBalance
args[2] = addrBalance args[2] = util.Uint160{} // not needed for now
args[3] = util.Uint160{} // not needed for now args[3] = addrNNS
args[4] = addrNNS args[4] = "frostfs"
args[5] = "frostfs"
c := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml")) c := neotest.CompileFile(t, e.CommitteeHash, containerPath, path.Join(containerPath, "config.yml"))
e.DeployContract(t, c, args) 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, func deployFrostFSContract(t *testing.T, e *neotest.Executor, addrProc util.Uint160,
pubs keys.PublicKeys, config ...interface{}) util.Uint160 { pubs keys.PublicKeys, config ...interface{}) util.Uint160 {
args := make([]interface{}, 5) args := make([]interface{}, 3)
args[0] = false args[0] = addrProc
args[1] = addrProc
arr := make([]interface{}, len(pubs)) arr := make([]interface{}, len(pubs))
for i := range pubs { for i := range pubs {
arr[i] = pubs[i].Bytes() arr[i] = pubs[i].Bytes()
} }
args[2] = arr args[1] = arr
args[3] = append([]interface{}{}, config...) args[2] = append([]interface{}{}, config...)
c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml")) c := neotest.CompileFile(t, e.CommitteeHash, frostfsPath, path.Join(frostfsPath, "config.yml"))
e.DeployContract(t, c, args) e.DeployContract(t, c, args)

View file

@ -17,10 +17,9 @@ import (
const frostfsidPath = "../frostfsid" const frostfsidPath = "../frostfsid"
func deployFrostFSIDContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 { func deployFrostFSIDContract(t *testing.T, e *neotest.Executor, addrNetmap, addrContainer util.Uint160) util.Uint160 {
args := make([]interface{}, 5) args := make([]interface{}, 2)
args[0] = false args[0] = addrNetmap
args[1] = addrNetmap args[1] = addrContainer
args[2] = addrContainer
c := neotest.CompileFile(t, e.CommitteeHash, frostfsidPath, path.Join(frostfsidPath, "config.yml")) c := neotest.CompileFile(t, e.CommitteeHash, frostfsidPath, path.Join(frostfsidPath, "config.yml"))
e.DeployContract(t, c, args) 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()) _, pubs, ok := vm.ParseMultiSigContract(e.Committee.Script())
require.True(t, ok) require.True(t, ok)
args := make([]interface{}, 5) args := make([]interface{}, 4)
args[0] = false args[0] = addrBalance
args[1] = addrBalance args[1] = addrContainer
args[2] = addrContainer args[2] = []interface{}{pubs[0]}
args[3] = []interface{}{pubs[0]} args[3] = append([]interface{}{}, config...)
args[4] = append([]interface{}{}, config...)
c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml")) c := neotest.CompileFile(t, e.CommitteeHash, netmapPath, path.Join(netmapPath, "config.yml"))
e.DeployContract(t, c, args) 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, c := neotest.CompileFile(t, e.CommitteeHash, reputationPath,
path.Join(reputationPath, "config.yml")) path.Join(reputationPath, "config.yml"))
args := make([]interface{}, 1) e.DeployContract(t, c, []interface{}{})
args[0] = false
e.DeployContract(t, c, args)
return c.Hash return c.Hash
} }