polkadot icon indicating copy to clipboard operation
polkadot copied to clipboard

Runtime API Subsystem should not do version negotiation internally

Open rphmeier opened this issue 3 years ago • 3 comments

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

rphmeier avatar Mar 07 '22 06:03 rphmeier

After #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).

ordian avatar Mar 07 '22 16:03 ordian

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

rphmeier avatar Mar 07 '22 16:03 rphmeier

related to #5048

rphmeier avatar Sep 12 '22 20:09 rphmeier