From 80387f13065c299f157b3b0b0f9685a9baf7b47e Mon Sep 17 00:00:00 2001 From: Agnish Ghosh Date: Thu, 30 May 2024 03:51:32 +0530 Subject: [PATCH] fix: code styles --- beacon_chain/spec/eip7594_helpers.nim | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/beacon_chain/spec/eip7594_helpers.nim b/beacon_chain/spec/eip7594_helpers.nim index 631c04e90..ffa9372bc 100644 --- a/beacon_chain/spec/eip7594_helpers.nim +++ b/beacon_chain/spec/eip7594_helpers.nim @@ -9,9 +9,7 @@ # Uncategorized helper functions from the spec import - tables, - algorithm, - std/macros, + std/[algorithm, macros, tables], stew/results, ssz_serialization/proofs, chronicles, @@ -39,14 +37,14 @@ proc get_custody_columns*(node_id: NodeId, custody_subnet_count: uint64): Result if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT): return err("Eip7594: Custody subnet count exceeds the DATA_COLUMN_SIDECAR_SUBNET_COUNT") - var subnet_ids: HashSet[uint64] - var current_id = node_id + var + subnet_ids: HashSet[uint64] + current_id = node_id while subnet_ids.len < int(custody_subnet_count): - - # var subnet_id_bytes: seq[byte] let subnet_id_bytes = eth2digest(current_id.toBytesLE().toOpenArray(0,8)) - var subnet_id = bytes_to_uint64(subnet_id_bytes.data) mod DATA_COLUMN_SIDECAR_SUBNET_COUNT + var subnet_id = bytes_to_uint64(subnet_id_bytes.data) mod + DATA_COLUMN_SIDECAR_SUBNET_COUNT if subnet_id notin subnet_ids: subnet_ids.incl(subnet_id) @@ -81,7 +79,6 @@ proc compute_extended_matrix* (blobs: seq[KzgBlob]): Result[ExtendedMatrix, cstr # https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#recover_matrix proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), KzgCell], blobCount: uint64): Result[ExtendedMatrix, cstring] = - # This helper demonstrates how to apply recover_all_cells # The data structure for storing cells is implementation-dependent @@ -97,7 +94,7 @@ proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), KzgCell], blobCount: if blIdx == blobIndex: cellIds.add(cellId) - var cells: seq[KzgCell] = @[] + var cells: seq[KzgCell] for cellId in cellIds: var interim_key = (BlobIndex(blobIndex), cellId) @@ -109,13 +106,13 @@ proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), KzgCell], blobCount: debug "DataColumn: Key not found in Cell Dictionary", interim_key let allCellsForRow = recoverAllCells(ctx, cellIds, cells) - discard extended_matrix.add(allCellsForRow.get()) + let check = extended_matrix.add(allCellsForRow.get()) + doAssert check == true, "DataColumn: Could not add cells to the extended matrix" ok(extended_matrix) # https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#get_data_column_sidecars proc get_data_column_sidecars*(signed_block: deneb.SignedBeaconBlock, blobs: seq[KzgBlob]): Result[seq[DataColumnSidecar], cstring] = - var sidecar: DataColumnSidecar var signed_block_header: deneb.SignedBeaconBlockHeader var blck = signed_block.message @@ -194,18 +191,20 @@ proc verify_data_column_sidecar_kzg_proofs*(sidecar: DataColumnSidecar): Result[ return err("EIP7594: Data column sidecar kzg_commitments length is not equal to the kzg_proofs length") # Iterate through the row indices - var rowIndices: seq[RowIndex] = @[] + var rowIndices: seq[RowIndex] for i in 0..