diff --git a/beacon_chain/consensus_object_pools/data_column_quarantine.nim b/beacon_chain/consensus_object_pools/data_column_quarantine.nim index 7cd044861..a1eea6669 100644 --- a/beacon_chain/consensus_object_pools/data_column_quarantine.nim +++ b/beacon_chain/consensus_object_pools/data_column_quarantine.nim @@ -116,9 +116,27 @@ func checkForInitialDcSidecars*(quarantine: DataColumnQuarantine, return false true -func hasDataColumns*(quarantine: DataColumnQuarantine, + +func hasMissingDataColumns*(quarantine: DataColumnQuarantine, + blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock): bool = + let + localSubnetCount = + if quarantine.supernode: + DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64 + else: + CUSTODY_REQUIREMENT.uint64 + localCustodyColumns = + get_custody_columns(quarantine.nodeid, + max(SAMPLES_PER_SLOT.uint64, + localSubnetCount)) + + for i in localCustodyColumns: + if (blck.root, ColumnIndex i) notin quarantine.data_columns: + return false + true + +func hasEnoughDataColumns*(quarantine: DataColumnQuarantine, blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock): bool = - var counter = 0 let localSubnetCount = if quarantine.supernode: diff --git a/beacon_chain/gossip_processing/block_processor.nim b/beacon_chain/gossip_processing/block_processor.nim index f73628580..57927ba09 100644 --- a/beacon_chain/gossip_processing/block_processor.nim +++ b/beacon_chain/gossip_processing/block_processor.nim @@ -31,7 +31,7 @@ from ../consensus_object_pools/block_quarantine import from ../consensus_object_pools/blob_quarantine import BlobQuarantine, hasBlobs, popBlobs, put from ../consensus_object_pools/data_column_quarantine import - DataColumnQuarantine, hasDataColumns, popDataColumns, put + DataColumnQuarantine, hasEnoughDataColumns, popDataColumns, put from ../validators/validator_monitor import MsgSource, ValidatorMonitor, registerAttestationInBlock, registerBeaconBlock, registerSyncAggregateInBlock @@ -868,7 +868,7 @@ proc storeBlock( # discard self.consensusManager.quarantine[].addBlobless( # dag.finalizedHead.slot, forkyBlck) - if self.dataColumnQuarantine[].hasDataColumns(forkyBlck): + if self.dataColumnQuarantine[].hasEnoughDataColumns(forkyBlck): let data_columns = self.dataColumnQuarantine[].popDataColumns( forkyBlck.root, forkyBlck) self[].enqueueBlock(MsgSource.gossip, quarantined, Opt.none(BlobSidecars), Opt.some(data_columns)) diff --git a/beacon_chain/gossip_processing/eth2_processor.nim b/beacon_chain/gossip_processing/eth2_processor.nim index ae6e6e295..e517da3bb 100644 --- a/beacon_chain/gossip_processing/eth2_processor.nim +++ b/beacon_chain/gossip_processing/eth2_processor.nim @@ -274,7 +274,7 @@ proc processSignedBeaconBlock*( let data_columns = when typeof(signedBlock).kind >= ConsensusFork.Deneb: - if self.dataColumnQuarantine[].hasDataColumns(signedBlock): + if self.dataColumnQuarantine[].hasEnoughDataColumns(signedBlock): Opt.some(self.dataColumnQuarantine[].popDataColumns(signedBlock.root, signedBlock)) else: discard self.quarantine[].addColumnless(self.dag.finalizedHead.slot, @@ -406,7 +406,7 @@ proc processDataColumnSidecar*( self.processReconstructionFromGossip(forkyBlck, columns) for rc in reconstructed_columns.get: self.dataColumnQuarantine[].put(newClone(rc)) - if self.dataColumnQuarantine[].hasDataColumns(forkyBlck): + if self.dataColumnQuarantine[].hasEnoughDataColumns(forkyBlck): self.blockProcessor[].enqueueBlock( MsgSource.gossip, columnless, Opt.none(BlobSidecars), diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 7669fe11e..69dbded16 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1551,7 +1551,7 @@ proc tryReconstructingDataColumns* (self: BeaconNode, # storedColumn number is less than the NUMBER_OF_COLUMNS # then reconstruction is not possible, and if all the data columns # are already stored then we do not need to reconstruct at all - if not storedColumns.len < NUMBER_OF_COLUMNS div 2: + if not storedColumns.len < NUMBER_OF_COLUMNS div 2 and storedColumns.len != NUMBER_OF_COLUMNS: # Recover blobs from saved data column sidecars let recovered_cps = recover_cells_and_proofs(data_column_sidecars, signed_block) if not recovered_cps.isOk: diff --git a/beacon_chain/sync/request_manager.nim b/beacon_chain/sync/request_manager.nim index 880161352..8b7428520 100644 --- a/beacon_chain/sync/request_manager.nim +++ b/beacon_chain/sync/request_manager.nim @@ -541,7 +541,7 @@ proc getMissingDataColumns(rman: RequestManager): seq[DataColumnIdentifier] = debug "Not handling missing data columns early in slot" continue - if not rman.dataColumnQuarantine[].hasDataColumns(forkyBlck): + if not rman.dataColumnQuarantine[].hasMissingDataColumns(forkyBlck): let missing = rman.dataColumnQuarantine[].dataColumnFetchRecord(forkyBlck) if len(missing.indices) == 0: warn "quarantine is missing data columns, but missing indices are empty",