feat: reorg handling
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- rust
- Domain
- blockchain, databases, distributed-systems
Research direction
The issue points to tidx's sync/engine.rs and find_fork_point as a reference; start there, then locate Atlas's batch indexing, sinks, indexer_state, HeadTracker, and SSE paths. Done means canonical-chain reorgs are detected, orphaned and derived data are reconciled, indexing resumes correctly, and affected clients are handled.
Written by the indexing model from the issue text.
Description
Summary
Atlas currently has no chain reorganization handling. If the chain reorgs, previously indexed blocks may become orphaned and the explorer will serve inconsistent data (e.g., transactions that no longer exist on the canonical chain).
Motivation
Any EVM chain can experience reorgs. Without handling them, Atlas may:
- Show transactions/blocks that were reverted
- Miss the canonical replacement blocks
- Have inconsistent state in derived tables (ERC-20 balances, NFT ownership)
This is a correctness issue, not just a performance one.
Design
Detection
- On each new batch, validate the parent hash of the first block against the stored hash of the previous block
- If mismatch detected, walk back up to N blocks (e.g., 128) to find the fork point
Rollback
- Delete orphaned blocks and all associated data (transactions, logs, transfers, etc.) from the fork point onward
- For partitioned tables, deletion needs to target the correct partitions
- Update derived tables (ERC-20 balances, NFT ownership) — either recompute or reverse the orphaned changes
- Update
indexer_statewatermark to the fork point - Resume indexing from the fork point
Considerations
- Derived tables (erc20_balances, nft_tokens) make rollback more complex than raw-data-only indexers — may need to replay transfers from the fork point
- The
HeadTrackerin-memory buffer needs to be pruned of orphaned blocks - SSE clients should be notified of the reorg (new event type or resync signal)
- Configurable max reorg depth (default 128, matching tidx)
- Optional
trust_rpcflag to skip parent hash validation for trusted RPCs
References
- tidx implementation:
sync/engine.rs—find_fork_pointwalks back, deletes orphans from all sinks
- Dominant language
- Rust
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from evstack/atlas
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
feat: admin API Open
Difficulty 4/5 3-5 days Newbie friendliness 55/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100