mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Fix bug in block root storage (#4663)
## Issue Addressed Fix a bug in the storage of the linear block roots array in the freezer DB. Previously this array was always written as part of state storage (or block backfill). With state pruning enabled by #4610, these states were no longer being written and as a result neither were the block roots. The impact is quite low, we would just log an error when trying to forwards-iterate the block roots, which for validating nodes only happens when they try to look up blocks for peers: > Aug 25 03:42:36.980 ERRO Missing chunk in forwards iterator chunk index: 49726, service: freezer_db Any node checkpoint synced off `unstable` is affected and has a corrupt database. If you see the log above, you need to re-sync with the fix. Nodes that haven't checkpoint synced recently should _not_ be corrupted, even if they ran the buggy version. ## Proposed Changes - Use a `ChunkWriter` to write the block roots when states are not being stored. - Tweak the usage of `get_latest_restore_point` so that it doesn't return a nonsense value when state pruning is enabled. - Tweak the guarantee on the block roots array so that block roots are assumed available up to the split slot (exclusive). This is a bit nicer than relying on anything to do with the latest restore point, which is a nonsensical concept when there aren't any restore points. ## Additional Info I'm looking forward to deleting the chunked vector code for good when we merge tree-states 😁
This commit is contained in:
@@ -481,6 +481,21 @@ where
|
||||
let (_, updated_builder) = self.set_genesis_state(genesis_state)?;
|
||||
self = updated_builder;
|
||||
|
||||
// Fill in the linear block roots between the checkpoint block's slot and the aligned
|
||||
// state's slot. All slots less than the block's slot will be handled by block backfill,
|
||||
// while states greater or equal to the checkpoint state will be handled by `migrate_db`.
|
||||
let block_root_batch = store
|
||||
.store_frozen_block_root_at_skip_slots(
|
||||
weak_subj_block.slot(),
|
||||
weak_subj_state.slot(),
|
||||
weak_subj_block_root,
|
||||
)
|
||||
.map_err(|e| format!("Error writing frozen block roots: {e:?}"))?;
|
||||
store
|
||||
.cold_db
|
||||
.do_atomically(block_root_batch)
|
||||
.map_err(|e| format!("Error writing frozen block roots: {e:?}"))?;
|
||||
|
||||
// Write the state and block non-atomically, it doesn't matter if they're forgotten
|
||||
// about on a crash restart.
|
||||
store
|
||||
|
||||
Reference in New Issue
Block a user