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

Fix live reloading of staker config #2587

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

ganeshvanahalli
Copy link
Contributor

In staker's L1ValidatorConfig, most of the fields with hot-reload tag (except log-query-batch-size) are not used inside staker itself but used and handled correctly in different other places. Previously Staker struct didn't implement live-reloading of its config even though it was marked as hot-reload, this PR fixes it.

Note: Since most fields are not required to be hot-reloaded, this PR also tries to minimize invoking L1ValidatorConfigFetcher field of staker to lower the number of RLocks

Resolves NIT-2660

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Aug 19, 2024
@ganeshvanahalli ganeshvanahalli marked this pull request as ready for review August 19, 2024 11:35
@@ -660,7 +660,7 @@ func createNodeImpl(
confirmedNotifiers = append(confirmedNotifiers, messagePruner)
}

stakerObj, err = staker.NewStaker(l1Reader, wallet, bind.CallOpts{}, config.Staker, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, fatalErrChan)
stakerObj, err = staker.NewStaker(l1Reader, wallet, bind.CallOpts{}, func() *staker.L1ValidatorConfig { return &configFetcher.Get().Staker }, blockValidator, statelessBlockValidator, nil, confirmedNotifiers, deployInfo.ValidatorUtils, fatalErrChan)
Copy link
Member

Choose a reason for hiding this comment

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

This means that the options in Staker will only be loaded during startup, the hot reloadable flag will be ignored.

Copy link
Contributor Author

@ganeshvanahalli ganeshvanahalli Aug 20, 2024

Choose a reason for hiding this comment

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

Since the staker now takes a function of type L1ValidatorConfigFetcher which is a function that would call configFetcher every time we invoke it this effectively implements live reloading.
(this impl is similar to how its done for other hot-reloadable configs such as batchposterconfig

Config: func() *BatchPosterConfig { return &configFetcher.Get().BatchPoster },
)

I've tested this locally that hot-reloadable options are updated periodically.

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@eljobe eljobe left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@joshuacolvin0 joshuacolvin0 left a comment

Choose a reason for hiding this comment

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

LGTM

@ganeshvanahalli ganeshvanahalli merged commit 40601f7 into master Aug 20, 2024
13 checks passed
@ganeshvanahalli ganeshvanahalli deleted the fix-hotreloading-staker branch August 20, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants