Skip to content

Commit

Permalink
Various nits and alignments for SP runtimes (#154)
Browse files Browse the repository at this point in the history
There were several improvements and PRs that didn't apply to all
runtimes, so this PR attempts to align those small differences.

---------

Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
  • Loading branch information
bkontur and joepetrowski authored Jan 23, 2024
1 parent 659f6e0 commit 1d8bdb2
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 128 deletions.
155 changes: 83 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions relay/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,9 @@ try-runtime = [
"sp-runtime/try-runtime",
]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]

# Set timing constants (e.g. session period) to faster versions to speed up testing.
Expand Down
4 changes: 2 additions & 2 deletions relay/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ try-runtime = [
"sp-runtime/try-runtime",
]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]

# Set timing constants (e.g. session period) to faster versions to speed up testing.
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ std = [

experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
6 changes: 1 addition & 5 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,13 +954,9 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Local]
[pallet_assets, Foreign]
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ std = [

experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
6 changes: 1 addition & 5 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,13 +873,9 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_assets, Local]
[pallet_assets, Foreign]
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ try-runtime = [

experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
6 changes: 1 addition & 5 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,9 @@ construct_runtime!(
}
);

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ try-runtime = [

experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
6 changes: 1 addition & 5 deletions system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,9 @@ construct_runtime!(
}
);

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/collectives/collectives-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ std = [

experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,9 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_multisig, Multisig]
Expand Down
11 changes: 9 additions & 2 deletions system-parachains/encointer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repository.workspace = true
version.workspace = true

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false, features = [
"derive",
] }
hex-literal = { version = "0.4.1", optional = true }
Expand Down Expand Up @@ -65,6 +65,7 @@ sp-session = { default-features = false, version = "24.0.0" }
sp-std = { default-features = false, version = "12.0.0" }
sp-transaction-pool = { default-features = false, version = "23.0.0" }
sp-version = { default-features = false, version = "26.0.0" }
sp-genesis-builder = { default-features = false , version = "0.4.0" }

# Polkadot dependencies
pallet-xcm = { default-features = false, version = "4.0.0" }
Expand Down Expand Up @@ -174,6 +175,7 @@ std = [
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-runtime/std",
Expand Down Expand Up @@ -220,4 +222,9 @@ try-runtime = [
"parachain-info/try-runtime",
]

experimental = ["pallet-aura/experimental"]
experimental = [ "pallet-aura/experimental" ]

# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
31 changes: 23 additions & 8 deletions system-parachains/encointer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub use encointer_primitives::{
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
genesis_builder_helper::{build_config, create_default_config},
parameter_types,
traits::{
tokens::{pay::PayFromAccount, ConversionFromAssetBalance, ConversionToAssetBalance},
Expand All @@ -70,7 +71,6 @@ pub use pallet_encointer_faucet::Call as EncointerFaucetCall;
pub use pallet_encointer_reputation_commitments::Call as EncointerReputationCommitmentsCall;
pub use pallet_encointer_scheduler::Call as EncointerSchedulerCall;
use pallet_xcm::{EnsureXcm, IsMajorityOfBody};
pub use parachains_common as common;
use parachains_common::{
kusama::{consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, currency::*, fee::WeightToFee},
AuraId, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO,
Expand Down Expand Up @@ -721,13 +721,9 @@ pub type Executive = frame_executive::Executive<
Migrations,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_collective, Collective]
Expand Down Expand Up @@ -915,6 +911,16 @@ impl_runtime_apis! {
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn create_default_config() -> Vec<u8> {
create_default_config::<RuntimeGenesisConfig>()
}

fn build_config(config: Vec<u8>) -> sp_genesis_builder::Result {
build_config::<RuntimeGenesisConfig>(config)
}
}

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) {
Expand Down Expand Up @@ -957,11 +963,20 @@ impl_runtime_apis! {
fn dispatch_benchmark(
config: frame_benchmarking::BenchmarkConfig
) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {
use frame_benchmarking::{Benchmarking, BenchmarkBatch};
use frame_benchmarking::{Benchmarking, BenchmarkBatch, BenchmarkError};
use frame_support::traits::TrackedStorageKey;

use frame_system_benchmarking::Pallet as SystemBench;
impl frame_system_benchmarking::Config for Runtime {}
impl frame_system_benchmarking::Config for Runtime {
fn setup_set_code_requirements(code: &sp_std::vec::Vec<u8>) -> Result<(), BenchmarkError> {
ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32);
Ok(())
}

fn verify_set_code() {
System::assert_last_event(cumulus_pallet_parachain_system::Event::<Runtime>::ValidationFunctionStored.into());
}
}

let whitelist: Vec<TrackedStorageKey> = vec![
// Block Number
Expand Down
4 changes: 2 additions & 2 deletions system-parachains/gluttons/glutton-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ try-runtime = [
"sp-runtime/try-runtime",
]

# A feature that should be enabled when the runtime should be build for on-chain
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller like logging for example.
# to make it smaller, like logging for example.
on-chain-release-build = [ "sp-api/disable-logging" ]
6 changes: 1 addition & 5 deletions system-parachains/gluttons/glutton-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,9 @@ pub type Executive = frame_executive::Executive<
AllPalletsWithSystem,
>;

#[cfg(feature = "runtime-benchmarks")]
#[macro_use]
extern crate frame_benchmarking;

#[cfg(feature = "runtime-benchmarks")]
mod benches {
define_benchmarks!(
frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_glutton, Glutton]
);
Expand Down

0 comments on commit 1d8bdb2

Please sign in to comment.