diff --git a/beacon_chain/consensus_object_pools/data_column_quarantine.nim b/beacon_chain/consensus_object_pools/data_column_quarantine.nim index 73922d7b3..ee85b3c80 100644 --- a/beacon_chain/consensus_object_pools/data_column_quarantine.nim +++ b/beacon_chain/consensus_object_pools/data_column_quarantine.nim @@ -23,7 +23,7 @@ const type DataColumnQuarantine* = object data_columns*: - OrderedTable[(Eth2Digest, ColumnIndex), ref DataColumnSidecar] + OrderedTable[DataColumnIdentifier, ref DataColumnSidecar] onDataColumnSidecarCallback*: OnDataColumnSidecarCallback DataColumnFetchRecord* = object @@ -32,15 +32,13 @@ type OnDataColumnSidecarCallback = proc(data: DataColumnSidecar) {.gcsafe, raises: [].} -func shortLog*(x: seq[ColumnIndex]): string = - "<" & x.mapIt($it).join(", ") & ">" func shortLog*(x: seq[DataColumnFetchRecord]): string = "[" & x.mapIt(shortLog(it.block_root) & shortLog(it.indices)).join(", ") & "]" func put*(quarantine: var DataColumnQuarantine, dataColumnSidecar: ref DataColumnSidecar) = - if quarantine.data_columns.lenu64 >= MaxDataColumns: + if quarantine.data_columns.len >= static(MaxDataColumns.int): # FIFO if full. For example, sync manager and request manager can race # to put data columns in at the same time, so one gets data column # insert -> block resolve -> data column insert, which leaves @@ -49,7 +47,7 @@ func put*(quarantine: var DataColumnQuarantine, # This also therefore automatically garbage-collects otherwise valid # data columns that are correctly signed, point to either correct block # root which isn't ever seen, and then for any reason simply never used. - var oldest_column_key: (Eth2Digest, ColumnIndex) + var oldest_column_key: DataColumnIdentifier for k in quarantine.data_columns.keys: oldest_column_key = k break @@ -57,7 +55,9 @@ func put*(quarantine: var DataColumnQuarantine, let block_root = hash_tree_root(dataColumnSidecar.signed_block_header.message) discard quarantine.data_columns.hasKeyOrPut( - (block_root, dataColumnSidecar.index), dataColumnSidecar) + DataColumnIdentifier(block_root: block_root, + index: dataColumnSidecar.index), + dataColumnSidecar) func hasDataColumn*( quarantine: DataColumnQuarantine, @@ -75,29 +75,40 @@ func hasDataColumn*( func popDataColumns*( quarantine: var DataColumnQuarantine, digest: Eth2Digest, - blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock): + blck: electra.SignedBeaconBlock): seq[ref DataColumnSidecar] = var r: seq[ref DataColumnSidecar] for idx in 0.." \ No newline at end of file diff --git a/beacon_chain/spec/network.nim b/beacon_chain/spec/network.nim index 89c31dc96..f7d9631b1 100644 --- a/beacon_chain/spec/network.nim +++ b/beacon_chain/spec/network.nim @@ -109,7 +109,7 @@ func getBlobSidecarTopic*(forkDigest: ForkDigest, func compute_subnet_for_blob_sidecar*(blob_index: BlobIndex): BlobId = BlobId(blob_index mod BLOB_SIDECAR_SUBNET_COUNT) -# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/_features/eip7594/p2p-interface.md#data_column_sidecar_subnet_id +# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/_features/eip7594/p2p-interface.md#compute_subnet_for_data_column_sidecar func compute_subnet_for_data_column_sidecar*(column_index: ColumnIndex): uint64 = uint64(column_index mod DATA_COLUMN_SIDECAR_SUBNET_COUNT)