mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-03-01 10:40:36 +00:00
Merge pull request #3555 from ethereum/random-blob_kzg_commitment_merkle_proof
Add randomized block `blob_kzg_commitment_merkle_proof` cases
This commit is contained in:
commit
113c58f9bf
@ -1,3 +1,5 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
with_deneb_and_later,
|
with_deneb_and_later,
|
||||||
@ -5,7 +7,7 @@ from eth2spec.test.context import (
|
|||||||
)
|
)
|
||||||
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
|
sign_block,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.execution_payload import (
|
from eth2spec.test.helpers.execution_payload import (
|
||||||
compute_el_block_hash,
|
compute_el_block_hash,
|
||||||
@ -13,14 +15,25 @@ from eth2spec.test.helpers.execution_payload import (
|
|||||||
from eth2spec.test.helpers.sharding import (
|
from eth2spec.test.helpers.sharding import (
|
||||||
get_sample_opaque_tx,
|
get_sample_opaque_tx,
|
||||||
)
|
)
|
||||||
|
from eth2spec.debug.random_value import (
|
||||||
|
RandomizationMode,
|
||||||
|
get_random_ssz_object,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@with_test_suite_name("BeaconBlockBody")
|
def _run_blob_kzg_commitment_merkle_proof_test(spec, state, rng=None):
|
||||||
@with_deneb_and_later
|
|
||||||
@spec_state_test
|
|
||||||
def test_blob_kzg_commitment_merkle_proof(spec, state):
|
|
||||||
opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=1)
|
opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=1)
|
||||||
block = build_empty_block_for_next_slot(spec, state)
|
if rng is None:
|
||||||
|
block = build_empty_block_for_next_slot(spec, state)
|
||||||
|
else:
|
||||||
|
block = get_random_ssz_object(
|
||||||
|
rng,
|
||||||
|
spec.BeaconBlock,
|
||||||
|
max_bytes_length=2000,
|
||||||
|
max_list_length=2000,
|
||||||
|
mode=RandomizationMode,
|
||||||
|
chaos=True,
|
||||||
|
)
|
||||||
block.body.blob_kzg_commitments = blob_kzg_commitments
|
block.body.blob_kzg_commitments = blob_kzg_commitments
|
||||||
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)
|
||||||
@ -44,3 +57,34 @@ def test_blob_kzg_commitment_merkle_proof(spec, state):
|
|||||||
index=spec.get_subtree_index(gindex),
|
index=spec.get_subtree_index(gindex),
|
||||||
root=blob_sidecar.signed_block_header.message.body_root,
|
root=blob_sidecar.signed_block_header.message.body_root,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@with_test_suite_name("BeaconBlockBody")
|
||||||
|
@with_deneb_and_later
|
||||||
|
@spec_state_test
|
||||||
|
def test_blob_kzg_commitment_merkle_proof__basic(spec, state):
|
||||||
|
yield from _run_blob_kzg_commitment_merkle_proof_test(spec, state)
|
||||||
|
|
||||||
|
|
||||||
|
@with_test_suite_name("BeaconBlockBody")
|
||||||
|
@with_deneb_and_later
|
||||||
|
@spec_state_test
|
||||||
|
def test_blob_kzg_commitment_merkle_proof__random_block_1(spec, state):
|
||||||
|
rng = random.Random(1111)
|
||||||
|
yield from _run_blob_kzg_commitment_merkle_proof_test(spec, state, rng=rng)
|
||||||
|
|
||||||
|
|
||||||
|
@with_test_suite_name("BeaconBlockBody")
|
||||||
|
@with_deneb_and_later
|
||||||
|
@spec_state_test
|
||||||
|
def test_blob_kzg_commitment_merkle_proof__random_block_2(spec, state):
|
||||||
|
rng = random.Random(2222)
|
||||||
|
yield from _run_blob_kzg_commitment_merkle_proof_test(spec, state, rng=rng)
|
||||||
|
|
||||||
|
|
||||||
|
@with_test_suite_name("BeaconBlockBody")
|
||||||
|
@with_deneb_and_later
|
||||||
|
@spec_state_test
|
||||||
|
def test_blob_kzg_commitment_merkle_proof__random_block_3(spec, state):
|
||||||
|
rng = random.Random(3333)
|
||||||
|
yield from _run_blob_kzg_commitment_merkle_proof_test(spec, state, rng=rng)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user