From 212a314287568a1414f389569a0bda0a8343354f Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 24 May 2023 11:27:26 +0800 Subject: [PATCH] Fix ToC and remove `validate_blobs_and_kzg_commitments` --- specs/bellatrix/beacon-chain.md | 2 + specs/deneb/beacon-chain.md | 3 +- specs/deneb/validator.md | 13 +-- .../unittests/validator/test_validator.py | 87 ------------------- 4 files changed, 4 insertions(+), 101 deletions(-) diff --git a/specs/bellatrix/beacon-chain.md b/specs/bellatrix/beacon-chain.md index e8eef346d..6cc69d747 100644 --- a/specs/bellatrix/beacon-chain.md +++ b/specs/bellatrix/beacon-chain.md @@ -37,6 +37,8 @@ - [`NewPayloadRequest`](#newpayloadrequest) - [Engine APIs](#engine-apis) - [`notify_new_payload`](#notify_new_payload) + - [`is_valid_block_hash`](#is_valid_block_hash) + - [`verify_and_notify_new_payload`](#verify_and_notify_new_payload) - [Block processing](#block-processing) - [Execution payload](#execution-payload) - [`process_execution_payload`](#process_execution_payload) diff --git a/specs/deneb/beacon-chain.md b/specs/deneb/beacon-chain.md index 5c31f1fc0..85c1fbdce 100644 --- a/specs/deneb/beacon-chain.md +++ b/specs/deneb/beacon-chain.md @@ -29,9 +29,8 @@ - [Request data](#request-data) - [Modified `NewPayloadRequest`](#modified-newpayloadrequest) - [Engine APIs](#engine-apis) - - [`is_valid_block_hash`](#is_valid_block_hash) - [`is_valid_versioned_hashes`](#is_valid_versioned_hashes) - - [`verify_and_notify_new_payload`](#verify_and_notify_new_payload) + - [Modified `verify_and_notify_new_payload`](#modified-verify_and_notify_new_payload) - [Block processing](#block-processing) - [Execution payload](#execution-payload) - [`process_execution_payload`](#process_execution_payload) diff --git a/specs/deneb/validator.md b/specs/deneb/validator.md index fa6f1651e..ae5f26673 100644 --- a/specs/deneb/validator.md +++ b/specs/deneb/validator.md @@ -101,18 +101,7 @@ All validator responsibilities remain unchanged other than those noted below. 1. After retrieving the execution payload from the execution engine as specified in Capella, use the `payload_id` to retrieve `blobs`, `blob_kzg_commitments`, and `blob_kzg_proofs` via `get_payload(payload_id).blobs_bundle`. -2. Validate `blobs` and `blob_kzg_commitments`: - -```python -def validate_blobs_and_kzg_commitments(blobs: Sequence[Blob], - blob_kzg_commitments: Sequence[KZGCommitment], - blob_kzg_proofs: Sequence[KZGProof]) -> None: - # Optionally sanity-check that the KZG commitments match the blobs (as produced by the execution engine) - assert len(blob_kzg_commitments) == len(blobs) == len(blob_kzg_proofs) - assert verify_blob_kzg_proof_batch(blobs, blob_kzg_commitments, blob_kzg_proofs) -``` - -3. If valid, set `block.body.blob_kzg_commitments = blob_kzg_commitments`. +2. Set `block.body.blob_kzg_commitments = blob_kzg_commitments`. #### Constructing the `SignedBlobSidecar`s diff --git a/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py b/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py index 62b8e9dc1..876824107 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py +++ b/tests/core/pyspec/eth2spec/test/deneb/unittests/validator/test_validator.py @@ -2,7 +2,6 @@ from eth2spec.test.context import ( always_bls, spec_state_test, with_deneb_and_later, - expect_assertion_error ) from eth2spec.test.helpers.execution_payload import ( compute_el_block_hash, @@ -18,92 +17,6 @@ from eth2spec.test.helpers.keys import ( ) -@with_deneb_and_later -@spec_state_test -def test_validate_blobs_and_kzg_commitments(spec, state): - """ - Test `validate_blobs_and_kzg_commitments` - """ - blob_count = 4 - block = build_empty_block_for_next_slot(spec, state) - opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=blob_count) - block.body.blob_kzg_commitments = blob_kzg_commitments - block.body.execution_payload.transactions = [opaque_tx] - block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) - - spec.validate_blobs_and_kzg_commitments(blobs, - blob_kzg_commitments, - proofs) - - -@with_deneb_and_later -@spec_state_test -def test_validate_blobs_and_kzg_commitments_missing_blob(spec, state): - """ - Test `validate_blobs_and_kzg_commitments` - """ - blob_count = 4 - block = build_empty_block_for_next_slot(spec, state) - opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=blob_count) - block.body.blob_kzg_commitments = blob_kzg_commitments - block.body.execution_payload.transactions = [opaque_tx] - block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) - - expect_assertion_error( - lambda: spec.validate_blobs_and_kzg_commitments( - blobs[:-1], - blob_kzg_commitments, - proofs - ) - ) - - -@with_deneb_and_later -@spec_state_test -def test_validate_blobs_and_kzg_commitments_missing_proof(spec, state): - """ - Test `validate_blobs_and_kzg_commitments` - """ - blob_count = 4 - block = build_empty_block_for_next_slot(spec, state) - opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=blob_count) - block.body.blob_kzg_commitments = blob_kzg_commitments - block.body.execution_payload.transactions = [opaque_tx] - block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) - - expect_assertion_error( - lambda: spec.validate_blobs_and_kzg_commitments( - blobs, - blob_kzg_commitments, - proofs[:-1] - ) - ) - - -@with_deneb_and_later -@spec_state_test -def test_validate_blobs_and_kzg_commitments_incorrect_blob(spec, state): - """ - Test `validate_blobs_and_kzg_commitments` - """ - blob_count = 4 - block = build_empty_block_for_next_slot(spec, state) - opaque_tx, blobs, blob_kzg_commitments, proofs = get_sample_opaque_tx(spec, blob_count=blob_count) - block.body.blob_kzg_commitments = blob_kzg_commitments - block.body.execution_payload.transactions = [opaque_tx] - block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) - - blobs[1] = spec.Blob(blobs[1][:13] + bytes([(blobs[1][13] + 1) % 256]) + blobs[1][14:]) - - expect_assertion_error( - lambda: spec.validate_blobs_and_kzg_commitments( - blobs, - blob_kzg_commitments, - proofs - ) - ) - - @with_deneb_and_later @spec_state_test def test_blob_sidecar_signature(spec, state):