Skip to content

Commit 80b0dae

Browse files
committed
EIP 7516: BLOBBASEFEE opcode
1 parent 61b8f9e commit 80b0dae

File tree

3 files changed

+38
-72
lines changed

3 files changed

+38
-72
lines changed

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

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,23 @@ These are just used by the other operators for shuffling local execution state a
875875
andBool Gemptyisnonexistent << SCHED >>
876876
```
877877

878+
- `#baseFeePerBlobGas` will compute the blob base fee as specified by EIPs 4844 and 7516
879+
880+
```k
881+
syntax Int ::= #baseFeePerBlobGas( Int ) [symbol(#baseFeePerBlobGas), function]
882+
// -------------------------------------------------------------------------------
883+
rule #baseFeePerBlobGas(BLOBGAS) => #fakeExponential(1, BLOBGAS, 3338477)
884+
885+
syntax Int ::= #fakeExponential(Int, Int, Int) [symbol(#fakeExponential), function]
886+
| #fakeExponential(Int, Int, Int, Int, Int) [function]
887+
// -------------------------------------------------------------------
888+
rule #fakeExponential(FACTOR, NUMER, DENOM) => #fakeExponential(1, 0, FACTOR *Int DENOM, NUMER, DENOM)
889+
890+
rule #fakeExponential(I, OUTPUT, ACCUM, NUMER, DENOM)
891+
=> #fakeExponential(I +Int 1, OUTPUT +Int ACCUM, ACCUM *Int NUMER /Int (DENOM *Int I), NUMER, DENOM) requires ACCUM >Int 0
892+
rule #fakeExponential(_, OUTPUT, _, _, DENOM) => OUTPUT /Int DENOM [owise]
893+
```
894+
878895
### Invalid Operator
879896

880897
We use `INVALID` both for marking the designated invalid operator, and `UNDEFINED(_)` for garbage bytes in the input program.
@@ -1005,13 +1022,14 @@ NOTE: We have to call the opcode `OR` by `EVMOR` instead, because K has trouble
10051022
These operators make queries about the current execution state.
10061023

10071024
```k
1008-
syntax NullStackOp ::= "PC" | "GAS" | "GASPRICE" | "GASLIMIT" | "BASEFEE"
1009-
// -------------------------------------------------------------------------
1010-
rule <k> PC => PCOUNT ~> #push ... </k> <pc> PCOUNT </pc>
1011-
rule <k> GAS => gas2Int(GAVAIL) ~> #push ... </k> <gas> GAVAIL </gas>
1012-
rule <k> GASPRICE => GPRICE ~> #push ... </k> <gasPrice> GPRICE </gasPrice>
1013-
rule <k> GASLIMIT => GLIMIT ~> #push ... </k> <gasLimit> GLIMIT </gasLimit>
1014-
rule <k> BASEFEE => BFEE ~> #push ... </k> <baseFee> BFEE </baseFee>
1025+
syntax NullStackOp ::= "PC" | "GAS" | "GASPRICE" | "GASLIMIT" | "BASEFEE" | "BLOBBASEFEE"
1026+
// -----------------------------------------------------------------------------------------
1027+
rule <k> PC => PCOUNT ~> #push ... </k> <pc> PCOUNT </pc>
1028+
rule <k> GAS => gas2Int(GAVAIL) ~> #push ... </k> <gas> GAVAIL </gas>
1029+
rule <k> GASPRICE => GPRICE ~> #push ... </k> <gasPrice> GPRICE </gasPrice>
1030+
rule <k> GASLIMIT => GLIMIT ~> #push ... </k> <gasLimit> GLIMIT </gasLimit>
1031+
rule <k> BASEFEE => BFEE ~> #push ... </k> <baseFee> BFEE </baseFee>
1032+
rule <k> BLOBBASEFEE => #baseFeePerBlobGas(BLOBGAS) ~> #push ... </k> <excessBlobGas> BLOBGAS </excessBlobGas>
10151033
10161034
syntax NullStackOp ::= "COINBASE" | "TIMESTAMP" | "NUMBER" | "DIFFICULTY" | "PREVRANDAO"
10171035
// ----------------------------------------------------------------------------------------
@@ -2259,6 +2277,7 @@ The intrinsic gas calculation mirrors the style of the YellowPaper (appendix H).
22592277
rule <k> #gasExec(SCHED, PREVRANDAO) => Gbase < SCHED > ... </k>
22602278
rule <k> #gasExec(SCHED, GASLIMIT) => Gbase < SCHED > ... </k>
22612279
rule <k> #gasExec(SCHED, BASEFEE) => Gbase < SCHED > ... </k>
2280+
rule <k> #gasExec(SCHED, BLOBBASEFEE) => Gbase < SCHED > ... </k>
22622281
rule <k> #gasExec(SCHED, POP _) => Gbase < SCHED > ... </k>
22632282
rule <k> #gasExec(SCHED, PC) => Gbase < SCHED > ... </k>
22642283
rule <k> #gasExec(SCHED, PUSHZERO) => Gbase < SCHED > ... </k>
@@ -2454,6 +2473,7 @@ After interpreting the strings representing programs as a `WordStack`, it should
24542473
rule #dasmOpCode( 70, SCHED ) => CHAINID requires Ghaschainid << SCHED >>
24552474
rule #dasmOpCode( 71, SCHED ) => SELFBALANCE requires Ghasselfbalance << SCHED >>
24562475
rule #dasmOpCode( 72, SCHED ) => BASEFEE requires Ghasbasefee << SCHED >>
2476+
rule #dasmOpCode( 74, SCHED ) => BLOBBASEFEE requires Ghasblobbasefee << SCHED >>
24572477
rule #dasmOpCode( 80, _ ) => POP
24582478
rule #dasmOpCode( 81, _ ) => MLOAD
24592479
rule #dasmOpCode( 82, _ ) => MSTORE

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module SCHEDULE
2929
| "Ghassstorestipend" | "Ghaschainid" | "Ghasaccesslist" | "Ghasbasefee"
3030
| "Ghasrejectedfirstbyte" | "Ghasprevrandao" | "Ghasmaxinitcodesize" | "Ghaspushzero"
3131
| "Ghaswarmcoinbase" | "Ghastransient" | "Ghasmcopy" | "Ghasbeaconroot"
32-
| "Ghaseip6780"
32+
| "Ghaseip6780" | "Ghasblobbasefee"
3333
// -------------------------------------
3434
```
3535

@@ -142,6 +142,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
142142
rule Ghaschainid << DEFAULT >> => false
143143
rule Ghasaccesslist << DEFAULT >> => false
144144
rule Ghasbasefee << DEFAULT >> => false
145+
rule Ghasblobbasefee << DEFAULT >> => false
145146
rule Ghasrejectedfirstbyte << DEFAULT >> => false
146147
rule Ghasprevrandao << DEFAULT >> => false
147148
rule Ghasmaxinitcodesize << DEFAULT >> => false
@@ -389,17 +390,19 @@ A `ScheduleConst` is a constant determined by the fee schedule.
389390
rule SCHEDCONST < CANCUN > => SCHEDCONST < SHANGHAI >
390391
requires notBool (SCHEDCONST ==K Gwarmstoragedirtystore)
391392
392-
rule Ghastransient << CANCUN >> => true
393-
rule Ghasmcopy << CANCUN >> => true
394-
rule Ghasbeaconroot << CANCUN >> => true
395-
rule Ghaseip6780 << CANCUN >> => true
393+
rule Ghastransient << CANCUN >> => true
394+
rule Ghasmcopy << CANCUN >> => true
395+
rule Ghasbeaconroot << CANCUN >> => true
396+
rule Ghaseip6780 << CANCUN >> => true
397+
rule Ghasblobbasefee << CANCUN >> => true
396398
rule SCHEDFLAG << CANCUN >> => SCHEDFLAG << SHANGHAI >>
397399
requires notBool ( SCHEDFLAG ==K Ghastransient
398400
orBool SCHEDFLAG ==K Ghasmcopy
399401
orBool SCHEDFLAG ==K Ghasbeaconroot
400402
orBool SCHEDFLAG ==K Ghaseip6780
403+
orBool SCHEDFLAG ==K Ghasblobbasefee
401404
)
402405
```
403406
```k
404407
endmodule
405-
```
408+
```

0 commit comments

Comments
 (0)