[#107] Remove contract owner argument at contract deploy

Contract owner entity does exist anymore. Contract migration
now managed by side chain committee which are Alphabet nodes of
the Inner Ring.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-09-20 18:41:46 +03:00 committed by Alex Vanin
parent 378e69c015
commit 6d0c5d110c
10 changed files with 62 additions and 134 deletions

View file

@ -39,24 +39,18 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrProxy := args[3].(interop.Hash160)
name := args[4].(string)
index := args[5].(int)
total := args[6].(int)
addrNetmap := args[1].(interop.Hash160)
addrProxy := args[2].(interop.Hash160)
name := args[3].(string)
index := args[4].(int)
total := args[5].(int)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNetmap) != 20 || !notaryDisabled && len(addrProxy) != 20 {
panic("incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapKey, addrNetmap)
storage.Put(ctx, proxyKey, addrProxy)
storage.Put(ctx, nameKey, name)
@ -74,12 +68,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -48,20 +48,14 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrNetmap := args[1].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNetmap) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
// initialize the way to collect signatures
@ -74,12 +68,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
@ -186,7 +178,6 @@ func list(it iterator.Iterator) [][]byte {
ignore := [][]byte{
[]byte(netmapContractKey),
[]byte(common.OwnerKey),
[]byte(notaryDisabledKey),
}

View file

@ -65,21 +65,15 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
addrNetmap := args[1].(interop.Hash160)
addrContainer := args[2].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
storage.Put(ctx, containerContractKey, addrContainer)
@ -94,12 +88,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -70,20 +70,14 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrBalance := args[3].(interop.Hash160)
addrID := args[4].(interop.Hash160)
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
addrNetmap := args[1].(interop.Hash160)
addrBalance := args[2].(interop.Hash160)
addrID := args[3].(interop.Hash160)
if len(addrNetmap) != 20 || len(addrBalance) != 20 || len(addrID) != 20 {
panic("incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
storage.Put(ctx, balanceContractKey, addrBalance)
storage.Put(ctx, neofsIDContractKey, addrID)
@ -99,12 +93,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -6,7 +6,9 @@ import (
"github.com/nspcc-dev/neo-go/pkg/interop/iterator"
"github.com/nspcc-dev/neo-go/pkg/interop/native/crypto"
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
"github.com/nspcc-dev/neo-go/pkg/interop/native/std"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
@ -51,17 +53,12 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrProc := args[2].(interop.Hash160)
keys := args[3].([]interop.PublicKey)
config := args[4].([][]byte)
addrProc := args[1].(interop.Hash160)
keys := args[2].([]interop.PublicKey)
config := args[3].([][]byte)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
var irList []common.IRNode
if len(keys) == 0 {
@ -84,7 +81,6 @@ func _deploy(data interface{}, isUpdate bool) {
common.SetSerialized(ctx, alphabetKey, irList)
common.SetSerialized(ctx, candidatesKey, []common.IRNode{})
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, processingContractKey, addrProc)
// initialize the way to collect signatures
@ -110,12 +106,14 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by side chain committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
blockHeight := ledger.CurrentIndex()
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight))
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !runtime.CheckWitness(alphabetCommittee) {
panic("only side chain committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -30,21 +30,15 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrNetmap := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
addrNetmap := args[1].(interop.Hash160)
addrContainer := args[2].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNetmap) != 20 || len(addrContainer) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
storage.Put(ctx, containerContractKey, addrContainer)
@ -59,12 +53,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -67,22 +67,15 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
addrBalance := args[2].(interop.Hash160)
addrContainer := args[3].(interop.Hash160)
keys := args[4].([]interop.PublicKey)
config := args[5].([][]byte)
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
addrBalance := args[1].(interop.Hash160)
addrContainer := args[2].(interop.Hash160)
keys := args[3].([]interop.PublicKey)
config := args[4].([][]byte)
if len(addrBalance) != 20 || len(addrContainer) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
// epoch number is a little endian int, it doesn't need to be serialized
storage.Put(ctx, snapshotEpoch, 0)
storage.Put(ctx, snapshotBlockKey, 0)
@ -124,12 +117,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -4,7 +4,9 @@ import (
"github.com/nspcc-dev/neo-go/pkg/interop"
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
"github.com/nspcc-dev/neo-go/pkg/interop/native/gas"
"github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
"github.com/nspcc-dev/neo-go/pkg/interop/native/roles"
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
"github.com/nspcc-dev/neofs-contract/common"
@ -30,32 +32,28 @@ func _deploy(data interface{}, isUpdate bool) {
}
arr := data.([]interop.Hash160)
owner := arr[0]
addrNeoFS := arr[1]
addrNeoFS := arr[0]
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNeoFS) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, neofsContractKey, addrNeoFS)
runtime.Log("processing contract initialized")
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by side chain committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
blockHeight := ledger.CurrentIndex()
alphabetKeys := roles.GetDesignatedByRole(roles.NeoFSAlphabet, uint32(blockHeight))
alphabetCommittee := common.Multiaddress(alphabetKeys, true)
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !runtime.CheckWitness(alphabetCommittee) {
panic("only side chain committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -29,32 +29,24 @@ func _deploy(data interface{}, isUpdate bool) {
}
args := data.([]interface{})
owner := args[0].(interop.Hash160)
addrNetmap := args[1].(interop.Hash160)
addrNetmap := args[0].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
if len(addrNetmap) != 20 {
panic("init: incorrect length of contract script hash")
}
storage.Put(ctx, common.OwnerKey, owner)
storage.Put(ctx, netmapContractKey, addrNetmap)
runtime.Log("proxy contract initialized")
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)

View file

@ -22,16 +22,9 @@ func _deploy(data interface{}, isUpdate bool) {
args := data.([]interface{})
notaryDisabled := args[0].(bool)
owner := args[1].(interop.Hash160)
ctx := storage.GetContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can reinitialize contract")
}
storage.Put(ctx, common.OwnerKey, owner)
// initialize the way to collect signatures
storage.Put(ctx, notaryDisabledKey, notaryDisabled)
if notaryDisabled {
@ -43,12 +36,10 @@ func _deploy(data interface{}, isUpdate bool) {
}
// Update method updates contract source code and manifest. Can be invoked
// only by contract owner.
// only by committee.
func Update(script []byte, manifest []byte, data interface{}) {
ctx := storage.GetReadOnlyContext()
if !common.HasUpdateAccess(ctx) {
panic("only owner can update contract")
if !common.HasUpdateAccess() {
panic("only committee can update contract")
}
contract.Call(interop.Hash160(management.Hash), "update", contract.All, script, manifest, data)
@ -136,7 +127,6 @@ func ListByEpoch(epoch int) [][]byte {
var result [][]byte
ignore := [][]byte{
[]byte(common.OwnerKey),
[]byte(notaryDisabledKey),
}