From 325bdfd4a2833601ef16a6ae5396fe365eb4a9a3 Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Tue, 25 Jun 2024 18:08:00 +0530 Subject: [PATCH] support for enqueueing whichever is activated blob/data_column --- .../gossip_processing/block_processor.nim | 26 +++++++++++---- .../gossip_processing/eth2_processor.nim | 10 +++++- beacon_chain/sync/sync_queue.nim | 32 ------------------- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index d37d09e4a..385e6e944 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -431,7 +431,7 @@ proc enqueueBlock*( self.blockQueue.addLastNoWait(BlockEntry( blck: blck, blobs: blobs, - data_columns: data_columns, + data_columns: Opt.none(DataColumnSidecars), maybeFinalized: maybeFinalized, resfut: resfut, queueTick: Moment.now(), validationDur: validationDur, @@ -542,6 +542,11 @@ proc storeBlock( else: Opt.none BlobSidecars + if blobsOk: + debug "Loaded parent block from storage", parent_root + self[].enqueueBlock( + MsgSource.gossip, parentBlck.unsafeGet().asSigned(), blobs, Opt.none(DataColumnSidecars)) + var columnsOk = true let data_columns = withBlck(parentBlck.get()): @@ -556,10 +561,10 @@ proc storeBlock( Opt.some data_column_sidecars else: Opt.none DataColumnSidecars - if blobsOk and columnsOk: + if columnsOk: debug "Loaded parent block from storage", parent_root self[].enqueueBlock( - MsgSource.gossip, parentBlck.unsafeGet().asSigned(), blobs, data_columns) + MsgSource.gossip, parentBlck.unsafeGet().asSigned(), Opt.none(BlobSidecars), data_columns) return handleVerifierError(parent.error()) @@ -835,16 +840,23 @@ proc storeBlock( blck = shortLog(forkyBlck), error = res.error() continue - if self.blobQuarantine[].hasBlobs(forkyBlck) and self.dataColumnQuarantine[].hasDataColumns(forkyBlck): + if self.blobQuarantine[].hasBlobs(forkyBlck): let blobs = self.blobQuarantine[].popBlobs( forkyBlck.root, forkyBlck) - let data_columns = self.dataColumnQuarantine[].popDataColumns( - forkyBlck.root, forkyBlck) - self[].enqueueBlock(MsgSource.gossip, quarantined, Opt.some(blobs), Opt.some(data_columns)) + self[].enqueueBlock(MsgSource.gossip, quarantined, Opt.some(blobs), Opt.none(DataColumnSidecars)) else: discard self.consensusManager.quarantine[].addBlobless( dag.finalizedHead.slot, forkyBlck) + if self.dataColumnQuarantine[].hasDataColumns(forkyBlck): + let data_columns = self.dataColumnQuarantine[].popDataColumns( + forkyBlck.root, forkyBlck) + self[].enqueueBlock(MsgSource.gossip, quarantined, Opt.none(BlobSidecars), Opt.some(data_columns)) + + else: + discard self.consensusManager.quarantine[].addColumnless( + dag.finalizedHead.slot, forkyBlck) + ok blck.value() # Enqueue diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index 6f267d320..355a87701 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -261,6 +261,14 @@ proc processSignedBeaconBlock*( else: Opt.none(BlobSidecars) + self.blockProcessor[].enqueueBlock( + src, ForkedSignedBeaconBlock.init(signedBlock), + blobs, + Opt.none(DataColumnSidecars), + maybeFinalized = maybeFinalized, + validationDur = nanoseconds( + (self.getCurrentBeaconTime() - wallTime).nanoseconds)) + let data_columns = when typeof(signedBlock).kind >= ConsensusFork.Deneb: if self.dataColumnQuarantine[].hasDataColumns(signedBlock): @@ -274,7 +282,7 @@ proc processSignedBeaconBlock*( self.blockProcessor[].enqueueBlock( src, ForkedSignedBeaconBlock.init(signedBlock), - blobs, + Opt.none(BlobSidecars), data_columns, maybeFinalized = maybeFinalized, validationDur = nanoseconds( diff --git a/beacon_chain/sync/sync_queue.nim b/beacon_chain/sync/sync_queue.nim index 7888a5b81..27c1f7218 100644 --- a/beacon_chain/sync/sync_queue.nim +++ b/beacon_chain/sync/sync_queue.nim @@ -736,38 +736,6 @@ proc push*[T](sq: SyncQueue[T], sr: SyncRequest[T], req.item.updateScore(PeerScoreBadValues) break - var counter = 0 - for blk, dc in sq.das_blocks(item): - res = await sq.blockVerifier(blk[], Opt.none(BlobSidecars), dc, maybeFinalized) - inc(counter) - - if res.isOk(): - goodBlock = some(blk[].slot) - else: - case res.error() - of VerifierError.MissingParent: - missingParentSlot = some(blk[].slot) - break - of VerifierError.Duplicate: - # Keep going, happens naturally - discard - of VerifierError.UnviableFork: - # Keep going so as to register other unviable blocks with the - # qurantine - if unviableBlock.isNone: - # Remember the first unviable block, so we can log it - unviableBlock = some((blk[].root, blk[].slot)) - - of VerifierError.Invalid: - hasInvalidBlock = true - - let req = item.request - notice "Received invalid sequence of blocks", request = req, - blocks_count = len(item.data), - blocks_map = getShortMap(req, item.data) - req.item.updateScore(PeerScoreBadValues) - break - # When errors happen while processing blocks, we retry the same request # with, hopefully, a different peer let retryRequest =