From 3ad0a8f4462e2816ed5fecb88abc2f85d7789181 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 18 Jul 2023 18:30:02 +0000 Subject: [PATCH 1/2] tests/deneb: add more execution payload processing test cases --- .../test_process_execution_payload.py | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py index 988070278..6266b6c79 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py @@ -78,14 +78,14 @@ def test_incorrect_blob_tx_type(spec, state): @with_deneb_and_later @spec_state_test -def test_incorrect_transaction_length_1_byte(spec, state): +def test_incorrect_transaction_length_1_extra_byte(spec, state): """ The versioned hashes are wrong, but the testing ExecutionEngine returns VALID by default. """ execution_payload = build_empty_execution_payload(spec, state) opaque_tx, _, blob_kzg_commitments, _ = get_sample_opaque_tx(spec) - opaque_tx = opaque_tx + b'\x12' # incorrect tx length + opaque_tx = opaque_tx + b'\x12' # incorrect tx length, longer execution_payload.transactions = [opaque_tx] execution_payload.block_hash = compute_el_block_hash(spec, execution_payload) @@ -95,7 +95,41 @@ def test_incorrect_transaction_length_1_byte(spec, state): @with_deneb_and_later @spec_state_test -def test_incorrect_transaction_length_32_bytes(spec, state): +def test_incorrect_transaction_length_1_byte_short(spec, state): + """ + The versioned hashes are wrong, but the testing ExecutionEngine returns VALID by default. + """ + execution_payload = build_empty_execution_payload(spec, state) + + opaque_tx, _, blob_kzg_commitments, _ = get_sample_opaque_tx(spec) + opaque_tx = opaque_tx[:-1] # incorrect tx length, shorter + + execution_payload.transactions = [opaque_tx] + execution_payload.block_hash = compute_el_block_hash(spec, execution_payload) + + yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments) + + +@with_deneb_and_later +@spec_state_test +def test_incorrect_transaction_length_empty(spec, state): + """ + The versioned hashes are wrong, but the testing ExecutionEngine returns VALID by default. + """ + execution_payload = build_empty_execution_payload(spec, state) + + opaque_tx, _, blob_kzg_commitments, _ = get_sample_opaque_tx(spec) + opaque_tx = opaque_tx[0:0] # incorrect tx length, empty + + execution_payload.transactions = [opaque_tx] + execution_payload.block_hash = compute_el_block_hash(spec, execution_payload) + + yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments) + + +@with_deneb_and_later +@spec_state_test +def test_incorrect_transaction_length_32_extra_bytes(spec, state): """ The versioned hashes are wrong, but the testing ExecutionEngine returns VALID by default. """ @@ -110,6 +144,22 @@ def test_incorrect_transaction_length_32_bytes(spec, state): yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments) +@with_deneb_and_later +@spec_state_test +def test_no_transactions_with_commitments(spec, state): + """ + The versioned hashes are wrong, but the testing ExecutionEngine returns VALID by default. + """ + execution_payload = build_empty_execution_payload(spec, state) + + _, _, blob_kzg_commitments, _ = get_sample_opaque_tx(spec) + + execution_payload.transactions = [] + execution_payload.block_hash = compute_el_block_hash(spec, execution_payload) + + yield from run_execution_payload_processing(spec, state, execution_payload, blob_kzg_commitments) + + @with_deneb_and_later @spec_state_test def test_incorrect_commitment(spec, state): From 419cbdcddc98e6f53d7e774eda9131b443848ac8 Mon Sep 17 00:00:00 2001 From: Mario Vega Date: Tue, 18 Jul 2023 19:28:12 +0000 Subject: [PATCH 2/2] tests/deneb: add small test descriptor --- .../block_processing/test_process_execution_payload.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py index 6266b6c79..b0937aac9 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/deneb/block_processing/test_process_execution_payload.py @@ -59,6 +59,13 @@ def run_execution_payload_processing(spec, state, execution_payload, blob_kzg_co assert state.latest_execution_payload_header == get_execution_payload_header(spec, body.execution_payload) +""" +Tests with incorrect blob transactions in the execution payload, but the execution client returns +VALID, and the purpose of these tests is that the beacon client must not reject the block by +attempting to do a validation of its own. +""" + + @with_deneb_and_later @spec_state_test def test_incorrect_blob_tx_type(spec, state):