File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed
beacon_node/beacon_chain/src Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -434,19 +434,17 @@ where
434
434
. update_tree_hash_cache ( )
435
435
. map_err ( |e| format ! ( "Error computing checkpoint state root: {:?}" , e) ) ?;
436
436
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
+ }
450
448
}
451
449
452
450
// Check that the checkpoint state is for the same network as the genesis state.
You can’t perform that action at this time.
0 commit comments