7 Common Mistakes in Blockchain Data Indexing (and How to Fix Them)
Review blockchain indexing failure modes, including reorgs, RPC calls, start blocks, validation, and provider outages.
Incorrect balances, missing chart data, and stalled syncs can originate in the indexing layer. Review reorg handling, RPC calls, start blocks, validation, and provider dependencies before relying on indexed data in production.
The following sections describe failure modes and ways to address them.
Mistake 1: Ignoring Chain Reorganizations
A block reorganization happens when the canonical chain switches to a competing fork. Blocks that appeared confirmed get replaced. If your indexer does not detect and roll back the orphaned state, you accumulate incorrect data silently.
This is not a theoretical concern. On high-throughput chains and during periods of network congestion, shallow reorgs (1–3 blocks) happen regularly. On proof-of-work networks they were more common and deeper.
Fix: Use an indexing framework or platform that tracks block hashes alongside block numbers and rolls back entity state when a reorg is detected. Never assume block number alone is sufficient for deduplication. When building custom indexers, implement a reorg window: hold the last N blocks of writes in a rollback buffer before committing them as final.
Mistake 2: Making eth_calls Inside Event Handlers
Every eth_call inside a handler is a synchronous RPC call that blocks the indexing process until it returns. During historical sync — which may span millions of blocks — this multiplies into hours or days of added sync time.
The symptom: a subgraph that works fine on testnet (low block count) but takes days to sync on mainnet.
Fix: Read contract metadata once when an entity is first initialized and store it on the entity. For fields like token name, symbol, and decimals, fetch them in the TokenCreated or PairCreated handler and cache them. All subsequent handlers read from entity storage, not from the chain.
Mistake 3: Starting Sync from Block 0
A subgraph or custom indexer configured to start from block 0 scans the entire chain history before reaching your contract. On Ethereum mainnet, that is over 20 million blocks — most of which contain no relevant events.
Fix: Set startBlock in your manifest to the block in which your contract (or the factory that created it) was deployed. You can find the exact deployment block on any block explorer. This single change routinely reduces initial sync time from days to hours.
Mistake 4: Conflating Indexer Uptime with Data Correctness
An indexer that is running is not necessarily an indexer that is correct. Silent data drift — where the indexed state diverges from chain state due to missed events, handler bugs, or reorg failures — is harder to detect than a crash.
Fix: Build correctness checks into your operations. At minimum: periodically compare indexed aggregate values (total deposits, total volume) against a direct on-chain calculation via RPC. For critical protocol state, run a secondary read path against the chain and alert when the two diverge beyond a threshold. Some teams maintain a "shadow indexer" on a separate platform as a cross-check.
Common Mistakes in Blockchain Data Indexing: Schema and Query Issues
Mistake 5: Designing the Schema Around Events Instead of Domain Objects
A common beginner mistake: creating one entity type per event type. SwapEvent, MintEvent, BurnEvent — each a flat record of the raw event data. The result is a schema that forces the frontend to join and aggregate data at query time, making GraphQL queries slow and complex.
Fix: Design entities around the domain objects your application cares about — pools, positions, users, protocol aggregates. Events are inputs that mutate these entities. The entity schema should reflect your application's read model, not your contract's event signatures.
Mistake 6: Not Handling Missing or Unexpected RPC Responses
Custom indexers that call RPC providers directly are exposed to malformed responses, rate limit errors, and occasional invalid data from the node. A single bad response that the handler does not validate can corrupt entity state or crash the indexer process.
Fix: Validate all RPC responses before processing. Implement retry logic with exponential backoff for transient errors. For data that must be correct (e.g., transfer amounts), add sanity bounds checks in handler logic and log anomalies for review rather than writing potentially corrupt state.
Mistake 7: Deploying a Subgraph Without a Fallback
Managed indexing services — including large, well-resourced ones — have outages. If your protocol's frontend has a hard dependency on a single subgraph endpoint, a provider outage takes your UI down.
Fix: Maintain at least one fallback. Options include: a secondary deployment on a different provider (The Graph + Goldsky, for example), a degraded read mode that falls back to direct RPC for critical queries, or a read replica of indexed data in your own database via a streaming pipeline. The appropriate solution depends on your protocol's tolerance for read downtime.
Test the indexing layer under load, during reorgs, and during provider outages. Discuss an indexing pipeline review with LinkIT.