Skip to content

Commit

Permalink
Merge pull request #3836 from jtraglia/columns-cells-and-proofs
Browse files Browse the repository at this point in the history
Update get_data_column_sidecars to take cells/proofs
  • Loading branch information
asn-d6 committed Jul 16, 2024
2 parents b4432fb + 5961e26 commit bb8f3ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
28 changes: 16 additions & 12 deletions specs/_features/eip7594/das-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,27 +195,31 @@ def recover_matrix(partial_matrix: Sequence[MatrixEntry],

```python
def get_data_column_sidecars(signed_block: SignedBeaconBlock,
blobs: Sequence[Blob]) -> Sequence[DataColumnSidecar]:
cells_and_kzg_proofs: Sequence[Tuple[
Vector[Cell, CELLS_PER_EXT_BLOB],
Vector[KZGProof, CELLS_PER_EXT_BLOB]]]) -> Sequence[DataColumnSidecar]:
"""
Given a signed block and the cells/proofs associated with each blob in the
block, assemble the sidecars which can be distributed to peers.
"""
blob_kzg_commitments = signed_block.message.body.blob_kzg_commitments
assert len(cells_and_kzg_proofs) == len(blob_kzg_commitments)
signed_block_header = compute_signed_block_header(signed_block)
block = signed_block.message
kzg_commitments_inclusion_proof = compute_merkle_proof(
block.body,
signed_block.message.body,
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments'),
)
cells_and_proofs = [compute_cells_and_kzg_proofs(blob) for blob in blobs]
blob_count = len(blobs)
cells = [cells_and_proofs[i][0] for i in range(blob_count)]
proofs = [cells_and_proofs[i][1] for i in range(blob_count)]

sidecars = []
for column_index in range(NUMBER_OF_COLUMNS):
column_cells = [cells[row_index][column_index]
for row_index in range(blob_count)]
column_proofs = [proofs[row_index][column_index]
for row_index in range(blob_count)]
column_cells, column_proofs = [], []
for cells, proofs in cells_and_kzg_proofs:
column_cells.append(cells[column_index])
column_proofs.append(proofs[column_index])
sidecars.append(DataColumnSidecar(
index=column_index,
column=column_cells,
kzg_commitments=block.body.blob_kzg_commitments,
kzg_commitments=blob_kzg_commitments,
kzg_proofs=column_proofs,
signed_block_header=signed_block_header,
kzg_commitments_inclusion_proof=kzg_commitments_inclusion_proof,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def _run_blob_kzg_commitments_merkle_proof_test(spec, state, rng=None):
block.body.execution_payload.transactions = [opaque_tx]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = sign_block(spec, state, block, proposer_index=0)
column_sidcars = spec.get_data_column_sidecars(signed_block, blobs)
cells_and_kzg_proofs = [spec.compute_cells_and_kzg_proofs(blob) for blob in blobs]
column_sidcars = spec.get_data_column_sidecars(signed_block, cells_and_kzg_proofs)
column_sidcar = column_sidcars[0]

yield "object", block.body
Expand Down

0 comments on commit bb8f3ca

Please sign in to comment.