Skip to content

Commit 4dd2130

Browse files
committed
fix test
1 parent 36309d3 commit 4dd2130

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

beacon_node/beacon_chain/src/builder.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,19 +434,17 @@ where
434434
.update_tree_hash_cache()
435435
.map_err(|e| format!("Error computing checkpoint state root: {:?}", e))?;
436436

437-
let state_slot_block_root = weak_subj_state
438-
.get_block_root(weak_subj_state.slot())
439-
.map_err(|e| {
440-
format!(
441-
"Unable to get block root for slot {}: {e:?}",
442-
weak_subj_state.slot()
443-
)
444-
})?;
445-
if weak_subj_block_root != *state_slot_block_root {
446-
return Err(format!(
447-
"Snapshot state's most recent block root does not match block, expected: {:?}, got: {:?}",
448-
weak_subj_block_root, state_slot_block_root
449-
));
437+
let latest_block_slot = weak_subj_state.latest_block_header().slot;
438+
439+
// We can only validate the block root if it exists in the state. We can't calculated it
440+
// from the `latest_block_header` because the state root might be set to the zero hash.
441+
if let Ok(state_slot_block_root) = weak_subj_state.get_block_root(latest_block_slot) {
442+
if weak_subj_block_root != *state_slot_block_root {
443+
return Err(format!(
444+
"Snapshot state's most recent block root does not match block, expected: {:?}, got: {:?}",
445+
weak_subj_block_root, state_slot_block_root
446+
));
447+
}
450448
}
451449

452450
// Check that the checkpoint state is for the same network as the genesis state.

0 commit comments

Comments
 (0)