Skip to content

Commit 491091f

Browse files
committed
top-up pubkey cache on startup
1 parent 6d5a2be commit 491091f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

beacon_node/beacon_chain/src/builder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,20 @@ where
325325
.unwrap_or_else(OperationPool::new),
326326
);
327327

328-
let pubkey_cache = ValidatorPubkeyCache::load_from_store(store)
328+
let mut pubkey_cache = ValidatorPubkeyCache::load_from_store(store.clone())
329329
.map_err(|e| format!("Unable to open persisted pubkey cache: {:?}", e))?;
330330

331+
// If any validators weren't persisted to disk on previous runs, this will use the genesis_state to
332+
// "top-up" the in-memory validator cache and its on-disk representation with any missing validators.
333+
let pubkey_store_ops = pubkey_cache
334+
.import_new_pubkeys(&genesis_state)
335+
.map_err(|e| format!("Unable to top-up persisted pubkey cache {:?}", e))?;
336+
337+
// Write any missed validators to disk
338+
store
339+
.do_atomically_with_block_and_blobs_cache(pubkey_store_ops)
340+
.map_err(|e| format!("Unable to write pubkeys to disk {:?}", e))?;
341+
331342
self.genesis_block_root = Some(chain.genesis_block_root);
332343
self.genesis_state_root = Some(genesis_block.state_root());
333344
self.head_tracker = Some(

0 commit comments

Comments
 (0)