rework on cell and proof

This commit is contained in:
Agnish Ghosh 2024-07-07 04:35:06 +05:30
parent c14b59264c
commit 7a891f13d6
No known key found for this signature in database
GPG Key ID: 7BDDA05D1B25E9F8
2 changed files with 56 additions and 27 deletions

View File

@ -879,7 +879,8 @@ proc addBlock*(
# - RequestManager (missing ancestor blocks) # - RequestManager (missing ancestor blocks)
# - API # - API
let resfut = newFuture[Result[void, VerifierError]]("BlockProcessor.addBlock") let resfut = newFuture[Result[void, VerifierError]]("BlockProcessor.addBlock")
enqueueBlock(self, src, blck, blobs, data_columns, resfut, maybeFinalized, validationDur) enqueueBlock(self, src, blck, blobs, data_columns,
resfut, maybeFinalized, validationDur)
resfut resfut
# Event Loop # Event Loop
@ -900,8 +901,9 @@ proc processBlock(
let res = withBlck(entry.blck): let res = withBlck(entry.blck):
await self.storeBlock( await self.storeBlock(
entry.src, wallTime, forkyBlck, entry.blobs, entry.data_columns, entry.maybeFinalized, entry.src, wallTime, forkyBlck,
entry.queueTick, entry.validationDur) entry.blobs, entry.data_columns,
entry.maybeFinalized, entry.queueTick, entry.validationDur)
if res.isErr and res.error[1] == ProcessingStatus.notCompleted: if res.isErr and res.error[1] == ProcessingStatus.notCompleted:
# When an execution engine returns an error or fails to respond to a # When an execution engine returns an error or fails to respond to a
@ -912,8 +914,9 @@ proc processBlock(
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/sync/optimistic.md#execution-engine-errors # https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/sync/optimistic.md#execution-engine-errors
await sleepAsync(chronos.seconds(1)) await sleepAsync(chronos.seconds(1))
self[].enqueueBlock( self[].enqueueBlock(
entry.src, entry.blck, entry.blobs, entry.data_columns, entry.resfut, entry.maybeFinalized, entry.src, entry.blck, entry.blobs,
entry.validationDur) entry.data_columns, entry.resfut,
entry.maybeFinalized, entry.validationDur)
# To ensure backpressure on the sync manager, do not complete these futures. # To ensure backpressure on the sync manager, do not complete these futures.
return return

View File

@ -36,7 +36,9 @@ proc sortedColumnIndices*(columnsPerSubnet: ColumnIndex, subnetIds: HashSet[uint
res.sort() res.sort()
res res
proc get_custody_column_subnet*(node_id: NodeId, custody_subnet_count: uint64): Result[HashSet[uint64], 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 # fetches the subnets for custody column for the current node
# assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT # assert custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT
if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT): if not (custody_subnet_count <= DATA_COLUMN_SIDECAR_SUBNET_COUNT):
@ -69,7 +71,9 @@ proc get_custody_column_subnet*(node_id: NodeId, custody_subnet_count: uint64):
ok(subnet_ids) ok(subnet_ids)
# https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#get_custody_columns # 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_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 let subnet_ids = get_custody_column_subnet(node_id, custody_subnet_count).get
@ -94,7 +98,9 @@ proc compute_extended_matrix* (blobs: seq[KzgBlob]): Result[ExtendedMatrix, cstr
ok(extended_matrix) ok(extended_matrix)
# https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#recover_matrix # https://github.com/ethereum/consensus-specs/blob/5f48840f4d768bf0e0a8156a3ed06ec333589007/specs/_features/eip7594/das-core.md#recover_matrix
proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), Cell], blobCount: uint64): Result[ExtendedMatrix, cstring] = proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), Cell],
blobCount: uint64):
Result[ExtendedMatrix, cstring] =
# This helper demonstrates how to apply recover_all_cells # This helper demonstrates how to apply recover_all_cells
# The data structure for storing cells is implementation-dependent # The data structure for storing cells is implementation-dependent
@ -128,7 +134,9 @@ proc recover_matrix*(cells_dict: Table[(BlobIndex, CellID), Cell], blobCount: ui
ok(extended_matrix) ok(extended_matrix)
proc recover_matrix*(partial_matrix: seq[MatrixEntry], blobCount: int): Result[seq[MatrixEntry], cstring] = proc recover_matrix*(partial_matrix: seq[MatrixEntry],
blobCount: int):
Result[seq[MatrixEntry], cstring] =
# This helper demonstrates how to apply recover_cells_and_kzg_proofs # This helper demonstrates how to apply recover_cells_and_kzg_proofs
# The data structure for storing cells is implementation-dependent # The data structure for storing cells is implementation-dependent
@ -222,7 +230,6 @@ proc get_data_column_sidecars*(signed_block: deneb.SignedBeaconBlock |
var var
blck = signed_block.message blck = signed_block.message
signed_beacon_block_header = compute_signed_block_header(signed_block) signed_beacon_block_header = compute_signed_block_header(signed_block)
cellsAndProofs: seq[KzgCellsAndKzgProofs]
kzg_incl_proof: array[4, Eth2Digest] kzg_incl_proof: array[4, Eth2Digest]
var sidecars = newSeqOfCap[DataColumnSidecar](CELLS_PER_EXT_BLOB) var sidecars = newSeqOfCap[DataColumnSidecar](CELLS_PER_EXT_BLOB)
@ -231,27 +238,46 @@ proc get_data_column_sidecars*(signed_block: deneb.SignedBeaconBlock |
debugEcho "Checkpoint 3" debugEcho "Checkpoint 3"
return ok(sidecars) return ok(sidecars)
for blob in blobs:
let
cell_and_proof = computeCellsAndProofs(blob)
debugEcho "Checkpoint 4"
if cell_and_proof.isErr():
return err("EIP7549: Could not compute cells")
cellsAndProofs.add(cell_and_proof.get())
debugEcho "Checkpoint 5"
let blobCount = blobs.len
var var
cells = newSeqOfCap[CellBytes](blobs.len) cells = newSeqOfCap[CellBytes](blobs.len)
proofs = newSeqOfCap[ProofBytes](blobs.len) proofs = newSeqOfCap[ProofBytes](blobs.len)
for i in 0..<blobCount: debugEcho "Cells len"
for j in 0..<int(CELLS_PER_EXT_BLOB): debugEcho cells.len
for k in 0..<2048: debugEcho cells[0].len
cells[i][j][k] = (cellsAndProofs[i].cells[j][k]) debugEcho cells[0][0].len
for k in 0..<48:
proofs[i][j][k] = (cellsAndProofs[i].proofs[j][k]) debugEcho "Proofs len"
debugEcho proofs.len
debugEcho proofs[0].len
debugEcho proofs[0][0].len
for i in 0..<blobs.len:
let
cell_and_proof = computeCellsAndProofs(blobs[i])
debugEcho "Checkpoint 4"
if cell_and_proof.isErr():
return err("EIP7549: Could not compute cells")
cells[i] = cell_and_proof.get.cells
proofs[i] = cell_and_proof.get.proofs
debugEcho "Checkpoint 5"
let blobCount = blobs.len
debugEcho "BlobCount"
debugEcho blobCount
# for i in 0..<blobCount:
# for j in 0..<int(CELLS_PER_EXT_BLOB):
# for k in 0..<2048:
# cells[i][j][k] = (cellsAndProofs[i].cells[j][k])
# for i in 0..<blobCount:
# for j in 0..<int(CELLS_PER_EXT_BLOB):
# for k in 0..<48:
# proofs[i][j][k] = (cellsAndProofs[i].proofs[j][k])
debugEcho "Checkpoint 7" debugEcho "Checkpoint 7"