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

Do not depend on native runtimes for RuntimeApi #7451

Merged
merged 9 commits into from
Jul 4, 2023
Merged

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Jul 2, 2023

The RuntimeApi type is being generated by impl_runtime_apis!. It is used to check at compile time which runtime apis are implemented. The problem with this is that it requires to import the native runtimes. In the future Substrate will remove this requirement on statically proving that some runtime api is implemented. We also want to move out the runtimes from the Polkadot repo to the fellowship and thus, we could also not depend on them any more and this pull request brings us closer to this goal.

This pull request workarounds the compile runtime api check by implementing the runtime apis for some fake runtime. This fake runtime api is then used to fulfill the compile time checks. To ensure that we do not call the native runtime api of your fake implementation, we switch the executor to WasmExecutor. This executor can only work with the wasm runtime and nothing else.

Besides that the pull request removes the polkadot-client crate. This crate was adding complexity that isn't required anymore.

Another advantage is that it removes around 1min of build time on my machine ;)

cumulus companion: paritytech/cumulus#2807

These runtime api implementations are only used to make the compiler
think that we have implemented all required runtime apis. They will not
be called as we switch the executor to `WasmExecutor`. In the near
future we will not require these fake implementations anymore after
Substrate has shifted away from this compile time requirement.

This brings us the advantage that the `polkadot-service` doesn't need to
depend on the runtimes for getting the `RuntimeApi` type.

It also removes around 1min of build time on my machine ;)
@bkchr bkchr added A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. T0-node This PR/Issue is related to the topic “node”. B1-note_worthy Changes should be noted in the release notes labels Jul 2, 2023
@bkchr bkchr requested review from ggwpez and a team July 2, 2023 22:10
bkchr added a commit to paritytech/cumulus that referenced this pull request Jul 2, 2023
@bkchr bkchr changed the title Implement runtime apis for fake runtime Do not depend on native runtimes for RuntimeApi Jul 3, 2023
@michalkucharczyk michalkucharczyk requested a review from a team July 3, 2023 08:45
}

#[cfg(feature = "westend-native")]
fn westend_sign_call(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: westend/kusama/rococo sign_call seems to be exact copies (mod runtime name). Maybe this could be somehow avoided (macro maybe?).

@michalkucharczyk michalkucharczyk requested a review from a team July 3, 2023 09:23
@bkchr
Copy link
Member Author

bkchr commented Jul 3, 2023

bot fmt

@command-bot
Copy link

command-bot bot commented Jul 3, 2023

@bkchr https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3107029 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 10-5a7fd304-5a9f-4b47-9bb4-b3270eb247e6 to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jul 3, 2023

@bkchr Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3107029 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3107029/artifacts/download.

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable
Logs: https://gitlab.parity.io/parity/mirrors/polkadot/-/jobs/3112135

@bkchr bkchr merged commit 39b35b4 into master Jul 4, 2023
4 checks passed
@bkchr bkchr deleted the bkchr-fake-runtime-api branch July 4, 2023 08:09
paritytech-processbot bot pushed a commit to paritytech/cumulus that referenced this pull request Jul 4, 2023
* Companion for Polkadot#7451

paritytech/polkadot#7451

* Update Substrate & Polkadot

* FMT

* Fix integration tests

* Bring back `polkadot-native` feature for now

* 🤦
ggwpez pushed a commit to ggwpez/runtimes that referenced this pull request Jul 13, 2023
* Companion for Polkadot#7451

paritytech/polkadot#7451

* Update Substrate & Polkadot

* FMT

* Fix integration tests

* Bring back `polkadot-native` feature for now

* 🤦
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. B1-note_worthy Changes should be noted in the release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. T0-node This PR/Issue is related to the topic “node”.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants