Skip to content

Commit 973e220

Browse files
authored
feat(tests): test that 7702 set code txs are rejected pre-prague (#1463)
* chore(fw): add `TYPE_4_TX_PRE_FORK` exception * feat(tests): add a test to verify 7702 set code txs are rejected pre-prague * docs: update changelog
1 parent 84d28db commit 973e220

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

Diff for: docs/CHANGELOG.md

+1
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
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702): Test precompile case in same transaction as delegation without extra gas in case of precompile code execution; parametrize all call opcodes in existing precompile test ([#1431](https://github.com/ethereum/execution-spec-tests/pull/1431)).
2626
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702): Add invalid nonce authorizations tests for the case of multiple signers when the sender's nonce gets increased ([#1441](https://github.com/ethereum/execution-spec-tests/pull/1441)).
27+
-[EIP-7702](https://eips.ethereum.org/EIPS/eip-7702): Add a test that verifies that set code transactions are correctly rejected before Prague activation ([#1463](https://github.com/ethereum/execution-spec-tests/pull/1463)).
2728
-[EIP-7623](https://eips.ethereum.org/EIPS/eip-7623): Additionally parametrize transaction validity tests with the `to` set to an EOA account (previously only contracts) ([#1422](https://github.com/ethereum/execution-spec-tests/pull/1422)).
2829

2930
### 📋 Misc

Diff for: src/ethereum_clis/clis/execution_specs.py

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ class ExecutionSpecsExceptionMapper(ExceptionMapper):
146146
TransactionException.TYPE_3_TX_PRE_FORK: (
147147
"module 'ethereum.shanghai.transactions' has no attribute 'BlobTransaction'"
148148
),
149+
TransactionException.TYPE_4_TX_PRE_FORK: "Unknown transaction type: 0x4",
149150
TransactionException.TYPE_3_TX_INVALID_BLOB_VERSIONED_HASH: "d transaction: ",
150151
# This message is the same as TYPE_3_TX_MAX_BLOB_GAS_ALLOWANCE_EXCEEDED
151152
TransactionException.TYPE_3_TX_BLOB_COUNT_EXCEEDED: " transaction: ",

Diff for: src/ethereum_test_exceptions/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ class TransactionException(ExceptionBase):
381381
"""
382382
Transaction is type 4, but contains an authorization that has an invalid format.
383383
"""
384+
TYPE_4_TX_PRE_FORK = auto()
385+
"""
386+
Transaction type 4 included before activation fork.
387+
"""
384388

385389

386390
@unique

Diff for: tests/prague/eip7702_set_code_tx/test_set_code_txs_2.py

+61
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
Storage,
2222
Switch,
2323
Transaction,
24+
TransactionException,
2425
compute_create_address,
2526
)
2627
from ethereum_test_tools.vm.opcode import Opcodes as Op
@@ -1689,3 +1690,63 @@ def test_pointer_resets_an_empty_code_account_with_storage(
16891690
Block(txs=[tx_create_suicide_from_pointer]),
16901691
],
16911692
)
1693+
1694+
1695+
@pytest.mark.parametrize(
1696+
"tx_value",
1697+
[0, 1],
1698+
)
1699+
@pytest.mark.exception_test
1700+
@pytest.mark.valid_at_transition_to("Prague")
1701+
def test_set_code_type_tx_pre_fork(
1702+
state_test: StateTestFiller,
1703+
pre: Alloc,
1704+
tx_value: int,
1705+
):
1706+
"""
1707+
Reject blocks with set code type transactions before the Prague fork.
1708+
1709+
This test was based on:
1710+
tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_self_sponsored_set_code
1711+
"""
1712+
storage = Storage()
1713+
sender = pre.fund_eoa()
1714+
1715+
set_code = (
1716+
Op.SSTORE(storage.store_next(sender), Op.ORIGIN)
1717+
+ Op.SSTORE(storage.store_next(sender), Op.CALLER)
1718+
+ Op.SSTORE(storage.store_next(tx_value), Op.CALLVALUE)
1719+
+ Op.STOP
1720+
)
1721+
set_code_to_address = pre.deploy_contract(
1722+
set_code,
1723+
)
1724+
1725+
tx = Transaction(
1726+
gas_limit=10_000_000,
1727+
to=sender,
1728+
value=tx_value,
1729+
authorization_list=[
1730+
AuthorizationTuple(
1731+
address=set_code_to_address,
1732+
nonce=1,
1733+
signer=sender,
1734+
),
1735+
],
1736+
sender=sender,
1737+
error=TransactionException.TYPE_4_TX_PRE_FORK,
1738+
)
1739+
1740+
state_test(
1741+
env=Environment(),
1742+
pre=pre,
1743+
tx=tx,
1744+
post={
1745+
set_code_to_address: Account(storage={k: 0 for k in storage}),
1746+
sender: Account(
1747+
nonce=0,
1748+
code="",
1749+
storage={},
1750+
),
1751+
},
1752+
)

0 commit comments

Comments
 (0)