You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -39,47 +39,42 @@ We define access events as follows. When an access event takes place, the access
39
39
40
40
#### Access events for account headers
41
41
42
-
When a non-precompile address is the target of a `CALL`, `CALLCODE`, `DELEGATECALL`, `SELFDESTRUCT`, `EXTCODESIZE`, or `EXTCODECOPY` opcode, or is the target address of a contract creation whose initcode starts execution, process these access events:
42
+
When:
43
43
44
-
```
45
-
(address, 0, VERSION_LEAF_KEY)
46
-
(address, 0, CODE_SIZE_LEAF_KEY)
47
-
```
44
+
1. a non-precompile address is the target of a `*CALL`, `SELFDESTRUCT`, `EXTCODESIZE`, or `EXTCODECOPY` opcode,
45
+
2. a non-precompile address is the target address of a contract creation whose initcode starts execution,
46
+
3. any address is the target of the `BALANCE` opcode
47
+
4. a _deployed_ contract calls `CODECOPY`
48
48
49
-
If a call is value-bearing (ie. it transfers nonzero wei), whether or not the callee is a precompile, process these two access events:
49
+
process this access events:
50
50
51
51
```
52
-
(caller_address, 0, BALANCE_LEAF_KEY)
53
-
(callee_address, 0, BALANCE_LEAF_KEY)
52
+
(address, 0, BASIC_DATA_LEAF_KEY)
54
53
```
55
54
56
-
When a contract is created, process these access events:
57
-
58
-
```
59
-
(contract_address, 0, VERSION_LEAF_KEY)
60
-
(contract_address, 0, NONCE_LEAF_KEY)
61
-
(contract_address, 0, BALANCE_LEAF_KEY)
62
-
(contract_address, 0, CODE_KECCAK_LEAF_KEY)
63
-
(contract_address, 0, CODE_SIZE_LEAF_KEY)
64
-
```
55
+
Note: a non-value-bearing `SELFDESTRUCT` or `*CALL`, targetting a precompile, will not cause the `BASIC_DATA_LEAF_KEY` to be added to the witness.
65
56
66
-
If the `BALANCE` opcode is called targeting some address, process this access event:
57
+
If a `*CALL` or `SELFDESTRUCT`is value-bearing (ie. it transfers nonzero wei), whether or not the callee is a precompile, process this additional access event:
67
58
68
59
```
69
-
(address, 0, BALANCE_LEAF_KEY)
60
+
(origin, 0, BASIC_DATA_LEAF_KEY)
70
61
```
71
62
72
-
If the `SELFDESTRUCT` opcode is called by some caller_address targeting some target_address (regardless of whether it’s value-bearing or not), process access events of the form:
63
+
Note: when checking for the existence of the callee, the existence check is done by validating that there is an extension-and-suffix tree at the corresponding stem, and does not rely on `CODEHASH_LEAF_KEY`.
64
+
65
+
When calling `EXTCODEHASH` on a non-precompile target, process the access event:
73
66
74
67
```
75
-
(caller_address, 0, BALANCE_LEAF_KEY)
76
-
(target_address, 0, BALANCE_LEAF_KEY)
68
+
(address, 0, CODEHASH_LEAF_KEY)
77
69
```
78
70
79
-
If the `EXTCODEHASH` opcode is called targeting some address, process an access event of the form:
71
+
Note that precompiles are excluded, as their hashes are known to the client.
72
+
73
+
When a contract is created, process these access events:
80
74
81
75
```
82
-
(address, 0, CODEHASH_LEAF_KEY)
76
+
(contract_address, 0, BASIC_DATA_LEAF_KEY)
77
+
(contract_address, 0, CODEHASH_LEAF_KEY)
83
78
```
84
79
85
80
#### Access events for storage
@@ -120,34 +115,29 @@ We define **write events** as follows. Note that when a write takes place, an ac
120
115
121
116
#### Write events for account headers
122
117
123
-
When a nonzero-balance-sending `CALL` or `SELFDESTRUCT` with a given sender and recipient takes place, process these write events:
118
+
When a nonzero-balance-sending `*CALL` or `SELFDESTRUCT` with a given sender and recipient takes place, process these write events:
124
119
125
120
```
126
-
(sender, 0, BALANCE_LEAF_KEY)
127
-
(recipient, 0, BALANCE_LEAF_KEY)
121
+
(origin, 0, BASIC_DATA_LEAF_KEY)
122
+
(target, 0, BASIC_DATA_LEAF_KEY)
128
123
```
129
124
130
-
When a contract creation is initialized, process these write events:
125
+
if no account exists at `callee_address`, also process:
131
126
132
127
```
133
-
(contract_address, 0, VERSION_LEAF_KEY)
134
-
(contract_address, 0, NONCE_LEAF_KEY)
128
+
(target, 0, CODEHASH_LEAF_KEY)
135
129
```
136
130
137
-
Only if the value sent with the creation is nonzero, also process:
131
+
When a contract creation is initialized, process these write events:
138
132
139
133
```
140
-
(contract_address, 0, BALANCE_LEAF_KEY)
134
+
(contract_address, 0, BASIC_DATA_LEAF_KEY)
141
135
```
142
136
143
137
When a contract is created, process these write events:
144
138
145
139
```
146
-
(contract_address, 0, VERSION_LEAF_KEY)
147
-
(contract_address, 0, NONCE_LEAF_KEY)
148
-
(contract_address, 0, BALANCE_LEAF_KEY)
149
-
(contract_address, 0, CODE_KECCAK_LEAF_KEY)
150
-
(contract_address, 0, CODE_SIZE_LEAF_KEY)
140
+
(contract_address, 0, CODEHASH_LEAF_KEY)
151
141
```
152
142
153
143
#### Write events for storage
@@ -174,36 +164,31 @@ When a contract is created, process the write events:
174
164
175
165
For `i` in `0 ... (len(code)+30)//31`.
176
166
167
+
Note: since no access list existed for code up until this EIP, note that no warm costs are charged for code accesses.
168
+
177
169
### Transactions
178
170
179
171
#### Access events
180
172
181
173
For a transaction, make these access events:
182
174
183
175
```
184
-
(tx.origin, 0, VERSION_LEAF_KEY)
185
-
(tx.origin, 0, BALANCE_LEAF_KEY)
186
-
(tx.origin, 0, NONCE_LEAF_KEY)
187
-
(tx.origin, 0, CODE_SIZE_LEAF_KEY)
188
-
(tx.origin, 0, CODE_KECCAK_LEAF_KEY)
189
-
(tx.target, 0, VERSION_LEAF_KEY)
190
-
(tx.target, 0, BALANCE_LEAF_KEY)
191
-
(tx.target, 0, NONCE_LEAF_KEY)
192
-
(tx.target, 0, CODE_SIZE_LEAF_KEY)
193
-
(tx.target, 0, CODE_KECCAK_LEAF_KEY)
176
+
(tx.origin, 0, BASIC_DATA_LEAF_KEY)
177
+
(tx.origin, 0, CODEHASH_LEAF_KEY)
178
+
(tx.target, 0, BASIC_DATA_LEAF_KEY)
179
+
(tx.target, 0, CODEHASH_LEAF_KEY)
194
180
```
195
181
196
182
#### Write events
197
183
198
184
```
199
-
(tx.origin, 0, NONCE_LEAF_KEY)
185
+
(tx.origin, 0, BASIC_DATA_LEAF_KEY)
200
186
```
201
187
202
-
if`value` is non-zero:
188
+
If`value` is non-zero:
203
189
204
190
```
205
-
(tx.origin, 0, BALANCE_LEAF_KEY)
206
-
(tx.target, 0, BALANCE_LEAF_KEY)
191
+
(tx.target, 0, BASIC_DATA_LEAF_KEY)
207
192
```
208
193
209
194
### Witness gas costs
@@ -216,15 +201,15 @@ Remove the following gas costs:
216
201
217
202
Reduce gas cost:
218
203
219
-
*`CREATE` to 1000
204
+
*`CREATE`/`CREATE2` to 1000
220
205
221
206
|Constant |Value|
222
207
|-|-|
223
-
|`WITNESS_BRANCH_COST`|1900|
208
+
|`WITNESS_BRANCH_COST`|1900|
224
209
|`WITNESS_CHUNK_COST`|200|
225
210
|`SUBTREE_EDIT_COST`|3000|
226
-
|`CHUNK_EDIT_COST`|500|
227
-
|`CHUNK_FILL_COST`|6200|
211
+
|`CHUNK_EDIT_COST`|500|
212
+
|`CHUNK_FILL_COST`|6200|
228
213
229
214
When executing a transaction, maintain four sets:
230
215
@@ -251,6 +236,13 @@ When a **write** event of `(address, sub_key, leaf_key)` occurs, perform the fol
251
236
252
237
Note that tree keys can no longer be emptied: only the values `0...2**256-1` can be written to a tree key, and 0 is distinct from `None`. Once a tree key is changed from `None` to not-`None`, it can never go back to `None`.
253
238
239
+
Note that values should only be added to the witness if there is sufficient gas to cover their associated event costs.
240
+
241
+
`CREATE*` and `*CALL` reserve 1/64th of the gas before the nested execution. In order to match the behavior of this charge with the pre-fork behavior of access lists:
242
+
243
+
* this minimum 1/64th gas reservation is checked **AFTER** charging the witness costs when performing a `CALL`, `CODECALL`, `DELEGATECALL` or`STATICCALL`
244
+
* this 1/64th of the gas is subtracted **BEFORE** charging the witness costs when performing a `CREATE` or `CREATE2`
245
+
254
246
### Replacement for access lists
255
247
256
248
We replace [EIP-2930](./eip-2930.md) access lists with an SSZ structure of the form:
@@ -268,6 +260,22 @@ class AccessSubtree(Container):
268
260
elements: BitVector[256]
269
261
```
270
262
263
+
### Block-level operations
264
+
265
+
None of:
266
+
267
+
* Precompile accounts, system contract accounts and slots of a system contract that are accessed during a system call,
268
+
* The coinbase account
269
+
* Withdrawal accounts
270
+
271
+
are warm at the start of a transaction.
272
+
273
+
Note: When (and only when) calling a system contract _via a system call_, the code chunks and account should not appear in the witness.
274
+
275
+
### Account abstraction
276
+
277
+
TODO : still waiting on a final decision between 7702 and 3074
When any account header field is set, the `version` is also set to zero. The `code_keccak` and `code_size` fields are set upon contract creation.
165
+
An account's `version`, `balance`, `nonce` and `code_size` fields are packed in the value found at `BASIC_DATA_LEAF_KEY`:
166
+
167
+
| Name | Offset | Size |
168
+
| ----------- | ------ | ---- |
169
+
|`version`| 0 | 1 |
170
+
|`code_size`| 5 | 3 |
171
+
|`nonce`| 8 | 8 |
172
+
|`balance`| 16 | 16 |
173
+
174
+
Bytes `1..4` are reserved for future use.
175
+
176
+
Note: the code size is stored on 3 bytes. To allow for an extension to 4 bytes without changing the account version is possible, reserved byte #4 should be allocated last.
177
+
178
+
When any account header field is set, the `version` field is also set to zero. The `code_keccak` and `code_size` fields are set upon contract or EoA creation.
179
179
180
180
#### Code
181
181
@@ -239,7 +239,7 @@ Note that storage slots in the same size `VERKLE_NODE_WIDTH` range (ie. a range
0 commit comments