Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Jun 13, 2023
1 parent 36309d3 commit 4dd2130
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions beacon_node/beacon_chain/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,19 +434,17 @@ where
.update_tree_hash_cache()
.map_err(|e| format!("Error computing checkpoint state root: {:?}", e))?;

let state_slot_block_root = weak_subj_state
.get_block_root(weak_subj_state.slot())
.map_err(|e| {
format!(
"Unable to get block root for slot {}: {e:?}",
weak_subj_state.slot()
)
})?;
if weak_subj_block_root != *state_slot_block_root {
return Err(format!(
"Snapshot state's most recent block root does not match block, expected: {:?}, got: {:?}",
weak_subj_block_root, state_slot_block_root
));
let latest_block_slot = weak_subj_state.latest_block_header().slot;

// We can only validate the block root if it exists in the state. We can't calculated it
// from the `latest_block_header` because the state root might be set to the zero hash.
if let Ok(state_slot_block_root) = weak_subj_state.get_block_root(latest_block_slot) {
if weak_subj_block_root != *state_slot_block_root {
return Err(format!(
"Snapshot state's most recent block root does not match block, expected: {:?}, got: {:?}",
weak_subj_block_root, state_slot_block_root
));
}
}

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

0 comments on commit 4dd2130

Please sign in to comment.