hotfix(jsonrpc): restrict the newFilter size#71
hotfix(jsonrpc): restrict the newFilter size#71317787106 wants to merge 12 commits intorelease_v4.8.1from
Conversation
…newFilter, eth_newBlockFilter
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
2 issues found across 10 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpcImpl.java">
<violation number="1" location="framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpcImpl.java:236">
P0: The `ForkJoinPool` is created on every `handleLogsFilter` call but never shut down. This leaks worker threads on each invocation. Either shut down the pool in a `finally` block after `join()`, or make it a static/instance-level field that is reused across calls.</violation>
<violation number="2" location="framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpcImpl.java:1431">
P2: Inconsistent boundary check: block filter uses `>=` but log filter uses `>`, allowing one extra filter beyond `maxLogFilterNum`. Use `>=` to match the block filter behavior.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…e addAll matchedLog instead after
What does this PR do?
Why are these changes required?
This PR has been tested by:
Follow up
Extra details
Summary by cubic
Adds a configurable cap on active
eth_newFilterlog filters to prevent memory pressure and abuse. Optimizes log filtering by using a small, bounded ForkJoinPool only when many filters are present, and adds processing time logs.New Features
node.jsonrpc.maxLogFilterNum.eth_newFilterreturnsJsonRpcExceedLimitExceptionwith code-32005.CommonParameter,Constant, andArgs; updatedconfig.confand test configs.Bug Fixes
EventBloomExceptioninManager.switchForkto handle fork-related bloom errors safely.LogMatch.matchBlockOneByOne, checkMAX_RESULTbefore adding results to avoid overshooting limits.Written for commit 20f0cc1. Summary will update on new commits.