-
Notifications
You must be signed in to change notification settings - Fork 30
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
refactor(rpc): re-worked rpc tower server and added proper websocket support #350
Conversation
This file contains 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
jbcaron
reviewed
Oct 21, 2024
This is the start of an effort to delegate more of the request validation to the proxy instead of Madara handling it manually. In the future, this should also include rate limiting logic.
antiyro
changed the title
refactor(rpc): refactor(rpc): re-worked rpc tower server and added proper websocket support
refactor(rpc): re-worked rpc tower server and added proper websocket support
Oct 21, 2024
akhercha
approved these changes
Oct 21, 2024
jbcaron
reviewed
Oct 22, 2024
cchudant
approved these changes
Oct 23, 2024
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.
cool!
jbcaron
approved these changes
Oct 23, 2024
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.
Pull Request type
What is the current behavior?
Current RPC tower server was inherited from Substrate and is a bit of a mess, especially in how method versioning and websockets are handled. This pr fixes this.
What is the new behavior?
Note
Previously, the
VersionMiddleware
would only apply to http rpc requests and so any ws request to a starknet method would have to be of the formatstarknet_{version}_{method}
RpcMiddlewareLayerMetrics
andRpcMiddlewareLayerRateLimit
for ease of development.Warning
The current way by which I am communicating rate limiting between layers is questionable and any feedback is much appreciated.
The
versioned_starknet_rpc
macro has been rewritten to be more hygenic and no longer overwrites macro attributes other than#[method]
.Rpc call
rpc_methods
has had its output reworked to more closely resemble the actual rpc call api.Added some documentation on the rpc service explaining how this all ties together.
Does this introduce a breaking change?
No
Other information
Some debug logging has been left as part of an effort in instrumenting the rpc server with more runtime debug information. This mostly serves as a placeholder atm, as I would like to add more logging once #348 has been merged.
Please let me know what you think about this. I personally believe more observability would be quite nice (could enable output to a log file through a cmd line flag for example). Note that this does not even need to have any runtime overhead as we could disable debug logging under the production build flag (I'm not sure that would be a good idea though).