An open API service indexing awesome lists of open source software.

https://github.com/scroll-tech/reth-witness-indexer

A Reth Execution Extension (ExEx) that indexes Ethereum execution witnesses for stateless validation.
https://github.com/scroll-tech/reth-witness-indexer

Last synced: 2 days ago
JSON representation

A Reth Execution Extension (ExEx) that indexes Ethereum execution witnesses for stateless validation.

Awesome Lists containing this project

README

          

# Reth Witness Indexer

A Reth [Execution Extension (ExEx)](https://reth.rs/exex/overview) that indexes Ethereum [execution witnesses](https://docs.rs/alloy-rpc-types-debug/latest/alloy_rpc_types_debug/struct.ExecutionWitness.html) for stateless validation.

## Overview

Historical state reconstruction can be a bottleneck. As a result, extracting execution witnesses for historical blocks can be extremely slow, and often requests can timeout.

This project captures execution witnesses as blocks are committed to the chain and stores them in a database (reth-db/MDBX). These indexed witnesses can then be retrieved via JSON-RPC.

### Features

- **Real-time indexing**: Extracts witnesses by re-executing blocks against parent state
- **Reorg handling**: Automatically removes witnesses for reverted blocks
- **Pruning**: Two strategies available:
- **Periodic**: Keeps only the N most recent blocks
- **Event-driven**: Prunes up to a block number received via channel (useful for zk-rollups finalizing on L1)
- **JSON-RPC API**: Query witnesses by block number or hash (`indexed_witnessByNumber`, `indexed_witnessByBlockHash`)

### Modules

| Module | Description |
|----------|---------------------------------------------------------------|
| `db` | Database trait and reth-db implementation for witness storage |
| `exex` | Core `WitnessIndexer` ExEx that processes chain notifications |
| `pruner` | Background pruning task with configurable policies |
| `rpc` | JSON-RPC server under the `indexed` namespace |
| `error` | Error types for RPC operations |

## Build

```bash
# Build library
cargo build

# Build binary
cargo build --release --bin reth-witness-indexer --features=build-binary
```

## Test

```bash
# Run all tests
RUST_LOG=reth-witness-indexer=trace cargo test --all-features

# Run tests with reproducible randomness
SEED=12345 cargo test --all-features
```

## Usage

The binary can be run with standard reth CLI arguments plus indexer-specific options:

```bash
reth-witness-indexer node \ # other `reth node` CLI options
--reth-witness-indexer.start-block \
--reth-witness-indexer.max-backfill-distance \
--reth-witness-indexer.include-headers \
--reth-witness-indexer.pruner.interval \
--reth-witness-indexer.pruner.n-recent
```

## Dependencies

Built against [reth v1.10.2](https://github.com/paradigmxyz/reth/releases/tag/v1.10.2).