Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add staging runtime api #5048

Merged

Conversation

tdimitrov
Copy link
Contributor

@tdimitrov tdimitrov commented Mar 7, 2022

Quoting @rphmeier (with small edits):

The broader idea I have around runtime API upgrades is that we'd
maintain a vstaging which is based on the latest API version and has a
special STAGING_VERSION (u32::MAX). We'd be able to conditionally enable
this on runtimes for testing. And then we'd eventually set the next
runtime API version to be equal to vstaging and start a fresh vstaging

cumulus companion: paritytech/cumulus#1108

@tdimitrov tdimitrov marked this pull request as draft March 7, 2022 18:08
@tdimitrov tdimitrov added C1-low PR touches the given topic and has a low impact on builders. A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes labels Mar 7, 2022
@bkchr
Copy link
Member

bkchr commented Mar 11, 2022

Where would this staging runtime api being used? What is the idea behind using u32::MAX as version?

If you will try to implement the staging + the normal runtime api in the same runtime, the macro will start to complain that this doesn't work.

@ordian
Copy link
Member

ordian commented Mar 11, 2022

I think we should only enable one of them (either v2 or vstaging) conditionally.
The general idea is that we want to continue adding methods to the runtime API on master without affecting releases of polkadot/kusama/westend/rococo.

Quoting some previous comments from @rphmeier

Depends what we want from the staging API, tbh. If we require that it's always 'complete' in master, then it makes sense to deploy it to Rococo always. But I suspect that the following are more likely to be true:

  • Runtime API upgrades are fairly infrequent (in the mid-term of stronger protocol development, maybe 2-3 a year and after that about 1 a year)
  • A staging API builds in master over time and can be added to.
  • Staging is frozen, tested, and then released.

In this case, I would say that we shouldn't deploy staging to any network except ZombieNet tests most of the time, and only Versi once it's frozen.

@bkchr
Copy link
Member

bkchr commented Mar 11, 2022

Okay thank you.

You will need some sort of node code anyway to handle staging vs v2/vx/etc. You could also just add the methods to the normal runtime api. As your node code will need to be prepared for the staging version anyway, you can use that "to version". Aka you just add new methods but they are not being used by the normal node, just by staging stuff. If you then want to stabilize a method, you bump the trait version and change your node code to make this runtime api function usable when version X is present.

You could also do something like name the method unstable_xy and then already have them being present in all the runtimes and when the time comes that you want to stabilize something you just need to put a renamed_in() above the method and do a node release.

But these are just some random ideas by me.

@rphmeier
Copy link
Contributor

rphmeier commented Mar 11, 2022

@bkchr

Thanks, that's a good suggestion.

@tdimitrov - what I suggest, then, is that we move the declaration of ParachainHost to not be inside of v2/vx and instead be one level above. explicitly refer to the types in its methods as v2::SomeType or vstaging::OtherType. staging types should only be used for unstable_ methods.

@tdimitrov
Copy link
Contributor Author

tdimitrov commented Mar 15, 2022

@rphmeier @bkchr could you please review?

EDIT: I need to fix the usage here in parallel to this PR.

Copy link
Member

@eskimor eskimor left a comment

Choose a reason for hiding this comment

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

Looks good overall. One thing struck me though:

ParachainsHost is versioned .... so should not staging be implemented in the following way:

  1. Have staging correspond to the next version number that is not yet used - we merely just name it staging to make it clear that we don't want that version on production networks yet.
  2. Only support the latest stable version of ParachainHost on production network, but support the staging version number (3 currently) on test networks.
  3. Staging gets stabilized, by letting staging point to the next version number (4) and by implementing/supporting the old staging ParachainHost (3) on production networks.

primitives/src/runtime_api.rs Outdated Show resolved Hide resolved
@tdimitrov
Copy link
Contributor Author

Only support the latest stable version of ParachainHost on production network, but support the staging version number (3 currently) on test networks.

I think this is a problem, because two runtime API versions can't easily coexist in the code. For this reason the ParachainHost trait is moved outside v2.

tdimitrov added a commit to tdimitrov/cumulus that referenced this pull request Mar 23, 2022
`ParachainHost` is no longer versioned and is in `runtime_api` module.

This is a companion for
paritytech/polkadot#5048
tdimitrov added a commit to tdimitrov/cumulus that referenced this pull request Mar 23, 2022
`ParachainHost` is no longer versioned and is in `runtime_api` module.

This is a companion for
paritytech/polkadot#5048
@tdimitrov tdimitrov force-pushed the runtime-staging-api branch 3 times, most recently from 44e00a6 to 660680b Compare March 23, 2022 13:46
@ordian
Copy link
Member

ordian commented Mar 23, 2022

How do we prevent an unstable_ API accidentally leaking into a release version of polkadot/kusama/westend runtime, which is one of the main points of vstaging idea?

@bkchr
Copy link
Member

bkchr commented Mar 23, 2022

How do we prevent an unstable_ API accidentally leaking into a release version of polkadot/kusama/westend runtime, which is one of the main points of vstaging idea?

There would be no problem of having a unstable_ API as part of a release. You are doing the versioning on the client anyway. This means, if you don't call the api, nothing bad happens ;)

@ordian
Copy link
Member

ordian commented Mar 23, 2022

How do we prevent an unstable_ API accidentally leaking into a release version of polkadot/kusama/westend runtime, which is one of the main points of vstaging idea?

There would be no problem of having a unstable_ API as part of a release. You are doing the versioning on the client anyway. This means, if you don't call the api, nothing bad happens ;)

But how the client is supposed to quiery this API? We use versioning here

Request::Authorities(sender) => query!(Authorities, authorities(), ver = 1, sender),
Request::Validators(sender) => query!(Validators, validators(), ver = 1, sender),
Request::ValidatorGroups(sender) =>
query!(ValidatorGroups, validator_groups(), ver = 1, sender),

When introducing an unstable API, what version should be put there? And how's the client will be using it? Like any other runtime API? Or are we going to feature gate the unstable functionality on the client side? Then the worry is accidental feature leaking.

@paritytech-ci paritytech-ci requested review from a team April 11, 2022 19:27
primitives/src/runtime_api.rs Outdated Show resolved Hide resolved
primitives/src/runtime_api.rs Outdated Show resolved Hide resolved
tdimitrov added a commit to tdimitrov/cumulus that referenced this pull request Apr 12, 2022
`ParachainHost` is no longer versioned and is in `runtime_api` module.

This is a companion for
paritytech/polkadot#5048
`trait ParachainHost` is no longer part of a specific primitives
version. Instead there is a single trait for stable and staging api
versions. The trait contains stable AND staging methods. The latter are
explicitly marked as unstable.
`polkadot_primitives::v2` becomes `polkadot_primitives::runtime_api`
Introduces the concept for 'staging functions' in runtime API. These
functions are still in testing and they are meant to be used only
within test networks (Westend).
They coexist with the stable calls for technical reasons - maintaining
different runtime APIs for different networks is hard to implement.

Check the doc comments in source files for more details how the staging
API should be used.
Add `staging_get_session_disputes` to `ParachainHost` as the first
method of the staging API.
@ordian
Copy link
Member

ordian commented Apr 12, 2022

bot merge

@paritytech-processbot
Copy link

Error: pr-custom-review is not passing for paritytech/cumulus#1108

@ordian
Copy link
Member

ordian commented Apr 12, 2022

bot merge

@paritytech-processbot paritytech-processbot bot merged commit 722936d into paritytech:master Apr 12, 2022
@tdimitrov tdimitrov deleted the runtime-staging-api branch April 12, 2022 15:48
paritytech-processbot bot pushed a commit to paritytech/cumulus that referenced this pull request Apr 12, 2022
* Handle relocation of `ParachainHost` in Polkadot

`ParachainHost` is no longer versioned and is in `runtime_api` module.

This is a companion for
paritytech/polkadot#5048

* Update dependencies
ordian added a commit that referenced this pull request Apr 13, 2022
* master: (62 commits)
  Bump tracing from 0.1.32 to 0.1.33 (#5299)
  Add staging runtime api (#5048)
  CI: rename ambiguous jobs (#5313)
  Prepare for rust 1.60 (#5282)
  Bump proc-macro2 from 1.0.36 to 1.0.37 (#5265)
  Fixes the dead lock when any of the channels get at capacity. (#5297)
  Bump syn from 1.0.90 to 1.0.91 (#5273)
  create .github/workflows/pr-custom-review.yml (#5280)
  [ci] fix pallet benchmark script (#5247) (#5292)
  bump spec_version to 9190 (#5291)
  bump version to 0.9.19 (#5290)
  Session is actually ancient not unknown. (#5286)
  [ci] point benchmark script to sub-commands (#5247) (#5289)
  Remove Travis CI (#5287)
  Improve error handling in approval voting block import (#5283)
  fix .github/pr-custom-review.yml (#5279)
  Co #11164: Sub-commands for `benchmark` (#5247)
  Bump clap from 3.1.6 to 3.1.8 (#5240)
  Custom Slots Migration for Fund Index Change (#5227)
  create pr-custom-review.yml (#5253)
  ...
WebWizrd8 added a commit to WebWizrd8/cumulus that referenced this pull request Nov 21, 2022
* Handle relocation of `ParachainHost` in Polkadot

`ParachainHost` is no longer versioned and is in `runtime_api` module.

This is a companion for
paritytech/polkadot#5048

* Update dependencies
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants