Skip to content

Commit ed82b3a

Browse files
authored
Merge of #8353
2 parents 0507eca + f1f28de commit ed82b3a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
883883
return Ok(None);
884884
}
885885

886+
// Fast-path for the split slot (which usually corresponds to the finalized slot).
887+
let split = self.store.get_split_info();
888+
if request_slot == split.slot {
889+
return Ok(Some(split.state_root));
890+
}
891+
886892
// Try an optimized path of reading the root directly from the head state.
887893
let fast_lookup: Option<Hash256> = self.with_head(|head| {
888894
if head.beacon_block.slot() <= request_slot {

beacon_node/beacon_chain/tests/store_tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,6 +3155,10 @@ async fn weak_subjectivity_sync_test(
31553155
.get_state(&state_root, Some(slot), CACHE_STATE_IN_TESTS)
31563156
.unwrap()
31573157
.unwrap();
3158+
assert_eq!(
3159+
state_root,
3160+
beacon_chain.state_root_at_slot(slot).unwrap().unwrap()
3161+
);
31583162
assert_eq!(state.slot(), slot);
31593163
assert_eq!(state.canonical_root().unwrap(), state_root);
31603164
}

0 commit comments

Comments
 (0)