Skip to content

Commit 496cb34

Browse files
anvacarurv-auditorrv-jenkinsPetarMaxpalinatolmach
authored
EIP-6780: SELFDESTRUCT only in same transaction (#2545)
* tests with cid 0 * tests with cid 0 tweaks * implement eip-6780 * failing.llvm: update failing tests * Set Version: 1.0.662 * add new cell to k proofs * Set Version: 1.0.662 * update expected integration tests * update kontrol proofs * Set Version: 1.0.664 * draft: update kontrol specs * Set Version: 1.0.671 * add cell to mcd-structured claims * fix mcd proofs * Update dependency: deps/k_release (#2664) * deps/k_release: Set Version 7.1.187 * kevm-pyk/: sync poetry files pyk version 7.1.187 * flake.{nix,lock}: update Nix derivations --------- Co-authored-by: devops <[email protected]> * Support for multimasks in slot updates (#2657) * support for multimasks * syntax correction * test correction * Update dependency: deps/k_release (#2665) * deps/k_release: Set Version 7.1.190 * kevm-pyk/: sync poetry files pyk version 7.1.190 * flake.{nix,lock}: update Nix derivations --------- Co-authored-by: devops <[email protected]> * introducing the optimize_kcfg parameter (#2666) * Update dependency: deps/k_release (#2667) * deps/k_release: Set Version 7.1.191 * kevm-pyk/: sync poetry files pyk version 7.1.191 * flake.{nix,lock}: update Nix derivations --------- Co-authored-by: devops <[email protected]> * update kontrol claims * passing kontrol specs * update newer specs * add cell to remaining tests.. * Update kevm-pyk/src/kevm_pyk/kproj/evm-semantics/schedule.md Co-authored-by: Palina <[email protected]> --------- Co-authored-by: devops <[email protected]> Co-authored-by: rv-jenkins <[email protected]> Co-authored-by: Petar Maksimović <[email protected]> Co-authored-by: Palina <[email protected]>
1 parent f28dcd9 commit 496cb34

File tree

164 files changed

+411
-3314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+411
-3314
lines changed

Diff for: kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md

+31-2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ In the comments next to each cell, we've marked which component of the YellowPap
8282
<refund> 0 </refund> // A_r
8383
<accessedAccounts> .Set </accessedAccounts>
8484
<accessedStorage> .Map </accessedStorage>
85+
<createdAccounts> .Set </createdAccounts>
8586
</substate>
8687
8788
// Immutable during a single transaction
@@ -554,9 +555,10 @@ After executing a transaction, it's necessary to have the effect of the substate
554555
rule <k> #finalizeTx(true) => #finalizeStorage(Set2List(SetItem(MINER) |Set ACCTS)) ... </k>
555556
<selfDestruct> .Set </selfDestruct>
556557
<coinbase> MINER </coinbase>
557-
<touchedAccounts> ACCTS </touchedAccounts>
558+
<touchedAccounts> ACCTS => .Set </touchedAccounts>
558559
<accessedAccounts> _ => .Set </accessedAccounts>
559560
<accessedStorage> _ => .Map </accessedStorage>
561+
<createdAccounts> _ => .Set </createdAccounts>
560562
561563
rule <k> #finalizeTx(false) ... </k>
562564
<useGas> true </useGas>
@@ -1618,6 +1620,7 @@ For each `CALL*` operation, we make a corresponding call to `#call` and a state-
16181620
<nonce> NONCE => #if Gemptyisnonexistent << SCHED >> #then NONCE +Int 1 #else NONCE #fi </nonce>
16191621
...
16201622
</account>
1623+
<createdAccounts> ACCTS => ACCTS |Set SetItem(ACCTTO) </createdAccounts>
16211624
16221625
rule <k> #incrementNonce ACCT => .K ... </k>
16231626
<account>
@@ -1749,6 +1752,7 @@ Self destructing to yourself, unlike a regular transfer, destroys the balance in
17491752
syntax UnStackOp ::= "SELFDESTRUCT"
17501753
// -----------------------------------
17511754
rule <k> SELFDESTRUCT ACCTTO => #touchAccounts ACCT ACCTTO ~> #accessAccounts ACCTTO ~> #transferFunds ACCT ACCTTO BALFROM ~> #end EVMC_SUCCESS ... </k>
1755+
<schedule> SCHED </schedule>
17521756
<id> ACCT </id>
17531757
<selfDestruct> SDS => SDS |Set SetItem(ACCT) </selfDestruct>
17541758
<account>
@@ -1757,9 +1761,12 @@ Self destructing to yourself, unlike a regular transfer, destroys the balance in
17571761
...
17581762
</account>
17591763
<output> _ => .Bytes </output>
1760-
requires ACCT =/=Int ACCTTO
1764+
<createdAccounts> CA </createdAccounts>
1765+
requires ((notBool Ghaseip6780 << SCHED >>) orBool ACCT in CA)
1766+
andBool ACCT =/=Int ACCTTO
17611767
17621768
rule <k> SELFDESTRUCT ACCT => #touchAccounts ACCT ~> #accessAccounts ACCT ~> #end EVMC_SUCCESS ... </k>
1769+
<schedule> SCHED </schedule>
17631770
<id> ACCT </id>
17641771
<selfDestruct> SDS => SDS |Set SetItem(ACCT) </selfDestruct>
17651772
<account>
@@ -1768,6 +1775,28 @@ Self destructing to yourself, unlike a regular transfer, destroys the balance in
17681775
...
17691776
</account>
17701777
<output> _ => .Bytes </output>
1778+
<createdAccounts> CA </createdAccounts>
1779+
requires ((notBool Ghaseip6780 << SCHED >>) orBool ACCT in CA)
1780+
1781+
rule <k> SELFDESTRUCT ACCTTO => #touchAccounts ACCT ACCTTO ~> #accessAccounts ACCTTO ~> #transferFunds ACCT ACCTTO BALFROM ~> #end EVMC_SUCCESS ... </k>
1782+
<schedule> SCHED </schedule>
1783+
<id> ACCT </id>
1784+
<account>
1785+
<acctID> ACCT </acctID>
1786+
<balance> BALFROM </balance>
1787+
...
1788+
</account>
1789+
<output> _ => .Bytes </output>
1790+
<createdAccounts> CA </createdAccounts>
1791+
requires Ghaseip6780 << SCHED >> andBool (notBool ACCT in CA)
1792+
andBool ACCT =/=Int ACCTTO
1793+
1794+
rule <k> SELFDESTRUCT ACCT => #touchAccounts ACCT ~> #accessAccounts ACCT ~> #end EVMC_SUCCESS ... </k>
1795+
<schedule> SCHED </schedule>
1796+
<id> ACCT </id>
1797+
<output> _ => .Bytes </output>
1798+
<createdAccounts> CA </createdAccounts>
1799+
requires Ghaseip6780 << SCHED >> andBool (notBool ACCT in CA)
17711800
```
17721801

17731802
Precompiled Contracts

Diff for: kevm-pyk/src/kevm_pyk/kproj/evm-semantics/schedule.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ module SCHEDULE
2929
| "Ghassstorestipend" | "Ghaschainid" | "Ghasaccesslist" | "Ghasbasefee"
3030
| "Ghasrejectedfirstbyte" | "Ghasprevrandao" | "Ghasmaxinitcodesize" | "Ghaspushzero"
3131
| "Ghaswarmcoinbase" | "Ghastransient" | "Ghasmcopy" | "Ghasbeaconroot"
32-
// -----------------------------------------------------------------------------------------------------------------
32+
| "Ghaseip6780"
33+
// -------------------------------------
3334
```
3435

3536
### Schedule Constants
@@ -149,6 +150,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
149150
rule Ghastransient << DEFAULT >> => false
150151
rule Ghasmcopy << DEFAULT >> => false
151152
rule Ghasbeaconroot << DEFAULT >> => false
153+
rule Ghaseip6780 << DEFAULT >> => false
152154
```
153155

154156
### Frontier Schedule
@@ -390,10 +392,12 @@ A `ScheduleConst` is a constant determined by the fee schedule.
390392
rule Ghastransient << CANCUN >> => true
391393
rule Ghasmcopy << CANCUN >> => true
392394
rule Ghasbeaconroot << CANCUN >> => true
395+
rule Ghaseip6780 << CANCUN >> => true
393396
rule SCHEDFLAG << CANCUN >> => SCHEDFLAG << SHANGHAI >>
394397
requires notBool ( SCHEDFLAG ==K Ghastransient
395398
orBool SCHEDFLAG ==K Ghasmcopy
396399
orBool SCHEDFLAG ==K Ghasbeaconroot
400+
orBool SCHEDFLAG ==K Ghaseip6780
397401
)
398402
```
399403
```k

Diff for: kevm-pyk/src/kevm_pyk/kproj/evm-semantics/state-utils.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module STATE-UTILS
5050
<origin> _ => .Account </origin>
5151
<touchedAccounts> _ => .Set </touchedAccounts>
5252
<accessedAccounts> _ => .Set </accessedAccounts>
53+
<createdAccounts> _ => .Set </createdAccounts>
5354
5455
syntax EthereumCommand ::= "clearBLOCK"
5556
// ---------------------------------------

Diff for: kevm-pyk/src/tests/integration/test_conformance.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131

3232
TEST_DIR: Final = REPO_ROOT / 'tests/ethereum-tests'
3333
GOLDEN: Final = (REPO_ROOT / 'tests/templates/output-success-llvm.json').read_text().rstrip()
34+
TEST_FILES_WITH_CID_0: Final = (REPO_ROOT / 'tests/bchain.0.chainId').read_text().splitlines()
3435

3536

36-
def _test(gst_file: Path, schedule: str, mode: str, chainid: int, usegas: bool) -> None:
37+
def _test(gst_file: Path, schedule: str, mode: str, usegas: bool) -> None:
3738
skipped_gst_tests = SKIPPED_TESTS.get(gst_file, [])
3839
if '*' in skipped_gst_tests:
3940
pytest.skip()
4041

42+
chainid = 0 if str(gst_file.relative_to(TEST_DIR)) in TEST_FILES_WITH_CID_0 else 1
43+
4144
with gst_file.open() as f:
4245
gst_data = json.load(f)
4346

@@ -93,7 +96,7 @@ def read_csv_file(csv_file: Path) -> tuple[tuple[Path, str], ...]:
9396
ids=[str(test_file.relative_to(VM_TEST_DIR)) for test_file in VM_TESTS],
9497
)
9598
def test_vm(test_file: Path) -> None:
96-
_test(test_file, 'DEFAULT', 'VMTESTS', 1, True)
99+
_test(test_file, 'DEFAULT', 'VMTESTS', True)
97100

98101

99102
@pytest.mark.skip(reason='failing / slow VM tests')
@@ -103,7 +106,7 @@ def test_vm(test_file: Path) -> None:
103106
ids=[str(test_file.relative_to(VM_TEST_DIR)) for test_file in SKIPPED_VM_TESTS],
104107
)
105108
def test_rest_vm(test_file: Path) -> None:
106-
_test(test_file, 'DEFAULT', 'VMTESTS', 1, True)
109+
_test(test_file, 'DEFAULT', 'VMTESTS', True)
107110

108111

109112
ALL_TEST_DIR: Final = TEST_DIR / 'BlockchainTests/GeneralStateTests'
@@ -118,7 +121,7 @@ def test_rest_vm(test_file: Path) -> None:
118121
ids=[str(test_file.relative_to(ALL_TEST_DIR)) for test_file in BCHAIN_TESTS],
119122
)
120123
def test_bchain(test_file: Path) -> None:
121-
_test(test_file, 'CANCUN', 'NORMAL', 1, True)
124+
_test(test_file, 'CANCUN', 'NORMAL', True)
122125

123126

124127
@pytest.mark.skip(reason='failing / slow blockchain tests')
@@ -128,4 +131,4 @@ def test_bchain(test_file: Path) -> None:
128131
ids=[str(test_file.relative_to(ALL_TEST_DIR)) for test_file in SKIPPED_BCHAIN_TESTS],
129132
)
130133
def test_rest_bchain(test_file: Path) -> None:
131-
_test(test_file, 'CANCUN', 'NORMAL', 1, True)
134+
_test(test_file, 'CANCUN', 'NORMAL', True)

Diff for: tests/bchain.0.chainId

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/create_selfdestruct_same_tx.json
2+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/delegatecall_from_new_contract_to_pre_existing_contract.json
3+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/delegatecall_from_pre_existing_contract_to_new_contract.json
4+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/dynamic_create2_selfdestruct_collision_multi_tx.json
5+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/dynamic_create2_selfdestruct_collision_two_different_transactions.json
6+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/dynamic_create2_selfdestruct_collision.json
7+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/recreate_self_destructed_contract_different_txs.json
8+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/reentrancy_selfdestruct_revert.json
9+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/self_destructing_initcode_create_tx.json
10+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/self_destructing_initcode.json
11+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/selfdestruct_created_in_same_tx_with_revert.json
12+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/selfdestruct_created_same_block_different_tx.json
13+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/selfdestruct_not_created_in_same_tx_with_revert.json
14+
BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip6780_selfdestruct/selfdestruct_pre_existing.json

0 commit comments

Comments
 (0)