Speeding Up The EVM (Part 1) - Flashbots
Speeding Up The EVM (Part 1) - Flashbots
Speeding Up The EVM (Part 1) - Flashbots
Xinyuan Sun
Thanks to Alejo Salles, Hongbo Zhang, Alex Obadia, and Kushal Babel for
feedback and review of this post.
TLDR:
Ethereum Virtual Machine(EVM)'s performance is vital for several reasons.
First, if we have a faster VM then Ethereum clients will be able to process and
verify transactions faster, thus making it easier for everyone to run a full node
and strengthening the decentralization and security of the network.1 Second,
as MEV extraction on Ethereum becomes more prominent, we need to make
MEV extraction easier so profits from it can be more evenly distributed to
prevent economic centralization of the network. A more performant EVM
achieves this by helping searchers (and block builders when Ethereum
introduces Proposer-Builder Separation) to produce more profitable full blocks
and relays to have better latency. This means the builder market will become
more efficient, thus attracting more searchers and making the market even
more competitive, which in turn makes it more difficult for people to do reorgs
that endanger network stability.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 1/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
In part 1 of the series, we argue the need for a parallel EVM and cover
general approaches to achieve it such as EIP 648, EIP 2930 and speculative
execution. In part 2 we study how static analysis and formal methods can
make the EVM parallelizable, specifically we present two simple algorithms for
achieving parallelization.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 2/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
Background
Decentralization is vital to blockchain security: it is hard for participants in a
decentralized network to collude. Ideally, this is achieved by as many individual
parties as possible running nodes to verify ongoing transactions. However it
usually takes more than 3 days for regular users with a personal computer to
spin up a full node on Ethereum (it requires days to re-compute and validate
the 13 million blocks out there). Behind this inefficiency is Ethereum's large
storage size and more specifically EVM's storage design:
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 3/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 4/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 5/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
Today, MEV opportunities are much more complex and typical validators
(miners) see more than 10 MEV-emitting transactions per block.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 6/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
The high conflict rate indicates that we need to devise a more refined
parallelization algorithm, which will require more precise storage access
information. Next, we scope these tasks formally.
and the state transition function of the sequential EVM be δ(tˉ, s) which
returns a new EVM state given a list of transactions tˉ and a state s. Suppose in
list tˉ there are n transactions txn1 to txnn with an ordering of txn1
≺
txn2 ≺ ... ≺ txnn (txni ≺ txnj means we only start executing txnj after
Our goal is to devise a parallel EVM execution state transition function δp such
they are passed in, while in δp , tˉ's execution isn't ordered. For example, two
transactions running on two different CPU cores could finish execution at the
same time, or that txnj 's execute would finish before we start executing txni .
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 7/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
This means that if we are only parallelizing at the transaction level, shared data
conflict would be just the EVM storage since the only way in which info from
one transaction can spill over to a different transaction is via storage. If we
were parallelizing at deeper levels like EVM opcodes, then the information we
derive would also include EVM stack and memory.
Formally, this means that with each txni , we have some information on its
shared data access κ(txni ). This information could be anything, for example,
κ(txni ) could return a set of storage location literals in the contract code that
the transaction calls. Assuming the perfect information function is κperf ect ,
We realize that this formalization is different from what one would usually
employ to implement a parallel EVM (instantiating multiple VM instances with
read/write locks on the same storage database). The reason for us to choose
such a formalization is that by separating κ, we can easily re-purpose the
algorithm for optimizations like operation batching and caching6.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 8/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
additional information along with their bundles and only covers clients that
use mev-geth . More importantly, it is hard to enforce in a permission-less
system like flashbots without devising some additional incentive systems.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 9/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
their access information as a tuple of tuples {(r, w), (r, w)} . The first
tuple (r, w) denotes the read/write operation of txni and the second tuple
denotes those of txnj . For example, writing {(r), (r, w)} means that txni
read but didn't write to σ while txnj both read and wrote to σ .12
{(r), (r)} : txni and txnj are parallelizable, assuming that σ is only one
{(w), (r)} : txni and txnj must be executed sequentially in order of tˉ.
However, txni and txnj access not only σ but more locations, so we extend
our four simple rules to include a read set and a write set for every transaction,
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 10/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
else not.
Ultimately, it all depends on how refined our κ is and how refined we want our
parallel execution to be.10 For example, it could be more than quadratic,
meaning that we have κ not only contain storage access information but also
those on memory/calldata, as we are parallelizing within a single transaction as
well.
Of course, within those four situations, there are many complexities. For
example: {(w), (w)} . In this situation, it is possible that we have txni first
reads s′ and then changes it, but the value assigned to s′ always equals that of
txnj 's assignment because of how the smart contract was written. So this
effectively reduces to the {(r), (r)} case. Or this could easily go the other
way and reduce to {(w), (r)} , {(w), (w)} , or {(r), (w)} . And even then it
could be that the writer somehow doesn't change the storage's value or that
the reader doesn't affect state change in the EVM (e.g. reading some value to
be 2 while it was originally 1, but the only use for that storage reading was
only a require checking if the variable is positive).
The point of those examples is just to say that there are lots of specific classes
of situations where our parallelization algorithm doesn't work optimally.11 So
this means depending on the exact structure of κ, there are lots of long-tail
optimizations for us to devise vastly different parallelization algorithms for
optimal performance. We will come back to exact optimizations for this in the
next post.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 11/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
Conclusion
EVM parallelization facilitates Ethereum's throughput increase without
compromising on decentralization or requiring major changes to the protocol.
The adoption and open sharing of research on parallel EVMs can also help to
minimize economic centralization from MEV by allowing more individuals to
use better bundle merging and production.
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 12/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 13/14
4/11/23, 3:17 AM Speeding up the EVM (part 1) | Flashbots
https://web.archive.org/web/20220123202224/https://writings.flashbots.net/research/speeding-up-evm-part-1/ 14/14