OpenZeppelin / OpenZeppelin/Event-Scanner
Optimise reorg check in CollectLatest mode by deferring to end of collection
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 19
- Forks
- 7
- Avg merge
- 2h 15m
- Merged PRs (30d)
- 4
Description
Summary
Reduce RPC calls by performing the reorg check only once after the last block range is streamed, rather than checking on every ReorgDetected notification during collection.
Background
Currently, in rewind mode, the scanner handles ReorgDetected notifications as they arrive, invalidating collected logs immediately. This is correct but potentially wasteful since:
- Reorgs are rare, especially during the collection phase
- Each reorg check may trigger additional processing
Proposed Optimisation
Defer the reorg check until the collection phase completes. Based on the assumption that reorgs are rare, this reduces unnecessary work in the common case.
Implementation Challenges
Because the event scanner stops BRS (Block Range Scanner) as soon as it collects enough events, BRS can't simply perform a reorg check at the end of the specified rewind block range.
Potential solutions:
- Add a callback/hook mechanism for the scanner to request a reorg check on-demand
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.
Research direction
Start with the CollectLatest and rewind collection flow, including ReorgDetected handling and the point where BRS stops after enough events are collected. Determine how an on-demand reorg check could run once after the final streamed block range while preserving log invalidation correctness. Done means the common collection path avoids repeated reorg checks without changing scanner results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100