paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.78k stars 645 forks source link

Runtime API Subsystem should not do version negotiation internally #858

Open rphmeier opened 2 years ago

rphmeier commented 2 years ago

'have one joint and oil it well' - subsystems should be aware (at a high level) of which runtime API version they're running code against and should dispatch requests appropriately. We can add more request types for the METHOD_before_version_VERSION APIs that are auto-generated when the runtime API is upgraded on the node-side before an upgrade lands on the runtime and use those where needed. If an API is called at a relay-chain block where it is unsupported, the runtime API subsystem should just fail the request gracefully; this is a bug in higher-level code and shouldn't be patched around in low-level code.

ordian commented 2 years ago

After paritytech/polkadot#5037, we can simplify https://github.com/paritytech/polkadot/blob/9907414f50f92c126f2f0a860d71332fc4d0f2d6/node/core/runtime-api/src/lib.rs#L450-L485 to always quiery v2 of session_info. When changing an existing method (e.g. v3 of SessionInfo), we can implement that backwards compatible functionality as a function instead of directly backing it into the runtime api subsystem (now that we have version runtime API).

rphmeier commented 2 years ago

Yeah, I think the way we'd do this is add a Request::METHODBeforeVersionX or something of the kind.

rphmeier commented 2 years ago

related to paritytech/polkadot#5048