From 53a1b15693e3a14ec6343c2ef02dd080c6b752d8 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Thu, 18 May 2023 11:19:08 +0300 Subject: [PATCH] [#338] ir: Drop notaryless code from governance Signed-off-by: Dmitrii Stepanov --- pkg/innerring/initialization.go | 19 +++---- .../processors/governance/handlers_test.go | 56 +++++++++---------- .../processors/governance/process_update.go | 25 ++------- .../processors/governance/processor.go | 27 ++++----- 4 files changed, 52 insertions(+), 75 deletions(-) diff --git a/pkg/innerring/initialization.go b/pkg/innerring/initialization.go index 076d7be43..8e5aef951 100644 --- a/pkg/innerring/initialization.go +++ b/pkg/innerring/initialization.go @@ -161,16 +161,15 @@ func (s *Server) createAlphaSync(cfg *viper.Viper, frostfsCli *frostfsClient.Cli } else { // create governance processor governanceProcessor, err := governance.New(&governance.Params{ - Log: s.log, - FrostFSClient: frostfsCli, - NetmapClient: s.netmapClient, - AlphabetState: s, - EpochState: s, - Voter: s, - IRFetcher: irf, - MorphClient: s.morphClient, - MainnetClient: s.mainnetClient, - NotaryDisabled: s.sideNotaryConfig.disabled, + Log: s.log, + FrostFSClient: frostfsCli, + NetmapClient: s.netmapClient, + AlphabetState: s, + EpochState: s, + Voter: s, + IRFetcher: irf, + MorphClient: s.morphClient, + MainnetClient: s.mainnetClient, }) if err != nil { return nil, err diff --git a/pkg/innerring/processors/governance/handlers_test.go b/pkg/innerring/processors/governance/handlers_test.go index 23f91869a..63d156dac 100644 --- a/pkg/innerring/processors/governance/handlers_test.go +++ b/pkg/innerring/processors/governance/handlers_test.go @@ -42,16 +42,15 @@ func TestHandleAlphabetSyncEvent(t *testing.T) { proc, err := New( &Params{ - Log: test.NewLogger(t, true), - EpochState: es, - AlphabetState: as, - Voter: v, - IRFetcher: irf, - NotaryDisabled: true, - MorphClient: m, - MainnetClient: mn, - FrostFSClient: f, - NetmapClient: nm, + Log: test.NewLogger(t, true), + EpochState: es, + AlphabetState: as, + Voter: v, + IRFetcher: irf, + MorphClient: m, + MainnetClient: mn, + FrostFSClient: f, + NetmapClient: nm, }, ) @@ -74,17 +73,19 @@ func TestHandleAlphabetSyncEvent(t *testing.T) { }, }, v.votes, "invalid vote calls") - var irUpdateExp nmClient.UpdateIRPrm - irUpdateExp.SetKeys(testKeys.newInnerRingExp) - irUpdateExp.SetHash(ev.txHash) + var irUpdateExp []nmClient.UpdateIRPrm - require.EqualValues(t, []nmClient.UpdateIRPrm{irUpdateExp}, nm.updates, "invalid IR updates") + require.EqualValues(t, irUpdateExp, nm.updates, "invalid IR updates") - var expAlphabetUpdates []client.UpdateAlphabetListPrm - require.EqualValues(t, expAlphabetUpdates, m.alphabetUpdates, "invalid alphabet updates") + var expAlphabetUpdate client.UpdateAlphabetListPrm + expAlphabetUpdate.SetHash(ev.txHash) + expAlphabetUpdate.SetList(testKeys.newInnerRingExp) + require.EqualValues(t, []client.UpdateAlphabetListPrm{expAlphabetUpdate}, m.alphabetUpdates, "invalid alphabet updates") - var expNotaryUpdates []client.UpdateNotaryListPrm - require.EqualValues(t, expNotaryUpdates, m.notaryUpdates, "invalid notary list updates") + var expNotaryUpdate client.UpdateNotaryListPrm + expNotaryUpdate.SetHash(ev.txHash) + expNotaryUpdate.SetList(testKeys.newAlphabetExp) + require.EqualValues(t, []client.UpdateNotaryListPrm{expNotaryUpdate}, m.notaryUpdates, "invalid notary list updates") buf := make([]byte, 8) binary.LittleEndian.PutUint64(buf, es.epoch) @@ -122,16 +123,15 @@ func TestHandleAlphabetDesignateEvent(t *testing.T) { proc, err := New( &Params{ - Log: test.NewLogger(t, true), - EpochState: es, - AlphabetState: as, - Voter: v, - IRFetcher: irf, - NotaryDisabled: false, - MorphClient: m, - MainnetClient: mn, - FrostFSClient: f, - NetmapClient: nm, + Log: test.NewLogger(t, true), + EpochState: es, + AlphabetState: as, + Voter: v, + IRFetcher: irf, + MorphClient: m, + MainnetClient: mn, + FrostFSClient: f, + NetmapClient: nm, }, ) diff --git a/pkg/innerring/processors/governance/process_update.go b/pkg/innerring/processors/governance/process_update.go index 629d8741e..3eae676d4 100644 --- a/pkg/innerring/processors/governance/process_update.go +++ b/pkg/innerring/processors/governance/process_update.go @@ -9,7 +9,6 @@ import ( "git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs" "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client" frostfscontract "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/frostfs" - nmClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/netmap" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" "go.uber.org/zap" @@ -114,33 +113,17 @@ func (gp *Processor) updateNeoFSAlphabetRoleInSidechain(sidechainAlphabet, newAl zap.String("after", prettyKeys(newInnerRing)), ) - if gp.notaryDisabled { - updPrm := nmClient.UpdateIRPrm{} + updPrm := client.UpdateAlphabetListPrm{} + updPrm.SetList(newInnerRing) + updPrm.SetHash(txHash) - updPrm.SetKeys(newInnerRing) - updPrm.SetHash(txHash) - - err = gp.netmapClient.UpdateInnerRing(updPrm) - } else { - updPrm := client.UpdateAlphabetListPrm{} - - updPrm.SetList(newInnerRing) - updPrm.SetHash(txHash) - - err = gp.morphClient.UpdateNeoFSAlphabetList(updPrm) - } - - if err != nil { + if err = gp.morphClient.UpdateNeoFSAlphabetList(updPrm); err != nil { gp.log.Error(logs.GovernanceCantUpdateInnerRingListWithNewAlphabetKeys, zap.String("error", err.Error())) } } func (gp *Processor) updateNotaryRoleInSidechain(newAlphabet keys.PublicKeys, txHash util.Uint256) { - if gp.notaryDisabled { - return - } - updPrm := client.UpdateNotaryListPrm{} updPrm.SetList(newAlphabet) diff --git a/pkg/innerring/processors/governance/processor.go b/pkg/innerring/processors/governance/processor.go index e08bd3809..07b5b5cef 100644 --- a/pkg/innerring/processors/governance/processor.go +++ b/pkg/innerring/processors/governance/processor.go @@ -87,8 +87,6 @@ type ( mainnetClient MainnetClient morphClient MorphClient - notaryDisabled bool - designate util.Uint160 } @@ -105,8 +103,6 @@ type ( MainnetClient MainnetClient FrostFSClient FrostFSClient NetmapClient NetmapClient - - NotaryDisabled bool } ) @@ -138,18 +134,17 @@ func New(p *Params) (*Processor, error) { designate := p.MainnetClient.GetDesignateHash() return &Processor{ - log: p.Log, - pool: pool, - frostfsClient: p.FrostFSClient, - netmapClient: p.NetmapClient, - alphabetState: p.AlphabetState, - epochState: p.EpochState, - voter: p.Voter, - irFetcher: p.IRFetcher, - mainnetClient: p.MainnetClient, - morphClient: p.MorphClient, - notaryDisabled: p.NotaryDisabled, - designate: designate, + log: p.Log, + pool: pool, + frostfsClient: p.FrostFSClient, + netmapClient: p.NetmapClient, + alphabetState: p.AlphabetState, + epochState: p.EpochState, + voter: p.Voter, + irFetcher: p.IRFetcher, + mainnetClient: p.MainnetClient, + morphClient: p.MorphClient, + designate: designate, }, nil }