fix: start onchain events ingest from latest block by default#745
Open
aditiharini wants to merge 4 commits into
Open
fix: start onchain events ingest from latest block by default#745aditiharini wants to merge 4 commits into
aditiharini wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts the default onchain events ingestion start point so new validator nodes don’t backfill from the beginning of chain history when no explicit bounds are configured.
Changes:
- Introduces a default live-sync start offset from the chain head (
LIVE_SYNC_BLOCK_OFFSET). - Updates the
Subscriber::run()default start-block logic to use(latest_on_chain - offset)as the baseline.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Three issues raised in review: 1. Silent skip when DB is behind tip - offset (regression). The original default_start.max(latest_block_in_db) only protects when the DB is ahead of the offset window. After long downtime or restoring from a stale snapshot, latest_block_in_db < tip - offset, so the node would jump forward and permanently miss onchain events in the gap. Resume from the DB checkpoint whenever one exists; only use the offset for a truly fresh start. 2. default_start could fall below the contract-deployment block on chains where the tip is near genesis (testnets, future chains). Clamp to first_block(chain) so we don't issue invalid pre-deployment RPC log queries. 3. No unit coverage for the start-block selection. Extract the logic into a pure associated fn (live_sync_start_block) and cover: empty DB → tip - offset, empty DB near genesis → clamps to first_block, empty DB with tiny tip (saturating_sub edge) → clamps to first_block, DB ahead of default → resume from DB, DB behind default → resume from DB (the regression guard). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diff CoverageDiff: origin/main...HEAD, staged and unstaged changes
Summary
src/connectors/onchain_events/mod.rs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When starting a new validator node we end up picking up all blocks from beginning of history by default rather than starting at current. Fix this by starting at current if no explicit bounds are specified.