Skip to content

Commit 131daee

Browse files
committed
feat(tests): Check minimum gaslimit (5000) is validated
1 parent 9563a51 commit 131daee

File tree

8 files changed

+105
-0
lines changed

8 files changed

+105
-0
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Test fixtures for use by clients are available for each release on the [Github r
2929
- ✨ Expand cases to test *CALL opcodes causing OOG ([#1703](https://github.com/ethereum/execution-specs/pull/1703)).
3030
- ✨ Add tests for `modexp` and `ripemd` precompiled contracts ([#1691](https://github.com/ethereum/execution-specs/pull/1691)).
3131
- ✨ Add `ecrecover` precompile tests originating form `evmone` unittests ([#1685](https://github.com/ethereum/execution-specs/pull/1685)).
32+
- ✨ Add tests for an old validation rule for gas limit above 5000 ([#1731](https://github.com/ethereum/execution-specs/pull/1731)).
3233

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

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,14 @@ 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",
280+
BlockException.INVALID_LOG_BLOOM: "failed to validate output of imported block",
281+
BlockException.INVALID_RECEIPTS_ROOT: "failed to validate output of imported block",
282+
BlockException.INVALID_STATE_ROOT: "World State Root does not match expected value",
275283
}
276284
mapping_regex = {
277285
BlockException.INVALID_REQUESTS: (

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ 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",
54+
BlockException.INVALID_STATE_ROOT: "invalid block: wrong trie root",
55+
BlockException.INVALID_RECEIPTS_ROOT: "receiptHash mismatch",
56+
BlockException.INVALID_LOG_BLOOM: "invalid bloom",
4957
}
5058
mapping_regex = {
5159
TransactionException.GAS_LIMIT_EXCEEDS_MAXIMUM: (

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ class GethExceptionMapper(ExceptionMapper):
8787
BlockException.SYSTEM_CONTRACT_CALL_FAILED: "system call failed to execute:",
8888
BlockException.INVALID_BLOCK_HASH: "blockhash mismatch",
8989
BlockException.RLP_BLOCK_LIMIT_EXCEEDED: "block RLP-encoded size exceeds maximum",
90+
BlockException.INVALID_BASEFEE_PER_GAS: "invalid baseFee",
91+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: "invalid timestamp",
92+
BlockException.INVALID_GASLIMIT: "invalid gas limit",
93+
BlockException.INVALID_BLOCK_NUMBER: "invalid block number",
94+
BlockException.EXTRA_DATA_TOO_BIG: "invalid extradata length",
95+
BlockException.INVALID_RECEIPTS_ROOT: "invalid receipt root hash",
96+
BlockException.INVALID_LOG_BLOOM: "invalid bloom",
97+
BlockException.INVALID_STATE_ROOT: "invalid merkle root",
9098
}
9199
mapping_regex: ClassVar[Dict[ExceptionBase, str]] = {
92100
TransactionException.TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED: (

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,14 @@ 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",
433+
BlockException.INVALID_RECEIPTS_ROOT: "InvalidReceiptsRoot: Receipts root in header does not match",
434+
BlockException.INVALID_LOG_BLOOM: "InvalidLogsBloom: Logs bloom in header does not match",
435+
BlockException.INVALID_STATE_ROOT: "InvalidStateRoot: State root in header does not match",
428436
}
429437
mapping_regex = {
430438
TransactionException.INSUFFICIENT_ACCOUNT_FUNDS: (

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,14 @@ 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",
117+
BlockException.INVALID_STATE_ROOT: "stateRoot mismatch",
118+
BlockException.INVALID_RECEIPTS_ROOT: "receiptRoot mismatch",
119+
BlockException.INVALID_LOG_BLOOM: "bloom mismatch",
111120
}
112121
mapping_regex: ClassVar[Dict[ExceptionBase, str]] = {}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ 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",
44+
BlockException.INVALID_LOG_BLOOM: "header bloom filter mismatch",
4245
}
4346
mapping_regex = {
4447
TransactionException.NONCE_MISMATCH_TOO_LOW: r"nonce \d+ too low, expected \d+",
@@ -74,6 +77,15 @@ class RethExceptionMapper(ExceptionMapper):
7477
BlockException.INVALID_GAS_USED_ABOVE_LIMIT: (
7578
r"block used gas \(\d+\) is greater than gas limit \(\d+\)"
7679
),
80+
BlockException.INVALID_GASLIMIT: (
81+
r"child gas_limit \d+ max .* is .*|child gas limit \d+ is below the minimum allowed limit"
82+
),
83+
BlockException.INVALID_BLOCK_TIMESTAMP_OLDER_THAN_PARENT: (
84+
r"block timestamp \d+ is in the past compared to the parent timestamp \d+"
85+
),
86+
BlockException.INVALID_BLOCK_NUMBER: (
87+
r"block number \d+ does not match parent block number \d+"
88+
),
7789
# BAL Exceptions: TODO - review once all clients completed.
7890
BlockException.INVALID_BAL_EXTRA_ACCOUNT: (
7991
r"Block BAL contains an account change that is not present in the computed BAL."
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""Test the validations applied from Frontier."""
2+
3+
import pytest
4+
from execution_testing.base_types.base_types import ZeroPaddedHexNumber
5+
from execution_testing.base_types.composite_types import Alloc
6+
from execution_testing.exceptions.exceptions import BlockException
7+
from execution_testing.specs.blockchain import (
8+
Block,
9+
BlockchainTestFiller,
10+
Header,
11+
)
12+
from execution_testing.test_types.block_types import Environment
13+
14+
15+
def test_gas_limit_at_minimum(
16+
blockchain_test: BlockchainTestFiller,
17+
pre: Alloc,
18+
env: Environment,
19+
) -> None:
20+
"""
21+
Tests that a block with an invalid header (e.g. difficulty) is rejected.
22+
"""
23+
modified_fields = {"gas_limit": 5000}
24+
env.gas_limit = ZeroPaddedHexNumber(5000)
25+
26+
block = Block(txs=[], rlp_modifier=Header(**modified_fields))
27+
28+
blockchain_test(pre=pre, post={}, blocks=[block], genesis_environment=env)
29+
30+
31+
@pytest.mark.exception_test
32+
@pytest.mark.parametrize("gas_limit", [0, 1, 4999])
33+
def test_gas_limit_below_minimum(
34+
blockchain_test: BlockchainTestFiller,
35+
pre: Alloc,
36+
gas_limit: int,
37+
env: Environment,
38+
) -> None:
39+
"""
40+
Tests that a block with an invalid header (e.g. difficulty) is rejected.
41+
"""
42+
invalid_fields = {"gas_limit": gas_limit}
43+
env.gas_limit = ZeroPaddedHexNumber(5000)
44+
45+
block = Block(
46+
txs=[],
47+
rlp_modifier=Header(**invalid_fields),
48+
exception=BlockException.INVALID_GASLIMIT,
49+
)
50+
51+
blockchain_test(pre=pre, post={}, blocks=[block], genesis_environment=env)

0 commit comments

Comments
 (0)