From aa390e9adab2a7a700daee9aafb4ec287cff7ae7 Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Wed, 26 Jun 2024 02:04:06 +0530 Subject: [PATCH] rm: message router logic for data column, need to move it --- beacon_chain/spec/eip7594_helpers.nim | 18 +++++++-- beacon_chain/validators/message_router.nim | 44 +++++++++++----------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/beacon_chain/spec/eip7594_helpers.nim b/beacon_chain/spec/eip7594_helpers.nim index 81a9d96b4..585bc4ad4 100644 --- a/beacon_chain/spec/eip7594_helpers.nim +++ b/beacon_chain/spec/eip7594_helpers.nim @@ -17,6 +17,7 @@ import kzg4844/kzg_ex, eth/p2p/discoveryv5/[node], ./helpers, + ./datatypes/[eip7594, deneb] proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex, subnetIds: HashSet[uint64]): seq[ColumnIndex] = @@ -28,9 +29,8 @@ proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex, subnetIds: HashSet[uint res.sort() res -# https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#get_custody_columns -proc get_custody_columns*(node_id: NodeId, custody_subnet_count: uint64): Result[seq[ColumnIndex], cstring] = - +proc get_custody_column_subnet*(node_id: NodeId, custody_subnet_count: uint64): Result[HashSet[uint64], cstring] = + # fetches the subnets for custody column for the current node # assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT): return err("Eip7594: Custody subnet count exceeds the DATA_COLUMN_SIDECAR_SUBNET_COUNT") @@ -59,6 +59,13 @@ proc get_custody_columns*(node_id: NodeId, custody_subnet_count: uint64): Result if not (subnet_ids.len == subnet_ids.len): return err("Eip7594: Subnet ids are not unique") + ok(subnet_ids) + +# https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#get_custody_columns +proc get_custody_columns*(node_id: NodeId, custody_subnet_count: uint64): Result[seq[ColumnIndex], cstring] = + + let subnet_ids = get_custody_column_subnet(node_id, custody_subnet_count).get + # columns_per_subnet = NUMBER_OF_COLUMNS // DATA_COLUMN_SIDECAR_SUBNET_COUNT let columns_per_subnet = NUMBER_OF_COLUMNS div DATA_COLUMN_SIDECAR_SUBNET_COUNT @@ -184,7 +191,10 @@ proc get_data_column_sidecars*(signed_block: deneb.SignedBeaconBlock | electra.S # Helper function to `verifyCellKzgProofBatch` at https://github.com/ethereum/c-kzg-4844/blob/das/bindings/nim/kzg_ex.nim#L170 proc validate_data_column_sidecar*( - expected_commitments: seq[KzgCommitment], rowIndex: seq[RowIndex], columnIndex: seq[ColumnIndex], column: seq[Cell], + expected_commitments: seq[KzgCommitment], + rowIndex: seq[RowIndex], + columnIndex: seq[ColumnIndex], + column: seq[Cell], proofs: seq[KzgProof]): Result[void, string] = let res = verifyCellKzgProofBatch(expected_commitments, rowIndex, columnIndex, column, proofs).valueOr: return err("DataColumnSidecar: Proof verification error: " & error()) diff --git a/beacon_chain/validators/message_router.nim b/beacon_chain/validators/message_router.nim index cd9f786ff..479a91e9d 100644 --- a/beacon_chain/validators/message_router.nim +++ b/beacon_chain/validators/message_router.nim @@ -161,30 +161,30 @@ proc routeSignedBeaconBlock*( notice "Blob sent", blob = shortLog(blobs[i]) blobRefs = Opt.some(blobs.mapIt(newClone(it))) - var dataColumnRefs = Opt.none(DataColumnSidecars) - when typeof(blck).kind >= ConsensusFork.Deneb: - if blobsOpt.isSome(): - let blobs = blobsOpt.get() - let data_columns = get_data_column_sidecars(blck, blobs.mapIt(it.blob)).get() - var das_workers = newSeq[Future[SendResult]](len(data_columns)) - for i in 0..= ConsensusFork.Deneb: + # if blobsOpt.isSome(): + # let blobs = blobsOpt.get() + # let data_columns = get_data_column_sidecars(blck, blobs.mapIt(it.blob)).get() + # var das_workers = newSeq[Future[SendResult]](len(data_columns)) + # for i in 0..