rpc: add method name length limit and configurable message size limit#3063
Merged
alex-10072 merged 2 commits intodevelopfrom May 6, 2025
Merged
rpc: add method name length limit and configurable message size limit#3063alex-10072 merged 2 commits intodevelopfrom
alex-10072 merged 2 commits intodevelopfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces two improvements to the RPC system: enforcing a 256-character limit on RPC method names and enabling configurable WebSocket message size limits.
- Added validations in the RPC handler for both standard and subscription method calls to enforce the method name length limit.
- Modified the WebSocket handler and related configuration to accept a messageSizeLimit parameter, with corresponding test updates.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rpc/websocket_test.go | Updated WebsocketHandler invocations and added tests for method name length limit. |
| rpc/websocket.go | Modified WebsocketHandler signature and logic to use a configurable messageSizeLimit. |
| rpc/json.go | Defined maxMethodNameLength constant. |
| rpc/handler.go | Added method name length validation in handleCall and handleSubscribe. |
| rpc/client_test.go | Updated WebsocketHandler invocations to pass messageSizeLimit. |
| node/rpcstack.go | Updated WebsocketHandler instantiation to accept messageSizeLimit from config. |
| node/node.go | Forwarded WSMessageSizeLimit from node configuration. |
| node/config.go | Added WSMessageSizeLimit configuration field. |
| node/api.go | Propagated WSMessageSizeLimit in API setup. |
41d7dd7 to
765de8b
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces two improvements to the RPC system: enforcing a 256‑character limit on RPC method names and making the WebSocket message size limit configurable.
- Adds checks in both regular calls and subscription requests for method name length limits.
- Propagates a new configurable messageSizeLimit parameter throughout the server, client tests, and node configurations.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rpc/websocket_test.go | Updates tests to pass an explicit messageSizeLimit parameter and adds tests for method name length limits. |
| rpc/websocket.go | Modifies the WebsocketHandler signature to accept and use messageSizeLimit. |
| rpc/json.go | Introduces a constant for maxMethodNameLength. |
| rpc/handler.go | Adds error responses for method/subscription name lengths exceeding the limit. |
| rpc/client_test.go | Updates WebsocketHandler invocations to include a messageSizeLimit parameter. |
| node/* | Passes the new messageSizeLimit from node configuration to the RPC stack. |
alex-10072
approved these changes
May 5, 2025
Contributor
|
similar PR in Go-Ethereum: https://github.com/ethereum/go-ethereum/pull/31711/files |
buddh0
approved these changes
May 6, 2025
This was referenced May 16, 2025
Merged
galaio
pushed a commit
to galaio/bsc
that referenced
this pull request
May 29, 2025
galaio
pushed a commit
to galaio/bsc
that referenced
this pull request
May 29, 2025
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.
This PR introduces two important improvements to the RPC system:
Both changes maintain backward compatibility: