Skip to content
/ pevm Public
forked from risechain/pevm

Blazingly fast Parallel EVM

License

Notifications You must be signed in to change notification settings

akfork/pevm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RISE Parallel EVM

CI

Blazingly fast Parallel EVM in Rust.

⚠️ This repository is a work in progress and is not production ready 🚧

Banner

RISE pevm is a parallel execution engine for EVM transactions heavily inspired by Block-STM. Since Blockchain transactions are inherently sequential, a parallel execution engine must detect dependencies and conflicts to guarantee the same deterministic outcome with sequential execution. Block-STM optimistically executes transactions and re-executes when conflicts arise using a collaborative scheduler and a shared multi-version data structure. Since it does not require prior knowledge or constraints on the input transactions, replacing an existing sequential executor with Block-STM is easy for substantial performance boosts.

Block-STM was initially designed for the Aptos blockchain that runs MoveVM. We must consider several modifications to make it work well with EVM. For instance, all EVM transactions in the same block read and write to the beneficiary account for gas payment, making all transactions interdependent by default. We must carefully monitor reads to this beneficiary account to lazily evaluate it at the end of the block or when an explicit read arises.

While Polygon has adapted a version of Block-STM for EVM in Go, it is still slower than sequential execution in Rust and C++. On the other hand, our redesign and Rust implementation have achieved the fastest execution speed of any public EVM executor.

Finally, while Aptos and Polygon embed their pevm implementation directly into their nodes, this dedicated repository provides robust versions and a playground for further advancements. For instance, we can introduce static-analysed metadata from an optimised mempool, support multiple underlying executors, track read checkpoints to re-execute from upon conflicts and hyper-optimise the implementation at low system levels.

Goals

  • Become the fastest EVM (block) execution engine for rapid block building and syncing — 10 Gigagas/s and beyond.
  • Provide deep tests and audits to guarantee safety and support new developments.
  • Provide deep benchmarks to showcase improvements and support new developments.
  • Complete a robust version for syncing and building blocks for Ethereum, RISE, Optimism, and more EVM chains.
  • Get integrated into Ethereum clients and ZK provers like Reth, Helios, and Zeth to help make the Ethereum ecosystem blazingly fast.

Development

⚠️ Warning pevm is performing poorly in recent Linux kernel versions. We noticed huge performance degradation after updating a machine to Ubuntu 24.04 with Linux kernel 6.8. The current suspect is the new EEVDF scheduler, which does not go well with pevm's scheduler & thread management. Until we fully fix the issue, it is advised to build and run pevm on Linux kernel 6.5.

  • Install cmake to build snmalloc (a highly performant memory allocator).

Alpha Done

  • Build a Block-STM foundation to improve on.
  • Lazily update gas payments to the beneficiary account as implicit reads & writes.
  • Lazily update raw transfer senders & recipients as implicit reads & writes.
  • Improve scheduler design & aggressively find tasks to save scheduling cycles.
  • Many low-level optimisations.
  • Complete foundation test & benchmark suites.

Alpha TODO

  • Complete OP & RISE support.
  • Lazily update ERC-20 transfers.
  • Robust error handling.
  • Better types and API for integration.
  • More low-hanging fruit optimisations.
  • Complete a Reth integration for syncing and building Ethereum and RISE blocks.

Future Plans

  • Optimise concurrent data structures to maximise CPU cache and stack memory.
  • Optimise the scheduler & worker threads to minimise synchronization.
  • Add pre-provided metadata (DAG, states to preload, etc.) from a statically analysed mempool and upstream nodes.
  • Custom memory allocators for the whole execution phase and the multi-version data structure.
  • Track read checkpoints to re-execute from instead of re-executing the whole transaction upon conflicts.
  • Support multiple EVM executors (REVM, JIT & AOT compilers, etc.).
  • Hyper-optimise at low system levels (kernel configurations, writing hot paths in Assembly, etc.).
  • Propose an EIP to "tax" blocks with low parallelism.
$ cargo build

Testing

We have three test groups:

$ git submodule update --init
# Running our heavy tests in parallel would congest resources.
# Each test still executes parallelly anyway.
$ cargo test --release -- --test-threads=1

Benchmarks

See the dedicated doc here.

About

Blazingly fast Parallel EVM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.1%
  • Python 0.9%