-
Notifications
You must be signed in to change notification settings - Fork 1
/
2024-07-14-parallel-evm:-bep-130.html
162 lines (162 loc) · 7.57 KB
/
2024-07-14-parallel-evm:-bep-130.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="description" content="This is a personal note for [[https://github.com/bnb-chain/BEPs/blob/master/BEPs/BEP130.md][BEP-130]]">
<link rel="alternate"
type="application/rss+xml"
href="https://chenyo.me/rss.xml"
title="RSS feed for https://chenyo.me">
<title>Parallel EVM: BEP-130</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">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>
<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>