Skip to content

Commit

Permalink
feat: add options to disable upgrade & commission watchers (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKetmo authored Jun 7, 2024
1 parent 8ae35b5 commit 78b52ae
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
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

0 comments on commit 78b52ae

Please sign in to comment.