[#338] ir: Drop notaryless code from governance

Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
Dmitrii Stepanov 2023-05-18 11:19:08 +03:00 committed by Evgenii Stratonikov
parent 0ab589dd52
commit 53a1b15693
4 changed files with 52 additions and 75 deletions

View file

@ -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

View file

@ -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,
},
)

View file

@ -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)

View file

@ -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
}