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

Staging Runtime API implementation #11577

@tdimitrov

Description

@tdimitrov

This is a follow up from #11338, paritytech/polkadot#5048 and some offline discussions.

What we need

I write this from the point of view of a substrate user in polkadot. This problem might not be relevant for other projects.

At the moment we use the primitives provided by substrate to build versioned runtime API. We have got different runtimes (for polkadot, kusama, rococo, etc) but they implement the same runtime API interface. For specific runtimes (rococo to be concrete) we want to introduce breaking changes like:

  • Modify the behaviour of a function already present in the stable API in sort of a breaking/incompatible way.
  • Add completely new functions which we consider 'staging'. This means they are not production ready and we want to test them in safe but real environment. By 'safe' I mean 'not on a production network. By 'real' - actual network where we can see how runtime upgrade behaves, how version mismatch between the node and the runtime works and so on.

Additionally we need versioning independent from the one of the stable staging API. We expect the development around it to be dynamic so we should be able to create new versions easily.

A quote from @eskimor from the linked discussion:

So in a way we actually want two runtimes to be built .... One stable one and the staging one with an incremented version number. Stable will be the default (native) and we can upgrade test networks to the staging one via sudo and see whether it works.

Another one regarding the versioning:

The thing is if you are checking for the presence of the function, that is not quite the same as checking a version.

In particular: If the function was not yet added, (the case we are discussing) we just want to handle it by simply behaving in the old way. What could also happen, is that the function gets removed at a later point in time - in that case we would at least want an error message, so we will detect early in debugging that a needed function was accidentally removed.

That's actually the reason we bother about versioning at all, otherwise we could always just check whether the function is there or not and versioning becomes irrelevant (to the node).

And a final one from @rphmeier :

So in short: we want the node to be able to declare both the staging runtime API and the 'current' runtime API. The staging runtime API should have its own version so it can be detected at runtime. We should not have 2 types for this, because then you have to write a lot of dispatch logic based on the version and add a lot of trait bounds. We should have the ability to maintain multiple staging versions at once.

Things we want to avoid (if possible)

  • We want to avoid adding new type for the staging API (see @rphmeier quote above) because native runtime will be gone and adding dispatch logic + new trait bounds may quickly turn into a mess.
  • The staging API to be a first class concept in substrate so that it's straightforward to use. Currently we relay on hacks to achieve the same behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I7-refactorCode needs refactoring.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions