Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing BLOBHASH Opcode #2693

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
8cf5809
Introducing `BLOBHASH` OpCode as 73.
Robertorosmaninho Jan 23, 2025
97b1958
Modifying type of `txVersionedHashes` from `JSONs` to `List` to imple…
Robertorosmaninho Jan 23, 2025
763745d
Implementing the operation of `BLOBHASH`
Robertorosmaninho Jan 23, 2025
9cc6638
Adding `Blob` transaction to `effectiveGasPrice`
Robertorosmaninho Jan 23, 2025
0aa36d0
Updating integration tests with the new `txVersionedHashes` type
Robertorosmaninho Jan 23, 2025
f18175d
Updating `failing.llvm` list of tests
Robertorosmaninho Jan 23, 2025
a0d834b
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 23, 2025
76d22fa
Fixing Opcode execution and transaction parsing
Robertorosmaninho Jan 23, 2025
fe73ccc
Addressing comments
Robertorosmaninho Jan 27, 2025
be1cd23
Adding `versionedHashes` to evm's `callState`
Robertorosmaninho Jan 27, 2025
c30f0ae
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 27, 2025
783c8bb
Addressing comments
Robertorosmaninho Jan 27, 2025
d0419e0
Updating failing tests
Robertorosmaninho Jan 27, 2025
b1453ce
Filling `BENCHMARK_TESTS`
Robertorosmaninho Jan 27, 2025
ac2d861
Filling `ERC20_TESTS`
Robertorosmaninho Jan 27, 2025
eb67f2e
Filling `EXAMPLES_TESTS`
Robertorosmaninho Jan 27, 2025
1c31ab1
Filling `MCD_TESTS`
Robertorosmaninho Jan 27, 2025
c7e9d7e
Filling `MCD_STRUCTURED_TESTS` and `VAT_STRUCTURED_TESTS`
Robertorosmaninho Jan 27, 2025
192167d
Filling `KONTROL_TESTS`
Robertorosmaninho Jan 27, 2025
d6a1646
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 27, 2025
9e08a38
Updating `failing.llvm`
Robertorosmaninho Jan 28, 2025
6a0ed4f
Fix dash size
Robertorosmaninho Jan 28, 2025
534bd14
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 28, 2025
b6bb2b6
Updating `failing.llvm`
Robertorosmaninho Jan 28, 2025
6a2cf02
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 28, 2025
94d465d
Re-adding failing.llvm tests
Robertorosmaninho Jan 28, 2025
46f6722
Fix `kontrol` prove tests
Robertorosmaninho Jan 28, 2025
34b085b
Fix `mcd` prove tests
Robertorosmaninho Jan 28, 2025
2043414
Fix `mcd-strutured` prove tests
Robertorosmaninho Jan 28, 2025
80602d4
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 29, 2025
063fda4
Adding BASEFEE to #asmOpCode
Robertorosmaninho Jan 29, 2025
cb5f631
Fixing `#parseList2JSONs` and updating `failing.llvm`
Robertorosmaninho Jan 30, 2025
864f1b6
Changing back parseList2JSONs to avoid issues in rlp encoding
Robertorosmaninho Jan 30, 2025
f73799b
Fixing `BLOBBASEFEE` and Updating `failing.llvm`
Robertorosmaninho Jan 30, 2025
2e3b8c0
Merge branch 'master' into pi2/robertorosmaninho/eip-4844-blobhash-op…
Robertorosmaninho Jan 30, 2025
eaa785c
Fixing `#rangeNegUInt64`
Robertorosmaninho Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ Operator `#revOps` can be used to reverse a program.
rule #asmOpCode( GASLIMIT ) => 69
rule #asmOpCode( CHAINID ) => 70
rule #asmOpCode( SELFBALANCE ) => 71
rule #asmOpCode( BLOBHASH ) => 73
Robertorosmaninho marked this conversation as resolved.
Show resolved Hide resolved
rule #asmOpCode( POP ) => 80
rule #asmOpCode( MLOAD ) => 81
rule #asmOpCode( MSTORE ) => 82
Expand Down
10 changes: 1 addition & 9 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ Here we check the other post-conditions associated with an EVM test.

rule <k> check "transactions" : "blobVersionedHashes" : [ .JSONs ] => .K ... </k>
rule <k> check "transactions" : "blobVersionedHashes" : [ VHASH, REST ] => check "transactions" : "blobVersionedHashes" : VHASH ~> check "transactions" : "blobVersionedHashes" : [ REST ] ... </k>
rule <k> check "transactions" : ("blobVersionedHashes" : VHASH ) => .K ... </k> <txOrder> ListItem(TXID) ... </txOrder> <message> <msgID> TXID </msgID> <txVersionedHashes> VH </txVersionedHashes> ... </message> requires isInVersionedHashes(VHASH, VH)
rule <k> check "transactions" : ("blobVersionedHashes" : VHASH ) => .K ... </k> <txOrder> ListItem(TXID) ... </txOrder> <message> <msgID> TXID </msgID> <txVersionedHashes> VH </txVersionedHashes> ... </message> requires VHASH in VH

rule <k> check "transactions" : ("data" : VALUE) => .K ... </k> <txOrder> ListItem(TXID) ... </txOrder> <message> <msgID> TXID </msgID> <data> VALUE </data> ... </message>
rule <k> check "transactions" : ("gasLimit" : VALUE) => .K ... </k> <txOrder> ListItem(TXID) ... </txOrder> <message> <msgID> TXID </msgID> <txGasLimit> VALUE </txGasLimit> ... </message>
Expand Down Expand Up @@ -627,14 +627,6 @@ Here we check the other post-conditions associated with an EVM test.
rule isInAccessListStorage(KEY, [SKEY, REST]) => #if KEY ==Int #asWord(SKEY)
#then true
#else isInAccessListStorage(KEY, [REST]) #fi

// Different from AccessList, Versioned Hashs doesn't contains a list of key-value jsons, but a list of strings finishing in .JSONs like [ "0x01...", "0x02", .JSONs]
syntax Bool ::= isInVersionedHashes(Bytes, JSON) [symbol(isInVersionedHashes), function]
// ---------------------------------------------------------------------------------------
rule isInVersionedHashes(_, [.JSONs]) => false
rule isInVersionedHashes(KEY, [SKEY, REST]) => #if KEY ==K SKEY
#then true
#else isInVersionedHashes(KEY, [REST]) #fi
```

TODO: case with nonzero ommers.
Expand Down
12 changes: 6 additions & 6 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ Productions related to transactions
syntax TxData ::= LegacyTx | AccessListTx | DynamicFeeTx | BlobTx
// -----------------------------------------------------------------

syntax LegacyTx ::= LegacyTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes ) [symbol(LegacyTxData)]
| LegacySignedTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, networkChainId: Int ) [symbol(LegacySignedTxData)]
syntax AccessListTx ::= AccessListTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs ) [symbol(AccessListTxData)]
syntax DynamicFeeTx ::= DynamicFeeTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs) [symbol(DynamicFeeTxData)]
syntax BlobTx ::= BlobTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: AccountNotNil, value: Int, data: Bytes, chainId: Int, accessLists: JSONs, maxBlobGasFee: Int, blobVersionedHashes: JSONs ) [symbol(BlobTxData)]
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
syntax LegacyTx ::= LegacyTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes ) [symbol(LegacyTxData)]
| LegacySignedTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, networkChainId: Int ) [symbol(LegacySignedTxData)]
syntax AccessListTx ::= AccessListTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs ) [symbol(AccessListTxData)]
syntax DynamicFeeTx ::= DynamicFeeTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs) [symbol(DynamicFeeTxData)]
syntax BlobTx ::= BlobTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: AccountNotNil, value: Int, data: Bytes, chainId: Int, accessLists: JSONs, maxBlobGasFee: Int, blobVersionedHashes: List ) [symbol(BlobTxData)]
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

endmodule
```
16 changes: 13 additions & 3 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ In the comments next to each cell, we've marked which component of the YellowPap
<txMaxFee> 0 </txMaxFee> // T_m
<txType> .TxType </txType> // T_x
<txMaxBlobFee> 0 </txMaxBlobFee>
<txVersionedHashes> [ .JSONs ] </txVersionedHashes>
<txVersionedHashes> .List </txVersionedHashes>
</message>
</messages>

Expand Down Expand Up @@ -915,11 +915,19 @@ Some operators don't calculate anything, they just push the stack around a bit.
These operations are getters/setters of the local execution memory.

```k
syntax UnStackOp ::= "MLOAD"
// ----------------------------
syntax UnStackOp ::= "MLOAD" | "BLOBHASH"
// -----------------------------------------
Robertorosmaninho marked this conversation as resolved.
Show resolved Hide resolved
rule <k> MLOAD INDEX => #asWord(#range(LM, INDEX, 32)) ~> #push ... </k>
<localMem> LM </localMem>

rule <k> BLOBHASH INDEX => PUSHZERO ~> #push ... </k>
<txVersionedHashes> HASHES </txVersionedHashes>
requires INDEX >=Int size(HASHES)

rule <k> BLOBHASH INDEX => #asWord( {HASHES[INDEX]}:>Bytes ) ~> #push ... </k>
<txVersionedHashes> HASHES </txVersionedHashes>
requires INDEX <Int size(HASHES)

syntax BinStackOp ::= "MSTORE" | "MSTORE8"
// ------------------------------------------
rule <k> MSTORE INDEX VALUE => .K ... </k>
Expand Down Expand Up @@ -2289,6 +2297,7 @@ The intrinsic gas calculation mirrors the style of the YellowPaper (appendix H).
rule <k> #gasExec(SCHED, PUSH(_)) => Gverylow < SCHED > ... </k>
rule <k> #gasExec(SCHED, DUP(_) _) => Gverylow < SCHED > ... </k>
rule <k> #gasExec(SCHED, SWAP(_) _) => Gverylow < SCHED > ... </k>
rule <k> #gasExec(SCHED, BLOBHASH _) => Gverylow < SCHED > ... </k>

// Wlow
rule <k> #gasExec(SCHED, MUL _ _) => Glow < SCHED > ... </k>
Expand Down Expand Up @@ -2453,6 +2462,7 @@ After interpreting the strings representing programs as a `WordStack`, it should
rule #dasmOpCode( 70, SCHED ) => CHAINID requires Ghaschainid << SCHED >>
rule #dasmOpCode( 71, SCHED ) => SELFBALANCE requires Ghasselfbalance << SCHED >>
rule #dasmOpCode( 72, SCHED ) => BASEFEE requires Ghasbasefee << SCHED >>
rule #dasmOpCode( 73, SCHED ) => BLOBHASH requires Ghasblobhash << SCHED >>
rule #dasmOpCode( 80, _ ) => POP
rule #dasmOpCode( 81, _ ) => MLOAD
rule #dasmOpCode( 82, _ ) => MSTORE
Expand Down
5 changes: 4 additions & 1 deletion kevm-pyk/src/kevm_pyk/kproj/evm-semantics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module SCHEDULE
| "Ghassstorestipend" | "Ghaschainid" | "Ghasaccesslist" | "Ghasbasefee"
| "Ghasrejectedfirstbyte" | "Ghasprevrandao" | "Ghasmaxinitcodesize" | "Ghaspushzero"
| "Ghaswarmcoinbase" | "Ghastransient" | "Ghasmcopy" | "Ghasbeaconroot"
| "Ghaseip6780"
| "Ghaseip6780" | "Ghasblobhash"
// -------------------------------------
```

Expand Down Expand Up @@ -151,6 +151,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
rule Ghasmcopy << DEFAULT >> => false
rule Ghasbeaconroot << DEFAULT >> => false
rule Ghaseip6780 << DEFAULT >> => false
rule Ghasblobhash << DEFAULT >> => false
```

### Frontier Schedule
Expand Down Expand Up @@ -393,11 +394,13 @@ A `ScheduleConst` is a constant determined by the fee schedule.
rule Ghasmcopy << CANCUN >> => true
rule Ghasbeaconroot << CANCUN >> => true
rule Ghaseip6780 << CANCUN >> => true
rule Ghasblobhash << CANCUN >> => true
rule SCHEDFLAG << CANCUN >> => SCHEDFLAG << SHANGHAI >>
requires notBool ( SCHEDFLAG ==K Ghastransient
orBool SCHEDFLAG ==K Ghasmcopy
orBool SCHEDFLAG ==K Ghasbeaconroot
orBool SCHEDFLAG ==K Ghaseip6780
orBool SCHEDFLAG ==K Ghasblobhash
)
```
```k
Expand Down
10 changes: 8 additions & 2 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ Unparsing
- `#addrBytes` Takes an Account and represents it as a 20-byte wide Bytes (or an empty Bytes for a null address)
- `#addrBytesNotNil` Takes an Account and represents it as a 20-byte wide Bytes. It throws an error if the account is null.
- `#wordBytes` Takes an Int and represents it as a 32-byte wide Bytes
- `#parseList2JSONs` Takes a List of Bytes and represents it as a JSON array.

```k
syntax Bytes ::= #addrBytes ( Account ) [symbol(#addrBytes), function]
Expand All @@ -239,6 +240,11 @@ Unparsing
rule #addrBytes(.Account) => .Bytes
rule #addrBytes(ACCT) => #padToWidth(20, #asByteStack(ACCT)) requires #rangeAddress(ACCT)
rule #wordBytes(WORD) => #padToWidth(32, #asByteStack(WORD)) requires #rangeUInt(256, WORD)

syntax JSONs ::= #parseList2JSONs ( List ) [function]
// ----------------------------------------------------
rule #parseList2JSONs( .List ) => .JSONs
rule #parseList2JSONs( ListItem(X:Bytes) REST ) => X , #parseList2JSONs(REST)
```

Recursive Length Prefix (RLP)
Expand Down Expand Up @@ -352,8 +358,8 @@ Encoding
rule #rlpEncodeTxData( DynamicFeeTxData(TN, TF, TM, TG, TT, TV, DATA, TC, [TA]) )
=> #rlpEncode( [ TC, TN, TF, TM, TG, #addrBytes(TT), TV, DATA, [TA] ] )

rule #rlpEncodeTxData( BlobTxData(TN, TF, TM, TG, TT, TV, DATA, CID, [TA], TB, [TVH]) )
=> #rlpEncode( [ CID, TN, TF, TM, TG, #addrBytes({TT}:>Account), TV, DATA, [TA], TB, [TVH] ] )
rule #rlpEncodeTxData( BlobTxData(TN, TF, TM, TG, TT, TV, DATA, CID, [TA], TB, TVH) )
=> #rlpEncode( [ CID, TN, TF, TM, TG, #addrBytes({TT}:>Account), TV, DATA, [TA], TB, [#parseList2JSONs(TVH)] ] )

syntax Bytes ::= #rlpEncodeMerkleTree ( MerkleTree ) [symbol(#rlpEncodeMerkleTree), function]
// ---------------------------------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion kevm-pyk/src/kevm_pyk/kproj/evm-semantics/state-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ The `"network"` key allows setting the fee schedule inside the test.
rule #asScheduleString("ShanghaiToCancunAtTime15k") => CANCUN
```

- `#parseJSONs2List` parse a JSON object with string values into a list of value.
```k
syntax List ::= "#parseJSONs2List" "(" JSONs ")" [function]
// ----------------------------------------------------------
rule #parseJSONs2List ( .JSONs ) => .List
rule #parseJSONs2List ( (VAL:Bytes) , REST ) => ListItem(VAL) #parseJSONs2List ( REST )
```

The `"rlp"` key loads the block information.

```k
Expand Down Expand Up @@ -378,7 +386,7 @@ The `"rlp"` key loads the block information.
<message> <msgID> TXID </msgID> <txMaxBlobFee> _ => TB </txMaxBlobFee> ... </message>

rule <k> loadTransaction TXID { "blobVersionedHashes" : [TVH:JSONs], REST => REST } ... </k>
<message> <msgID> TXID </msgID> <txVersionedHashes> _ => [TVH] </txVersionedHashes> ... </message>
<message> <msgID> TXID </msgID> <txVersionedHashes> _ => #parseJSONs2List(TVH) </txVersionedHashes> ... </message>
```

### Getting State
Expand Down Expand Up @@ -479,6 +487,7 @@ The `"rlp"` key loads the block information.
=> #if ( notBool Ghasbasefee << SCHED >> )
orBool TXTYPE ==K Legacy
orBool TXTYPE ==K AccessList
orBool TXTYPE ==K Blob
Robertorosmaninho marked this conversation as resolved.
Show resolved Hide resolved
#then GPRICE
#else BFEE +Int minInt(TPF, TM -Int BFEE)
#fi
Expand Down
Loading
Loading