diff --git a/polkadot/runtime/rococo/Cargo.toml b/polkadot/runtime/rococo/Cargo.toml index 50970965e11e..26d9f8d29e8d 100644 --- a/polkadot/runtime/rococo/Cargo.toml +++ b/polkadot/runtime/rococo/Cargo.toml @@ -328,6 +328,9 @@ try-runtime = [ # Enable the metadata hash generation in the wasm builder. metadata-hash = ["substrate-wasm-builder/metadata-hash"] +# If enabled, the runtime apis will not be exposed by the runtime. +disable-runtime-api = [] + # Set timing constants (e.g. session period) to faster versions to speed up testing. fast-runtime = ["rococo-runtime-constants/fast-runtime"] diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 30b915d32deb..d3d654e90904 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -168,6 +168,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 0, spec_version: 1_015_000, impl_version: 0, + #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, transaction_version: 26, state_version: 1, @@ -1768,6 +1769,7 @@ mod benches { ); } +#[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/polkadot/runtime/westend/Cargo.toml b/polkadot/runtime/westend/Cargo.toml index 4226595cd2ff..0e91efdb8ab2 100644 --- a/polkadot/runtime/westend/Cargo.toml +++ b/polkadot/runtime/westend/Cargo.toml @@ -347,6 +347,9 @@ try-runtime = [ # Enable the metadata hash generation in the wasm builder. metadata-hash = ["substrate-wasm-builder/metadata-hash"] +# If enabled, the runtime apis will not be exposed by the runtime. +disable-runtime-api = [] + # Set timing constants (e.g. session period) to faster versions to speed up testing. fast-runtime = [] diff --git a/polkadot/runtime/westend/src/lib.rs b/polkadot/runtime/westend/src/lib.rs index 5f8d5d424938..102cf413ca74 100644 --- a/polkadot/runtime/westend/src/lib.rs +++ b/polkadot/runtime/westend/src/lib.rs @@ -169,6 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { authoring_version: 2, spec_version: 1_015_000, impl_version: 0, + #[cfg(not(feature = "disable-runtime-api"))] apis: RUNTIME_API_VERSIONS, transaction_version: 26, state_version: 1, @@ -208,12 +209,12 @@ impl frame_system::Config for Runtime { type BaseCallFilter = EverythingBut; type BlockWeights = BlockWeights; type BlockLength = BlockLength; + type DbWeight = RocksDbWeight; type Nonce = Nonce; type Hash = Hash; type AccountId = AccountId; type Block = Block; type BlockHashCount = BlockHashCount; - type DbWeight = RocksDbWeight; type Version = Version; type AccountData = pallet_balances::AccountData; type SystemWeightInfo = weights::frame_system::WeightInfo; @@ -1109,7 +1110,8 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::Staking(..) | - RuntimeCall::Session(..) | RuntimeCall::Utility(..) | + RuntimeCall::Session(..) | + RuntimeCall::Utility(..) | RuntimeCall::FastUnstake(..) | RuntimeCall::VoterList(..) | RuntimeCall::NominationPools(..) @@ -1879,6 +1881,7 @@ mod benches { ); } +#[cfg(not(feature = "disable-runtime-api"))] sp_api::impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/prdoc/pr_4325.prdoc b/prdoc/pr_4325.prdoc new file mode 100644 index 000000000000..2cdc3393d69f --- /dev/null +++ b/prdoc/pr_4325.prdoc @@ -0,0 +1,14 @@ +title: Restore disable_runtime_api logic to test nodes + +doc: + - audience: Runtime Dev + description: | + There should be an option for runtime dev to choose whether to expose apis. This feature existed but was mistakenly removed. + +crates: + - name: polkadot-runtime-rococo + bump: patch + + - name: polkadot-runtime-westend + bump: patch +