mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 19:34:37 +00:00
Top-up pubkey cache on startup (#7217)
This is a workaround for #7216 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
This commit is contained in:
@@ -847,10 +847,31 @@ where
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let validator_pubkey_cache = self.validator_pubkey_cache.map(Ok).unwrap_or_else(|| {
|
let validator_pubkey_cache = self
|
||||||
ValidatorPubkeyCache::new(&head_snapshot.beacon_state, store.clone())
|
.validator_pubkey_cache
|
||||||
.map_err(|e| format!("Unable to init validator pubkey cache: {:?}", e))
|
.map(|mut validator_pubkey_cache| {
|
||||||
})?;
|
// If any validators weren't persisted to disk on previous runs, this will use the head state to
|
||||||
|
// "top-up" the in-memory validator cache and its on-disk representation with any missing validators.
|
||||||
|
let pubkey_store_ops = validator_pubkey_cache
|
||||||
|
.import_new_pubkeys(&head_snapshot.beacon_state)
|
||||||
|
.map_err(|e| format!("Unable to top-up persisted pubkey cache {:?}", e))?;
|
||||||
|
if !pubkey_store_ops.is_empty() {
|
||||||
|
// Write any missed validators to disk
|
||||||
|
debug!(
|
||||||
|
store.log,
|
||||||
|
"Topping up validator pubkey cache";
|
||||||
|
"missing_validators" => pubkey_store_ops.len()
|
||||||
|
);
|
||||||
|
store
|
||||||
|
.do_atomically_with_block_and_blobs_cache(pubkey_store_ops)
|
||||||
|
.map_err(|e| format!("Unable to write pubkeys to disk {:?}", e))?;
|
||||||
|
}
|
||||||
|
Ok(validator_pubkey_cache)
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
ValidatorPubkeyCache::new(&head_snapshot.beacon_state, store.clone())
|
||||||
|
.map_err(|e| format!("Unable to init validator pubkey cache: {:?}", e))
|
||||||
|
})?;
|
||||||
|
|
||||||
let migrator_config = self.store_migrator_config.unwrap_or_default();
|
let migrator_config = self.store_migrator_config.unwrap_or_default();
|
||||||
let store_migrator = BackgroundMigrator::new(
|
let store_migrator = BackgroundMigrator::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user