eth/filters: honor context cancellation in bor block-log range scan#2259
Draft
lucca30 wants to merge 1 commit into
Draft
eth/filters: honor context cancellation in bor block-log range scan#2259lucca30 wants to merge 1 commit into
lucca30 wants to merge 1 commit into
Conversation
BorBlockLogsFilter.unindexedLogs iterated the full block range without ever
checking the request context, so a cancelled request (client disconnect or an
expired deadline) kept scanning and held its RPC worker until the whole range
was exhausted. Upstream go-ethereum eth/filters/filter.go performs this check
at the top of its unindexedLogs loop; the bor copy omitted it.
Add the same select{<-ctx.Done()} guard so a range scan stops promptly when
the caller is gone, and add tests covering both cancellation and deadline.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2259 +/- ##
===========================================
- Coverage 53.41% 53.40% -0.02%
===========================================
Files 896 896
Lines 159713 159721 +8
===========================================
- Hits 85314 85302 -12
- Misses 69071 69090 +19
- Partials 5328 5329 +1
... and 16 files with indirect coverage changes
🚀 New features to boost your workflow:
|
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.


What
BorBlockLogsFilter.unindexedLogsscans a block range one sprint at a time butnever checked the request context, so a request whose context was cancelled —
the client disconnected, or a deadline fired — kept scanning the full range and
held its RPC worker until the range was exhausted.
Upstream go-ethereum performs this check at the top of its
unindexedLogsloop(
eth/filters/filter.go); the bor block-log filter omitted it.Change
Restore parity with a
select { case <-ctx.Done(): ... }guard at the top ofthe loop, so a range scan stops promptly once the caller is gone. With the
context now observed, any deadline attached upstream (e.g. an operator-configured
RPC timeout) also bounds the scan.
Why
Without the check, a long range query keeps consuming a worker after its result
can no longer be delivered, reducing the RPC server's effective capacity under
cancelled or abandoned requests. The fix is small and matches the canonical
go-ethereum loop.
Changes
eth/filters/bor_filter.go: add the context-cancellation check to theunindexedLogsscan loop.eth/filters/bor_filter_test.go: addTestBorFilterHonorsContextCancellationand
TestBorFilterHonorsContextDeadline.Testing
go test ./eth/filters/— all pass (28).already-cancelled context and returned a nil error) and pass with the fix.