From 56b3e357792ef1c663d63f60ad447e5786a7b7e2 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 4 May 2021 13:47:20 +0300 Subject: [PATCH] [#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 --- pkg/innerring/innerring.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index bb9560af..02a94f28 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -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 {