-
Notifications
You must be signed in to change notification settings - Fork 1
/
tag-parallel-evm.html
1397 lines (1376 loc) · 69.1 KB
/
tag-parallel-evm.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="alternate"
type="application/rss+xml"
href="https://chenyo.me/rss.xml"
title="RSS feed for https://chenyo.me">
<title>Chenyo's Blog</title>
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'],['\\(','\\)']]}});
</script>
<meta name="author" content="chenyo">
<meta name="referrer" content="no-referrer">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="assets/style.css" type="text/css"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"/>
<link rel="favicon" type="image/x-icon" href="favicon.ico">
<script src="assets/search.js"></script></head>
<body>
<div id="preamble" class="status">
<header>
<h1><a href="https://chenyo.me">Chenyo's org-static-blog</a></h1>
<nav>
<a href="https://chenyo.me">Home</a>
<a href="archive.html">Archive</a>
<a href="tags.html">Tags</a>
<div id="search-container">
<input type="text" id="search-input" placeholder="Search anywhere...">
<i class="fas fa-search search-icon"></i>
</div>
</nav>
</header></div>
<div id="content">
<h1 class="title">Posts tagged "parallel-evm":</h1>
<div class="post-date">08 Aug 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-08-08-parallel-evm:-blockworks-bigger-picture.html">Parallel EVM: Blockworks news (Sei, Monad, Solana)</a></h1>
<nav id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#orga587ecd">1. Terminology</a>
<ul>
<li><a href="#org5f410f3">1.1. Ethereum sharding</a></li>
<li><a href="#org17f2a79">1.2. Blob</a></li>
<li><a href="#org83bbc3a">1.3. Erasure coding</a></li>
<li><a href="#org51c3b10">1.4. Data availability sampling (DAS)</a></li>
<li><a href="#orgcd92788">1.5. Danksharding (L2 optimization)</a></li>
<li><a href="#org3dd14bd">1.6. Relations between L1 and L2 scaling</a></li>
<li><a href="#orgb76173b">1.7. Double spending prevention</a></li>
<li><a href="#org826e3b0">1.8. Sealevel (Solana)</a></li>
</ul>
</li>
<li><a href="#org471cb12">2. Ways to achieve parallel processing</a></li>
<li><a href="#orge5e259b">3. Production-ready parallelized EVM projects (Jan 2024)</a></li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://blockworks.co/news/parallelized-evms-gaining-popularity">Blockworks news (12.01.2024)</a> as well as some terminology explained online, e.g., <a href="https://www.coindesk.com/learn/what-is-ethereum-sharding-a-beginners-guide/">Coindesk</a> and <a href="https://chatgpt.com/c/824f05c9-dc75-4eb6-aeda-59d057baf83a">GPT-4o</a>.
</p>
<div id="outline-container-orga587ecd" class="outline-2">
<h2 id="orga587ecd"><span class="section-number-2">1.</span> Terminology</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org5f410f3" class="outline-3">
<h3 id="org5f410f3"><span class="section-number-3">1.1.</span> Ethereum sharding</h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>The Ethereum mainnet is divided into smaller interconnected networks called shards.</li>
<li>Each shard processes and validates its own transactions parallel to others.</li>
<li>Pros: increase scalability and <b><b>participation</b></b>.</li>
<li>Cons: a single unit can be compromised; lead to centralization.</li>
</ul>
</div>
</div>
<div id="outline-container-org17f2a79" class="outline-3">
<h3 id="org17f2a79"><span class="section-number-3">1.2.</span> Blob</h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>Rather than storing each transaction data directly in the blockchain, the data is aggregated into a blob (binary object).</li>
<li>Each blob performs erasure coding to dive the blob into multiple smaller pieces with redundancy.</li>
<li>Encoded pieces are stored separately, the block header contain pointers to the piece locations without storing actual data.</li>
<li>Transactions in a block may be distributed across multiple blobs.</li>
</ul>
</div>
</div>
<div id="outline-container-org83bbc3a" class="outline-3">
<h3 id="org83bbc3a"><span class="section-number-3">1.3.</span> Erasure coding</h3>
<div class="outline-text-3" id="text-1-3">
<ul class="org-ul">
<li>Allows one to encode blobs such that if at least half of the data in the blob is published, anyone in the network can reconstruct and re-publish the rest of the data.</li>
</ul>
</div>
</div>
<div id="outline-container-org51c3b10" class="outline-3">
<h3 id="org51c3b10"><span class="section-number-3">1.4.</span> Data availability sampling (DAS)</h3>
<div class="outline-text-3" id="text-1-4">
<ul class="org-ul">
<li>Validators randomly sample blob pieces to confirm the data can be reconstructed.g</li>
<li>If a client cannot get enough pieces to verify the blob availability, or the blob fails the integrity check, or transactions within the blob are invalid or inconsistent with the blockchain state, the blob is rejected.</li>
</ul>
</div>
</div>
<div id="outline-container-orgcd92788" class="outline-3">
<h3 id="orgcd92788"><span class="section-number-3">1.5.</span> Danksharding (L2 optimization)</h3>
<div class="outline-text-3" id="text-1-5">
<ul class="org-ul">
<li>A specific sharding implementation proposal.</li>
<li>Require data availability sampling and <a href="https://chenyo-17.github.io/org-static-blog/tag-evm.html#orgf2db0ef">proposer-builder separation</a>.</li>
<li>Can support hundreds of individual rollups.</li>
</ul>
</div>
</div>
<div id="outline-container-org3dd14bd" class="outline-3">
<h3 id="org3dd14bd"><span class="section-number-3">1.6.</span> Relations between L1 and L2 scaling</h3>
<div class="outline-text-3" id="text-1-6">
<ul class="org-ul">
<li>L1 scaling: optimizations directly to the Ethereum mainnet and core infrastructure, e.g., parallel EVM.</li>
<li>L2 scaling: building secondary rollup layers, e.g., optimistic rollups and ZK rollups, to offload mainnet computation and storage.</li>
</ul>
</div>
</div>
<div id="outline-container-orgb76173b" class="outline-3">
<h3 id="orgb76173b"><span class="section-number-3">1.7.</span> Double spending prevention</h3>
<div class="outline-text-3" id="text-1-7">
<ul class="org-ul">
<li>Bitcoin: uses UTXOs to track which inputs have been spent (no need to go through the entire chain).</li>
<li>Ethereum: uses a nounce to track the number of transactions sent from an account, the nounce is included in the transaction and is incremented by 1 for every new transaction, and all transactions must be executed in order.</li>
</ul>
</div>
</div>
<div id="outline-container-org826e3b0" class="outline-3">
<h3 id="org826e3b0"><span class="section-number-3">1.8.</span> Sealevel (Solana)</h3>
<div class="outline-text-3" id="text-1-8">
<ul class="org-ul">
<li>Solana’s parallel smart contract runtime to process thousands of contracts in parallel.</li>
<li>Solana transactions describe all states a transaction accesses to efficiently recognize transaction dependency and to schedule parallel execution without accessing full blockchain state.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org471cb12" class="outline-2">
<h2 id="org471cb12"><span class="section-number-2">2.</span> Ways to achieve parallel processing</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>Process independent transactions in parallel.</li>
<li>Sharding.</li>
</ul>
</div>
</div>
<div id="outline-container-orge5e259b" class="outline-2">
<h2 id="orge5e259b"><span class="section-number-2">3.</span> Production-ready parallelized EVM projects (Jan 2024)</h2>
<div class="outline-text-2" id="text-3">
<ul class="org-ul">
<li>Sei: optimistic parallel execution.</li>
<li>Monad: custom EVM implementation, optimistic parallel execution, <b><b>custom state database</b></b>.
<ul class="org-ul">
<li>Commodity databases are not optimized for Merkle tree data read/write with SSD.</li>
</ul></li>
<li>Neon (Solana): transactions pre-specify dependencies.</li>
<li>See <a href="https://chenyo-17.github.io/org-static-blog/tag-evm.html#orgcb5510d">BNB chain post</a> for more solutions.</li>
</ul>
</div>
</div>
<div class="taglist"><a href="https://chenyo.me/tags.html">Tags</a>: <a href="https://chenyo.me/tag-evm.html">evm</a> <a href="https://chenyo.me/tag-parallel-evm.html">parallel-evm</a> <a href="https://chenyo.me/tag-blockworks.html">blockworks</a> </div>
<div class="post-date">24 Jul 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-07-24-parallel-evm:-reth.html">Parallel EVM: Reth scaling plan</a></h1>
<nav id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org20950c8">1. Blockchain fundamentals</a>
<ul>
<li><a href="#orgf59b06d">1.1. Ethereum engine API</a></li>
<li><a href="#org6a6169c">1.2. Foundry</a></li>
<li><a href="#org97695c9">1.3. Revm</a></li>
<li><a href="#org97ce1ae">1.4. Alloy</a></li>
<li><a href="#org88dd316">1.5. Erigon & Staged sync</a></li>
<li><a href="#org21fc794">1.6. Storage engines</a>
<ul>
<li><a href="#orgf604566">1.6.1. ACID</a></li>
<li><a href="#org737338e">1.6.2. MVCC (Multi-version concurrency control)</a></li>
<li><a href="#orge0cbff7">1.6.3. Common database models</a></li>
<li><a href="#orgceb3dd0">1.6.4. Common storage engines</a></li>
</ul>
</li>
<li><a href="#org6b0a87a">1.7. Reth</a></li>
<li><a href="#org478ab9b">1.8. Why gas per second as the performance metric</a></li>
<li><a href="#org3e971b2">1.9. EVM cost models</a></li>
<li><a href="#orged77b07">1.10. TPC benchmark</a></li>
<li><a href="#org89f5af9">1.11. State growth</a></li>
<li><a href="#orgdf456e7">1.12. JIT (Just-In-Time) and AOT (Ahead-of-Time) EVM</a></li>
<li><a href="#orgf3797a6">1.13. Actor model</a></li>
<li><a href="#orge6bfe92">1.14. Storage trie</a></li>
<li><a href="#org9662699">1.15. Serverless database</a></li>
</ul>
</li>
<li><a href="#orgb4b09e9">2. Reth scaling plan</a>
<ul>
<li><a href="#org1900484">2.1. Vertical scaling (2024)</a>
<ul>
<li><a href="#org61d0655">2.1.1. JIT/AOT EVM</a></li>
<li><a href="#org05122cc">2.1.2. Parallel EVM</a></li>
<li><a href="#org6bffaf9">2.1.3. Optimized state commitment</a></li>
</ul>
</li>
<li><a href="#org266842c">2.2. Horizontal scaling (2025)</a>
<ul>
<li><a href="#org729b06d">2.2.1. Multi-Rollup (?)</a></li>
<li><a href="#orgb4aacf1">2.2.2. Cloud-Native nodes.</a></li>
</ul>
</li>
<li><a href="#org2b8c868">2.3. Open questions</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://www.paradigm.xyz/2024/04/reth-perf">Reth-performance-blog</a> as well as some terminology explain online, e.g., <a href="https://github.com/paradigmxyz/reth">Reth-repo</a> and <a href="https://claude.ai/chat/6364436f-d279-4c6b-947e-237bfea26409">Claude.ai</a>.
</p>
<div id="outline-container-org20950c8" class="outline-2">
<h2 id="org20950c8"><span class="section-number-2">1.</span> Blockchain fundamentals</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-orgf59b06d" class="outline-3">
<h3 id="orgf59b06d"><span class="section-number-3">1.1.</span> <a href="https://github.com/ethereum/execution-apis/blob/a0d03086564ab1838b462befbc083f873dcf0c0f/src/engine/paris.md">Ethereum engine API</a></h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>A collection of JSON-RPC methods that all execution clients implement.</li>
<li>Specify the interfaces between consensus and execution layers.</li>
</ul>
</div>
</div>
<div id="outline-container-org6a6169c" class="outline-3">
<h3 id="org6a6169c"><span class="section-number-3">1.2.</span> <a href="https://github.com/foundry-rs/foundry/">Foundry</a></h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>A Rust-written toolkit for Ethereum application development.</li>
<li>Consists of an Ethereum testing framework Forge; a framework to interact with the chain Cast; a local Ethereum node Anvil; and a Solidity REPL (Read-Eval-Print-Loop: an interactive environment) Chisel.</li>
</ul>
</div>
</div>
<div id="outline-container-org97695c9" class="outline-3">
<h3 id="org97695c9"><span class="section-number-3">1.3.</span> <a href="https://github.com/bluealloy/revm/">Revm</a></h3>
<div class="outline-text-3" id="text-1-3">
<ul class="org-ul">
<li>A Rust-written EVM; responsible for executing transactions and contracts.</li>
</ul>
</div>
</div>
<div id="outline-container-org97ce1ae" class="outline-3">
<h3 id="org97ce1ae"><span class="section-number-3">1.4.</span> <a href="https://github.com/alloy-rs">Alloy</a></h3>
<div class="outline-text-3" id="text-1-4">
<ul class="org-ul">
<li>A library to interact with the Ethereum and other EVM-base chains.</li>
</ul>
</div>
</div>
<div id="outline-container-org88dd316" class="outline-3">
<h3 id="org88dd316"><span class="section-number-3">1.5.</span> <a href="https://erigon.tech/">Erigon</a> & Staged sync</h3>
<div class="outline-text-3" id="text-1-5">
<ul class="org-ul">
<li>Erigon: a Go-written Ethereum client implementation (execution layer).</li>
<li>Staged sync: break the chain synchronization process into distinct stages in order to achieve better efficiency.</li>
</ul>
</div>
</div>
<div id="outline-container-org21fc794" class="outline-3">
<h3 id="org21fc794"><span class="section-number-3">1.6.</span> Storage engines</h3>
<div class="outline-text-3" id="text-1-6">
</div>
<div id="outline-container-orgf604566" class="outline-4">
<h4 id="orgf604566"><span class="section-number-4">1.6.1.</span> ACID</h4>
<div class="outline-text-4" id="text-1-6-1">
<ul class="org-ul">
<li>A set of properties for database transactions: atomicity, consistency, isolation, duration.</li>
<li>Atomicity: a transaction is treated as an indivisible unit; if any part of the transaction fails, the entire transaction is rolled back.</li>
<li>Consistency: a transaction brings the database from one valid state to another.</li>
<li>Isolation: concurrent transaction execution leave the database in the same state as if transactions are executed sequentially</li>
<li>Duration: a committed transaction remains committed even when the system fails.</li>
</ul>
</div>
</div>
<div id="outline-container-org737338e" class="outline-4">
<h4 id="org737338e"><span class="section-number-4">1.6.2.</span> MVCC (Multi-version concurrency control)</h4>
<div class="outline-text-4" id="text-1-6-2">
<ul class="org-ul">
<li>A concurrency control model used in DBMS.</li>
<li>MVCC keeps multiple version of data simultaneously, each transaction sees a snapshot of the database.</li>
</ul>
</div>
</div>
<div id="outline-container-orge0cbff7" class="outline-4">
<h4 id="orge0cbff7"><span class="section-number-4">1.6.3.</span> Common database models</h4>
<div class="outline-text-4" id="text-1-6-3">
<ul class="org-ul">
<li>Relational model, e.g., SQL.</li>
<li>Document model.</li>
<li>Network model.</li>
<li>key-value, e.g., NoSQL.</li>
</ul>
</div>
</div>
<div id="outline-container-orgceb3dd0" class="outline-4">
<h4 id="orgceb3dd0"><span class="section-number-4">1.6.4.</span> Common storage engines</h4>
<div class="outline-text-4" id="text-1-6-4">
<ul class="org-ul">
<li>MDBX: Ultra-fate key-value embedded database with ACID and MVCC supported.</li>
<li>LevelDB: Google-developed key-value store using log-structured merge-tree for high write throughput.</li>
<li>RocksDB: Meta’s fork of LevelDB, optimized for fast storage.</li>
<li>LSM-based DBs, e.g., BadgerDB: optimized for write-heavy workloads with log-structured merge-tree.</li>
<li>BoltDB: Go-written key-value database with optimized B+ tree, ACID supported.</li>
<li>LMDB: memory-mapped key-value store with ACID and MVCC supported.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org6b0a87a" class="outline-3">
<h3 id="org6b0a87a"><span class="section-number-3">1.7.</span> Reth</h3>
<div class="outline-text-3" id="text-1-7">
<ul class="org-ul">
<li>A Rust implementation of an Ethereum full node; allows users to interact with the Ethereum blockchain.</li>
<li>An execution layer that implements all Ethereum engine APIs.</li>
<li>Modularity: every component is built as a library.</li>
<li>Performance: uses Erigon staged-sync node architecture and other Rust libraries (e.g., Alloy, revm); tests and optimizes on Foundry.</li>
<li>Database/Storage engine: MDBX.</li>
</ul>
</div>
</div>
<div id="outline-container-org478ab9b" class="outline-3">
<h3 id="org478ab9b"><span class="section-number-3">1.8.</span> Why gas per second as the performance metric</h3>
<div class="outline-text-3" id="text-1-8">
<ul class="org-ul">
<li>More nuanced than TPS.</li>
<li>Allows for a clear understanding for the capacity and efficiency.</li>
<li>Helps assessing the cost implications, e.g., DoS attacks.</li>
</ul>
</div>
</div>
<div id="outline-container-org3e971b2" class="outline-3">
<h3 id="org3e971b2"><span class="section-number-3">1.9.</span> EVM cost models</h3>
<div class="outline-text-3" id="text-1-9">
<ul class="org-ul">
<li>Determines the computational and storage costs for the execution.</li>
<li>Key aspects: gas, gas cost (for each operation), gas price (in Wei), gas limit.</li>
</ul>
</div>
</div>
<div id="outline-container-orged77b07" class="outline-3">
<h3 id="orged77b07"><span class="section-number-3">1.10.</span> TPC benchmark</h3>
<div class="outline-text-3" id="text-1-10">
<ul class="org-ul">
<li>Standardized performance tests for transaction processing and databases, e.g., how many transactions a system can process in a given period.</li>
<li>Offer benchmarks for different scenarios, e.g., TPC-C for online transaction processing.</li>
</ul>
</div>
</div>
<div id="outline-container-org89f5af9" class="outline-3">
<h3 id="org89f5af9"><span class="section-number-3">1.11.</span> State growth</h3>
<div class="outline-text-3" id="text-1-11">
<ul class="org-ul">
<li>State: the set of data for building and validating new Ethereum blocks.</li>
<li>State growth: the accumulation of new account and new contract storage.</li>
</ul>
</div>
</div>
<div id="outline-container-orgdf456e7" class="outline-3">
<h3 id="orgdf456e7"><span class="section-number-3">1.12.</span> JIT (Just-In-Time) and AOT (Ahead-of-Time) EVM</h3>
<div class="outline-text-3" id="text-1-12">
<ul class="org-ul">
<li>JIT: convert bytecode to native machine code just before execution to bypass the VM’s interpretative process.</li>
<li>AOT: compile the highest demand contracts and store them on disk, to avoid untrusted bytecode absuing native-code compilation.</li>
</ul>
</div>
</div>
<div id="outline-container-orgf3797a6" class="outline-3">
<h3 id="orgf3797a6"><span class="section-number-3">1.13.</span> Actor model</h3>
<div class="outline-text-3" id="text-1-13">
<ul class="org-ul">
<li>A paradigm/framework for designing distributed systems.</li>
<li>Actor: each actor is an independent entity to receive, process and send messages; create new actors or modify its state.</li>
</ul>
</div>
</div>
<div id="outline-container-orge6bfe92" class="outline-3">
<h3 id="orge6bfe92"><span class="section-number-3">1.14.</span> Storage trie</h3>
<div class="outline-text-3" id="text-1-14">
<ul class="org-ul">
<li>Each contract account has its own storage trie, which is usually stored in a KV database.</li>
</ul>
</div>
</div>
<div id="outline-container-org9662699" class="outline-3">
<h3 id="org9662699"><span class="section-number-3">1.15.</span> Serverless database</h3>
<div class="outline-text-3" id="text-1-15">
<ul class="org-ul">
<li>Allow developers to focus on writing queries without managing database servers.</li>
<li>Automatically scales up or down base on the workload.</li>
<li>Pay-per-use pricing.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-orgb4b09e9" class="outline-2">
<h2 id="orgb4b09e9"><span class="section-number-2">2.</span> Reth scaling plan</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>Current status (April 2024): achieves 100-200 mg/s during live sync, including sender recovery, transaction execution and block trie calculation.</li>
<li>The scaling plan does not involve solving state growth.</li>
</ul>
</div>
<div id="outline-container-org1900484" class="outline-3">
<h3 id="org1900484"><span class="section-number-3">2.1.</span> Vertical scaling (2024)</h3>
<div class="outline-text-3" id="text-2-1">
<ul class="org-ul">
<li>Optimize how each system handle transactions and data.</li>
</ul>
</div>
<div id="outline-container-org61d0655" class="outline-4">
<h4 id="org61d0655"><span class="section-number-4">2.1.1.</span> JIT/AOT EVM</h4>
<div class="outline-text-4" id="text-2-1-1">
<ul class="org-ul">
<li>Reduce EVM interpreter overhead to speed up single-threaded transaction processing.</li>
<li>The processing costs \(\approx\) 50% EVM time</li>
<li>Released on <a href="https://www.paradigm.xyz/2024/06/revmc">June 2024</a>.</li>
</ul>
<figure id="org2993c7d">
<img src="https://www.paradigm.xyz/static/reth-perf/3.png" alt="3.png" align="center" width="500px">
<figcaption><span class="figure-number">Figure 1: </span>The JIT/AOT compiler (<a href="https://www.paradigm.xyz/static/reth-perf/3.png">source</a>)</figcaption>
</figure>
</div>
</div>
<div id="outline-container-org05122cc" class="outline-4">
<h4 id="org05122cc"><span class="section-number-4">2.1.2.</span> Parallel EVM</h4>
<div class="outline-text-4" id="text-2-1-2">
<ul class="org-ul">
<li>Utilize multiple cores during EVM execution.</li>
<li><80% of historical transactions have non-conflicting dependencies.</li>
<li>Historical sync: can calculate the best parallelization schedule offline; an early attempt is <a href="https://github.com/paradigmxyz/reth/tree/rkrasiuk/parallel">available</a>.</li>
<li>Live sync: combine serial and parallel execution based on static analysis, since Block STM has poor performance during heavy state contention periods; an early attempt is <a href="https://github.com/risechain/pevm">available</a>.</li>
</ul>
</div>
</div>
<div id="outline-container-org6bffaf9" class="outline-4">
<h4 id="org6bffaf9"><span class="section-number-4">2.1.3.</span> Optimized state commitment</h4>
<div class="outline-text-4" id="text-2-1-3">
<ul class="org-ul">
<li>Traditional EVM implementation <b><b>couples</b></b> the transaction execution and the state root computation: the state root is updated whenever a transaction updates a trie, since the state root computation has to be sequential from the updated node to the root, this is slow.</li>
<li>Reth <b><b>decouples</b></b> the process: raw state data is stored in KV databases, and each trie is <b><b>re-built</b></b> for each block from the databases in the end.
<ul class="org-ul">
<li>Pro: can use more efficient databases.</li>
<li>Con: need to re-calculate the entire trie, which costs >75% of end-to-end block production time.</li>
</ul></li>
<li>Optimizations:
<ul class="org-ul">
<li>Now already re-calculate the storage trie for each updated contract in parallel.</li>
<li>Can also calculate the account trie when the storage tries are computed.</li>
<li>Pre-fetch cached trie nodes (cached by the state root computation) by tracking updated accounts and storage, e.g., a part of the trie may remain the same hash.</li>
</ul></li>
<li>Going beyond:
<ul class="org-ul">
<li>Only calculate the state root every \(T\) blocks.</li>
<li><b><b>Lag</b></b> the state root computation a few blocks behind to advance executions.</li>
<li>Use a cheaper encoder and hash function (Blake3).</li>
<li>Use wider branch nodes.</li>
</ul></li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org266842c" class="outline-3">
<h3 id="org266842c"><span class="section-number-3">2.2.</span> Horizontal scaling (2025)</h3>
<div class="outline-text-3" id="text-2-2">
<ul class="org-ul">
<li>Spread the workload across multiple systems.</li>
</ul>
</div>
<div id="outline-container-org729b06d" class="outline-4">
<h4 id="org729b06d"><span class="section-number-4">2.2.1.</span> Multi-Rollup (?)</h4>
<div class="outline-text-4" id="text-2-2-1">
<ul class="org-ul">
<li>Reduce operational overhead of running multiple rollups.</li>
</ul>
</div>
</div>
<div id="outline-container-orgb4aacf1" class="outline-4">
<h4 id="orgb4aacf1"><span class="section-number-4">2.2.2.</span> Cloud-Native nodes.</h4>
<div class="outline-text-4" id="text-2-2-2">
<ul class="org-ul">
<li>Deploy the heavy node (e.g., sequencer) as a service stack that can autoscale with compute demand and use cloud storage for persistence.</li>
<li>Similar to serverless database projects, e.g., NeonDB.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org2b8c868" class="outline-3">
<h3 id="org2b8c868"><span class="section-number-3">2.3.</span> Open questions</h3>
<div class="outline-text-3" id="text-2-3">
<ul class="org-ul">
<li>Second order effects of above changes, e.g., on light clients.</li>
<li>What is the best, average and worst case scenarios for each optimization.</li>
</ul>
</div>
</div>
</div>
<div class="taglist"><a href="https://chenyo.me/tags.html">Tags</a>: <a href="https://chenyo.me/tag-evm.html">evm</a> <a href="https://chenyo.me/tag-parallel-evm.html">parallel-evm</a> <a href="https://chenyo.me/tag-reth.html">reth</a> </div>
<div class="post-date">14 Jul 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-07-14-parallel-evm:-bep-130.html">Parallel EVM: BEP-130</a></h1>
<nav id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#orge2771bc">1. Blockchain fundamentals</a>
<ul>
<li><a href="#org69c633d">1.1. System contract</a></li>
<li><a href="#org9e40074">1.2. Transaction execution phases</a></li>
</ul>
</li>
<li><a href="#org87059dc">2. Design principle</a></li>
<li><a href="#org3917a6e">3. Workflow</a>
<ul>
<li><a href="#orgc2b83c6">3.1. Dispatch factors</a></li>
<li><a href="#orge09585a">3.2. Slot execution stages</a></li>
<li><a href="#org01ea43d">3.3. Conflict detection</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP130.md">BEP-130</a>.
BEP-130 is a proposal that introduces a parallel transaction execution mechanism on the BNB Smart Chain (BSC).
</p>
<div id="outline-container-orge2771bc" class="outline-2">
<h2 id="orge2771bc"><span class="section-number-2">1.</span> Blockchain fundamentals</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org69c633d" class="outline-3">
<h3 id="org69c633d"><span class="section-number-3">1.1.</span> System contract</h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>Built-in contracts to perform system level operations, e,g., gas fee reward, cross chain communication.</li>
<li>Cannot be executed concurrently since they depend on the execution results of other transactions, e.g., a number of transaction made by an account at some timestamp.</li>
</ul>
</div>
</div>
<div id="outline-container-org9e40074" class="outline-3">
<h3 id="org9e40074"><span class="section-number-3">1.2.</span> Transaction execution phases</h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>Block mining phase: received from the P2P transaction pool, could contain invalid transactions.</li>
<li>Block sync phase: the block is confirmed.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org87059dc" class="outline-2">
<h2 id="org87059dc"><span class="section-number-2">2.</span> Design principle</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>Should always produce the same result as the current sequential execution.</li>
<li>Should be decoupled into existing or new modules with no circular dependency.</li>
<li>Should be configurable based on node hardware resources.</li>
<li>Keep it simple and smart.</li>
</ul>
</div>
</div>
<div id="outline-container-org3917a6e" class="outline-2">
<h2 id="org3917a6e"><span class="section-number-2">3.</span> Workflow</h2>
<div class="outline-text-2" id="text-3">
</div>
<div id="outline-container-orgc2b83c6" class="outline-3">
<h3 id="orgc2b83c6"><span class="section-number-3">3.1.</span> Dispatch factors</h3>
<div class="outline-text-3" id="text-3-1">
<ul class="org-ul">
<li>Is the slot idle or occupied?</li>
<li>Is there a same address contract running or pending in this slot?</li>
<li>Has the slot’s pending transactions size reached the max transactions queue size limitation?</li>
<li>Is there a big transaction index gap between the slot’s head transaction and the dispatched transaction?</li>
<li>Is the transaction contract likely to have high gas cost or a conflict rate?</li>
</ul>
</div>
</div>
<div id="outline-container-orge09585a" class="outline-3">
<h3 id="orge09585a"><span class="section-number-3">3.2.</span> Slot execution stages</h3>
<div class="outline-text-3" id="text-3-2">
<ol class="org-ol">
<li>Execute the transaction \(Tx_i\)based on a specific worldstate, e.g., the state when the execution starts.</li>
<li>Wait for the finalization of the previous transaction \(Tx_{i-1}\).</li>
<li>Detect if there is any conflict between the state read by \(Tx_i\) and the state change after the execution of \(Tx_i\) starts.</li>
<li>If a conflict is detected, re-execute \(Tx_{i}\) again based on the latest finalized worldstate.</li>
<li>Finalize the state changed by \(Tx_i\) to the latest worldstate.</li>
<li>The state changes are kept within each slot, and are merged to the main StateDB once the execution is done.</li>
<li>The first transaction in a block can be immediately finalized.</li>
<li>If \(Tx_i\) and \(Tx_{i-1}\) are in the same slot, \(Tx_i\) can immediately start conflict detection.</li>
<li>Re-executed transaction can be immediately finalized as it reads the latest worldstate.</li>
</ol>
</div>
</div>
<div id="outline-container-org01ea43d" class="outline-3">
<h3 id="org01ea43d"><span class="section-number-3">3.3.</span> Conflict detection</h3>
<div class="outline-text-3" id="text-3-3">
<ul class="org-ul">
<li>Detection items: storage key/value pair; account balance; contract content and status.</li>
<li>Overlap reads without write, or hardcode writes without read are not conflicts.</li>
</ul>
</div>
</div>
</div>
<div class="taglist"><a href="https://chenyo.me/tags.html">Tags</a>: <a href="https://chenyo.me/tag-evm.html">evm</a> <a href="https://chenyo.me/tag-parallel-evm.html">parallel-evm</a> <a href="https://chenyo.me/tag-bnb.html">bnb</a> </div>
<div class="post-date">07 Jul 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-07-07-parallel-evm:-bnb-chain.html">Parallel EVM: BNB chain</a></h1>
<nav id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org3cfd85a">1. Blockchain fundamentals</a>
<ul>
<li><a href="#org9489617">1.1. Why is parallel EVM not easy</a></li>
<li><a href="#org91459cc">1.2. A Parallel EVM ideas</a></li>
<li><a href="#orgac74760">1.3. Block STM algorithm</a></li>
</ul>
</li>
<li><a href="#org89b3b0e">2. BNB Parallel EVM 1.0: Infrastructure</a></li>
<li><a href="#orgc6e3320">3. BNB Parallel EVM 2.0: Performance enhancement</a></li>
<li><a href="#org3031326">4. BNB Parallel EVM 3.0: Production</a>
<ul>
<li><a href="#org41dcabc">4.1. Hint-based dispatcher</a></li>
<li><a href="#orgbf38fde">4.2. Seamless BNB chain ecosystem integration</a></li>
</ul>
</li>
<li><a href="#org0a50e59">5. Comparison with other solutions</a></li>
<li><a href="#org48a8333">6. Other optimizations</a></li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://www.bnbchain.org/zh-CN/blog/road-to-high-performance-parallel-evm-for-bnb-chain">BNB chain-blog</a>.
</p>
<div id="outline-container-org3cfd85a" class="outline-2">
<h2 id="org3cfd85a"><span class="section-number-2">1.</span> Blockchain fundamentals</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org9489617" class="outline-3">
<h3 id="org9489617"><span class="section-number-3">1.1.</span> Why is parallel EVM not easy</h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>Lack of visibility of potential transaction conflict.</li>
<li>Blockchains experience transaction bursts, e.g., >70M transactions per day.</li>
</ul>
</div>
</div>
<div id="outline-container-org91459cc" class="outline-3">
<h3 id="org91459cc"><span class="section-number-3">1.2.</span> A Parallel EVM ideas</h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>Run multiple EVM instances concurrently on different threads.</li>
<li>Execute transactions independently on each thread and later merge a finial state update.</li>
<li><a href="https://lh7-us.googleusercontent.com/Dh1GAMYlMkiRI0xWQ0ByYOxq_GNtA9h1PP1OF7FP9b8O3VRxVtlh1eq991OlNa4rNX_ZXH8tVPRBeN58_0dBF1jPUVRuuJMl4JqmBchhCTZp_vF-W003l77KajIjIMCHfapjsBH--0EpMi0FT2iNPlw">Parallel EVM scheme</a></li>
</ul>
</div>
</div>
<div id="outline-container-orgac74760" class="outline-3">
<h3 id="orgac74760"><span class="section-number-3">1.3.</span> Block STM algorithm</h3>
<div class="outline-text-3" id="text-1-3">
<ul class="org-ul">
<li>Optimistic parallelism: assigns transactions to various threads.</li>
<li>Software transaction memory (STM): detect conflicts when transactions try to modify the same shared state simultaneously.</li>
<li>Conflict resolution: when conflicts are detected, the offending transactions are discarded without affecting the blockchain state and are re-executed.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org89b3b0e" class="outline-2">
<h2 id="org89b3b0e"><span class="section-number-2">2.</span> BNB Parallel EVM 1.0: Infrastructure</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>Proposal: <a href="https://github.com/bnb-chain/BEPs/pull/130?ref=bnbchain.ghost.io">BEP-130 (2022)</a></li>
<li>Dispatcher: distributes transactions across threads to optimize throughput.</li>
<li>Parallel execution engine: execute transactions independently on each thread.</li>
<li>Local stateDB: each thread maintains a local stateDB to record state access.</li>
<li>Conflict detection: detect conflicts and re-execute conflicting transactions.</li>
<li>State commit: the finalized results are committed to the global state DB.</li>
</ul>
</div>
</div>
<div id="outline-container-orgc6e3320" class="outline-2">
<h2 id="orgc6e3320"><span class="section-number-2">3.</span> BNB Parallel EVM 2.0: Performance enhancement</h2>
<div class="outline-text-2" id="text-3">
<ul class="org-ul">
<li>Dispatcher: combine both static and dynamic dispatch strategies.</li>
<li>Execution engine: streaming pipeline to enable smooth transaction processing.</li>
<li>Conflict detection: ensure data integrity while minimizing unnecessary re-execution.</li>
<li>Memory: shared memory pools and light copying techniques to reduce memory footprint.</li>
<li>The overall performance ranges from 20% to 50%.</li>
</ul>
</div>
</div>
<div id="outline-container-org3031326" class="outline-2">
<h2 id="org3031326"><span class="section-number-2">4.</span> BNB Parallel EVM 3.0: Production</h2>
<div class="outline-text-2" id="text-4">
</div>
<div id="outline-container-org41dcabc" class="outline-3">
<h3 id="org41dcabc"><span class="section-number-3">4.1.</span> Hint-based dispatcher</h3>
<div class="outline-text-3" id="text-4-1">
<ul class="org-ul">
<li>leverages external hint providers to analyze transactions and generate predictions about potential state access conflicts.</li>
<li>Simple hints include read/write state sets; advanced hints incorporate weak/strong ordering for optimal parallelism.</li>
<li>Conflicting transactions are assigned to the same slot.</li>
<li>Transactions with no conflicts are distributed across different slots.</li>
<li>Conflict detector remains as a backup for handling unforeseen conflicts.</li>
</ul>
</div>
</div>
<div id="outline-container-orgbf38fde" class="outline-3">
<h3 id="orgbf38fde"><span class="section-number-3">4.2.</span> Seamless BNB chain ecosystem integration</h3>
<div class="outline-text-3" id="text-4-2">
<ul class="org-ul">
<li>Modularization and reconstructing.</li>
<li>Thorough testing and validation.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org0a50e59" class="outline-2">
<h2 id="org0a50e59"><span class="section-number-2">5.</span> Comparison with other solutions</h2>
<div class="outline-text-2" id="text-5">
<table>
<colgroup>
<col class="org-left">
<col class="org-left">
<col class="org-left">
<col class="org-left">
</colgroup>
<thead>
<tr>
<th scope="col" class="org-left">Solutions</th>
<th scope="col" class="org-left">TX dependency check</th>
<th scope="col" class="org-left">Conflict resolution</th>
<th scope="col" class="org-left">StateDB optimization</th>
</tr>
</thead>
<tbody>
<tr>
<td class="org-left">BlockSTM</td>
<td class="org-left">tracks at execution</td>
<td class="org-left">re-execution</td>
<td class="org-left">N/A</td>
</tr>
<tr>
<td class="org-left">Polygon</td>
<td class="org-left">minimal metadata solution</td>
<td class="org-left">reduced re-execution</td>
<td class="org-left">N/A</td>
</tr>
<tr>
<td class="org-left">Monad</td>
<td class="org-left">static analysis</td>
<td class="org-left">reduced re-execution</td>
<td class="org-left">Monad DB</td>
</tr>
<tr>
<td class="org-left">Sei</td>
<td class="org-left">tracks at execution</td>
<td class="org-left">re-execution</td>
<td class="org-left">SeiDB</td>
</tr>
<tr>
<td class="org-left">Neon EVM and Solana Sealevel</td>
<td class="org-left">contract provided</td>
<td class="org-left">reduced re-execution</td>
<td class="org-left">depends on Solana</td>
</tr>
<tr>
<td class="org-left">BNBChain</td>
<td class="org-left">hint info</td>
<td class="org-left">reduced or eliminated re-execution</td>
<td class="org-left">Thread local DB</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="outline-container-org48a8333" class="outline-2">
<h2 id="org48a8333"><span class="section-number-2">6.</span> Other optimizations</h2>
<div class="outline-text-2" id="text-6">
<ul class="org-ul">
<li>Opcode-level optimization: fine-tuning individual EVM instructions for maximum efficiency.</li>
<li>Compilation optimization: JIT/AOT compilation paradigms; instruction-level parallelism (SIMD).</li>
<li>Database sharding: distribute data across multiple databases.</li>
<li>Concurrent node execution.</li>
</ul>
</div>
</div>
<div class="taglist"><a href="https://chenyo.me/tags.html">Tags</a>: <a href="https://chenyo.me/tag-evm.html">evm</a> <a href="https://chenyo.me/tag-parallel-evm.html">parallel-evm</a> <a href="https://chenyo.me/tag-bnb.html">bnb</a> </div>
<div class="post-date">04 Jul 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-07-04-parallel-evm:-megaeth.html">Parallel EVM: MegaETH</a></h1>
<nav id="table-of-contents" role="doc-toc">
<h2>Table of Contents</h2>
<div id="text-table-of-contents" role="doc-toc">
<ul>
<li><a href="#org9e99d3a">1. Blockchain fundamentals</a>
<ul>
<li><a href="#org818b1e5">1.1. Conduit chain</a></li>
<li><a href="#org61fac75">1.2. Gas per second</a></li>
<li><a href="#orgcf006aa">1.3. Target gas per block</a></li>
<li><a href="#orgafe64cc">1.4. Current blockchain scalability</a></li>
<li><a href="#org0588eb1">1.5. Blockchain node hardware requirements</a></li>
<li><a href="#orgf2aadab">1.6. L1 and L2 nodes</a></li>
<li><a href="#org8e224b5">1.7. Verifying a block</a></li>
<li><a href="#orgfc6f496">1.8. Maximum extractable value (MEV)</a></li>
<li><a href="#orgc7b0b39">1.9. Proposer-builder separation (PBS)</a></li>
<li><a href="#orgc48f850">1.10. Live and historical sync</a></li>
<li><a href="#org828a882">1.11. Portal Network</a></li>
<li><a href="#org8caa3fa">1.12. Verkle tree</a></li>
<li><a href="#org874e0a3">1.13. Node storage</a>
<ul>
<li><a href="#orge91cca5">1.13.1. History expiry</a></li>
<li><a href="#org4fad4d5">1.13.2. State expiry</a></li>
<li><a href="#org4f48281">1.13.3. Statelessness</a></li>
</ul>
</li>
<li><a href="#orgc1128ac">1.14. Software transactional memory (STM)</a></li>
<li><a href="#org7ce2c93">1.15. Block-STM</a></li>
</ul>
</li>
<li><a href="#org74556bf">2. What is MagaETH</a>
<ul>
<li><a href="#org71014a6">2.1. Node specialization</a></li>
<li><a href="#org4417424">2.2. Design philosophy</a></li>
</ul>
</li>
<li><a href="#orge430787">3. MegaETH challenges</a></li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://megaeth.systems/research">MegaETH-blog</a> as well as some terminology explained online, e.g., <a href="https://ethereum.org/en/roadmap/">ethereum.org</a>.
</p>
<p>
In summary, this blog proposes many challenges when designing a high-performance EVM chain, but does not include any design details of MegaETH itself.
</p>
<div id="outline-container-org9e99d3a" class="outline-2">
<h2 id="org9e99d3a"><span class="section-number-2">1.</span> Blockchain fundamentals</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org818b1e5" class="outline-3">
<h3 id="org818b1e5"><span class="section-number-3">1.1.</span> <a href="https://docs.conduit.xyz/">Conduit chain</a></h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>Allows one to deploy a rollup through its Rollups-as-a-service platform within in minutes.</li>
</ul>
</div>
</div>
<div id="outline-container-org61fac75" class="outline-3">
<h3 id="org61fac75"><span class="section-number-3">1.2.</span> Gas per second</h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>Reflects the amount of computation the blockchain can handle per second.</li>
<li>Different EVM operation costs different gas, e.g., <code>ADD</code> costs 3 gas.</li>
<li>Block gas limit: ensures that any node can reliably keep up with the rest of the network.</li>
</ul>
</div>
</div>
<div id="outline-container-orgcf006aa" class="outline-3">
<h3 id="orgcf006aa"><span class="section-number-3">1.3.</span> Target gas per block</h3>
<div class="outline-text-3" id="text-1-3">
<ul class="org-ul">
<li>Dynamically regulate the amount of computation a block can include.</li>
<li><code>Gas per second = Target Gas per block / Block time</code>.</li>
</ul>
</div>
</div>
<div id="outline-container-orgafe64cc" class="outline-3">
<h3 id="orgafe64cc"><span class="section-number-3">1.4.</span> Current blockchain scalability</h3>
<div class="outline-text-3" id="text-1-4">
<figure id="orgb6a52bd">
<img src="https://hackmd.io/_uploads/rkHVB0iHR.png" alt="rkHVB0iHR.png" align="center" width="500px">
<figcaption><span class="figure-number">Figure 1: </span>2024 blockchain scalability comparison</figcaption>
</figure>
<ul class="org-ul">
<li>Throughput: 100MGas/s (\(\approx\) 3700 ERC-20 transfer) cannot compares to Web2 database with >1M transactions per second.</li>
<li>Capacity: Complex applications cannot be on-chain, e.g., compute large Fibonacci (e.g., \(10^8\)) number would take 55 seconds on opBNB, while in C just 30 milliseconds in a single core.</li>
<li>Delay: Applications that require fast feedback loop, e.g., high-frequency trading are not feasible with long block times, e.g., 1s.</li>
</ul>
</div>
</div>
<div id="outline-container-org0588eb1" class="outline-3">
<h3 id="org0588eb1"><span class="section-number-3">1.5.</span> Blockchain node hardware requirements</h3>
<div class="outline-text-3" id="text-1-5">
<ul class="org-ul">
<li>Lower hardware requirements for full nodes increase decentralization.</li>
<li>Higher requirements increase performance and security.</li>
</ul>
</div>
</div>
<div id="outline-container-orgf2aadab" class="outline-3">
<h3 id="orgf2aadab"><span class="section-number-3">1.6.</span> L1 and L2 nodes</h3>
<div class="outline-text-3" id="text-1-6">
<ul class="org-ul">
<li>L1 nodes are homogeneous; each node performs identical tasks, i.e., transaction consensus and execution without specialization.</li>
<li>L2 nodes are heterogeneous; different nodes perform specific tasks, e.g., sequencer node determines the transaction order, prover nodes rely on accelerators to enhance proof generation.</li>
</ul>
</div>
</div>
<div id="outline-container-org8e224b5" class="outline-3">
<h3 id="org8e224b5"><span class="section-number-3">1.7.</span> Verifying a block</h3>
<div class="outline-text-3" id="text-1-7">
<ul class="org-ul">
<li>Re-execute the transactions in the block.</li>
<li>Applying the changes to Ethereum state trie.</li>
<li>Calculate the new root hash and compare it with the root hash provided by the block.</li>
</ul>
</div>
</div>
<div id="outline-container-orgfc6f496" class="outline-3">
<h3 id="orgfc6f496"><span class="section-number-3">1.8.</span> Maximum extractable value (MEV)</h3>
<div class="outline-text-3" id="text-1-8">
<ul class="org-ul">
<li>Validators maximize their profitability by favorably ordering transactions.</li>
</ul>
</div>
</div>
<div id="outline-container-orgc7b0b39" class="outline-3">
<h3 id="orgc7b0b39"><span class="section-number-3">1.9.</span> Proposer-builder separation (PBS)</h3>
<div class="outline-text-3" id="text-1-9">
<ul class="org-ul">
<li>Block builders are responsible for creating blocks and offering them to the block proposer in each slot.</li>
<li>Block proposers cannot see the contents, but simply choose the most profitable one and pay a fee to the block builder before broadcasting the block.</li>
<li>PBS makes it harder for block builders to censor transactions, and to outperform individuals at MEV extraction.</li>
</ul>
</div>
</div>
<div id="outline-container-orgc48f850" class="outline-3">
<h3 id="orgc48f850"><span class="section-number-3">1.10.</span> Live and historical sync</h3>
<div class="outline-text-3" id="text-1-10">
<ul class="org-ul">
<li>Live (online): continuously update a node with the latest data.</li>
<li>Historical (offline): synchronize a node by downloading the processing data up to a certain point.</li>
<li>Historical sync has much higher TPS than live sync, e.g., 10x, since historical sync can perform batch processing and does not have network latency.</li>
</ul>
</div>
</div>
<div id="outline-container-org828a882" class="outline-3">
<h3 id="org828a882"><span class="section-number-3">1.11.</span> <a href="https://ethereum.org/en/developers/docs/networking-layer/portal-network/">Portal Network</a></h3>
<div class="outline-text-3" id="text-1-11">
<ul class="org-ul">
<li>An in-development p2p network for serving historical data where each node stores a small piece of Ethereum’s history.</li>
<li>Light nodes do not need to trust on full nodes.</li>
<li>The entire history exists distributed across the network.</li>
</ul>
</div>
</div>
<div id="outline-container-org8caa3fa" class="outline-3">
<h3 id="org8caa3fa"><span class="section-number-3">1.12.</span> <a href="https://ethereum.org/en/roadmap/verkle-trees/">Verkle tree</a></h3>
<div class="outline-text-3" id="text-1-12">
<ul class="org-ul">
<li>Stateless clients rely on a witness that arrives with the block for PoI rather on maintaining own local trie.</li>
<li><b><b>Witness</b></b>: the minimal set of data that prove the values of the state that are being changed by the transactions in a block.</li>
</ul>
<ul class="org-ul">
<li>Merkle tree is too large to be broadcast between peers; the witness is a path connecting the data from leaved to the root, and to verify the data the hash of all sibling nodes are also required (to compute the parent hash).</li>
<li>Verkle trees reduce the witness size by shortening the distance between leaves and eliminating the need to provide sibling nodes; Using a polynomial commitment scheme (see <a href="https://chenyo-17.github.io/org-static-blog/2024-07-28-ethereum-merkle-patricia-trie.html">Ethereum MPT post</a> for explanation) allows the witness to have a fixed size.</li>
</ul>
</div>
</div>
<div id="outline-container-org874e0a3" class="outline-3">
<h3 id="org874e0a3"><span class="section-number-3">1.13.</span> Node storage</h3>
<div class="outline-text-3" id="text-1-13">
<ul class="org-ul">
<li>High disk space is the main barrier to a full node access, due to the need to store large chunks of Ethereum state data to process new transactions.</li>
<li>Using cheap hard drivers to store old data cannot keep up with new blocks.</li>
<li>Clients should find new ways to verify transactions without relying on looking up local databases.</li>
</ul>
</div>
<div id="outline-container-orge91cca5" class="outline-4">
<h4 id="orge91cca5"><span class="section-number-4">1.13.1.</span> History expiry</h4>
<div class="outline-text-4" id="text-1-13-1">
<ul class="org-ul">
<li>Nodes discard state data older than X blocks with weak subjectivity checkpoints, i.e., a genesis block close to the present.</li>
<li>Nodes can request historical data from peers with Portal Network, e.g., altruistic nodes that are willing to maintain and serve historical achieves, e.g., DAO.</li>
<li>Does not fundamentally change how Ethereum node handles data.</li>