No description
  • Cairo 41.6%
  • Python 31.6%
  • Solidity 14%
  • Rust 11.3%
  • Makefile 1%
  • Other 0.5%
Find a file
2025-04-03 15:03:22 +01:00
.github initial 2024-08-22 16:24:11 +01:00
audit initial 2024-08-22 16:24:11 +01:00
cairo_vm_hints rust hints & inputs python compatibility 2025-04-03 15:03:22 +01:00
solidity-verifier updated PROGRAM_HASH 2024-12-11 12:05:36 +01:00
src Merge branch 'rust_hints' 2025-04-03 15:02:49 +01:00
tests rust hints & inputs python compatibility 2025-04-03 15:03:22 +01:00
tools Merge branch 'rust_hints' 2025-04-03 15:02:49 +01:00
.gitignore hints refactored & fmt 2024-10-30 11:40:59 +01:00
.gitmodules forge install: openzeppelin-contracts 2024-08-25 16:26:49 +01:00
.nvmrc initial 2024-08-22 16:24:11 +01:00
Cargo.lock rust hints & inputs python compatibility 2025-04-03 15:03:22 +01:00
Cargo.toml rust hints & inputs python compatibility 2025-04-03 15:03:22 +01:00
LICENSE initial 2024-08-22 16:24:11 +01:00
Makefile initial 2024-08-22 16:24:11 +01:00
README.md initial 2024-08-22 16:24:11 +01:00

Off-chain EVM Headers Processor


This repository implements the logic of building and maintaining two Merkle Mountain Ranges (MMRs) containing only provably valid Ethereum block headers.

Visualization of an MMR merkle mountain range tree

Building the MMRs happens off-chain and is proven using a Cairo program in the src directory. The CAIRO program takes as an input a blockhash passed by the verifier to then provide preimages to the given blockhash or a decoded parent hash that must be valid block headers.

Please read src/single_chunk_processor/README.md for more details about the chunk processor.

Visualization of the linkage between blocks. linked blocks

The 2 MMRs store the same data and have the same size however are built with two different hash functions:

  • Poseidon over the stark field
  • Keccak256 The values at the bottom of the MMR are keccak/poseidon hashes of the RLP encoded block headers.

The Starkware SHARP generates the proofs, and the proof verification happens on-chain. The resulting facts are then aggregated by the contracts implemented in the directory solidity-verifier.

Offchain processing

Create a virtual environment and install the dependencies (one-time setup)

make setup

After that and every time you get back to the repo, you will need to activate the virtual environment by doing:

source venv/bin/activate

Run Cairo unit tests

make test

Get the chunk processor program's hash

make get-program-hash

This command computes the hash of the main chunk processor program and outputs it to stdout. It is used to make sure that STARK proofs of this program are indeed relative to the chunk processor. The hash is hardcoded in the solidity contract that verifies SHARP facts.

Prepare inputs for the chunk processor, SHARP submitting & more

The general workflow is as follows:

  1. Update the database of block headers
  2. Prepare the inputs and expected outputs for the chunk processor
  3. Run the chunk processor to create PIE objects
  4. Submit those PIE objects to SHARP to prove the execution.

For more details about the other make commands and test the repository, see tools/make/README.md.

Onchain Solidity verifier (SHARP verifier)

See solidity-verifier/README.md for more details.

Additional data

Max Resources per mainnet SHARP Job:

Resource Value
Steps 16,777,216
RC 1,048,576
Bitwise 262,144
Keccaks 8,192
Poseidon 524,288

Chunk processor program hash :

0x1eca36d586f5356fba096edbf7414017d51cd0ed24b8fde80f78b61a9216ed2

Herodotus Dev Ltd - 2023.