Skip to content

Commit a5edb7e

Browse files
authored
Zero the EIP-6780 entry contract's returned byte in EEST (#4471)
Three EIP-6780 tests in EEST's `test_selfdestruct.py` (`test_recursive_contract_creation_and_selfdestruct`, `test_parent_creates_child_selfdestruct_one` and `test_create_and_destroy_multiple_contracts_same_tx`) end their entry contract with `Op.RETURN(32, 1)`, meant to deploy a single zero byte. That memory byte is not zero: these entry contracts `EXTCODECOPY` initcode to offset 0, and that initcode embeds the addresses of contracts deployed earlier. Upstream fills with fixed addresses, but on our devnet they depend on live nonces, so roughly one run in 256 per vector that byte is `0xEF` and EIP-3541 rejects the deployment. The tx then fails with all gas used and the expected storage never lands. In the 10-05 failure the rebuilt initcode has `0xef` at byte 32, from the embedded address `0xa4d0c0974fef…`. The compatibility patch now writes `MSTORE8(32, 0)` before each of those returns, and before the same return in `test_selfdestruct_pre_existing` and `test_selfdestruct_created_same_block_different_tx`, which never write memory today and are patched only so a future EEST bump can't reintroduce it, so the deployed byte is always zero as upstream intended. None of these tests checks the entry contract's code, so expected post-state is unchanged; `fill` against the patched tests still passes all 170 affected vectors. The README's compatibility patch policy lists the new hunk. Flaked in: https://github.com/sei-protocol/sei-chain/actions/runs/37383269055/job/112013686385 https://github.com/sei-protocol/sei-chain/actions/runs/36018465389/job/107699232433 https://github.com/sei-protocol/sei-chain/actions/runs/35840429705/job/107115658633 https://github.com/sei-protocol/sei-chain/actions/runs/35789756861/job/106956775871 https://github.com/sei-protocol/sei-chain/actions/runs/35222729730/job/105208351969
1 parent bf6c14f commit a5edb7e

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎integration_test/exec_specs/README.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ to cases that cannot otherwise execute faithfully against a live Sei chain:
7676
precompile's balance, which a persistent remote chain cannot do.
7777
- `test_set_code_txs.py` raises fixed EIP-1559 fee caps above the devnet base
7878
fee so the transaction reaches the behavior under test.
79+
- `test_selfdestruct.py` zeroes the byte its entry contracts return as runtime
80+
code. Upstream relies on that memory byte being zero, but it holds part of a
81+
live-chain contract address and is sometimes `0xEF`, which EIP-3541 rejects.
7982

8083
These changes adapt transaction construction or remote-state limitations; they
8184
do not alter expected post-state. Re-evaluate each hunk when updating the

‎integration_test/exec_specs/patches/sei-compat.patch‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,55 @@ index 58cfb1403..57b8266df 100644
399399
calls = [
400400
RPCCall(
401401
method="sendRawTransaction",
402+
diff --git a/tests/cancun/eip6780_selfdestruct/test_selfdestruct.py b/tests/cancun/eip6780_selfdestruct/test_selfdestruct.py
403+
index a78ddccb..d3fc920b 100644
404+
--- a/tests/cancun/eip6780_selfdestruct/test_selfdestruct.py
405+
+++ b/tests/cancun/eip6780_selfdestruct/test_selfdestruct.py
406+
@@ -1002,7 +1002,7 @@ def test_selfdestruct_pre_existing(
407+
408+
# Lastly return zero so the entry point contract is created and we can
409+
# retain the stored values for verification.
410+
- entry_code += Op.RETURN(32, 1)
411+
+ entry_code += Op.MSTORE8(32, 0) + Op.RETURN(32, 1)
412+
413+
tx = Transaction(
414+
value=entry_code_balance,
415+
@@ -1115,7 +1115,7 @@ def test_selfdestruct_created_same_block_different_tx(
416+
417+
# Lastly return zero so the entry point contract is created and we can
418+
# retain the stored values for verification.
419+
- entry_code += Op.RETURN(32, 1)
420+
+ entry_code += Op.MSTORE8(32, 0) + Op.RETURN(32, 1)
421+
422+
post: Dict[Address, Account] = {
423+
entry_code_address: Account(
424+
@@ -1877,7 +1877,7 @@ def test_create_and_destroy_multiple_contracts_same_tx(
425+
Op.BALANCE(contract_addresses[i]),
426+
)
427+
428+
- entry_code += Op.RETURN(32, 1)
429+
+ entry_code += Op.MSTORE8(32, 0) + Op.RETURN(32, 1)
430+
431+
tx = Transaction(
432+
data=entry_code,
433+
@@ -2182,7 +2182,7 @@ def test_parent_creates_child_selfdestruct_one(
434+
Op.CALL(Op.GASLIMIT, parent_address, 0, 0, 32, 0, 0),
435+
)
436+
437+
- entry_code += Op.RETURN(32, 1)
438+
+ entry_code += Op.MSTORE8(32, 0) + Op.RETURN(32, 1)
439+
440+
tx = Transaction(
441+
data=entry_code,
442+
@@ -2357,7 +2357,7 @@ def test_recursive_contract_creation_and_selfdestruct(
443+
Op.CALL(Op.GASLIMIT, contract_addresses[0], 0, 0, 0, 0, 0),
444+
)
445+
446+
- entry_code += Op.RETURN(32, 1)
447+
+ entry_code += Op.MSTORE8(32, 0) + Op.RETURN(32, 1)
448+
449+
tx = Transaction(
450+
data=entry_code,
402451
diff --git a/tests/istanbul/eip1344_chainid/test_chainid.py b/tests/istanbul/eip1344_chainid/test_chainid.py
403452
index 963a7b3..319249e 100644
404453
--- a/tests/istanbul/eip1344_chainid/test_chainid.py

0 commit comments

Comments
 (0)