From c2419a51320ac2d098c3f349d6e80ab5f6b08cc3 Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Thu, 10 Oct 2024 00:26:01 +0530 Subject: [PATCH] add more extensive da checks --- beacon_chain/nimbus_beacon_node.nim | 33 ++++++++++++++++++----------- beacon_chain/sync/sync_manager.nim | 7 +++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index bb7d6848e..9de1067a6 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -420,19 +420,28 @@ proc initFullNode( localSubnetCount)) accumulatedColumns = dataColumnQuarantine[].accumulateDataColumns(forkyBlck) - for ac in accumulatedColumns: - if ac notin localCustodyColumns: - # We don't have all the data columns for this block, so we have - # to put it in columnless quarantine. - if not quarantine[].addColumnless(dag.finalizedHead.slot, forkyBlck): - return err(VerifierError.UnviableFork) - else: - return err(VerifierError.MissingParent) + if accumulatedColumns.len == 0: + # We don't have all the data columns for this block, so we have + # to put it in columnless quarantine. + if not quarantine[].addColumnless(dag.finalizedHead.slot, forkyBlck): + return err(VerifierError.UnviableFork) else: - let data_columns = dataColumnQuarantine[].popDataColumns(forkyBlck.root, forkyBlck) - return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, - Opt.none(BlobSidecars), Opt.some(data_columns), - maybeFinalized = maybeFinalized) + return err(VerifierError.MissingParent) + elif supernode == true and accumulatedColumns.len >= localCustodyColumns.len div 2: + let data_columns = dataColumnQuarantine[].popDataColumns(forkyBlck.root, forkyBlck) + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, + Opt.none(BlobSidecars), Opt.some(data_columns), + maybeFinalized = maybeFinalized) + + elif supernode == false and accumulatedColumns.len <= localCustodyColumns.len div 2: + let data_columns = dataColumnQuarantine[].popDataColumns(forkyBlck.root, forkyBlck) + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, + Opt.none(BlobSidecars), Opt.some(data_columns), + maybeFinalized = maybeFinalized) + else: + return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, + Opt.none(BlobSidecars), Opt.none(DataColumnSidecars), + maybeFinalized = maybeFinalized) else: return await blockProcessor[].addBlock(MsgSource.gossip, signedBlock, Opt.none(BlobSidecars), Opt.none(DataColumnSidecars), diff --git a/beacon_chain/sync/sync_manager.nim b/beacon_chain/sync/sync_manager.nim index dad6d82a9..d8bf05935 100644 --- a/beacon_chain/sync/sync_manager.nim +++ b/beacon_chain/sync/sync_manager.nim @@ -360,11 +360,10 @@ func groupDataColumns*[T](req: SyncRequest[T], # The following data column sidecars, where they exist, MUST be sent in consecutive (slot, index) order. # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/_features/eip7594/p2p-interface.md let header = forkyBlck.toSignedBeaconBlockHeader() - for column_idx in data_columns - if column_cursor >= data_columns.len: - return err("DataColumnSidecar: response too short") + for column_idx in 0..