-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API] add batch size limit for jsonrpc #3805
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3805 +/- ##
==========================================
+ Coverage 74.47% 75.40% +0.93%
==========================================
Files 269 303 +34
Lines 23925 25855 +1930
==========================================
+ Hits 17818 19496 +1678
- Misses 5174 5340 +166
- Partials 933 1019 +86
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
only the message body size is limited here(15M), there needs to limit jsonRPC batch request array size. |
api/web3server.go
Outdated
@@ -41,6 +41,7 @@ type ( | |||
} | |||
|
|||
web3Handler struct { | |||
cfg Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can just add batchSizeLimit
, since web3handler does not need the entire Config
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
api/web3server.go
Outdated
@@ -81,10 +82,11 @@ func init() { | |||
} | |||
|
|||
// NewWeb3Handler creates a handle to process web3 requests | |||
func NewWeb3Handler(core CoreService, cacheURL string) Web3Handler { | |||
func NewWeb3Handler(core CoreService, cfg Config) Web3Handler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(core CoreService, limit uint16)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cacheURL string
also from cfg Config
api/web3server.go
Outdated
@@ -41,8 +41,9 @@ type ( | |||
} | |||
|
|||
web3Handler struct { | |||
coreService CoreService | |||
cache apiCache | |||
batchSizeLimit uint16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
batchSizeLimit int
api/web3server.go
Outdated
return &web3Handler{ | ||
coreService: core, | ||
cache: newAPICache(15*time.Minute, cacheURL), | ||
batchSizeLimit: cfg.BatchSizeLimit, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert type here
SonarCloud Quality Gate failed. 0 Bugs No Coverage information |
* add batch size limit for jsonrpc
Description
Limit the count of batch requests in websocket
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist: