From fe0c6db67d72760cab2c94be5c006665042b256c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 5 Sep 2022 12:54:24 +0300 Subject: [PATCH] [#1749] neofs-adm: Delete NNS records before updating In case we already have the record and it is invalid, we should overwrite it instead of having several conflicting records. Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/deploy.go | 1 + cmd/neofs-adm/internal/modules/morph/initialize_deploy.go | 1 + cmd/neofs-adm/internal/modules/morph/initialize_nns.go | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/deploy.go b/cmd/neofs-adm/internal/modules/morph/deploy.go index a04a5638..48ce3583 100644 --- a/cmd/neofs-adm/internal/modules/morph/deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/deploy.go @@ -146,6 +146,7 @@ func deployContractCmd(cmd *cobra.Command, args []string) error { } } if needRecord { + emit.AppCall(bw.BinWriter, nnsCs.Hash, "deleteRecords", callflag.All, domain, int64(nns.TXT)) emit.AppCall(bw.BinWriter, nnsCs.Hash, "addRecord", callflag.All, domain, int64(nns.TXT), address.Uint160ToString(cs.Hash)) } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index a945dea7..199b55af 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -273,6 +273,7 @@ func (c *initializeContext) updateContracts() error { } if !ok { w.WriteBytes(script) + emit.AppCall(w.BinWriter, nnsHash, "deleteRecords", callflag.All, domain, int64(nns.TXT)) emit.AppCall(w.BinWriter, nnsHash, "addRecord", callflag.All, domain, int64(nns.TXT), cs.Hash.StringLE()) } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index b9ef87f5..ad355ce3 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -23,8 +23,6 @@ import ( morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client" ) -const defaultNameServiceDomainPrice = 10_0000_0000 -const defaultRegisterSysfee = 10_0000_0000 + defaultNameServiceDomainPrice const defaultExpirationTime = 10 * 365 * 24 * time.Hour / time.Second func (c *initializeContext) setNNS() error { @@ -125,6 +123,8 @@ func (c *initializeContext) emitUpdateNNSGroupScript(bw *io.BufBinWriter, nnsHas "ops@nspcc.ru", int64(3600), int64(600), int64(defaultExpirationTime), int64(3600)) emit.Opcodes(bw.BinWriter, opcode.ASSERT) } + + emit.AppCall(bw.BinWriter, nnsHash, "deleteRecords", callflag.All, "group.neofs", int64(nns.TXT)) emit.AppCall(bw.BinWriter, nnsHash, "addRecord", callflag.All, "group.neofs", int64(nns.TXT), hex.EncodeToString(pub.Bytes())) @@ -194,6 +194,7 @@ func (c *initializeContext) nnsRegisterDomain(nnsHash, expectedHash util.Uint160 emit.Instruction(w.BinWriter, opcode.INITSSLOT, []byte{1}) wrapRegisterScriptWithPrice(w, nnsHash, script) + emit.AppCall(w.BinWriter, nnsHash, "deleteRecords", callflag.All, domain, int64(nns.TXT)) emit.AppCall(w.BinWriter, nnsHash, "addRecord", callflag.All, domain, int64(nns.TXT), expectedHash.StringLE()) return c.sendCommitteeTx(w.Bytes(), -1, true)