-
Notifications
You must be signed in to change notification settings - Fork 886
Top-up pubkey cache on startup #7217
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
Top-up pubkey cache on startup #7217
Conversation
// If any validators weren't persisted to disk on previous runs, this will use the genesis_state to | ||
// "top-up" the in-memory validator cache and its on-disk representation with any missing validators. | ||
let pubkey_store_ops = pubkey_cache | ||
.import_new_pubkeys(&genesis_state) |
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.
I don't think we wanna do this with the genesis state, we need the head state (or maybe the finalized state, but the head would be better)
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.
Here:
lighthouse/beacon_node/beacon_chain/src/builder.rs
Lines 817 to 820 in 491091f
let (_head_state_root, head_state) = store | |
.get_advanced_hot_state(head_block_root, current_slot, head_block.state_root()) | |
.map_err(|e| descriptive_db_error("head state", &e))? | |
.ok_or("Head state not found in store")?; |
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.
We'd do the top up in the Ok
case here:
lighthouse/beacon_node/beacon_chain/src/builder.rs
Lines 861 to 864 in 491091f
let validator_pubkey_cache = self.validator_pubkey_cache.map(Ok).unwrap_or_else(|| { | |
ValidatorPubkeyCache::new(&head_snapshot.beacon_state, store.clone()) | |
.map_err(|e| format!("Unable to init validator pubkey cache: {:?}", e)) | |
})?; |
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.
LGTM!
Issue Addressed
This is a workaround for #7216
Proposed Changes
In the case of gaps between the in-memory pub key cache and its on-disk representation, use the head state on startup to "top-up" the cache/db w/ any missing validators