Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sovereign] Add config option to disable notifier #6578

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/sovereignnode/config/sovereignConfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
Hasher = "sha256"

[NotifierConfig]
# This flag indicates whether the node will establish a WebSocket receiver connection from a light node or observer.
# Running an additional main chain light node as a notifier requires extra hardware resources.
# When disabled, the node will rely on and trust incoming headers from the main chain proposed by other leaders.
# Disabling this flag can be useful in scenarios where additional validation infrastructure isn't necessary,
# such as for a CEX observer setup that only requires balance checks on various addresses.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line 52.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remved the line

Enabled = true

SubscribedEvents = [
{ Identifier = "deposit", Addresses = ["erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"] },
{ Identifier = "execute", Addresses = ["erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"] }
Expand Down
70 changes: 45 additions & 25 deletions cmd/sovereignnode/sovereignNodeRunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -529,44 +529,27 @@ func (snr *sovereignNodeRunner) executeOneComponentCreationCycle(
return true, err
}

sovereignNotifier, err := createSovereignNotifier(&configs.SovereignExtraConfig.NotifierConfig)
if err != nil {
return true, err
}

sovereignWsReceiver, err := createSovereignWsReceiver(
notifierServices, err := createNotifierWSReceiverServicesIfNeeded(
&configs.SovereignExtraConfig.NotifierConfig,
sovereignNotifier,
)
if err != nil {
return true, err
}

sovereignNotifierBootstrapper, err := startSovereignNotifierBootstrapper(
incomingHeaderHandler,
sovereignNotifier,
managedCoreComponents.GenesisNodesSetup().GetRoundDuration(),
managedProcessComponents.ForkDetector(),
managedConsensusComponents.Bootstrapper(),
)
if err != nil {
return true, err
}

log.Debug("creating node structure")

extraOptionNotifierReceiver := func(n *node.Node) error {
n.AddClosableComponent(sovereignWsReceiver)
extraOptionsNotifier := func(n *node.Node) error {
for _, notifierService := range notifierServices {
n.AddClosableComponent(notifierService)
}

return nil
}
extraOptionOutGoingBridgeSender := func(n *node.Node) error {
n.AddClosableComponent(outGoingBridgeOpHandler)
return nil
}
extraOptionNotifierBootstrapper := func(n *node.Node) error {
n.AddClosableComponent(sovereignNotifierBootstrapper)
return nil
}

nodeHandler, err := node.CreateNode(
configs.GeneralConfig,
Expand All @@ -585,9 +568,8 @@ func (snr *sovereignNodeRunner) executeOneComponentCreationCycle(
flagsConfig.BootstrapRoundIndex,
configs.ImportDbConfig.IsImportDBMode,
node.NewSovereignNodeFactory(configs.GeneralConfig.SovereignConfig.GenesisConfig.NativeESDT),
extraOptionNotifierReceiver,
extraOptionsNotifier,
extraOptionOutGoingBridgeSender,
extraOptionNotifierBootstrapper,
)
if err != nil {
return true, err
Expand Down Expand Up @@ -1904,6 +1886,44 @@ func createWhiteListerVerifiedTxs(generalConfig *config.Config) (process.WhiteLi
return interceptors.NewWhiteListDataVerifier(whiteListCacheVerified)
}

func createNotifierWSReceiverServicesIfNeeded(
config *config.NotifierConfig,
incomingHeaderHandler process.IncomingHeaderSubscriber,
roundDuration uint64,
forkDetector process.ForkDetector,
bootstrapper process.Bootstrapper,
) ([]mainFactory.Closer, error) {
if !config.Enabled {
log.Info("running without any notifier attached")
return make([]mainFactory.Closer, 0), nil
}

sovereignNotifier, err := createSovereignNotifier(config)
if err != nil {
return nil, err
}

sovereignWsReceiver, err := createSovereignWsReceiver(
config,
sovereignNotifier,
)
if err != nil {
return nil, err
}
sovereignNotifierBootstrapper, err := startSovereignNotifierBootstrapper(
incomingHeaderHandler,
sovereignNotifier,
roundDuration,
forkDetector,
bootstrapper,
)
if err != nil {
return nil, err
}

return []mainFactory.Closer{sovereignWsReceiver, sovereignNotifierBootstrapper}, nil
}

func createSovereignWsReceiver(
config *config.NotifierConfig,
sovereignNotifier notifierProcess.SovereignNotifier,
Expand Down
1 change: 1 addition & 0 deletions config/sovereignConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type OutGoingBridgeCertificate struct {

// NotifierConfig holds sovereign notifier configuration
type NotifierConfig struct {
Enabled bool `toml:"Enabled"`
SubscribedEvents []SubscribedEvent `toml:"SubscribedEvents"`
WebSocketConfig WebSocketConfig `toml:"WebSocket"`
}
Expand Down
Loading