Skip to content

rpc: Version the RPC APIs #75

Closed

Description

@thanethomson

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.

Activity

  1. added
    tracking
    on Jan 4, 2023
  2. changed the title [-]rpc: Version the JSON-RPC API[/-] [+]rpc: Version the RPC APIs[/+] on Mar 2, 2023
  3. added
    P:integrator-experience
    P:tech-debt
    on Jun 20, 2023
  4. self-assigned this
    on Sep 28, 2023
  5. added this to the 2023-Q4 milestone on Sep 29, 2023
  6. moved this from Todo to In Progress in CometBFT 2023on Sep 29, 2023
  7. removed
    tracking
    on Oct 10, 2023
  8. KrishnaPG commented on Oct 14, 2023

    @KrishnaPG

    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.

  9. thanethomson commented on Oct 15, 2023

    @thanethomson
    ContributorAuthor

    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.

  10. KrishnaPG commented on Oct 16, 2023

    @KrishnaPG

    Thanks @thanethomson Not sure what you mean.

    1. 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).
    2. 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.

  11. thanethomson commented on Oct 16, 2023

    @thanethomson
    ContributorAuthor

    @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.

  12. KrishnaPG commented on Oct 16, 2023

    @KrishnaPG

    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.

  13. thanethomson commented on Oct 16, 2023

    @thanethomson
    ContributorAuthor

    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.

  14. moved this from In Progress to Done in CometBFT 2023on Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P:integrator-experienceP:tech-debtrpc

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions