1
1
# beacon_chain
2
- # Copyright (c) 2018-2024 Status Research & Development GmbH
2
+ # Copyright (c) 2018-2025 Status Research & Development GmbH
3
3
# Licensed and distributed under either of
4
4
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
5
5
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
@@ -18,7 +18,7 @@ export tables, forks
18
18
const
19
19
MaxRetriesPerMissingItem = 7
20
20
# # Exponential backoff, double interval between each attempt
21
- MaxMissingItems = 1024
21
+ MaxMissingItems* = 1024
22
22
# # Arbitrary
23
23
MaxOrphans = SLOTS_PER_EPOCH * 3
24
24
# # Enough for finalization in an alternative fork
@@ -215,6 +215,9 @@ func removeUnviableBloblessTree(
215
215
toRemove.setLen(0 )
216
216
217
217
func addUnviable* (quarantine: var Quarantine, root: Eth2Digest) =
218
+ # Unviable - don't try to download again!
219
+ quarantine.missing.del(root)
220
+
218
221
if root in quarantine.unviable:
219
222
return
220
223
@@ -281,18 +284,24 @@ func addOrphan*(
281
284
quarantine: var Quarantine, finalizedSlot: Slot,
282
285
signedBlock: ForkedSignedBeaconBlock): Result[void , cstring ] =
283
286
# # Adds block to quarantine's `orphans` and `missing` lists.
287
+
284
288
if not isViable(finalizedSlot, getForkedBlockField(signedBlock, slot)):
285
- quarantine.addUnviable(signedBlock.root)
289
+ quarantine.addUnviable(signedBlock.root) # will remove from missing
286
290
return err(" block unviable" )
287
291
288
292
quarantine.cleanupOrphans(finalizedSlot)
289
293
290
294
let parent_root = getForkedBlockField(signedBlock, parent_root)
291
295
292
296
if parent_root in quarantine.unviable:
293
- quarantine.unviable[ signedBlock.root] = ( )
297
+ quarantine.addUnviable( signedBlock.root)
294
298
return err(" block parent unviable" )
295
299
300
+ # It's no longer missing if we downloaded it - remove before adding to make
301
+ # sure parent chains get downloaded even if missing list is full (works as
302
+ # long as the orphan was in the missing list, which is likely)
303
+ quarantine.missing.del(signedBlock.root)
304
+
296
305
# Even if the quarantine is full, we need to schedule its parent for
297
306
# downloading or we'll never get to the bottom of things
298
307
quarantine.addMissing(parent_root)
@@ -307,7 +316,6 @@ func addOrphan*(
307
316
quarantine.blobless.del oldest_orphan_key[0 ]
308
317
309
318
quarantine.orphans[(signedBlock.root, signedBlock.signature)] = signedBlock
310
- quarantine.missing.del(signedBlock.root)
311
319
312
320
ok()
313
321
0 commit comments