Conversation
…lation in eth_getLogs Address and topic lists in eth_getLogs, eth_newFilter and the logs WebSocket subscription were unbounded, and the range scan ignored the request context, so one oversized query could keep a core busy for minutes after the caller disconnected. Mirror go-ethereum: 4 topic positions, 1000 entries per list. Check ctx.Err() before each block fetch.
This comment has been minimized.
This comment has been minimized.
|
@claude review |
|
Claude finished @JayT106's task in 2m 1s —— View job Code Review — fix(rpc): cap log filter address/topic lists and honor context cancellation
SummaryThis PR addresses a real RPC-node DoS vector: unbounded address/topic lists in Findings1. Sentinel errors are unexported — external callers can't use
|
NewRangeFilter already hashed every address and topic into BloomIV but blockLogs ignored them and re-ran keccak per entry per block. Compute the IVs in newFilter for both constructors and test the bloom bytes directly. 1000 addresses over 10000 blocks: ~3s -> 5.4ms.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1109 +/- ##
===========================================
+ Coverage 47.08% 47.43% +0.34%
===========================================
Files 200 200
Lines 17648 17657 +9
===========================================
+ Hits 8310 8376 +66
+ Misses 8476 8417 -59
- Partials 862 864 +2
🚀 New features to boost your workflow:
|
Signed-off-by: JayT106 <JayT106@users.noreply.github.com>
What
Bound address/topic lists in
eth_getLogs,eth_newFilterand thelogsWebSocket subscription, stop the range scan on context cancel, and match blocks against precomputed bloom bit positions.Issue
crit.Addresses/crit.Topics. The WebSocket parser builds criteria by hand, so go-ethereum'sUnmarshalJSONtopic limits don't apply there either.blockLogsran one keccak per address per block. 100k addresses (fits in the 5MB body limit) × 10k blocks ≈ 5 min CPU per request.Filter.Logsignoredctx, so the scan kept running after the client disconnected.NewRangeFilteralready precomputedbloomFilters [][]BloomIVbut nothing read it.RPC-node DoS only.
Solution
ValidateCriteria: max 4 topic positions, 1000 addresses, 1000 alternatives per position (go-ethereum defaults). Called fromGetLogs,NewFilter,subscribeLogs. Returns-32602.Filter.Logschecksctx.Err()before each block fetch.blockLogstests bloom bytes viabloomMatchesusing the precomputed IVs; keccak-per-lookupbloomFilterdeleted. Bloom is a prefilter only, exact match still inFilterLogs.1000 addresses × 10k blocks: ~3s → 5.4ms.