You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
P:integrator-experiencePriority: Improve experience for integratorsP:tech-debtPriority: Technical debt that needs to be paid off to enable us to move faster, reliablyrpc
At present, we support a single version of RPC API on a node. I propose we version our RPC API such that we can roll out substantial API changes in a non-breaking way.
Specifically, our current RPC API (JSON, HTTP, and Websocket) is available at the root of the node, e.g. /status, /block, etc.
We need to
Make our current RPC API is also available under a /v1 sub-path, e.g. /v1/status, /v1/block, etc.
JSON
Websocket
HTTP
Publish the extended API
With this change we can easily roll out new RPC API versions with "breaking" changes as compared to previous versions, e.g. under a /v2, /v3, etc. path
Eventually we would be able to deprecate the APIs available at the root, then we'd deprecate the /v1 API, etc. but this process would be progressive and consultative with integrators.
Instead of deprecating the APIs at the root, e.g. /status, /block, etc., always keep the root pointing to the latest version, so that by default the root API gives the latest version and anyone wants the older versions they can use /v1, /v2 etc.
Instead of deprecating the APIs at the root, e.g. /status, /block, etc., always keep the root pointing to the latest version, so that by default the root API gives the latest version and anyone wants the older versions they can use /v1, /v2 etc.
This would defeat the purpose of what we're trying to achieve: being able to roll out new APIs in non-breaking (minor) releases.
Users using the APIs at the root, e.g. /status, /block, etc., will automatically get the latest APIs at the root always. If they upgrade the version of their package, they do not need to change the code to use the latest non-breaking releases. If they find the new versioned package is breaking their code, then can always fix the version of the API in their code, such as v1/status (and still upgrade the package) without having to rollback the package version (which may include new bug fixes and other performance advantages if any).
On the contrary, without the APIs at the root, 1. user always has to know the latest version number to use the API which is anti-pattern, and 2. all users have to change their code to latest version number v5/ etc. to even to benefit from the non-breaking minor releases.
Since there are two version systems going on here: 1. the API versioning and 2. the package version, it is important to note how the package versioning will be combined with API versioning. In majority of the cases pointing the APIs root to the latest version, while adding new versions with prefixes is the most suitable option. E.g. Git commits use that approach (the default always pointing to the latest commit, while you can still access the other commits with explicit commit hashes), and this is no different.
@KrishnaPG I do understand what you're proposing, and the main problem with it is that it provides a poor integrator experience. Take the following example:
CometBFT v1.0 provides v1 of the RPC API at both the root and /v1 paths.
CometBFT v1.1 provides v1 and v2 of the RPC API, where the root now offers a different API (v2), and both /v1 and /v2 paths are available.
In that scenario, we've broken a public API (the root API) in a minor release, which in principle is not great. As an integrator, I would not expect upgrading to a new minor release to break my RPC integration. Most integrators, I would bet, would only discover this in production, which could lead to service downtime on their side. That should be unacceptable in my view.
We could opt to keep the root API at v1 until we release CometBFT v2.0, but that still defeats the purpose of what we're trying to achieve in trying to encourage integrators to make use of the latest RPC version while providing some grace period to upgrade.
Thanks @thanethomson I see your point. The problem arises because a new API version v2 is being added as minor package version increment CometBFT v1.1 instead of major version increment. (Minor package updates are expected to be API compatible, usually)
Anyway, each library has its own mechanism of mapping the package versions to the API versions. CometBFT can follow whichever best works for its audience. No issues.
The problem arises because a new API version v2 is being added as minor package version increment CometBFT v1.1 instead of major version increment. (Minor package updates are expected to be API compatible, usually)
Yes, this is exactly the goal of this issue. We want to be able to do this because it often takes chains anywhere between 6 and 12 months at least to update to a new major Comet release. Decoupling RPC versioning from Comet versioning allows us to roll out "breaking" RPC API changes without needing to cut a breaking Comet release.
Rolling out a /v2 API while keeping /v1 present is an additive change that doesn't require a major Comet release, therefore it's technically a non-breaking change.
P:integrator-experiencePriority: Improve experience for integratorsP:tech-debtPriority: Technical debt that needs to be paid off to enable us to move faster, reliablyrpc
Activity
[-]rpc: Version the JSON-RPC API[/-][+]rpc: Version the RPC APIs[/+]KrishnaPG commentedon Oct 14, 2023
Instead of deprecating the APIs at the root, e.g.
/status,/block, etc., always keep the root pointing to the latest version, so that by default the root API gives the latest version and anyone wants the older versions they can use/v1,/v2etc.thanethomson commentedon Oct 15, 2023
This would defeat the purpose of what we're trying to achieve: being able to roll out new APIs in non-breaking (minor) releases.
KrishnaPG commentedon Oct 16, 2023
Thanks @thanethomson Not sure what you mean.
/status,/block, etc., will automatically get the latest APIs at the root always. If they upgrade the version of their package, they do not need to change the code to use the latest non-breaking releases. If they find the new versioned package is breaking their code, then can always fix the version of the API in their code, such asv1/status(and still upgrade the package) without having to rollback the package version (which may include new bug fixes and other performance advantages if any).v5/etc. to even to benefit from the non-breaking minor releases.Since there are two version systems going on here: 1. the API versioning and 2. the package version, it is important to note how the package versioning will be combined with API versioning. In majority of the cases pointing the APIs root to the latest version, while adding new versions with prefixes is the most suitable option. E.g. Git commits use that approach (the default always pointing to the latest commit, while you can still access the other commits with explicit commit hashes), and this is no different.
thanethomson commentedon Oct 16, 2023
@KrishnaPG I do understand what you're proposing, and the main problem with it is that it provides a poor integrator experience. Take the following example:
/v1paths./v1and/v2paths are available.In that scenario, we've broken a public API (the root API) in a minor release, which in principle is not great. As an integrator, I would not expect upgrading to a new minor release to break my RPC integration. Most integrators, I would bet, would only discover this in production, which could lead to service downtime on their side. That should be unacceptable in my view.
We could opt to keep the root API at v1 until we release CometBFT v2.0, but that still defeats the purpose of what we're trying to achieve in trying to encourage integrators to make use of the latest RPC version while providing some grace period to upgrade.
KrishnaPG commentedon Oct 16, 2023
Thanks @thanethomson I see your point. The problem arises because a new API version
v2is being added as minor package version incrementCometBFT v1.1instead of major version increment. (Minor package updates are expected to be API compatible, usually)Anyway, each library has its own mechanism of mapping the package versions to the API versions. CometBFT can follow whichever best works for its audience. No issues.
thanethomson commentedon Oct 16, 2023
Yes, this is exactly the goal of this issue. We want to be able to do this because it often takes chains anywhere between 6 and 12 months at least to update to a new major Comet release. Decoupling RPC versioning from Comet versioning allows us to roll out "breaking" RPC API changes without needing to cut a breaking Comet release.
Rolling out a
/v2API while keeping/v1present is an additive change that doesn't require a major Comet release, therefore it's technically a non-breaking change.perf: Micro optimization to save one allocation per packet (backport …