-
Notifications
You must be signed in to change notification settings - Fork 1
/
2024-06-28-parallel-evm:-sei-v2.html
332 lines (332 loc) · 16.4 KB
/
2024-06-28-parallel-evm:-sei-v2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="This is a personal note for [[https://blog.sei.io/sei-v2-the-first-parallelized-evm/][Sei-v2-blog]]">
<link rel="alternate"
type="application/rss+xml"
href="https://chenyo.me/rss.xml"
title="RSS feed for https://chenyo.me">
<title>Parallel EVM: Sei-v2</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">
<div class="post-date">28 Jun 2024</div><h1 class="post-title"><a href="https://chenyo.me/2024-06-28-parallel-evm:-sei-v2.html">Parallel EVM: Sei-v2</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="#org4f51f09">1. Blockchain fundamentals</a>
<ul>
<li><a href="#org917b0c7">1.1. Mainnet and Testnet</a></li>
<li><a href="#org71dfd8d">1.2. Mainnet Alpha and Beta</a></li>
<li><a href="#orgdc5e688">1.3. Layer 1 and Layer 2</a></li>
<li><a href="#org4fe2515">1.4. Rollups</a></li>
<li><a href="#orga0a0779">1.5. State channels</a></li>
<li><a href="#orgff061af">1.6. Sidechains</a></li>
<li><a href="#org8e90e5d">1.7. Ethereum and EVM</a></li>
<li><a href="#orgf3eadbd">1.8. IAVL tree</a></li>
<li><a href="#orgefbf4ed">1.9. CosmWasm contract</a></li>
<li><a href="#org45d3413">1.10. Cosmos Ecosystem</a></li>
<li><a href="#orgfd294c1">1.11. Blockchain layers</a></li>
<li><a href="#orgee0e4f9">1.12. Optimistic parallelization</a></li>
<li><a href="#org65bb6f0">1.13. Integrated and Modular blockchain</a></li>
<li><a href="#org0b45d51">1.14. EVM Execution and storage layer</a></li>
<li><a href="#org0e1d6c6">1.15. Block time and finalize time</a></li>
<li><a href="#org42c57fa">1.16. Blockchain audit</a></li>
</ul>
</li>
<li><a href="#org1819b96">2. What is Sei</a></li>
<li><a href="#orgf396b7e">3. What is Sei v2</a>
<ul>
<li><a href="#orgbf992db">3.1. Backwards compatibility</a></li>
<li><a href="#org5897dfc">3.2. Optimistic parallelization</a></li>
<li><a href="#org42941d0">3.3. SeiDB</a></li>
<li><a href="#org01b9975">3.4. Interoperability</a></li>
</ul>
</li>
</ul>
</div>
</nav>
<p>
This is a personal note for <a href="https://blog.sei.io/sei-v2-the-first-parallelized-evm/">Sei-v2-blog</a> as well as some terminology explained by <a href="https://chatgpt.com/g/g-TJq7kBEsX-evm-gpt">EVM GPT</a>.
</p>
<div id="outline-container-org4f51f09" class="outline-2">
<h2 id="org4f51f09"><span class="section-number-2">1.</span> Blockchain fundamentals</h2>
<div class="outline-text-2" id="text-1">
</div>
<div id="outline-container-org917b0c7" class="outline-3">
<h3 id="org917b0c7"><span class="section-number-3">1.1.</span> Mainnet and Testnet</h3>
<div class="outline-text-3" id="text-1-1">
<ul class="org-ul">
<li>Mainnet: real transactions occur and have real-world value; any operation is final and irreversible.</li>
<li>Testnet: a sandbox environment with test cryptocurrencies without real-world value.</li>
</ul>
</div>
</div>
<div id="outline-container-org71dfd8d" class="outline-3">
<h3 id="org71dfd8d"><span class="section-number-3">1.2.</span> Mainnet Alpha and Beta</h3>
<div class="outline-text-3" id="text-1-2">
<ul class="org-ul">
<li>Alpha: test core functionalities and gather initial feedback in live environment.</li>
<li>Beta: more stable and feature-complete, but still need more testing.</li>
</ul>
</div>
</div>
<div id="outline-container-orgdc5e688" class="outline-3">
<h3 id="orgdc5e688"><span class="section-number-3">1.3.</span> Layer 1 and Layer 2</h3>
<div class="outline-text-3" id="text-1-3">
<ul class="org-ul">
<li>L1: the main network where all transactions are processed and the primary chain is maintained.</li>
<li>L2: secondary frameworks on top of L1 chain, aimed to enhance scalability without compromising the security of the L1.</li>
</ul>
</div>
</div>
<div id="outline-container-org4fe2515" class="outline-3">
<h3 id="org4fe2515"><span class="section-number-3">1.4.</span> Rollups</h3>
<div class="outline-text-3" id="text-1-4">
<ul class="org-ul">
<li>Processes transactions off-chain and periodically submits a summary (rollup) to L1.</li>
<li>Optimistic rollups: assume transactions are valid be default and use a challenge period to allow disputes
<ul class="org-ul">
<li>Examples: Optimism, Arbitrum.</li>
</ul></li>
<li>ZK-rollups: use zero-knowledge proofs to validate transactions.
<ul class="org-ul">
<li>Examples: zkSync, StarkNet.</li>
</ul></li>
</ul>
</div>
</div>
<div id="outline-container-orga0a0779" class="outline-3">
<h3 id="orga0a0779"><span class="section-number-3">1.5.</span> State channels</h3>
<div class="outline-text-3" id="text-1-5">
<ul class="org-ul">
<li>allow participants to conduct numerous off-chain transactions, with only the final state recorded on the L1.</li>
<li>Examples: Bitcoin lightning network.</li>
</ul>
</div>
</div>
<div id="outline-container-orgff061af" class="outline-3">
<h3 id="orgff061af"><span class="section-number-3">1.6.</span> Sidechains</h3>
<div class="outline-text-3" id="text-1-6">
<ul class="org-ul">
<li>Independent blockchains running parallel to the main chain, with own consensus and security.</li>
<li>Examples: Polygon.</li>
</ul>
</div>
</div>
<div id="outline-container-org8e90e5d" class="outline-3">
<h3 id="org8e90e5d"><span class="section-number-3">1.7.</span> Ethereum and EVM</h3>
<div class="outline-text-3" id="text-1-7">
<ul class="org-ul">
<li>Ethereum: a blockchain ecosystem, includes the blockchain, consensus mechanism, smart contracts, native cryptocurrency.</li>
<li>EVM: the runtime environment to execute smart contracts in Ethereum.</li>
</ul>
</div>
</div>
<div id="outline-container-orgf3eadbd" class="outline-3">
<h3 id="orgf3eadbd"><span class="section-number-3">1.8.</span> IAVL tree</h3>
<div class="outline-text-3" id="text-1-8">
<ul class="org-ul">
<li>AVL tree: self-balancing binary tree where the difference in heights between left and right subtrees of anynode is at most one.</li>
<li>IAVL tree: immutable AVL tree; node cannot be changed once it is added.</li>
</ul>
</div>
</div>
<div id="outline-container-orgefbf4ed" class="outline-3">
<h3 id="orgefbf4ed"><span class="section-number-3">1.9.</span> CosmWasm contract</h3>
<div class="outline-text-3" id="text-1-9">
<ul class="org-ul">
<li>Allows developers to write fast and portable smart contracts in WebAssembly.</li>
<li>Designed to be interoperable within in the Cosmos ecosystem, a network of independent blockchains connected via the Inter-blockchain communication (IBC) protocol.</li>
</ul>
</div>
</div>
<div id="outline-container-org45d3413" class="outline-3">
<h3 id="org45d3413"><span class="section-number-3">1.10.</span> Cosmos Ecosystem</h3>
<div class="outline-text-3" id="text-1-10">
<ul class="org-ul">
<li>A network of independent, interoperable blockchains designed to create an Internet of blockchain.</li>
<li>Decouples the consensus (BFT consensus engine) and networking (IBC protocol) layers from the application layers</li>
<li>Cosmos SDK: a modular framework for building application-specific blockchains efficiently.</li>
<li>Cosmos Hub: the first blockchain in the Cosmos network, serves as a central hub to connect multiple blockchains via IBC.</li>
</ul>
</div>
</div>
<div id="outline-container-orgfd294c1" class="outline-3">
<h3 id="orgfd294c1"><span class="section-number-3">1.11.</span> Blockchain layers</h3>
<div class="outline-text-3" id="text-1-11">
<ul class="org-ul">
<li>Infrastructure layer: the physical devices that support the network; and the underlying communication protocols for data transfer between nodes.</li>
<li>Data layer: the distributed ledger and the storage methods.</li>
<li>Consensus layer: the protocols, validators and miners; determines the transaction orders.</li>
<li>Execution layer: smart contracts and virtual machines; determines the transaction update.</li>
<li>Application layer: dApps to provide service and user interfaces.</li>
<li>Governance layer: the community decision-making process and proposals.</li>
<li>Security layer: cryptographic primitives and security protocols to avoid attacks.</li>
</ul>
</div>
</div>
<div id="outline-container-orgee0e4f9" class="outline-3">
<h3 id="orgee0e4f9"><span class="section-number-3">1.12.</span> Optimistic parallelization</h3>
<div class="outline-text-3" id="text-1-12">
<ul class="org-ul">
<li>Multiple transactions are processed in parallel under the assumption that they will conflict with each other; necessary corrections are made afterwards if conflicts are detected.</li>
<li>Increase throughput if conflicts are well handled.</li>
</ul>
</div>
</div>
<div id="outline-container-org65bb6f0" class="outline-3">
<h3 id="org65bb6f0"><span class="section-number-3">1.13.</span> Integrated and Modular blockchain</h3>
<div class="outline-text-3" id="text-1-13">
<ul class="org-ul">
<li>Integrated: all components, e.g., execution layer, consensus mechanism, networking are tightly coupled; faster internal communication but lower flexibility and scalability.</li>
<li>Modular: allow independent upgrades for different components; enhance scalability.</li>
</ul>
</div>
</div>
<div id="outline-container-org0b45d51" class="outline-3">
<h3 id="org0b45d51"><span class="section-number-3">1.14.</span> EVM Execution and storage layer</h3>
<div class="outline-text-3" id="text-1-14">
<ul class="org-ul">
<li>Execution: responsible for running smart contracts and processing transactions.</li>
<li>Storage: store all blockchain data, e.g., accounts, smart contract states, transaction history.</li>
</ul>
</div>
</div>
<div id="outline-container-org0e1d6c6" class="outline-3">
<h3 id="org0e1d6c6"><span class="section-number-3">1.15.</span> Block time and finalize time</h3>
<div class="outline-text-3" id="text-1-15">
<ul class="org-ul">
<li>Block: the average time for a new block to be added.</li>
<li>Finalize: the period after which a block is considered irreversible.</li>
<li>Faster block times often imply cheaper transaction fees due to increased transaction throughput and less block competition.</li>
</ul>
</div>
</div>
<div id="outline-container-org42c57fa" class="outline-3">
<h3 id="org42c57fa"><span class="section-number-3">1.16.</span> Blockchain audit</h3>
<div class="outline-text-3" id="text-1-16">
<ul class="org-ul">
<li>A review of a blockchain to ensures its security and functionality.</li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org1819b96" class="outline-2">
<h2 id="org1819b96"><span class="section-number-2">2.</span> What is Sei</h2>
<div class="outline-text-2" id="text-2">
<ul class="org-ul">
<li>On mainnet beta since August 2023.</li>
<li>Consistently finalizes blocks at 390ms; the fastest chain in existence.</li>
<li>Consistently sees activity of >45 TPS (transaction per seconds); the second highest number of successful transactions per second.</li>
<li>Allows for Cosmwasm smart contracts written in Rust; more execution environments like EVM is the biggest request.</li>
</ul>
</div>
</div>
<div id="outline-container-orgf396b7e" class="outline-2">
<h2 id="orgf396b7e"><span class="section-number-2">3.</span> What is Sei v2</h2>
<div class="outline-text-2" id="text-3">
<ul class="org-ul">
<li>The first fully parallelized EVM.</li>
<li>Backwards compatibility of EVM smart contracts.</li>
<li>Optimistic parallelization; support parallelization without requiring any dependencies.</li>
<li>Improves the storage layer to prevent state bloat, read/write, and state sync for new nodes.</li>
<li>Seamless composability between different execution environments.</li>
<li>Offers 28,300 batched transactions per second of throughput; 390ms block times and 390ms finality; far cheaper per-transaction costs.</li>
<li>Once audits are complete, the upgrade is released in a public testnet in Q1 2024, and deployed to mainnet in H1 2024.</li>
</ul>
</div>
<div id="outline-container-orgbf992db" class="outline-3">
<h3 id="orgbf992db"><span class="section-number-3">3.1.</span> Backwards compatibility</h3>
<div class="outline-text-3" id="text-3-1">
<ul class="org-ul">
<li>Ethereum contracts can be seamlessly deployed on Sei v2 with no code changes.</li>
<li>User can send a Eth transaction to the Ethereum contract on Sei v2 via the same interface, e.g., Metamask, Hardhat.</li>
<li>Sei v2 imports Geth (a Go EVM implementation) to process the Eth transaction, and convert the result to Sei storage.</li>
</ul>
</div>
</div>
<div id="outline-container-org5897dfc" class="outline-3">
<h3 id="org5897dfc"><span class="section-number-3">3.2.</span> Optimistic parallelization</h3>
<div class="outline-text-3" id="text-3-2">
<ul class="org-ul">
<li>Sei requires smart contract developers to optionally define the state that smart contracts are using, Sei v2 removes this need.</li>
<li>Sei v2 chain optimistically runs all transactions in parallel, when reaching conflicts, i.e., transactions touching the same state, the chain tracks the storage parts each transaction is touching.</li>
<li>Transactions touching different parts will be rerun in parallel; transactions touching the same state will be rerun sequentially.</li>
<li>Recursively continue until no more conflicts.</li>
<li>Since the transactions are ordered in a block, this process is deterministic.</li>
</ul>
</div>
</div>
<div id="outline-container-org42941d0" class="outline-3">
<h3 id="org42941d0"><span class="section-number-3">3.3.</span> SeiDB</h3>
<div class="outline-text-3" id="text-3-3">
<ul class="org-ul">
<li>Sei uses a vanilla database layer composed of an IAVL tree, which is less efficient in terms of storage and latency.</li>
<li>Sei v2 breaks the single IAVL tree into 2 components:
<ul class="org-ul">
<li>state store: provide low latency direct access to raw key-value pairs to remove the overhead of redundant metadata and disk usage; uses a write-ahead log to help event recovery.</li>
<li>state commitment: use an in-memory IAVL tree to help validators reach consensus faster.</li>
</ul></li>
<li>After benchmarking, Sei v2 replaces GoLevelDB with PebbleDB for better read/write in multi-threaded access.</li>
</ul>
</div>
</div>
<div id="outline-container-org01b9975" class="outline-3">
<h3 id="org01b9975"><span class="section-number-3">3.4.</span> Interoperability</h3>
<div class="outline-text-3" id="text-3-4">
<ul class="org-ul">
<li>Sei v2 processes different transactions, e.g., Cosmwasm, EVM in a uniformed way, and then forwards them to different storage sections.</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-sei.html">sei</a> </div></div>
<div id="postamble" class="status"><div id="search-results"></div>
<footer>
<div class="footer-content">
<div class="footer-left">
<p>© 2024 chenyo. Some rights reserved.</p>
<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">
<img alt="Creative Commons License" style="border-width: 0"
src="https://i.creativecommons.org/l/by-nc/4.0/88x31.png"/>
</a>
</div>
<div class="social-links">
<a href="https://t.me/chenyo17" target="_blank" rel="noopener noreferrer">
<i class="fab fa-telegram"></i>
</a>
<a href="https://github.com/chenyo-17" target="_blank" rel="noopener noreferrer">
<i class="fab fa-github"></i>
</a>
</div>
</footer></div>
</body>
</html>