From 6c21e2cc2842920fb7c5698b92c96811077f8573 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 24 Oct 2022 15:07:39 +0300 Subject: [PATCH] [#1959] neofs-adm: Fix `set-config` for >4 nodes Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/config.go | 2 +- cmd/neofs-adm/internal/modules/morph/epoch.go | 2 +- cmd/neofs-adm/internal/modules/morph/initialize.go | 9 ++++++++- cmd/neofs-adm/internal/modules/morph/initialize_test.go | 8 +++++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/config.go b/cmd/neofs-adm/internal/modules/morph/config.go index 841af502..1d3fb25c 100644 --- a/cmd/neofs-adm/internal/modules/morph/config.go +++ b/cmd/neofs-adm/internal/modules/morph/config.go @@ -132,7 +132,7 @@ func setConfigCmd(cmd *cobra.Command, args []string) error { } } - err = wCtx.sendCommitteeTx(bw.Bytes(), true) + err = wCtx.sendConsensusTx(bw.Bytes()) if err != nil { return err } diff --git a/cmd/neofs-adm/internal/modules/morph/epoch.go b/cmd/neofs-adm/internal/modules/morph/epoch.go index cf8b82a6..cd39d056 100644 --- a/cmd/neofs-adm/internal/modules/morph/epoch.go +++ b/cmd/neofs-adm/internal/modules/morph/epoch.go @@ -34,7 +34,7 @@ func forceNewEpochCmd(cmd *cobra.Command, args []string) error { return err } - if err := wCtx.sendMultiTx(bw.Bytes(), true, true); err != nil { + if err := wCtx.sendConsensusTx(bw.Bytes()); err != nil { return err } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 147dddec..ce6d2bfe 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -381,13 +381,20 @@ loop: return retErr } -// sendCommitteeTx creates transaction from script and sends it to RPC. +// sendCommitteeTx creates transaction from script, signs it by committee nodes and sends it to RPC. // If tryGroup is false, global scope is used for the signer (useful when // working with native contracts). func (c *initializeContext) sendCommitteeTx(script []byte, tryGroup bool) error { return c.sendMultiTx(script, tryGroup, false) } +// sendConsensusTx creates transaction from script, signs it by alphabet nodes and sends it to RPC. +// Not that because this is used only after the contracts were initialized and deployed, +// we always try to have a group scope. +func (c *initializeContext) sendConsensusTx(script []byte) error { + return c.sendMultiTx(script, true, true) +} + func (c *initializeContext) sendMultiTx(script []byte, tryGroup bool, withConsensus bool) error { var act *actor.Actor var err error diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_test.go b/cmd/neofs-adm/internal/modules/morph/initialize_test.go index 3535b469..e4125c93 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_test.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_test.go @@ -82,5 +82,11 @@ func testInitialize(t *testing.T, committeeSize int) { v.Set(epochDurationInitFlag, 1) v.Set(maxObjectSizeInitFlag, 1024) require.NoError(t, initializeSideChainCmd(initCmd, nil)) - require.NoError(t, forceNewEpochCmd(forceNewEpoch, nil)) + + t.Run("force-new-epoch", func(t *testing.T) { + require.NoError(t, forceNewEpochCmd(forceNewEpoch, nil)) + }) + t.Run("set-config", func(t *testing.T) { + require.NoError(t, setConfigCmd(setConfig, []string{"MaintenanceModeAllowed=true"})) + }) }