Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: runtime API implementations not exported #809

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

ntn-x2
Copy link
Member

@ntn-x2 ntn-x2 commented Nov 25, 2024

Fixes https://github.com/KILTprotocol/ticket/issues/3688.

Due to how the impl_runtime_apis macro works, it is expected to be included in a runtime's lib.rs file. Since we split up the runtimes, the runtime APIs were not included anymore. I found a related issue in the subxt repo: paritytech/subxt#1873.

Because the trait definition generated by the macro is local, we can't import it in the lib.rs module for the construct_runtime macro to pick up the right implementation, so we need a workaround that basically introduces a new marker trait, and we import that in the lib.rs file so that the right implementation of Runtime::runtime_metadata() is picked up. More details about the issue are presented in the subxt ticket.

How to test

Spin up a chopsticks deployment after building peregrine and spiritnet runtime, and verify that the runtime APIs are there now.

@ntn-x2 ntn-x2 self-assigned this Nov 25, 2024
@@ -54,6 +54,7 @@ mod migrations;
pub use migrations::RuntimeMigrations;
mod parachain;
mod runtime_apis;
use runtime_apis::_InternalImplRuntimeApis;
Copy link
Member Author

Choose a reason for hiding this comment

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

We basically need to import the runtime_metadata function, and since the real trait (InternalImplRuntimeApis) is private, we declare a second trait in the runtime_apis module which we then import here to import the runtime_metadata function.

@ntn-x2 ntn-x2 marked this pull request as ready for review November 26, 2024 10:19
@ntn-x2 ntn-x2 requested a review from Ad96el November 26, 2024 10:20
Copy link
Member

@Ad96el Ad96el left a comment

Choose a reason for hiding this comment

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

LGTM. Can confirm that the API is present in the metadata after those changes.

@ntn-x2 ntn-x2 merged commit 4148afb into develop Nov 27, 2024
17 of 18 checks passed
@ntn-x2 ntn-x2 deleted the aa/fix-runtime-api-export branch November 27, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants