fix unit tests
This commit is contained in:
parent
8712451c43
commit
f2649f65ba
|
@ -51,8 +51,8 @@ The specification of these changes continues in the same format as the network s
|
||||||
| `MAX_REQUEST_BLOB_SIDECARS` | `MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK` | Maximum number of blob sidecars in a single request |
|
| `MAX_REQUEST_BLOB_SIDECARS` | `MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK` | Maximum number of blob sidecars in a single request |
|
||||||
| `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve blob sidecars |
|
| `MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS` | `2**12` (= 4096 epochs, ~18 days) | The minimum epoch range over which a node must serve blob sidecars |
|
||||||
| `BLOB_SIDECAR_SUBNET_COUNT` | `6` | The number of blob sidecar subnets used in the gossipsub protocol. |
|
| `BLOB_SIDECAR_SUBNET_COUNT` | `6` | The number of blob sidecar subnets used in the gossipsub protocol. |
|
||||||
| `BLOB_KZG_COMMITMENTS_GINDEX` | `get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')` (= 27) | `blob_kzg_commitments` field gindex on `BeaconBlockBody` container |
|
| `BLOB_KZG_COMMITMENTS_GINDEX` | `2**4 + 11` (= 27) | `blob_kzg_commitments` field gindex on `BeaconBlockBody` container |
|
||||||
| `KZG_COMMITMENT_INCLUSION_PROOF_DEPTH` | `floorlog2(BLOB_KZG_COMMITMENTS_GINDEX) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK) # noqa: E501` | Merkle proof for `blob_kzg_commitments` list item |
|
| `KZG_COMMITMENT_INCLUSION_PROOF_DEPTH` | `4 + 1 + floorlog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` | Merkle proof for `blob_kzg_commitments` list item |
|
||||||
|
|
||||||
### Containers
|
### Containers
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ def get_blob_sidecars(signed_block: SignedBeaconBlock,
|
||||||
kzg_proof=blob_kzg_proofs[index],
|
kzg_proof=blob_kzg_proofs[index],
|
||||||
commitment_inclusion_proof=compute_commitment_inclusion_proof(
|
commitment_inclusion_proof=compute_commitment_inclusion_proof(
|
||||||
block.body,
|
block.body,
|
||||||
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', index),
|
get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments', index), # type: ignore
|
||||||
),
|
),
|
||||||
signed_block_header=signed_block_header,
|
signed_block_header=signed_block_header,
|
||||||
)
|
)
|
||||||
|
|
|
@ -10,46 +10,15 @@ from eth2spec.test.helpers.sharding import (
|
||||||
get_sample_opaque_tx,
|
get_sample_opaque_tx,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.block import (
|
from eth2spec.test.helpers.block import (
|
||||||
build_empty_block_for_next_slot
|
build_empty_block_for_next_slot,
|
||||||
|
sign_block
|
||||||
)
|
)
|
||||||
from tests.core.pyspec.eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
from tests.core.pyspec.eth2spec.utils.ssz.ssz_impl import hash_tree_root
|
||||||
|
|
||||||
|
|
||||||
def get_blob_sidecars(spec, signed_block, blobs, blob_kzg_proofs):
|
|
||||||
block = signed_block.message
|
|
||||||
block_header = spec.BeaconBlockHeader(
|
|
||||||
slot=block.slot,
|
|
||||||
proposer_index=block.proposer_index,
|
|
||||||
parent_root=block.parent_root,
|
|
||||||
state_root=block.state_root,
|
|
||||||
body_root=hash_tree_root(block.body),
|
|
||||||
)
|
|
||||||
signed_block_header = spec.SignedBeaconBlockHeader(message=block_header, signature=signed_block.signature)
|
|
||||||
return [
|
|
||||||
spec.BlobSidecar(
|
|
||||||
index=index,
|
|
||||||
blob=blob,
|
|
||||||
kzg_commitment=signed_block.message.body.blob_kzg_commitments[index],
|
|
||||||
kzg_proof=blob_kzg_proofs[index],
|
|
||||||
commitment_inclusion_proof=compute_commitment_inclusion_proof(
|
|
||||||
spec,
|
|
||||||
signed_block.message.body,
|
|
||||||
index,
|
|
||||||
),
|
|
||||||
signed_block_header=signed_block_header,
|
|
||||||
)
|
|
||||||
for index, blob in enumerate(blobs)
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def compute_commitment_inclusion_proof(spec, body, index):
|
|
||||||
gindex = spec.get_generalized_index(spec.BeaconBlockBody, 'blob_kzg_commitments', index)
|
|
||||||
return spec.build_proof(body, gindex)
|
|
||||||
|
|
||||||
|
|
||||||
@with_deneb_and_later
|
@with_deneb_and_later
|
||||||
@spec_state_test
|
@spec_state_test
|
||||||
def test_blob_sidecar_inclusion_proof(spec, state):
|
def test_blob_sidecar_inclusion_proof_correct(spec, state):
|
||||||
"""
|
"""
|
||||||
Test `verify_blob_sidecar_inclusion_proof`
|
Test `verify_blob_sidecar_inclusion_proof`
|
||||||
"""
|
"""
|
||||||
|
@ -60,7 +29,8 @@ def test_blob_sidecar_inclusion_proof(spec, state):
|
||||||
block.body.execution_payload.transactions = [opaque_tx]
|
block.body.execution_payload.transactions = [opaque_tx]
|
||||||
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
|
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
|
||||||
|
|
||||||
blob_sidecars = spec.get_blob_sidecars(spec, block, blobs, proofs)
|
signed_block = sign_block(spec, state, block, proposer_index=0)
|
||||||
|
blob_sidecars = spec.get_blob_sidecars(signed_block, blobs, proofs)
|
||||||
|
|
||||||
for blob_sidecar in blob_sidecars:
|
for blob_sidecar in blob_sidecars:
|
||||||
assert spec.verify_blob_sidecar_inclusion_proof(blob_sidecar)
|
assert spec.verify_blob_sidecar_inclusion_proof(blob_sidecar)
|
||||||
|
@ -80,7 +50,8 @@ def test_blob_sidecar_inclusion_proof_incorrect(spec, state):
|
||||||
block.body.execution_payload.transactions = [opaque_tx]
|
block.body.execution_payload.transactions = [opaque_tx]
|
||||||
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
|
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
|
||||||
|
|
||||||
blob_sidecars = spec.get_blob_sidecars(spec, block, blobs, proofs)
|
signed_block = sign_block(spec, state, block, proposer_index=0)
|
||||||
|
blob_sidecars = spec.get_blob_sidecars(signed_block, blobs, proofs)
|
||||||
|
|
||||||
for blob_sidecar in blob_sidecars:
|
for blob_sidecar in blob_sidecars:
|
||||||
block = blob_sidecar.signed_block_header.message
|
block = blob_sidecar.signed_block_header.message
|
||||||
|
|
Loading…
Reference in New Issue