
Designing a Crash-Safe, Idempotent EVM Indexer in Rust
Building a data pipeline that survives failures without corrupting state Data pipelines don’t fail because they’re slow. They fail because they write partial state, retry blindly, and restart into inconsistency. When building an EVM indexer, the real challenge isn’t fetching blocks — it’s answering a harder question: If the process crashes halfway through indexing a block, what state does the database end up in? If the answer is “it depends,” the system isn’t safe. This article walks through how I designed a Rust-based EVM indexer that: Processes blocks atomically Is safe to retry Never commits partial state Recovers deterministically after crashes Avoids duplicate data without sacrificing correctness Stack: Rust (Tokio) ethers-rs for RPC PostgreSQL SQLx Axum for query API The Real Problem: Partial State Let’s say block N contains: 120 transactions 350 logs Naively, you might: Insert block Insert transactions Insert logs Update checkpoint But what if the process crashes after inserting
Continue reading on Dev.to
Opens in a new tab

