-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: RPC Versioning #247
feat: RPC Versioning #247
Conversation
This reverts commit 84d7913.
Coverage reportThe coverage rate is
Diff Coverage details (click to unfold)crates/node/src/service/rpc/middleware.rs
crates/client/rpc/src/versions/v0_7_1/methods/read/lib.rs
crates/client/rpc/src/versions/v0_7_1/api.rs
crates/proc-macros/src/lib.rs
crates/client/rpc/src/test_utils.rs
crates/node/src/service/rpc.rs
crates/node/src/main.rs
crates/node/src/service/rpc/server.rs
crates/primitives/chain_config/src/rpc_version.rs
crates/client/rpc/src/lib.rs
|
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.
Approving this since it has been reviewed correctly in #242
Pull Request type
Please add the labels corresponding to the type of changes your PR introduces:
What is the current behavior?
Resolves: #NA
What is the new behavior?
Introduction of versions for our RPC API.
Versions are defined in the
mc-rpc::versions
module, organized as follow:All the implementations are then merged in our
RpcModule
in theversioned_rpc_api
function.Methods will be version-prefixed to avoid collisions, for example:
starknet_V0_7_1_blockNumber
,starknet_V0_8_0_blockNumber
The "routing" is done in the
VersionMiddlewareLayer
middleware, where depending on the version provided in the route by the request's user, we forward to the right method.If no version is provided, the latest RPC version available is used, defined in
RpcVersion::RPC_VERSION_LATEST
.Does this introduce a breaking change?
No
Possible improvement
I don't like the current process of adding a new version ; it is:
RpcVersion
primitive, like:pub const RPC_VERSION_0_7_1: RpcVersion = RpcVersion([0, 7, 1]);
SUPPORTED_RPC_VERSIONS
array,mc-rpc::versions
module,Lot of dependency between objects, the middleware also uses the
SUPPORTED_RPC_VERSIONS
array for routing.It is fine though because we don't have new versions everyday, that's an uncommon event.
But happy to hear your suggestions!