Skip to content

Commit 872321f

Browse files
committed
feat(tests): additional tests for header validation rules
1 parent c3e5260 commit 872321f

File tree

10 files changed

+78
-0
lines changed

10 files changed

+78
-0
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Test fixtures for use by clients are available for each release on the [Github r
2424

2525
- 🐞 Fix BALs opcode OOG test vectors by updating the Amsterdam commit hash in specs and validating appropriately on the testing side ([#2293](https://github.com/ethereum/execution-spec-tests/pull/2293)).
2626
- ✨ Fix test vector for BALs SSTORE with OOG by pointing to updated specs; add new boundary conditions cases for SSTORE w/ OOG ([#2297](https://github.com/ethereum/execution-spec-tests/pull/2297)).
27+
- ✨ Add a test case for base fee in block check after London ([#1702](https://github.com/ethereum/execution-specs/pull/1702))
2728

2829
## [v5.3.0](https://github.com/ethereum/execution-spec-tests/releases/tag/v5.3.0) - 2025-10-09
2930

packages/testing/src/execution_testing/client_clis/clis/besu.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ class BesuExceptionMapper(ExceptionMapper):
272272
"Payload BlobGasUsed does not match calculated BlobGasUsed"
273273
),
274274
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: "Header validation failed (FULL)",
275+
BlockException.INVALID_GASLIMIT: "Header validation failed (FULL)",
276+
BlockException.EXTRA_DATA_TOO_BIG: "Header validation failed (FULL)",
277+
BlockException.INVALID_BLOCK_NUMBER: "Header validation failed (FULL)",
278+
BlockException.INVALID_BASEFEE_PER_GAS: "Header validation failed (FULL)",
279+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "block timestamp not greater than parent",
275280
}
276281
mapping_regex = {
277282
BlockException.INVALID_REQUESTS: (

packages/testing/src/execution_testing/client_clis/clis/erigon.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class ErigonExceptionMapper(ExceptionMapper):
4646
BlockException.INVALID_REQUESTS: "invalid requests root hash in header",
4747
BlockException.INVALID_BLOCK_HASH: "invalid block hash",
4848
BlockException.RLP_BLOCK_LIMIT_EXCEEDED: "block exceeds max rlp size",
49+
BlockException.INVALID_BASEFEE_PER_GAS: "invalid block: invalid baseFee",
50+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "invalid block: timestamp older than parent",
51+
BlockException.INVALID_BLOCK_NUMBER: "invalid block number",
52+
BlockException.EXTRA_DATA_TOO_BIG: "invalid block: extra-data longer than 32 bytes",
53+
BlockException.INVALID_GASLIMIT: "invalid block: invalid gas limit",
4954
}
5055
mapping_regex = {
5156
TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM: (

packages/testing/src/execution_testing/client_clis/clis/geth.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ class GethExceptionMapper(ExceptionMapper):
9090
BlockException.INVALID_BAL_EXTRA_ACCOUNT: "BAL change not reported in computed",
9191
BlockException.INVALID_BAL_MISSING_ACCOUNT: "additional mutations compared to BAL",
9292
BlockException.INVALID_BLOCK_ACCESS_LIST: "unequal",
93+
BlockException.INVALID_BASEFEE_PER_GAS: "invalid baseFee",
94+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "invalid timestamp",
95+
BlockException.INVALID_GASLIMIT: "invalid gas limit",
96+
BlockException.INVALID_BLOCK_NUMBER: "invalid block number",
97+
BlockException.EXTRA_DATA_TOO_BIG: "invalid extradata length",
9398
}
9499
mapping_regex: ClassVar[Dict[ExceptionBase, str]] = {
95100
TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED: (

packages/testing/src/execution_testing/client_clis/clis/nethermind.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ class NethermindExceptionMapper(ExceptionMapper):
425425
BlockException.INVALID_DEPOSIT_EVENT_LAYOUT: (
426426
"DepositsInvalid: Invalid deposit event layout:"
427427
),
428+
BlockException.INVALID_BASEFEE_PER_GAS: "InvalidBaseFeePerGas: Does not match calculated",
429+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "InvalidTimestamp: Timestamp in header cannot be lower than ancestor",
430+
BlockException.INVALID_BLOCK_NUMBER: "InvalidBlockNumber: Block number does not match the parent",
431+
BlockException.EXTRA_DATA_TOO_BIG: "InvalidExtraData: Extra data in header is not valid",
432+
BlockException.INVALID_GASLIMIT: "InvalidGasLimit: Gas limit is not correct",
428433
}
429434
mapping_regex = {
430435
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS: (

packages/testing/src/execution_testing/client_clis/clis/nimbus.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,11 @@ class NimbusExceptionMapper(ExceptionMapper):
108108
# TODO:
109109
"ExceededBlockSizeLimit: Exceeded block size limit"
110110
),
111+
BlockException.INVALID_BASEFEE_PER_GAS: "invalid baseFee",
112+
BlockException.INVALID_BLOCK_NUMBER: "Blocks must be numbered consecutively",
113+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "Invalid timestamp",
114+
BlockException.INVALID_GASLIMIT: "invalid gas limit",
115+
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: "gasUsed should be non negative and smaller or equal gasLimit",
116+
BlockException.INVALID_BLOCK_HASH: "blockhash mismatch",
111117
}
112118
mapping_regex: ClassVar[Dict[ExceptionBase, str]] = {}

packages/testing/src/execution_testing/client_clis/clis/reth.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class RethExceptionMapper(ExceptionMapper):
3939
BlockException.INVALID_BLOCK_HASH: "block hash mismatch",
4040
BlockException.INVALID_GAS_USED: "block gas used mismatch",
4141
BlockException.RLP_BLOCK_LIMIT_EXCEEDED: "block is too large: ",
42+
BlockException.INVALID_BASEFEE_PER_GAS: "block base fee mismatch",
43+
BlockException.EXTRA_DATA_TOO_BIG: "invalid payload extra data",
4244
}
4345
mapping_regex = {
4446
TransactionException.NONCE_MISMATCH_TOO_LOW: r"nonce \d+ too low, expected \d+",
@@ -74,4 +76,11 @@ class RethExceptionMapper(ExceptionMapper):
7476
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: (
7577
r"block used gas \(\d+\) is greater than gas limit \(\d+\)"
7678
),
79+
BlockException.INVALID_GASLIMIT: (r"child gas_limit \d+ max .* is .*"),
80+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: (
81+
r"block timestamp \d+ is in the past compared to the parent timestamp \d+"
82+
),
83+
BlockException.INVALID_BLOCK_NUMBER: (
84+
r"block number \d+ does not match parent block number \d+"
85+
),
7786
}

tests/london/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Test cases for EVM functionality introduced in London."""
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Test for validation rules that apply for all forks starting from London.
3+
"""
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Test the validations applying after London."""
2+
3+
import pytest
4+
from execution_testing.base_types.composite_types import Alloc
5+
from execution_testing.exceptions.exceptions.block import BlockException
6+
from execution_testing.specs.blockchain import (
7+
Block,
8+
BlockchainTestFiller,
9+
Header,
10+
)
11+
12+
13+
@pytest.mark.valid_from("London")
14+
@pytest.mark.exception_test
15+
@pytest.mark.parametrize(
16+
"field,invalid_value,exception",
17+
[
18+
("base_fee_per_gas", 1, BlockException.INVALID_BASEFEE_PER_GAS),
19+
],
20+
)
21+
def test_invalid_header(
22+
blockchain_test: BlockchainTestFiller,
23+
pre: Alloc,
24+
field: str,
25+
invalid_value: int,
26+
exception: BlockException | list[BlockException],
27+
) -> None:
28+
"""
29+
Tests that a block with an invalid header (e.g. base_fee_per_gas) is
30+
rejected.
31+
"""
32+
invalid_fields = {field: invalid_value}
33+
34+
block = Block(
35+
txs=[], rlp_modifier=Header(**invalid_fields), exception=exception
36+
)
37+
38+
blockchain_test(pre=pre, post={}, blocks=[block])

0 commit comments

Comments
 (0)