modify get_blob_sidecars to use nested proof

This commit is contained in:
Potuz 2024-07-08 09:42:01 -03:00
parent 9181e2937f
commit 17b7905e5c
2 changed files with 28 additions and 15 deletions

View File

@ -59,7 +59,7 @@ The `BlobSidecar` container is modified indirectly because the constant `KZG_COM
```python
def get_blob_sidecars(signed_block: SignedBeaconBlock,
blobs: Sequence[Blob],
blob_kzg_commitments: Sequence[KZGCommitment],
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK],
blob_kzg_proofs: Sequence[KZGProof]) -> Sequence[BlobSidecar]:
block = signed_block.message
block_header = BeaconBlockHeader(
@ -70,20 +70,32 @@ def get_blob_sidecars(signed_block: SignedBeaconBlock,
body_root=hash_tree_root(block.body),
)
signed_block_header = SignedBeaconBlockHeader(message=block_header, signature=signed_block.signature)
return [
BlobSidecar(
index=index,
blob=blob,
kzg_commitment=blob_kzg_commitments[index],
kzg_proof=blob_kzg_proofs[index],
signed_block_header=signed_block_header,
kzg_commitment_inclusion_proof=compute_merkle_proof(
block.body,
GeneralizedIndex(KZG_GENERALIZED_INDEX_PREFIX + index),
sidecars: List[BlobSidecar] = []
for index, blob in enumerate(blobs):
inner_proof = compute_merkle_proof(
blob_kzg_commitments,
get_generalized_index(List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK], index),
)
outer_proof = compute_merkle_proof(
block.body,
get_generalized_index(
BeaconBlockBody,
"signed_execution_payload_header",
"message",
"blob_kzg_commitments_root",
),
)
for index, blob in enumerate(blobs)
]
sidecars.append(
BlobSidecar(
index=index,
blob=blob,
kzg_commitment=blob_kzg_commitments[index],
kzg_proof=blob_kzg_proofs[index],
signed_block_header=signed_block_header,
kzg_commitment_inclusion_proof=outer_proof + inner_proof,
)
)
return sidecars
```
### Constructing the execution payload envelope

View File

@ -35,8 +35,9 @@ This document contains the consensus-layer networking specification for EIP7732.
| Name | Value | Description |
|------------------------------------------|-----------------------------------|---------------------------------------------------------------------|
| `KZG_COMMITMENT_INCLUSION_PROOF_DEPTH` | `0` # TODO: Compute it when the spec stabilizes | Merkle proof depth for the `blob_kzg_commitments` list item |
| `KZG_GENERALIZED_INDEX_PREFIX` | `0` # TODO: Compute it when the spec stabilizes | Generalized index for the first item in the `blob_kzg_commitments` list |
| `KZG_COMMITMENT_INCLUSION_PROOF_DEPTH` | `13` # TODO: Compute it when the spec stabilizes | Merkle proof depth for the `blob_kzg_commitments` list item |
| `KZG_GENERALIZED_INDEX_PREFIX` | `13` # TODO: Compute it when the spec stabilizes | Generalized index for the first item in the `blob_kzg_commitments` list |
### Containers