From 1dbb68d3d72cdfa40427582440229de07a2710cc Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Mon, 8 Jul 2024 14:07:53 -0500 Subject: [PATCH 1/3] Update get_data_column_sidecars to take cells/proofs --- specs/_features/eip7594/das-core.md | 34 ++++++++++++------- .../merkle_proof/test_single_merkle_proof.py | 3 +- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index 0d6530226d..30cb411bf9 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -195,27 +195,37 @@ 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 + blob, assemble the sidecars which can be distributed to peers. + + Since there is no method which converts cells back to a blob, this method + takes cells/proofs instead of blobs so that it can be re-create sidecars + after recovery. + """ + 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, diff --git a/tests/core/pyspec/eth2spec/test/eip7594/merkle_proof/test_single_merkle_proof.py b/tests/core/pyspec/eth2spec/test/eip7594/merkle_proof/test_single_merkle_proof.py index 3cdf3685e9..98c751508d 100644 --- a/tests/core/pyspec/eth2spec/test/eip7594/merkle_proof/test_single_merkle_proof.py +++ b/tests/core/pyspec/eth2spec/test/eip7594/merkle_proof/test_single_merkle_proof.py @@ -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 From 8da90b27020813d0a90abc156d68446984fe37a1 Mon Sep 17 00:00:00 2001 From: Justin Traglia Date: Mon, 8 Jul 2024 14:20:45 -0500 Subject: [PATCH 2/3] Fix linter issues --- specs/_features/eip7594/das-core.md | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index 30cb411bf9..c3f19b4cb0 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -195,18 +195,15 @@ def recover_matrix(partial_matrix: Sequence[MatrixEntry], ```python def get_data_column_sidecars(signed_block: SignedBeaconBlock, - cells_and_kzg_proofs: Sequence[ - Tuple[ - Vector[Cell, CELLS_PER_EXT_BLOB], - Vector[KZGProof, CELLS_PER_EXT_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 - blob, assemble the sidecars which can be distributed to peers. + block, assemble the sidecars which can be distributed to peers. - Since there is no method which converts cells back to a blob, this method - takes cells/proofs instead of blobs so that it can be re-create sidecars - after recovery. + 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. """ blob_kzg_commitments = signed_block.message.body.blob_kzg_commitments assert len(cells_and_kzg_proofs) == len(blob_kzg_commitments) From 5961e269316c8dda36b481390623eee9b789fe2f Mon Sep 17 00:00:00 2001 From: Justin Traglia <95511699+jtraglia@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:09:01 -0500 Subject: [PATCH 3/3] Remove unnecessary comment --- specs/_features/eip7594/das-core.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/specs/_features/eip7594/das-core.md b/specs/_features/eip7594/das-core.md index c3f19b4cb0..f25e29ce3a 100644 --- a/specs/_features/eip7594/das-core.md +++ b/specs/_features/eip7594/das-core.md @@ -201,9 +201,6 @@ def get_data_column_sidecars(signed_block: SignedBeaconBlock, """ 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. """ blob_kzg_commitments = signed_block.message.body.blob_kzg_commitments assert len(cells_and_kzg_proofs) == len(blob_kzg_commitments)