DraftEngineering
Building Idempotent Indexers
Retries are the common case. An indexer that appends on retry duplicates the chain.
Context
RPC timeouts, process restarts and reorg repairs all re-process blocks that may already be stored.
Method
Inserts are keyed by block hash. A retry for the same hash replaces. A retry for a new hash at the same height is a reorg, not a duplicate.
Findings
Draft. The first writer used block_number as the key and duplicated every repaired block.
Implications for the data model
Uniqueness is (block_number, block_hash) at the raw layer and (tx_hash, log_index) at the decoded layer.