Skip to content

Commit ddf5842

Browse files
pdobaczmarioevz
andauthored
feat(tests): Typed txs are invalid and void before their fork (#1754)
* feat(tests): Typed txs are invalid and void before their fork * fix(client_clis): Exception message * fix(tests): Use parametrize_by_fork instead * Update packages/testing/src/execution_testing/client_clis/clis/ethrex.py --------- Co-authored-by: Mario Vega <[email protected]>
1 parent cf78d6f commit ddf5842

File tree

14 files changed

+197
-126
lines changed

14 files changed

+197
-126
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Test fixtures for use by clients are available for each release on the [Github r
3434
- ✨ Add tests for `modexp` and `ripemd` precompiled contracts ([#1691](https://github.com/ethereum/execution-specs/pull/1691)).
3535
- ✨ Add `ecrecover` precompile tests originating form `evmone` unittests ([#1685](https://github.com/ethereum/execution-specs/pull/1685)).
3636
- ✨ Add stack overflow tests and expand `BLOCKHASH` tests ([#1728](https://github.com/ethereum/execution-specs/pull/1728)).
37+
- ✨ Add tests that EIP-1559 and EIP-2930 typed txs are invalid and void before their fork ([#1754](https://github.com/ethereum/execution-specs/pull/1754)).
3738

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

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class EthrexExceptionMapper(ExceptionMapper):
5151
TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH: (
5252
r"blob version not supported|Invalid blob versioned hash"
5353
),
54+
TransactionException.TYPE_2_TX_PRE_FORK: (
55+
r"Type 2 transactions are not supported before the London fork"
56+
),
5457
TransactionException.TYPE_3_TX_PRE_FORK: (
5558
r"blob versioned hashes not supported|"
5659
r"Type 3 transactions are not supported before the Cancun fork"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ class EvmoneExceptionMapper(ExceptionMapper):
350350
),
351351
TransactionException.TYPE_4_TX_PRE_FORK: "transaction type not supported",
352352
TransactionException.TYPE_3_TX_PRE_FORK: "transaction type not supported",
353+
TransactionException.TYPE_2_TX_PRE_FORK: "transaction type not supported",
354+
TransactionException.TYPE_1_TX_PRE_FORK: "transaction type not supported",
353355
TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH: "invalid blob hash version",
354356
TransactionException.TYPE_3_TX_BLOB_COUNT_EXCEEDED: "blob gas limit exceeded",
355357
TransactionException.TYPE_3_TX_ZERO_BLOBS: "empty blob hashes list",

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ class ExecutionSpecsExceptionMapper(ExceptionMapper):
195195
TransactionException.INSUFFICIENT_MAX_FEE_PER_GAS: (
196196
r"InsufficientMaxFeePerGasError|InvalidBlock" # Temporary solution for issue #1981.
197197
),
198+
TransactionException.TYPE_1_TX_PRE_FORK: (
199+
r"module '.*transactions' has no attribute 'AccessListTransaction'"
200+
),
201+
TransactionException.TYPE_2_TX_PRE_FORK: (
202+
r"'.*transactions' has no attribute 'FeeMarketTransaction'"
203+
),
198204
TransactionException.TYPE_3_TX_PRE_FORK: (
199205
r"module '.*transactions' has no attribute 'BlobTransaction'"
200206
),

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ class GethExceptionMapper(ExceptionMapper):
5454
TransactionException.PRIORITY_GREATER_THAN_MAX_FEE_PER_GAS: (
5555
"max priority fee per gas higher than max fee per gas"
5656
),
57+
TransactionException.TYPE_1_TX_PRE_FORK: (
58+
"transaction type not supported"
59+
),
60+
TransactionException.TYPE_2_TX_PRE_FORK: (
61+
"transaction type not supported"
62+
),
5763
TransactionException.TYPE_3_TX_PRE_FORK: (
5864
"transaction type not supported"
5965
),

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ class NethermindExceptionMapper(ExceptionMapper):
395395
TransactionException.INSUFFICIENT_MAX_FEE_PER_BLOB_GAS: (
396396
"InsufficientMaxFeePerBlobGas: Not enough to cover blob gas fee"
397397
),
398+
TransactionException.TYPE_1_TX_PRE_FORK: (
399+
"InvalidTxType: Transaction type in Custom is not supported"
400+
),
401+
TransactionException.TYPE_2_TX_PRE_FORK: (
402+
"InvalidTxType: Transaction type in Custom is not supported"
403+
),
398404
TransactionException.TYPE_3_TX_PRE_FORK: (
399405
"InvalidTxType: Transaction type in Custom is not supported"
400406
),

packages/testing/src/execution_testing/exceptions/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ class TransactionException(ExceptionBase):
269269
"""
270270
Transaction's initcode for a contract-creating transaction is too large.
271271
"""
272+
TYPE_1_TX_PRE_FORK = auto()
273+
"""Transaction type 1 included before activation fork."""
274+
TYPE_2_TX_PRE_FORK = auto()
275+
"""Transaction type 2 included before activation fork."""
272276
TYPE_3_TX_PRE_FORK = auto()
273277
"""Transaction type 3 included before activation fork."""
274278
TYPE_3_TX_ZERO_BLOBS_PRE_FORK = auto()

packages/testing/src/execution_testing/exceptions/exceptions/transaction.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ class TransactionException(ExceptionBase):
153153
"""
154154
Transaction's initcode for a contract-creating transaction is too large.
155155
"""
156+
TYPE_1_TX_PRE_FORK = auto()
157+
"""Transaction type 1 included before activation fork."""
158+
TYPE_2_TX_PRE_FORK = auto()
159+
"""Transaction type 2 included before activation fork."""
156160
TYPE_3_TX_PRE_FORK = auto()
157161
"""Transaction type 3 included before activation fork."""
158162
TYPE_3_TX_ZERO_BLOBS_PRE_FORK = auto()
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""Test the tx type validation for EIP-2930."""
2+
3+
from typing import Generator
4+
5+
import pytest
6+
from execution_testing import (
7+
Account,
8+
Alloc,
9+
Fork,
10+
ParameterSet,
11+
StateTestFiller,
12+
Transaction,
13+
TransactionException,
14+
)
15+
from execution_testing import Opcodes as Op
16+
from execution_testing.forks import Byzantium
17+
18+
from .spec import ref_spec_2930
19+
20+
REFERENCE_SPEC_GIT_PATH = ref_spec_2930.git_path
21+
REFERENCE_SPEC_VERSION = ref_spec_2930.version
22+
23+
TX_TYPE = 1
24+
25+
26+
def tx_validity(fork: Fork) -> Generator[ParameterSet, None, None]:
27+
"""
28+
Return a generator of parameters for the tx validity test.
29+
"""
30+
valid = TX_TYPE in fork.tx_types()
31+
yield pytest.param(
32+
valid,
33+
marks=[pytest.mark.exception_test] if not valid else [],
34+
id="valid" if valid else "invalid",
35+
)
36+
37+
38+
@pytest.mark.ported_from(
39+
[
40+
"https://github.com/ethereum/legacytests/blob/master/src/LegacyTests/Cancun/GeneralStateTestsFiller/stExample/accessListExampleFiller.yml"
41+
],
42+
pr=["https://github.com/ethereum/execution-specs/pull/1754"],
43+
)
44+
@pytest.mark.parametrize_by_fork("valid", tx_validity)
45+
def test_eip2930_tx_validity(
46+
state_test: StateTestFiller,
47+
fork: Fork,
48+
pre: Alloc,
49+
valid: bool,
50+
) -> None:
51+
"""
52+
Tests that an EIP-2930 tx is correctly rejected before fork activation.
53+
"""
54+
account = pre.deploy_contract(
55+
code=Op.SSTORE(0, 1),
56+
storage={0: 0xDEADBEEF},
57+
)
58+
sender = pre.fund_eoa()
59+
60+
tx = Transaction(
61+
to=account,
62+
sender=sender,
63+
gas_limit=100_000,
64+
access_list=[],
65+
protected=fork >= Byzantium,
66+
error=TransactionException.TYPE_1_TX_PRE_FORK if not valid else None,
67+
)
68+
69+
post = {account: Account(storage={0: 0xDEADBEEF if not valid else 1})}
70+
if not valid:
71+
post[sender] = pre[sender] # type: ignore
72+
73+
state_test(pre=pre, post=post, tx=tx)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
Tests for [EIP-1559: Fee market change for ETH 1.0 chain](https://eips.ethereum.org/EIPS/eip-1559).
3+
"""

0 commit comments

Comments
 (0)