[#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>
This commit is contained in:
Leonard Lyubich 2021-05-04 13:47:20 +03:00 committed by Alex Vanin
parent 969af596b4
commit 56b3e35779

View file

@ -276,7 +276,9 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
return nil, err 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, // This works as long as event Listener starts listening loop once,
// otherwise Server.Start will run two similar routines. // otherwise Server.Start will run two similar routines.
// This behavior most likely will not change. // 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 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 // create netmap processor
netmapProcessor, err := netmap.New(&netmap.Params{ netmapProcessor, err := netmap.New(&netmap.Params{
Log: log, Log: log,
@ -466,7 +478,7 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
AuditSettlementsHandler: server.onlyAlphabetEventHandler( AuditSettlementsHandler: server.onlyAlphabetEventHandler(
settlementProcessor.HandleAuditEvent, settlementProcessor.HandleAuditEvent,
), ),
AlphabetSyncHandler: governanceProcessor.HandleAlphabetSync, AlphabetSyncHandler: alphaSync,
NodeValidator: locodeValidator, NodeValidator: locodeValidator,
}) })
if err != nil { if err != nil {