Skip to content

Commit 8fa3665

Browse files
committed
Remove non-contiguous DAG checks
1 parent 54ded28 commit 8fa3665

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

beacon_node/beacon_chain/src/summaries_dag.rs

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ pub enum Error {
4444
state_root: Hash256,
4545
latest_block_root: Hash256,
4646
},
47-
StateSummariesNotContiguous {
48-
state_root: Hash256,
49-
state_slot: Slot,
50-
latest_block_root: Hash256,
51-
parent_block_root: Box<Hash256>,
52-
parent_block_latest_state_summary: Box<Option<(Slot, Hash256)>>,
53-
},
5447
MissingChildStateRoot(Hash256),
5548
RequestedSlotAboveSummary {
5649
starting_state_root: Hash256,
@@ -170,34 +163,17 @@ impl StateSummariesDAG {
170163
**state_root
171164
} else {
172165
// Common case: not a skipped slot.
166+
//
167+
// If we can't find a state summmary for the parent block and previous slot,
168+
// then there is some amount of disjointedness in the DAG. We set the parent
169+
// state root to 0x0 in this case, and will prune any dangling states.
173170
let parent_block_root = summary.block_parent_root;
174-
if let Some(parent_block_summaries) =
175-
state_summaries_by_block_root.get(&parent_block_root)
176-
{
177-
*parent_block_summaries
178-
.get(&previous_slot)
179-
// Should never error: summaries are contiguous, so if there's an
180-
// entry it must contain at least one summary at the previous slot.
181-
.ok_or(Error::StateSummariesNotContiguous {
182-
state_root: *state_root,
183-
state_slot: summary.slot,
184-
latest_block_root: summary.latest_block_root,
185-
parent_block_root: parent_block_root.into(),
186-
parent_block_latest_state_summary: parent_block_summaries
187-
.iter()
188-
.max_by(|a, b| a.0.cmp(b.0))
189-
.map(|(slot, (state_root, _))| (*slot, **state_root))
190-
.into(),
191-
})?
192-
.0
193-
} else {
194-
// We don't know of any summary with this parent block root. We'll
195-
// consider this summary to be a root of `state_summaries_v22`
196-
// collection and mark it as zero.
197-
// The test store_tests::finalizes_non_epoch_start_slot manages to send two
198-
// disjoint trees on its second migration.
199-
Hash256::ZERO
200-
}
171+
state_summaries_by_block_root
172+
.get(&parent_block_root)
173+
.and_then(|parent_block_summaries| {
174+
parent_block_summaries.get(&previous_slot)
175+
})
176+
.map_or(Hash256::ZERO, |(parent_state_root, _)| **parent_state_root)
201177
}
202178
};
203179

0 commit comments

Comments
 (0)