forked from TrueCloudLab/frostfs-node
[#2026] neofs-adm: Make contract update idempotent
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
parent
634792077e
commit
426fe97990
1 changed files with 15 additions and 3 deletions
|
@ -27,6 +27,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
"github.com/nspcc-dev/neo-go/pkg/vm/vmstate"
|
||||||
|
"github.com/nspcc-dev/neofs-contract/common"
|
||||||
"github.com/nspcc-dev/neofs-contract/nns"
|
"github.com/nspcc-dev/neofs-contract/nns"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/innerring"
|
"github.com/nspcc-dev/neofs-node/pkg/innerring"
|
||||||
morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
||||||
|
@ -106,7 +107,11 @@ func (c *initializeContext) deployNNS(method string) error {
|
||||||
nnsCs, err := c.nnsContractState()
|
nnsCs, err := c.nnsContractState()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if nnsCs.NEF.Checksum == cs.NEF.Checksum {
|
if nnsCs.NEF.Checksum == cs.NEF.Checksum {
|
||||||
|
if method == deployMethodName {
|
||||||
c.Command.Println("NNS contract is already deployed.")
|
c.Command.Println("NNS contract is already deployed.")
|
||||||
|
} else {
|
||||||
|
c.Command.Println("NNS contract is already updated.")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
h = nnsCs.Hash
|
h = nnsCs.Hash
|
||||||
|
@ -206,8 +211,11 @@ func (c *initializeContext) updateContracts() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.sendCommitteeTx(w.Bytes(), false); err != nil {
|
if err := c.sendCommitteeTx(w.Bytes(), false); err != nil {
|
||||||
|
if !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.Command.Println("Alphabet contracts are already updated.")
|
||||||
|
}
|
||||||
|
|
||||||
w.Reset()
|
w.Reset()
|
||||||
|
|
||||||
|
@ -243,8 +251,12 @@ func (c *initializeContext) updateContracts() error {
|
||||||
params := getContractDeployParameters(cs, c.getContractDeployData(ctrName, keysParam))
|
params := getContractDeployParameters(cs, c.getContractDeployData(ctrName, keysParam))
|
||||||
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if method != updateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||||
return fmt.Errorf("deploy contract: %w", err)
|
return fmt.Errorf("deploy contract: %w", err)
|
||||||
}
|
}
|
||||||
|
c.Command.Printf("%s contract is already updated.\n", ctrName)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteBytes(res.Script)
|
w.WriteBytes(res.Script)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue