Skip to content
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

Merged
merged 15 commits into from
Oct 23, 2024

Conversation

Trantorian1
Copy link
Collaborator

@Trantorian1 Trantorian1 commented Oct 19, 2024

Pull Request type

  • Refactoring (no functional changes, no API changes)

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?

  • Versioning is now a seperate rpc middleware layer. This means it will be applied to both http and ws rpc requests.

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 format starknet_{version}_{method}

  • Rpc middleware has been seperated into RpcMiddlewareLayerMetrics and RpcMiddlewareLayerRateLimit 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).

@Trantorian1 Trantorian1 added the rpc-0.8.0 Implementation of the new rpc specs label Oct 19, 2024
@Trantorian1 Trantorian1 self-assigned this Oct 19, 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 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
Copy link
Member

@cchudant cchudant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool!

@antiyro antiyro merged commit 7ef09fb into main Oct 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rpc-0.8.0 Implementation of the new rpc specs
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants