From 9801d084380f1a5be664ad97e527bce458c7291b Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Tue, 13 Feb 2024 14:56:25 +0300 Subject: [PATCH] [#932] adm: Move defaults for NNS to package `constants` Signed-off-by: Anton Nikiforov --- cmd/frostfs-adm/internal/modules/morph/constants/const.go | 5 ++++- cmd/frostfs-adm/internal/modules/morph/contract/deploy.go | 6 ++++-- .../internal/modules/morph/helper/initialize_ctx.go | 6 ++++-- .../internal/modules/morph/initialize/initialize_nns.go | 3 ++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/frostfs-adm/internal/modules/morph/constants/const.go b/cmd/frostfs-adm/internal/modules/morph/constants/const.go index 5a7f8f922..a3b4f129a 100644 --- a/cmd/frostfs-adm/internal/modules/morph/constants/const.go +++ b/cmd/frostfs-adm/internal/modules/morph/constants/const.go @@ -28,7 +28,10 @@ const ( ContractWalletFilename = "contract.json" ContractWalletPasswordKey = "contract" - FrostfsOpsEmail = "ops@frostfs.info" + FrostfsOpsEmail = "ops@frostfs.info" + NNSRefreshDefVal = int64(3600) + NNSRetryDefVal = int64(600) + NNSTtlDefVal = int64(3600) DefaultExpirationTime = 10 * 365 * 24 * time.Hour / time.Second diff --git a/cmd/frostfs-adm/internal/modules/morph/contract/deploy.go b/cmd/frostfs-adm/internal/modules/morph/contract/deploy.go index 9a92e8f19..7a8f34a5d 100644 --- a/cmd/frostfs-adm/internal/modules/morph/contract/deploy.go +++ b/cmd/frostfs-adm/internal/modules/morph/contract/deploy.go @@ -148,12 +148,14 @@ func registerNNS(nnsCs *state.Contract, c *helper.InitializeContext, zone string emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All, zone, c.CommitteeAcc.Contract.ScriptHash(), - constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600)) + constants.FrostfsOpsEmail, constants.NNSRefreshDefVal, constants.NNSRetryDefVal, + int64(constants.DefaultExpirationTime), constants.NNSTtlDefVal) emit.Opcodes(bw.BinWriter, opcode.ASSERT) emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All, domain, c.CommitteeAcc.Contract.ScriptHash(), - constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600)) + constants.FrostfsOpsEmail, constants.NNSRefreshDefVal, constants.NNSRetryDefVal, + int64(constants.DefaultExpirationTime), constants.NNSTtlDefVal) emit.Opcodes(bw.BinWriter, opcode.ASSERT) } else { s, ok, err := c.NNSRegisterDomainScript(nnsCs.Hash, cs.Hash, domain) diff --git a/cmd/frostfs-adm/internal/modules/morph/helper/initialize_ctx.go b/cmd/frostfs-adm/internal/modules/morph/helper/initialize_ctx.go index 8269f19dc..09d64b352 100644 --- a/cmd/frostfs-adm/internal/modules/morph/helper/initialize_ctx.go +++ b/cmd/frostfs-adm/internal/modules/morph/helper/initialize_ctx.go @@ -478,7 +478,8 @@ func (c *InitializeContext) EmitUpdateNNSGroupScript(bw *io.BufBinWriter, nnsHas if isAvail { emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All, client.NNSGroupKeyName, c.CommitteeAcc.Contract.ScriptHash(), - constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600)) + constants.FrostfsOpsEmail, constants.NNSRefreshDefVal, constants.NNSRetryDefVal, + int64(constants.DefaultExpirationTime), constants.NNSTtlDefVal) emit.Opcodes(bw.BinWriter, opcode.ASSERT) } @@ -499,7 +500,8 @@ func (c *InitializeContext) NNSRegisterDomainScript(nnsHash, expectedHash util.U bw := io.NewBufBinWriter() emit.AppCall(bw.BinWriter, nnsHash, "register", callflag.All, domain, c.CommitteeAcc.Contract.ScriptHash(), - constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600)) + constants.FrostfsOpsEmail, constants.NNSRefreshDefVal, constants.NNSRetryDefVal, + int64(constants.DefaultExpirationTime), constants.NNSTtlDefVal) emit.Opcodes(bw.BinWriter, opcode.ASSERT) if bw.Err != nil { diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize/initialize_nns.go b/cmd/frostfs-adm/internal/modules/morph/initialize/initialize_nns.go index 7a628d5a3..14f12cf8e 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize/initialize_nns.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize/initialize_nns.go @@ -33,7 +33,8 @@ func setNNS(c *helper.InitializeContext) error { bw := io.NewBufBinWriter() emit.AppCall(bw.BinWriter, nnsCs.Hash, "register", callflag.All, "frostfs", c.CommitteeAcc.Contract.ScriptHash(), - constants.FrostfsOpsEmail, int64(3600), int64(600), int64(constants.DefaultExpirationTime), int64(3600)) + constants.FrostfsOpsEmail, constants.NNSRefreshDefVal, constants.NNSRetryDefVal, + int64(constants.DefaultExpirationTime), constants.NNSTtlDefVal) emit.Opcodes(bw.BinWriter, opcode.ASSERT) if err := c.SendCommitteeTx(bw.Bytes(), true); err != nil { return fmt.Errorf("can't add domain root to NNS: %w", err)