Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update get_data_column_sidecars to take cells/proofs #3836

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions specs/_features/eip7594/das-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,27 +195,34 @@ 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[
asn-d6 marked this conversation as resolved.
Show resolved Hide resolved
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.

Since there is no method which converts cells to a blob, this method takes
cells/proofs instead of blobs so it can re-create sidecars after recovery.
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
"""
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