Skip to content

Commit a087506

Browse files
committed
example
1 parent 3afee13 commit a087506

File tree

1 file changed

+25
-84
lines changed

1 file changed

+25
-84
lines changed

spec/eofv0_verkle.md

+25-84
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,31 @@ During execution of a jump two checks must be done in this order:
159159
It is possible to reconstruct sparse account code prior to execution with all the submitted chunks of the transaction
160160
and perform `JUMPDEST`-validation to build up a relevant *valid `JUMPDEST` locations* map instead.
161161

162+
#### Example
163+
164+
The top used bytecode: [0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2](https://etherscan.io/address/0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) (WETH).
165+
166+
```
167+
length: 3124
168+
chunks: 98
169+
170+
chunks with invalid jumpdests:
171+
chunk_index first_instruction_offset
172+
37 4
173+
49 12
174+
50 14
175+
87 13
176+
177+
encoding (7 bytes (0.22%), 1 chunk (1.02%)):
178+
[skip, 37]
179+
[value, 0, 4]
180+
[skip, 12]
181+
[value, 0, 12]
182+
[value, 1, 14]
183+
[skip, 37]
184+
[value, 0, 13]
185+
```
186+
162187
#### Reference encoding implementation
163188

164189
```python
@@ -221,90 +246,6 @@ class Scheme:
221246
return m
222247
```
223248

224-
#### Example
225-
226-
We have analyzed two contracts, Arbitrum validator and Uniswap router.
227-
228-
Arbitrum (2147-bytes long):
229-
```
230-
(chunk offset, chunk number, pushdata offset)
231-
malicious push byte: 85 2 21
232-
malicious push byte: 95 2 31
233-
malicious push byte: 116 3 20
234-
malicious push byte: 135 4 7
235-
malicious push byte: 216 6 24
236-
malicious push byte: 1334 41 22
237-
```
238-
239-
Encoding with *scheme 1*:
240-
```
241-
[skip, 2]
242-
[value, 21]
243-
[value, 31]
244-
[skip, 1]
245-
[value, 20]
246-
[skip, 1]
247-
[value, 7]
248-
[skip, 2]
249-
[value, 24]
250-
[skip, 35]
251-
[value, 22]
252-
```
253-
254-
Encoding size: `5 skips (5 * 11 bits) + 6 values (6 * 7 bits)` = 13-bytes header (0.605%)
255-
256-
Encoding with *scheme 2*:
257-
```
258-
[skip, 2]
259-
[value, 0, 21]
260-
[value, 0, 31]
261-
[value, 1, 20]
262-
[value, 1, 7]
263-
[value, 2, 24]
264-
[skip, 35, 22]
265-
```
266-
267-
Encoding size: `2 skips (2 * 11 bits) + 5 values (5 * 11 bits)` = 10-bytes header (0.465%)
268-
269-
Uniswap router contract (17958 bytes):
270-
271-
```
272-
(chunk offset, chunk number, pushdata offset)
273-
malicious push byte: 1646 51 14
274-
malicious push byte: 1989 62 5
275-
malicious push byte: 4239 132 15
276-
malicious push byte: 4533 141 21
277-
malicious push byte: 7043 220 3
278-
malicious push byte: 8036 251 4
279-
malicious push byte: 8604 268 28
280-
malicious push byte: 12345 385 25
281-
malicious push byte: 15761 492 17
282-
```
283-
284-
Encoding using *scheme 2*:
285-
```
286-
[skip, 51]
287-
[value, 0, 14]
288-
[value, 11, 5]
289-
[skip, 70]
290-
[value, 0, 15]
291-
[value, 9, 21]
292-
[skip, 79]
293-
[value, 0, 3]
294-
[skip, 31]
295-
[value, 0, 4]
296-
[skip, 17]
297-
[value, 0, 28]
298-
[skip, 117]
299-
[value, 0, 25]
300-
[skip, 107]
301-
[value, 0, 17]
302-
```
303-
304-
Encoding size: `7 skips (7 * 11 bits) + 9 values (9 * 11 bits)` = 22-bytes header (0.122%)
305-
306-
Our current hunch is that in average contracts this results in a sub-1% overhead, while the worst case is 4.1%.
307-
This compares against the constant 3.2% overhead of the current Verkle code chunking.
308249

309250
## Backwards Compatibility
310251

0 commit comments

Comments
 (0)