No description
  • Rust 91.1%
  • JavaScript 4.5%
  • Shell 4.4%
Find a file
2026-01-30 02:47:43 -08:00
.github k8s init 2025-09-15 12:13:53 +02:00
.ubuntu feat: added update and docker compose plugin 2024-05-09 13:17:02 +02:00
crates FDG as optional 2025-12-19 02:47:33 -08:00
docker Add dockerfile 2025-12-19 02:35:48 -08:00
k8s Merge branch 'main' of github.com:HerodotusDev/L2-indexer 2026-01-30 02:47:43 -08:00
migrations Add initial schema + base mainnet 2025-12-18 06:12:00 -08:00
scripts Instance setup + CI/CD 2024-05-03 11:45:49 +02:00
.gitignore add support for apechain sepolia aka curtis 2025-04-01 17:20:37 +01:00
Cargo.lock Use newer rust version 2025-09-17 16:01:42 +02:00
Cargo.toml fdg base 2025-12-18 07:14:52 -08:00
docker-compose.yml feat: unless stoped policy added to prevent stuff go sideways on reboots 2024-05-09 13:28:05 +02:00
LICENSE License 2023-10-25 16:32:14 +09:00
Makefile.toml more fixes 2024-05-03 12:47:41 +02:00
pm2.config.js add ape chain mainnet 2025-05-29 12:17:34 +01:00
README.md cleanup; added deployment blocks; changed endpoint to get; better setup/cleanup process; 2024-04-25 15:14:36 +02:00

L2 Indexer

This repo implements an indexer whose role is to watch for L2 rollups events emitted on Ethereum and index the Output Roots into a database for querying later -- providing examples for Arbitrum, Optimism, Base, Zora chain

Supported Networks

Type Network Network Detail Support
Arbitrum Arbitrum mainnet
Arbitrum Arbitrum sepolia
OP Stack Base mainnet
OP Stack Base sepolia
Optimism Optimism mainnet
Optimism Optimism sepolia
OP Stack Zora mainnet

Architecture

  1. Monitor Events: Run monitoring service that gets network spec as pm2 config. It keeps track OP Stack rollup & Arbitrum that emitted block hash preimage(Output Root) on the L1 contract.
  2. L2 Micro Service: Rust HTTP micro-service provides L2 information including block hash requested by block number.

Monitoring service:

Monitor events (OutputProposed) from L1 contract. Retrieve output_root

First check table is exist. If it's exist, get latest L1 block that stored in db, and use this block number as from_block filter. If it's not exist, create table and query all events from 0 to latest block - BLOCK_DELAY.

Monitor service will pull every POLL_PERIOD. If POLL_PERIOD is longer than block creation time, the service algorithm is already ensure to get not duplicated event. Here is the example log:

example log

output_root = 0x43949a1178f9fbcd851c5f6103603d7f7df0c05e399d09c7edb96ef4281a9d25, l2OutputIndex = 2873, l2BlockNumber = 110408263, l1Blocknumber = 18276691, l1Timestamp = 1696416911, l1_transaction_hash=0xbf90fd89af4a580695abd69bccce1ed3ef426e72021ee3c7e0aad2f4b3d8375d, l1_transaction_index=195, L1_block_hash=0x3d05fd1575b8b38b08a1e8d2a4253b09fba7e01f72e66e8c19eec0a3b39bc62f
from 18276743 to 18276747, 0 pools found!
from 18276748 to 18276752, 0 pools found!
from 18276753 to 18276757, 0 pools found!

Block number -> Output Index mapper Microservice

Request with l2_block_number, network_name return l2_output_root and l2_block_number. In this case, we can query the database directly:

  SELECT l2_output_root, l2_output_index, l2_block_number, l1_timestamp, l1_transaction_hash, l1_block_number, l1_transaction_index, l1_block_hash
            FROM optimism
            WHERE l2_block_number >= $1
            ORDER BY l2_block_number ASC
            LIMIT 1;

So that it return the nearest, but newer blocknumber from what was requested.

Endpoint:

http://127.0.0.1:8000/output-root?network=optimism_sepolia&l2_block=1

How to run

  1. Use the setup script
./setup.sh
  1. When developing rebuild and restart the services
./restart.sh
  1. Check the logs, start, stop services manually, etc. - use pm2

  2. Cleanup everything

./cleanup.sh

License

l2_indexer is licensed under the GNU General Public License v3.0.


Herodotus Dev Ltd - 2024