[#480] ir: Do not sync alphabet keys in sidechain-only configuration

Alphabet nodes synchronize list of alphabet keys from main chain
`NeoFSAlphabet` role once per epoch. This can lead to a wrong behavior in
single chain deployment (`without_mainnet` config parameter). Alphabet node
in single chain environment will try to get NeoFSAlphabet role from main
chain client, but it'll get result from side chain instead. Side chain
stores list of all inner ring nodes in this role. Therefore it is possible
that alphabet nodes will try to appoint inner ring nodes as alphabet nodes,
which is not correct.

Fix incorrect behavior with disabling of synchronization of alphabet keys in
sidechain-only mode.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/KirillovDenis/release/v0.21.1
Leonard Lyubich 2021-05-04 13:47:20 +03:00 committed by Alex Vanin
parent 969af596b4
commit 56b3e35779
1 changed files with 14 additions and 2 deletions

View File

@ -276,7 +276,9 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err
}
if cfg.GetBool("without_mainnet") {
withoutMainNet := cfg.GetBool("without_mainnet")
if withoutMainNet {
// This works as long as event Listener starts listening loop once,
// otherwise Server.Start will run two similar routines.
// This behavior most likely will not change.
@ -448,6 +450,16 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err
}
var alphaSync event.Handler
if withoutMainNet {
alphaSync = func(event.Event) {
log.Debug("alphabet keys sync is disabled")
}
} else {
alphaSync = governanceProcessor.HandleAlphabetSync
}
// create netmap processor
netmapProcessor, err := netmap.New(&netmap.Params{
Log: log,
@ -466,7 +478,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
AuditSettlementsHandler: server.onlyAlphabetEventHandler(
settlementProcessor.HandleAuditEvent,
),
AlphabetSyncHandler: governanceProcessor.HandleAlphabetSync,
AlphabetSyncHandler: alphaSync,
NodeValidator: locodeValidator,
})
if err != nil {