Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions beacon_chain/consensus_object_pools/blob_quarantine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ import
from std/sequtils import mapIt
from std/strutils import join

const
MaxBlobs = 3 * SLOTS_PER_EPOCH * MAX_BLOBS_PER_BLOCK_ELECTRA
## Same limit as `MaxOrphans` in `block_quarantine`;
## blobs may arrive before an orphan is tagged `blobless`
func maxBlobs(MAX_BLOBS_PER_BLOCK_ELECTRA: uint64): uint64 =
# Same limit as `MaxOrphans` in `block_quarantine`;
# blobs may arrive before an orphan is tagged `blobless`
3 * SLOTS_PER_EPOCH * MAX_BLOBS_PER_BLOCK_ELECTRA

type
BlobQuarantine* = object
maxBlobs: uint64
blobs*:
OrderedTable[(Eth2Digest, BlobIndex, KzgCommitment), ref BlobSidecar]
onBlobSidecarCallback*: OnBlobSidecarCallback
Expand All @@ -39,7 +40,7 @@ func shortLog*(x: seq[BlobFetchRecord]): string =
"[" & x.mapIt(shortLog(it.block_root) & shortLog(it.indices)).join(", ") & "]"

func put*(quarantine: var BlobQuarantine, blobSidecar: ref BlobSidecar) =
if quarantine.blobs.lenu64 >= MaxBlobs:
if quarantine.blobs.lenu64 >= quarantine.maxBlobs:
# FIFO if full. For example, sync manager and request manager can race to
# put blobs in at the same time, so one gets blob insert -> block resolve
# -> blob insert sequence, which leaves garbage blobs.
Expand Down Expand Up @@ -106,5 +107,8 @@ func blobFetchRecord*(quarantine: BlobQuarantine,
BlobFetchRecord(block_root: blck.root, indices: indices)

func init*(
T: type BlobQuarantine, onBlobSidecarCallback: OnBlobSidecarCallback): T =
T(onBlobSidecarCallback: onBlobSidecarCallback)
T: type BlobQuarantine,
cfg: RuntimeConfig,
onBlobSidecarCallback: OnBlobSidecarCallback): T =
T(maxBlobs: cfg.MAX_BLOBS_PER_BLOCK_ELECTRA.maxBlobs(),
onBlobSidecarCallback: onBlobSidecarCallback)
3 changes: 2 additions & 1 deletion beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ proc initFullNode(
dag, attestationPool, onVoluntaryExitAdded, onBLSToExecutionChangeAdded,
onProposerSlashingAdded, onPhase0AttesterSlashingAdded,
onElectraAttesterSlashingAdded))
blobQuarantine = newClone(BlobQuarantine.init(onBlobSidecarAdded))
blobQuarantine = newClone(BlobQuarantine.init(
dag.cfg, onBlobSidecarAdded))
dataColumnQuarantine = newClone(DataColumnQuarantine.init())
supernode = node.config.peerdasSupernode
localCustodyGroups =
Expand Down