Skip to content

A performant, type-1 zkEVM written in Rust & SP1.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

succinctlabs/sp1-reth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SP1 Reth

Telegram Chat

Warning

This repository is archived and no longer maintained.

SP1 Reth is a 100% open-source POC that showcases how any rollup can use SP1 to build a performant (type-1, bytecode compatible) zkEVM with less than 2000 lines of maintainable Rust code. SP1 Reth achieves incredible performance (around $0.01-0.02 proving cost for an average Ethereum transaction) by leveraging SP1’s open-source, customizable precompile system, with orders of magnitude improvements to come. SP1 Reth points to a future where all rollups can become ZK rollups, utilizing the magic of ZKPs with maintainable software written in Rust.

Blog Post | SP1 Repo | SP1 Docs

Requirements

To reproduce the benchmarks in our blog post, your system will need:

  • 64+ CPUs
  • 512+ GB RAM
  • NVME Hard Drive

We ran our benchmarks on a i4g.16xlarge instance on AWS. You may need to add a swap file on NVME.

Run

To build your program if the Rust version required by your libraries is greater than the Succinct toolchain's version:

cargo prove build --ignore-rust-version

Make sure you have mounted your NVME hard drive in a RAID0 setup with at raid0 with a tmp folder.

cd script
TMPDIR=/mnt/raid0/tmp \
SHARD_SIZE=524288 \
RUST_LOG="debug,p3_keccak_air=off" \
RUSTFLAGS="-C target-cpu=native" \
cargo run --release -- \
  --rpc-url <rpc_url> \
  --block-number <block_number>

Lines of Code

$ cloc --by-file --include-lang=Rust primitives program
      10 text files.
       8 unique files.
       5 files ignored.

github.com/AlDanial/cloc v 1.96  T=0.01 s (707.0 files/s, 264169.2 lines/s)
------------------------------------------------------------------------------------------
File                                        blank        comment           code
------------------------------------------------------------------------------------------
primitives/src/mpt.rs                         124            272           1022
primitives/src/processor.rs                    43             56            316
primitives/src/alloy2reth.rs                    8              3            145
primitives/src/db.rs                           19             11            134
primitives/src/lib.rs                          15             17             24
program/src/main.rs                             6              5             22
------------------------------------------------------------------------------------------
SUM:                                          215            364           1663
------------------------------------------------------------------------------------------

Security

This code has not yet been audited, and should not be used in any production systems.

Acknowledgements

We would like to acknowledge the projects below whose previous work has been instrumental in making this project a reality:

  • Reth: For providing an excellent execution client reference and primitives needed for processing blocks.
  • Revm: For providing core execution primitives and a performant EVM implementation.
  • Alloy: For providing core ethereum primitives and RPC methods.
  • Zeth: SP1 Reth is originally based on Zeth, but we chose to not fork Zeth directly because we noticed there was an opportunity to reuse significantly more code from Reth, Revm, and Alloy.