@@ -44,13 +44,6 @@ pub enum Error {
44
44
state_root : Hash256 ,
45
45
latest_block_root : Hash256 ,
46
46
} ,
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
- } ,
54
47
MissingChildStateRoot ( Hash256 ) ,
55
48
RequestedSlotAboveSummary {
56
49
starting_state_root : Hash256 ,
@@ -170,34 +163,17 @@ impl StateSummariesDAG {
170
163
* * state_root
171
164
} else {
172
165
// 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.
173
170
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)
201
177
}
202
178
} ;
203
179
0 commit comments