Remove blobsSidecar from orphans table (#4670)
This commit is contained in:
parent
a999da3361
commit
dede36fe86
|
@ -10,8 +10,7 @@
|
|||
import
|
||||
std/[tables],
|
||||
stew/bitops2,
|
||||
../spec/forks,
|
||||
../spec/datatypes/deneb
|
||||
../spec/forks
|
||||
|
||||
export tables, forks
|
||||
|
||||
|
@ -39,8 +38,7 @@ type
|
|||
##
|
||||
## Trivially invalid blocks may be dropped before reaching this stage.
|
||||
|
||||
orphans*: Table[(Eth2Digest, ValidatorSig),
|
||||
(ForkedSignedBeaconBlock, Opt[deneb.BlobsSidecar])]
|
||||
orphans*: Table[(Eth2Digest, ValidatorSig), ForkedSignedBeaconBlock]
|
||||
## Blocks that we don't have a parent for - when we resolve the parent, we
|
||||
## can proceed to resolving the block as well - we index this by root and
|
||||
## signature such that a block with invalid signature won't cause a block
|
||||
|
@ -149,7 +147,7 @@ func addUnviable*(quarantine: var Quarantine, root: Eth2Digest) =
|
|||
while toCheck.len > 0:
|
||||
let root = toCheck.pop()
|
||||
for k, v in quarantine.orphans.mpairs():
|
||||
if getForkedBlockField(v[0], parent_root) == root:
|
||||
if getForkedBlockField(v, parent_root) == root:
|
||||
toCheck.add(k[0])
|
||||
toRemove.add(k)
|
||||
elif k[0] == root:
|
||||
|
@ -167,7 +165,7 @@ func cleanupOrphans(quarantine: var Quarantine, finalizedSlot: Slot) =
|
|||
var toDel: seq[(Eth2Digest, ValidatorSig)]
|
||||
|
||||
for k, v in quarantine.orphans:
|
||||
if not isViableOrphan(finalizedSlot, v[0]):
|
||||
if not isViableOrphan(finalizedSlot, v):
|
||||
toDel.add k
|
||||
|
||||
for k in toDel:
|
||||
|
@ -192,8 +190,7 @@ func clearAfterReorg*(quarantine: var Quarantine) =
|
|||
# likely imminent arrival.
|
||||
func addOrphan*(
|
||||
quarantine: var Quarantine, finalizedSlot: Slot,
|
||||
signedBlock: ForkedSignedBeaconBlock,
|
||||
blobs: Opt[deneb.BlobsSidecar]): bool =
|
||||
signedBlock: ForkedSignedBeaconBlock): bool =
|
||||
## Adds block to quarantine's `orphans` and `missing` lists.
|
||||
if not isViableOrphan(finalizedSlot, signedBlock):
|
||||
quarantine.addUnviable(signedBlock.root)
|
||||
|
@ -214,14 +211,13 @@ func addOrphan*(
|
|||
if quarantine.orphans.lenu64 >= MaxOrphans:
|
||||
return false
|
||||
|
||||
quarantine.orphans[(signedBlock.root, signedBlock.signature)] =
|
||||
(signedBlock, blobs)
|
||||
quarantine.orphans[(signedBlock.root, signedBlock.signature)] = signedBlock
|
||||
quarantine.missing.del(signedBlock.root)
|
||||
|
||||
true
|
||||
|
||||
iterator pop*(quarantine: var Quarantine, root: Eth2Digest):
|
||||
(ForkedSignedBeaconBlock, Opt[deneb.BlobsSidecar]) =
|
||||
ForkedSignedBeaconBlock =
|
||||
# Pop orphans whose parent is the block identified by `root`
|
||||
|
||||
var toRemove: seq[(Eth2Digest, ValidatorSig)]
|
||||
|
@ -230,6 +226,6 @@ iterator pop*(quarantine: var Quarantine, root: Eth2Digest):
|
|||
quarantine.orphans.del k
|
||||
|
||||
for k, v in quarantine.orphans.mpairs():
|
||||
if getForkedBlockField(v[0], parent_root) == root:
|
||||
if getForkedBlockField(v, parent_root) == root:
|
||||
toRemove.add(k)
|
||||
yield v
|
||||
|
|
|
@ -470,7 +470,7 @@ proc storeBlock*(
|
|||
return err((VerifierError.UnviableFork, ProcessingStatus.completed))
|
||||
|
||||
if not self.consensusManager.quarantine[].addOrphan(
|
||||
dag.finalizedHead.slot, ForkedSignedBeaconBlock.init(signedBlock), blobs):
|
||||
dag.finalizedHead.slot, ForkedSignedBeaconBlock.init(signedBlock)):
|
||||
debug "Block quarantine full",
|
||||
blockRoot = shortLog(signedBlock.root),
|
||||
blck = shortLog(signedBlock.message),
|
||||
|
@ -591,7 +591,7 @@ proc storeBlock*(
|
|||
|
||||
for quarantined in self.consensusManager.quarantine[].pop(blck.get().root):
|
||||
# Process the blocks that had the newly accepted block as parent
|
||||
self[].addBlock(MsgSource.gossip, quarantined[0], quarantined[1])
|
||||
self[].addBlock(MsgSource.gossip, quarantined, Opt.none(deneb.BlobsSidecar))
|
||||
|
||||
return Result[BlockRef, (VerifierError, ProcessingStatus)].ok blck.get
|
||||
|
||||
|
|
|
@ -380,7 +380,7 @@ proc validateBeaconBlock*(
|
|||
# in the quarantine for later processing
|
||||
if not quarantine[].addOrphan(
|
||||
dag.finalizedHead.slot,
|
||||
ForkedSignedBeaconBlock.init(signed_beacon_block), blobs):
|
||||
ForkedSignedBeaconBlock.init(signed_beacon_block)):
|
||||
debug "Block quarantine full"
|
||||
|
||||
return errIgnore("BeaconBlock: Parent not found")
|
||||
|
|
|
@ -35,13 +35,13 @@ suite "Block quarantine":
|
|||
check:
|
||||
FetchRecord(root: b1.root) in quarantine.checkMissing()
|
||||
|
||||
quarantine.addOrphan(Slot 0, b1, Opt.none(BlobsSidecar))
|
||||
quarantine.addOrphan(Slot 0, b1)
|
||||
|
||||
FetchRecord(root: b1.root) notin quarantine.checkMissing()
|
||||
|
||||
quarantine.addOrphan(Slot 0, b2, Opt.none(BlobsSidecar))
|
||||
quarantine.addOrphan(Slot 0, b3, Opt.none(BlobsSidecar))
|
||||
quarantine.addOrphan(Slot 0, b4, Opt.none(BlobsSidecar))
|
||||
quarantine.addOrphan(Slot 0, b2)
|
||||
quarantine.addOrphan(Slot 0, b3)
|
||||
quarantine.addOrphan(Slot 0, b4)
|
||||
|
||||
(b4.root, ValidatorSig()) in quarantine.orphans
|
||||
|
||||
|
|
Loading…
Reference in New Issue