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

feat: add options to disable upgrade & commission watchers #74

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ GLOBAL OPTIONS:
--node value [ --node value ] rpc node endpoint to connect to (specify multiple for high availability) (default: "http://localhost:26657")
--no-gov disable calls to gov module (useful for consumer chains) (default: false)
--no-staking disable calls to staking module (useful for consumer chains) (default: false)
--no-commission disable calls to get validator commission (useful for chains without distribution module) (default: false)
--no-upgrade disable calls to upgrade module (for chains created without the upgrade module) (default: false)
--denom value denom used in metrics label (eg. atom or uatom)
--denom-exponent value denom exponent (eg. 6 for atom, 1 for uatom) (default: 0)
--start-timeout value timeout to wait on startup for one node to be ready (default: 10s)
Expand Down
8 changes: 8 additions & 0 deletions pkg/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ var Flags = []cli.Flag{
Name: "no-staking",
Usage: "disable calls to staking module (useful for consumer chains)",
},
&cli.BoolFlag{
Name: "no-commission",
Usage: "disable calls to get validator commission (useful for chains without distribution module)",
},
&cli.BoolFlag{
Name: "no-upgrade",
Usage: "disable calls to upgrade module (for chains created without the upgrade module)",
},
&cli.StringFlag{
Name: "denom",
Usage: "denom used in metrics label (eg. atom or uatom)",
Expand Down
35 changes: 23 additions & 12 deletions pkg/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func RunFunc(cCtx *cli.Context) error {
nodes = cCtx.StringSlice("node")
noGov = cCtx.Bool("no-gov")
noStaking = cCtx.Bool("no-staking")
noUpgrade = cCtx.Bool("no-upgrade")
noCommission = cCtx.Bool("no-commission")
denom = cCtx.String("denom")
denomExpon = cCtx.Uint("denom-exponent")
startTimeout = cCtx.Duration("start-timeout")
Expand Down Expand Up @@ -95,10 +97,12 @@ func RunFunc(cCtx *cli.Context) error {
errg.Go(func() error {
return statusWatcher.Start(ctx)
})
commissionWatcher := watcher.NewCommissionsWatcher(trackedValidators, metrics, pool)
errg.Go(func() error {
return commissionWatcher.Start(ctx)
})
if !noCommission {
commissionWatcher := watcher.NewCommissionsWatcher(trackedValidators, metrics, pool)
errg.Go(func() error {
return commissionWatcher.Start(ctx)
})
}

//
// Pool watchers
Expand Down Expand Up @@ -132,13 +136,17 @@ func RunFunc(cCtx *cli.Context) error {
}
wh = webhook.New(*whURL)
}
upgradeWatcher := watcher.NewUpgradeWatcher(metrics, pool, wh, watcher.UpgradeWatcherOptions{
CheckPendingProposals: !noGov,
GovModuleVersion: xGov,
})
errg.Go(func() error {
return upgradeWatcher.Start(ctx)
})

var upgradeWatcher *watcher.UpgradeWatcher
if !noUpgrade {
upgradeWatcher = watcher.NewUpgradeWatcher(metrics, pool, wh, watcher.UpgradeWatcherOptions{
CheckPendingProposals: !noGov,
GovModuleVersion: xGov,
})
errg.Go(func() error {
return upgradeWatcher.Start(ctx)
})
}

//
// Register watchers on nodes events
Expand All @@ -147,7 +155,10 @@ func RunFunc(cCtx *cli.Context) error {
node.OnStart(blockWatcher.OnNodeStart)
node.OnStatus(statusWatcher.OnNodeStatus)
node.OnEvent(rpc.EventNewBlock, blockWatcher.OnNewBlock)
node.OnEvent(rpc.EventNewBlock, upgradeWatcher.OnNewBlock)

if upgradeWatcher != nil {
node.OnEvent(rpc.EventNewBlock, upgradeWatcher.OnNewBlock)
}
}

//
Expand Down
Loading