Skip to content

Commit

Permalink
Introduce fix for Peregrine runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Nov 25, 2024
1 parent 4f5429d commit 7132eeb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ sp-core = { git = "https://github.com/parityt
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-inherents = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-metadata-ir = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
sp-session = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-crates-io-v1.7.0" }
Expand Down
2 changes: 2 additions & 0 deletions runtimes/peregrine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-inherents = { workspace = true }
sp-metadata-ir = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
Expand Down Expand Up @@ -241,6 +242,7 @@ std = [
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-metadata-ir/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
Expand Down
1 change: 1 addition & 0 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mod migrations;
pub use migrations::RuntimeMigrations;
mod parachain;
mod runtime_apis;
use runtime_apis::_InternalImplRuntimeApis;
pub use runtime_apis::{api, RuntimeApi};
mod system;
use sp_version::RuntimeVersion;
Expand Down
17 changes: 17 additions & 0 deletions runtimes/peregrine/src/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use sp_api::impl_runtime_apis;
use sp_core::OpaqueMetadata;
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_metadata_ir::RuntimeApiMetadataIR;
use sp_runtime::{
traits::{Block as BlockT, TryConvert},
ApplyExtrinsicResult, KeyTypeId,
Expand Down Expand Up @@ -53,6 +54,22 @@ use crate::{
// `impl_runtime_apis` is private.
pub(crate) const RUNTIME_API_VERSION: ApisVec = RUNTIME_API_VERSIONS;

// Workaround for runtime API impls not exposed in metadata if implemented in a
// different file than the runtime's `lib.rs`. Related issue (subxt) -> https://github.com/paritytech/subxt/issues/1873.
pub(crate) trait _InternalImplRuntimeApis {
fn runtime_metadata(&self) -> Vec<RuntimeApiMetadataIR>;
}

impl<T> _InternalImplRuntimeApis for T
where
T: InternalImplRuntimeApis,
{
#[inline(always)]
fn runtime_metadata(&self) -> Vec<RuntimeApiMetadataIR> {
<T as InternalImplRuntimeApis>::runtime_metadata(self)
}
}

impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
Expand Down

0 comments on commit 7132eeb

Please sign in to comment.