Skip to content

Commit 183e857

Browse files
authored
Refactoring eip-4844 (#2752)
* updates to the blob transaction * update conformance failing.llvm * add inline documentation * remove AccountNotNil unused sort * update failing.llvm files * update expected output * update expected output 2 * update proofs
1 parent f1e5b4b commit 183e857

File tree

149 files changed

+1564
-303
lines changed

Some content is hidden

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

149 files changed

+1564
-303
lines changed

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
7575
- `finishTx` is a place-holder for performing necessary cleanup after a transaction.
7676

7777
```k
78+
syntax InternalOp ::= "#deductBlobGas"
79+
// --------------------------------------
80+
rule <k> #deductBlobGas => .K ... </k>
81+
<schedule> SCHED </schedule>
82+
<excessBlobGas> EXCESS_BLOB_GAS </excessBlobGas>
83+
<origin> ACCTFROM </origin>
84+
<account>
85+
<acctID> ACCTFROM </acctID>
86+
<balance> BAL => BAL -Int Cblobfee(SCHED, EXCESS_BLOB_GAS, size(TVH)) </balance>
87+
...
88+
</account>
89+
<txPending> ListItem(TXID:Int) ... </txPending>
90+
<message>
91+
<msgID> TXID </msgID>
92+
<txVersionedHashes> TVH </txVersionedHashes>
93+
<txType> Blob </txType>
94+
...
95+
</message>
96+
requires Ghasblobbasefee << SCHED >>
97+
98+
rule <k> #deductBlobGas => .K ... </k> [owise]
99+
78100
syntax EthereumCommand ::= "startTx"
79101
// ------------------------------------
80102
rule <k> startTx => #finalizeBlock ... </k>
@@ -108,6 +130,7 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
108130
109131
rule <k> loadTx(ACCTFROM)
110132
=> #accessAccounts ACCTFROM #newAddr(ACCTFROM, NONCE) #precompiledAccountsSet(SCHED)
133+
~> #deductBlobGas
111134
~> #loadAccessList(TA)
112135
~> #checkCreate ACCTFROM VALUE
113136
~> #create ACCTFROM #newAddr(ACCTFROM, NONCE) VALUE CODE
@@ -128,24 +151,23 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
128151
<value> VALUE </value>
129152
<data> CODE </data>
130153
<txAccess> TA </txAccess>
131-
<txVersionedHashes> TVH </txVersionedHashes>
132154
...
133155
</message>
134-
<versionedHashes> _ => TVH </versionedHashes>
135156
<account>
136157
<acctID> ACCTFROM </acctID>
137158
<balance> BAL => BAL -Int (GLIMIT *Int #effectiveGasPrice(TXID)) </balance>
138159
<nonce> NONCE </nonce>
139-
<code> ACCTCODE </code>
140160
...
141161
</account>
142162
<accessedAccounts> _ => #if Ghaswarmcoinbase << SCHED >> #then SetItem(MINER) #else .Set #fi </accessedAccounts>
143163
<touchedAccounts> _ => SetItem(MINER) </touchedAccounts>
144164
requires #hasValidInitCode(lengthBytes(CODE), SCHED)
145-
andBool ACCTCODE ==K .Bytes
165+
andBool #isValidTransaction(TXID, ACCTFROM)
166+
146167
147168
rule <k> loadTx(ACCTFROM)
148169
=> #accessAccounts ACCTFROM ACCTTO #precompiledAccountsSet(SCHED)
170+
~> #deductBlobGas
149171
~> #loadAccessList(TA)
150172
~> #checkCall ACCTFROM VALUE
151173
~> #call ACCTFROM ACCTTO ACCTTO VALUE VALUE DATA false
@@ -174,16 +196,15 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
174196
<acctID> ACCTFROM </acctID>
175197
<balance> BAL => BAL -Int (GLIMIT *Int #effectiveGasPrice(TXID)) </balance>
176198
<nonce> NONCE => NONCE +Int 1 </nonce>
177-
<code> ACCTCODE </code>
178199
...
179200
</account>
180201
<accessedAccounts> _ => #if Ghaswarmcoinbase << SCHED >> #then SetItem(MINER) #else .Set #fi </accessedAccounts>
181202
<touchedAccounts> _ => SetItem(MINER) </touchedAccounts>
182203
requires ACCTTO =/=K .Account
183-
andBool ACCTCODE ==K .Bytes
204+
andBool #isValidTransaction(TXID, ACCTFROM)
184205
185206
rule <k> loadTx(ACCTFROM) => startTx ... </k>
186-
<statusCode> _ => EVMC_FAILURE </statusCode>
207+
<statusCode> _ => EVMC_INVALID_BLOCK </statusCode>
187208
<txPending> ListItem(_TXID:Int) REST => REST </txPending>
188209
<account>
189210
<acctID> ACCTFROM </acctID>

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,6 @@ Bytes helper functions
337337
- `#asInteger` will interpret a stack of bytes as a single arbitrary-precision integer (with MSB first).
338338
- `#asAccount` will interpret a stack of bytes as a single account id (with MSB first).
339339
Differs from `#asWord` only in that an empty stack represents the empty account, not account zero.
340-
- `asAccountNotNil` will interpret a stack of bytes as a single account id (with MSB first), but will fail if the
341-
stack is empty.
342340
- `#asByteStack` will split a single word up into a `Bytes`.
343341
- `#range(WS, N, W)` access the range of `WS` beginning with `N` of width `W`.
344342
- `#padToWidth(N, WS)` and `#padRightToWidth` make sure that a `Bytes` is the correct size.
@@ -353,13 +351,10 @@ Bytes helper functions
353351
rule #asInteger(WS) => Bytes2Int(WS, BE, Unsigned) [concrete]
354352
355353
syntax Account ::= #asAccount ( Bytes ) [symbol(#asAccount), function]
356-
syntax AccountNotNil ::= #asAccountNotNil ( Bytes ) [symbol(#asAccountNotNil), function]
357-
// ----------------------------------------------------------------------------------------
354+
// ----------------------------------------------------------------------------------
358355
rule #asAccount(BS) => .Account requires lengthBytes(BS) ==Int 0
359356
rule #asAccount(BS) => #asWord(BS) [owise]
360357
361-
rule #asAccountNotNil(BS) => #asWord(BS) requires lengthBytes(BS) >Int 0
362-
363358
syntax Bytes ::= #asByteStack ( Int ) [symbol(#asByteStack), function, total]
364359
// -----------------------------------------------------------------------------
365360
rule #asByteStack(W) => Int2Bytes(W, BE, Unsigned) [concrete]
@@ -390,8 +385,7 @@ Accounts
390385

391386
```k
392387
syntax Account ::= ".Account" | Int
393-
syntax AccountNotNil = Int
394-
// --------------------------
388+
// -----------------------------------
395389
396390
syntax AccountCode ::= Bytes
397391
// ----------------------------
@@ -468,12 +462,12 @@ Productions related to transactions
468462
syntax TxData ::= LegacyTx | AccessListTx | DynamicFeeTx | BlobTx
469463
// -----------------------------------------------------------------
470464
471-
syntax LegacyTx ::= LegacyTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes ) [symbol(LegacyTxData)]
472-
| LegacySignedTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, networkChainId: Int ) [symbol(LegacySignedTxData)]
473-
syntax AccessListTx ::= AccessListTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs ) [symbol(AccessListTxData)]
474-
syntax DynamicFeeTx ::= DynamicFeeTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs) [symbol(DynamicFeeTxData)]
475-
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)]
476-
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
465+
syntax LegacyTx ::= LegacyTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes ) [symbol(LegacyTxData)]
466+
| LegacySignedTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, networkChainId: Int ) [symbol(LegacySignedTxData)]
467+
syntax AccessListTx ::= AccessListTxData ( nonce: Int, gasPrice: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs ) [symbol(AccessListTxData)]
468+
syntax DynamicFeeTx ::= DynamicFeeTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs) [symbol(DynamicFeeTxData)]
469+
syntax BlobTx ::= BlobTxData ( nonce: Int, priorityGasFee: Int, maxGasFee: Int, gasLimit: Int, to: Account, value: Int, data: Bytes, chainId: Int, accessLists: JSONs, maxBlobGasFee: Int, blobVersionedHashes: List ) [symbol(BlobTxData)]
470+
// ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
477471
478472
endmodule
479473
```

0 commit comments

Comments
 (0)