-
Notifications
You must be signed in to change notification settings - Fork 5
refactor(eth2api): make ValidatorCache immutable in BeaconNodeClient #667
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a90b27b
refactor(eth2api): make ValidatorCache immutable in BeaconNodeClient
varex83agent 333a01e
refactor(app): build the validator cache and beacon clients in wire_c…
emlautarom1-agent[bot] 5faf3c1
Update Cargo.lock
emlautarom1 9749ee4
Merge remote-tracking branch 'origin/main' into feat/fix-482
varex83agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -258,6 +258,11 @@ pub struct WireInputs { | |||||||||
| pub eth2_cl: EthBeaconNodeApiClient, | ||||||||||
| /// Submission beacon node client used for broadcasting. | ||||||||||
| pub submission_client: BeaconNodeClient, | ||||||||||
| /// Pubkey-scoped validator cache shared by the beacon/submission clients | ||||||||||
| /// and the validator API. A clone of the same `Arc`-backed cache seeded | ||||||||||
| /// into those clients, so the per-epoch trim + refresh subscriber wired | ||||||||||
| /// below refreshes every consumer at once. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this comment:
Suggested change
|
||||||||||
| pub validator_cache: ValidatorCache, | ||||||||||
| /// Per-validator data for this node. | ||||||||||
| pub validators: Vec<ValidatorInfo>, | ||||||||||
| /// Current consensus implementation, from the controller. Forwards to the | ||||||||||
|
|
@@ -424,6 +429,7 @@ pub async fn wire_core_workflow( | |||||||||
| beacon_client, | ||||||||||
| eth2_cl, | ||||||||||
| submission_client, | ||||||||||
| validator_cache, | ||||||||||
| validators, | ||||||||||
| consensus, | ||||||||||
| builder_enabled, | ||||||||||
|
|
@@ -442,29 +448,19 @@ pub async fn wire_core_workflow( | |||||||||
| } = inputs; | ||||||||||
|
|
||||||||||
| // ---- Derived validator maps ---- | ||||||||||
| let mut eth2_pubkeys = Vec::with_capacity(validators.len()); | ||||||||||
| // DV root pubkey -> this node's public share (validatorapi wants this flat | ||||||||||
| // map already collapsed for our share index). | ||||||||||
| let mut pub_share_by_pubkey: HashMap<BLSPubKey, BLSPubKey> = HashMap::new(); | ||||||||||
| let mut fee_recipient_by_pubkey: HashMap<PubKey, ExecutionAddress> = HashMap::new(); | ||||||||||
| for val in &validators { | ||||||||||
| eth2_pubkeys.push(val.eth2_pubkey); | ||||||||||
| pub_share_by_pubkey.insert(val.eth2_pubkey, val.pubshare); | ||||||||||
| fee_recipient_by_pubkey.insert(val.pubkey, val.fee_recipient); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // One pubkey-scoped validator cache shared by the scheduler's beacon | ||||||||||
| // client, the submission client, and the validator API, so every consumer | ||||||||||
| // resolves the same cluster validator set. Without seeding, the scheduler | ||||||||||
| // would resolve duties against an empty (or unfiltered) set. `ValidatorCache` | ||||||||||
| // clones share state, so the per-epoch trim + refresh subscriber registered | ||||||||||
| // below refreshes every consumer at once. | ||||||||||
| let validator_cache = ValidatorCache::new(eth2_cl.clone(), eth2_pubkeys); | ||||||||||
| tokio::join!( | ||||||||||
| beacon_client.set_validator_cache(validator_cache.clone()), | ||||||||||
| submission_client.set_validator_cache(validator_cache.clone()), | ||||||||||
| ); | ||||||||||
|
|
||||||||||
| // The pubkey-scoped validator cache is built and seeded into the | ||||||||||
| // beacon/submission clients at construction (in `node::run`), and passed in | ||||||||||
| // here so the per-epoch trim + refresh subscriber registered below (and the | ||||||||||
| // validator API) share the same `Arc`-backed state. | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this comment:
Suggested change
|
||||||||||
| let fee_recipient_fn: FeeRecipientFunc = { | ||||||||||
| let map = fee_recipient_by_pubkey.clone(); | ||||||||||
| Arc::new(move |pubkey: &PubKey| map.get(pubkey).copied().unwrap_or_default()) | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it short: