Fix bridging backfill gap in RPC log streamer#1903
Open
xmtp-coder-agent wants to merge 3 commits intoxmtp:mainfrom
Open
Fix bridging backfill gap in RPC log streamer#1903xmtp-coder-agent wants to merge 3 commits intoxmtp:mainfrom
xmtp-coder-agent wants to merge 3 commits intoxmtp:mainfrom
Conversation
The RPC log streamer was missing logs between the HTTP RPC head (where backfill ends) and the WS head (where the subscription starts). This happened because buildSubscription set FromBlock to the WS head but never communicated that value back to watchContract, so there was no bridging fetch between the two endpoints. Return the subscription start block from buildSubscription and buildSubscriptionWithBackoff, then perform a bridging backfill loop after the initial backfill completes to cover any gap before entering the subscription loop. Resolves xmtp#1889 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…kfill - GetNextPage now returns NextBlockNumber on ErrEndOfBackfill so the caller advances past already-fetched blocks instead of re-fetching from the original start block - Remove redundant if-check before bridging loop - Simplify test: replace goto + redundant verification with simple loop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
GetNextPage returns nil NextBlockHash on ErrEndOfBackfill since the next block header can't be fetched beyond the chain head. Preserve the existing backfillFromBlockHash when NextBlockHash is nil to prevent NewUpdateProgressLog from panicking on a zero-length slice to [32]byte conversion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
I don't know enough about the indexer to be able to properly review this. The original issue came from the security audit, even though it's a correctness issue. @fbac do you mind taking a look at #1889 and seeing if it makes sense. The high level premise is that RPC providers might load balance your requests to different instances, and the web socket and HTTP request could be in different states. The solution looks a little ugly and over-complicated, but it does seem like a real (even if edge) potential issue. Would be very bad if our indexer could skip over messages. |
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.
Summary
Resolves #1889
buildSubscriptionandbuildSubscriptionWithBackoffto return the WS head block number used as the subscription'sFromBlockwatchContractthat runs after the initial backfill completes, fetching any logs between the HTTP head and the WS subscription start blockTest plan
TestRpcLogStreamerpassesTestBridgingBackfillvalidates gap coverage: HTTP head=10, WS head=15, verifies logs at block 12 are fetched via bridgingdev/lint-fixpasses with 0 issues🤖 Generated with Claude Code
Note
Fix bridging backfill gap between HTTP head and WS head in RPC log streamer
watchContract, a bridging backfill loop now fetches logs for any blocks between the HTTP head and the WS subscription start block before processing subscription events.buildSubscriptionandbuildSubscriptionWithBackoffnow return the WS head block number used to initialize the subscription, sowatchContractknows where to stop the bridging loop.GetNextPagenow setsNextBlockNumbertotoBlock+1(previouslynil) when returningErrEndOfBackfill, which the bridging loop relies on to advance correctly.TestBridgingBackfilltest simulates an HTTP head at block 10 and WS head at block 15, asserting logs at block 12 are emitted during bridging.Macroscope summarized 0470a5e.