Skip to content

Commit 71e5318

Browse files
authored
Add rules for new Prague schedule (#2747)
* fix typos in Makefile * define Prague schedule * update execution-spec-tests/failing.llvm * set Prague as the default schedule for testing * update expected output * keep cancun as default schedule for now * update golden files
1 parent 5dd05ea commit 71e5318

File tree

9 files changed

+36
-22
lines changed

9 files changed

+36
-22
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ test-fixtures: poetry download-json-fixtures
5959
$(MAKE) -C kevm-pyk/ test-integration PYTEST_ARGS+="-k test_execution_spec_tests.py"
6060

6161
fixtures-failing-list: poetry download-json-fixtures
62-
cat /dev/null > tests/ethereum-sepc-tests/failing.llvm
62+
cat /dev/null > tests/execution-spec-tests/failing.llvm
6363
- $(MAKE) -C kevm-pyk/ test-integration PYTEST_ARGS+="-k test_execution_spec_tests.py --save-failing --maxfail=10000"
6464
LC_ALL=en_US.UTF-8 sort -f -d -o tests/execution-spec-tests/failing.llvm tests/execution-spec-tests/failing.llvm
6565
if [ "$(shell uname)" = "Darwin" ]; then \
66-
sed -i '' '1{/^[[:space:]]*$$/d;}' tests/ethereum-sepc-tests/failing.llvm ;\
67-
echo >> tests/ethereum-sepc-tests/failing.llvm ;\
66+
sed -i '' '1{/^[[:space:]]*$$/d;}' tests/execution-spec-tests/failing.llvm ;\
67+
echo >> tests/execution-spec-tests/failing.llvm ;\
6868
else \
69-
sed -i '1{/^[[:space:]]*$$/d;}' tests/ethereum-sepc-tests/failing.llvm ;\
69+
sed -i '1{/^[[:space:]]*$$/d;}' tests/execution-spec-tests/failing.llvm ;\
7070
fi
7171

7272
test-vm: poetry

kevm-pyk/src/kevm_pyk/cli.py

+1
Original file line numberDiff line numberDiff line change
@@ -967,6 +967,7 @@ def evm_chain_args(self) -> ArgumentParser:
967967
'MERGE',
968968
'SHANGHAI',
969969
'CANCUN',
970+
'PRAGUE',
970971
)
971972
modes = ('NORMAL', 'VMTESTS')
972973

kevm-pyk/src/kevm_pyk/interpreter.py

-3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@
1515

1616
def interpret(gst_data: Any, schedule: str, mode: str, chainid: int, usegas: bool, *, check: bool = True) -> Pattern:
1717
"""Interpret the given GST data using the LLVM backend."""
18-
if 'config' in gst_data.keys():
19-
schedule = gst_data['config']['network'].upper()
20-
chainid = int(gst_data['config']['network'], 16)
2118
init_kore = gst_to_kore(filter_gst_keys(gst_data), schedule, mode, chainid, usegas)
2219
return llvm_interpret(kdist.get('evm-semantics.llvm'), init_kore, check=check)

kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md

+1
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,7 @@ Precompiled Contracts
20032003
rule #precompiledAccountsUB(MERGE) => #precompiledAccountsUB(LONDON)
20042004
rule #precompiledAccountsUB(SHANGHAI) => #precompiledAccountsUB(MERGE)
20052005
rule #precompiledAccountsUB(CANCUN) => 10
2006+
rule #precompiledAccountsUB(PRAGUE) => #precompiledAccountsUB(CANCUN)
20062007
20072008
20082009
syntax Set ::= #precompiledAccountsSet ( Schedule ) [symbol(#precompiledAccountsSet), function, total]

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

+12
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,18 @@ A `ScheduleConst` is a constant determined by the fee schedule.
415415
orBool SCHEDFLAG ==K Ghasblobhash
416416
)
417417
```
418+
419+
### Prague Schedule
420+
421+
```k
422+
syntax Schedule ::= "PRAGUE" [symbol(PRAGUE_EVM), smtlib(schedule_PRAGUE)]
423+
// --------------------------------------------------------------------------
424+
rule [SCHEDCONSTPrague]: SCHEDCONST < PRAGUE > => SCHEDCONST < CANCUN >
425+
426+
rule [SCHEDFLAGPrague]: SCHEDFLAG << PRAGUE >> => SCHEDFLAG << CANCUN >>
427+
428+
```
429+
418430
```k
419431
endmodule
420432
```

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

+11-8
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,19 @@ Here we load the environmental information.
137137

138138
```k
139139
rule <k> load "env" : { KEY : ((VAL:String) => #parseWord(VAL)) } ... </k>
140-
requires KEY in (SetItem("currentTimestamp") SetItem("currentGasLimit") SetItem("currentNumber") SetItem("currentDifficulty") SetItem("currentBaseFee"))
140+
requires KEY in (SetItem("currentTimestamp") SetItem("currentGasLimit") SetItem("currentNumber") SetItem("currentDifficulty") SetItem("currentBaseFee") SetItem("currentRandom") SetItem("currentExcessBlobGas"))
141141
rule <k> load "env" : { KEY : ((VAL:String) => #parseHexWord(VAL)) } ... </k>
142142
requires KEY in (SetItem("currentCoinbase") SetItem("previousHash"))
143143
// ----------------------------------------------------------------------
144-
rule <k> load "env" : { "currentCoinbase" : (CB:Int) } => .K ... </k> <coinbase> _ => CB </coinbase>
145-
rule <k> load "env" : { "currentDifficulty" : (DIFF:Int) } => .K ... </k> <difficulty> _ => DIFF </difficulty>
146-
rule <k> load "env" : { "currentGasLimit" : (GLIMIT:Int) } => .K ... </k> <gasLimit> _ => GLIMIT </gasLimit>
147-
rule <k> load "env" : { "currentNumber" : (NUM:Int) } => .K ... </k> <number> _ => NUM </number>
148-
rule <k> load "env" : { "previousHash" : (HASH:Int) } => .K ... </k> <previousHash> _ => HASH </previousHash>
149-
rule <k> load "env" : { "currentTimestamp" : (TS:Int) } => .K ... </k> <timestamp> _ => TS </timestamp>
150-
rule <k> load "env" : { "currentBaseFee" : (BF:Int) } => .K ... </k> <baseFee> _ => BF </baseFee>
144+
rule <k> load "env" : { "currentCoinbase" : (CB:Int) } => .K ... </k> <coinbase> _ => CB </coinbase>
145+
rule <k> load "env" : { "currentDifficulty" : (DIFF:Int) } => .K ... </k> <difficulty> _ => DIFF </difficulty>
146+
rule <k> load "env" : { "currentGasLimit" : (GLIMIT:Int) } => .K ... </k> <gasLimit> _ => GLIMIT </gasLimit>
147+
rule <k> load "env" : { "currentNumber" : (NUM:Int) } => .K ... </k> <number> _ => NUM </number>
148+
rule <k> load "env" : { "previousHash" : (HASH:Int) } => .K ... </k> <previousHash> _ => HASH </previousHash>
149+
rule <k> load "env" : { "currentTimestamp" : (TS:Int) } => .K ... </k> <timestamp> _ => TS </timestamp>
150+
rule <k> load "env" : { "currentBaseFee" : (BF:Int) } => .K ... </k> <baseFee> _ => BF </baseFee>
151+
rule <k> load "env" : { "currentRandom" : (RANDAO:Int) } => .K ... </k> <mixHash> _ => RANDAO </mixHash>
152+
rule <k> load "env" : { "currentExcessBlobGas" : (BGAS:Int) } => .K ... </k> <excessBlobGas> _ => BGAS </excessBlobGas>
151153
152154
syntax KItem ::= "loadCallState" JSON
153155
// -------------------------------------
@@ -188,6 +190,7 @@ The `"network"` key allows setting the fee schedule inside the test.
188190
rule #asScheduleString("Shanghai") => SHANGHAI
189191
rule #asScheduleString("Cancun") => CANCUN
190192
rule #asScheduleString("ShanghaiToCancunAtTime15k") => CANCUN
193+
rule #asScheduleString("Prague") => PRAGUE
191194
```
192195

193196
- `#parseJSONs2List` parse a JSON object with string values into a list of value.

kevm-pyk/src/tests/integration/test_conformance.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_rest_vm(test_file: Path, save_failing: bool) -> None:
8989
def test_bchain(test_file: Path, save_failing: bool) -> None:
9090
_test(
9191
test_file,
92-
schedule='CANCUN',
92+
schedule='PRAGUE',
9393
mode='NORMAL',
9494
usegas=True,
9595
save_failing=save_failing,
@@ -109,7 +109,7 @@ def test_bchain(test_file: Path, save_failing: bool) -> None:
109109
def test_rest_bchain(test_file: Path, save_failing: bool) -> None:
110110
_test(
111111
test_file,
112-
schedule='CANCUN',
112+
schedule='PRAGUE',
113113
mode='NORMAL',
114114
usegas=True,
115115
save_failing=save_failing,

kevm-pyk/src/tests/integration/test_execution_spec_tests.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def chain_id_always_one(_file: str) -> int:
4141
def test_bchain(test_file: Path, save_failing: bool) -> None:
4242
_test(
4343
test_file,
44-
schedule='CANCUN',
44+
schedule='PRAGUE',
4545
mode='NORMAL',
4646
usegas=True,
4747
save_failing=save_failing,
@@ -64,7 +64,7 @@ def test_bchain(test_file: Path, save_failing: bool) -> None:
6464
def test_bchain_engine(test_file: Path, save_failing: bool) -> None:
6565
_test(
6666
test_file,
67-
schedule='CANCUN',
67+
schedule='PRAGUE',
6868
mode='NORMAL',
6969
usegas=True,
7070
save_failing=save_failing,
@@ -87,7 +87,7 @@ def test_bchain_engine(test_file: Path, save_failing: bool) -> None:
8787
def test_state(test_file: Path, save_failing: bool) -> None:
8888
_test(
8989
test_file,
90-
schedule='CANCUN',
90+
schedule='PRAGUE',
9191
mode='NORMAL',
9292
usegas=True,
9393
save_failing=save_failing,
@@ -110,7 +110,7 @@ def test_state(test_file: Path, save_failing: bool) -> None:
110110
def test_transaction(test_file: Path, save_failing: bool) -> None:
111111
_test(
112112
test_file,
113-
schedule='CANCUN',
113+
schedule='PRAGUE',
114114
mode='NORMAL',
115115
usegas=True,
116116
save_failing=save_failing,

kevm-pyk/src/tests/integration/test_run.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_run(gst_file: Path, update_expected_output: bool) -> None:
3131
gst_data = json.load(f)
3232

3333
# When
34-
pattern = interpret(gst_data, 'CANCUN', 'NORMAL', 1, True, check=False)
34+
pattern = interpret(gst_data, 'PRAGUE', 'NORMAL', 1, True, check=False)
3535
actual = kore_print(pattern, definition_dir=kdist.get('evm-semantics.llvm'), output=PrintOutput.PRETTY)
3636

3737
# Then

0 commit comments

Comments
 (0)