Skip to content

Commit

Permalink
Enable async backing for system parachains: Phase 1 (polkadot-fellows…
Browse files Browse the repository at this point in the history
…#228)

This PR aims to prepare system parachains' runtimes for the async
backing enabling. Namely, it:
* Implements `AuraUnincludedSegmentApi` for every runtime;
* Allows relay block numbers to increase monotonically (as opposed to
increasing strictly) to enable producing more than one parablock on top
of every relay block;
* Enables constant Aura slot durations.

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 15, 2024
1 parent 503e481 commit c5f8556
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Bump parachains runtime API to v10 in Kusama to enable the `approval-voting-params` function [polkadot-fellows/runtimes#204](https://github.com/polkadot-fellows/runtimes/pull/204)
- Use Relay Chain's Treasury Pallet account as a destination for XCM fees on System Parachain ([polkadot-fellows/runtimes#191](https://github.com/polkadot-fellows/runtimes/pull/191))
- Bump parachains runtime API to v10 in Polkadot to enable async-backing subsystems(still in backwards compatible mode) [polkadot-fellows/runtimes#222](https://github.com/polkadot-fellows/runtimes/pull/222)
- Prepared system parachain runtimes for async backing enabling ([polkadot-fellows/runtimes#228](https://github.com/polkadot-fellows/runtimes/pull/228))

### Removed

Expand Down
21 changes: 21 additions & 0 deletions Cargo.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ frame-support = { version = "29.0.0" }
parachains-common = { version = "8.0.0" }
cumulus-primitives-core = { version = "0.8.0" }
emulated-integration-tests-common = { version = "4.0.0" }
penpal-runtime = { version = "0.15.0" }
penpal-runtime = { version = "0.15.0", features = ["experimental"] }

# Runtimes
kusama-emulated-chain = { path = "../../../relays/kusama" }
Expand Down
6 changes: 3 additions & 3 deletions system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ frame-try-runtime = { default-features = false, optional = true, version = "0.35
pallet-asset-conversion-tx-payment = { default-features = false, version = "11.0.0" }
pallet-assets = { default-features = false, version = "30.0.0" }
pallet-asset-conversion = { default-features = false, version = "11.0.0" }
pallet-aura = { default-features = false, version = "28.0.0" }
pallet-aura = { default-features = false, version = "28.0.0", features = ["experimental"] }
pallet-authorship = { default-features = false, version = "29.0.0" }
pallet-balances = { default-features = false, version = "29.0.0" }
pallet-message-queue = { default-features = false , version = "32.0.0" }
Expand Down Expand Up @@ -83,6 +83,7 @@ cumulus-pallet-parachain-system = { default-features = false, features = ["param
cumulus-pallet-session-benchmarking = { default-features = false, version = "10.0.0" }
cumulus-pallet-xcm = { default-features = false , version = "0.8.0" }
cumulus-pallet-xcmp-queue = { default-features = false , features = ["bridging"] , version = "0.8.0" }
cumulus-primitives-aura = { default-features = false , version = "0.8.0" }
cumulus-primitives-core = { default-features = false , version = "0.8.0" }
cumulus-primitives-utility = { default-features = false , version = "0.8.1" }
pallet-collator-selection = { default-features = false , version = "10.0.0" }
Expand Down Expand Up @@ -192,6 +193,7 @@ std = [
"cumulus-pallet-session-benchmarking/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
Expand Down Expand Up @@ -254,8 +256,6 @@ std = [
"xcm/std",
]

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.
Expand Down
32 changes: 21 additions & 11 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use assets_common::{
matching::FromSiblingParachain,
AssetIdForTrustBackedAssetsConvert,
};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand Down Expand Up @@ -631,16 +631,18 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;

impl parachain_info::Config for Runtime {}

parameter_types! {
Expand Down Expand Up @@ -741,8 +743,7 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
#[cfg(feature = "experimental")]
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
type SlotDuration = ConstU64<SLOT_DURATION>;
}

parameter_types! {
Expand Down Expand Up @@ -1036,14 +1037,23 @@ mod benches {
impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<AuraId> {
Aura::authorities().into_inner()
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
Expand Down
6 changes: 3 additions & 3 deletions system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ frame-system-rpc-runtime-api = { default-features = false, version = "27.0.0" }
frame-try-runtime = { default-features = false, optional = true, version = "0.35.0" }
pallet-asset-tx-payment = { default-features = false , version = "29.0.0" }
pallet-assets = { default-features = false, version = "30.0.0" }
pallet-aura = { default-features = false, version = "28.0.0" }
pallet-aura = { default-features = false, version = "28.0.0", features = ["experimental"] }
pallet-authorship = { default-features = false, version = "29.0.0" }
pallet-balances = { default-features = false, version = "29.0.0" }
pallet-message-queue = { default-features = false , version = "32.0.0" }
Expand Down Expand Up @@ -79,6 +79,7 @@ cumulus-pallet-parachain-system = { default-features = false, features = ["param
cumulus-pallet-session-benchmarking = { default-features = false, version = "10.0.0" }
cumulus-pallet-xcm = { default-features = false , version = "0.8.0" }
cumulus-pallet-xcmp-queue = { default-features = false , features = ["bridging"] , version = "0.8.0" }
cumulus-primitives-aura = { default-features = false , version = "0.8.0" }
cumulus-primitives-core = { default-features = false , version = "0.8.0" }
cumulus-primitives-utility = { default-features = false , version = "0.8.1" }
pallet-collator-selection = { default-features = false , version = "10.0.0" }
Expand Down Expand Up @@ -177,6 +178,7 @@ std = [
"cumulus-pallet-session-benchmarking/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
Expand Down Expand Up @@ -236,8 +238,6 @@ std = [
"xcm/std",
]

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.
Expand Down
32 changes: 21 additions & 11 deletions system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod weights;
pub mod xcm_config;

use assets_common::{foreign_creators::ForeignCreators, matching::FromSiblingParachain};
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand Down Expand Up @@ -556,16 +556,18 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type OutboundXcmpMessageSource = XcmpQueue;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;

impl parachain_info::Config for Runtime {}

parameter_types! {
Expand Down Expand Up @@ -666,8 +668,7 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
#[cfg(feature = "experimental")]
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
type SlotDuration = ConstU64<SLOT_DURATION>;
}

parameter_types! {
Expand Down Expand Up @@ -932,14 +933,23 @@ mod benches {
impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<AuraId> {
Aura::authorities().into_inner()
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

impl sp_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
Expand Down
6 changes: 3 additions & 3 deletions system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ frame-system = { default-features = false, version = "29.0.0" }
frame-system-benchmarking = { default-features = false, optional = true, version = "29.0.0" }
frame-system-rpc-runtime-api = { default-features = false, version = "27.0.0" }
frame-try-runtime = { default-features = false, optional = true, version = "0.35.0" }
pallet-aura = { default-features = false, version = "28.0.0" }
pallet-aura = { default-features = false, version = "28.0.0", features = ["experimental"] }
pallet-authorship = { default-features = false, version = "29.0.0" }
pallet-balances = { default-features = false, version = "29.0.0" }
pallet-message-queue = { default-features = false , version = "32.0.0" }
Expand Down Expand Up @@ -76,6 +76,7 @@ cumulus-pallet-parachain-system = { default-features = false, features = ["param
cumulus-pallet-session-benchmarking = { default-features = false, version = "10.0.0" }
cumulus-pallet-xcm = { default-features = false , version = "0.8.0" }
cumulus-pallet-xcmp-queue = { default-features = false , features = ["bridging"] , version = "0.8.0" }
cumulus-primitives-aura = { default-features = false , version = "0.8.0" }
cumulus-primitives-core = { default-features = false , version = "0.8.0" }
cumulus-primitives-utility = { default-features = false , version = "0.8.1" }
pallet-collator-selection = { default-features = false , version = "10.0.0" }
Expand Down Expand Up @@ -128,6 +129,7 @@ std = [
"cumulus-pallet-session-benchmarking/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
Expand Down Expand Up @@ -249,8 +251,6 @@ try-runtime = [
"sp-runtime/try-runtime",
]

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.
Expand Down
32 changes: 21 additions & 11 deletions system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub mod bridge_to_polkadot_config;
mod weights;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
Expand Down Expand Up @@ -304,16 +304,18 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedDmpWeight = ReservedDmpWeight;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
type ConsensusHook = ConsensusHook;
type WeightInfo = weights::cumulus_pallet_parachain_system::WeightInfo<Runtime>;
}

type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
RELAY_CHAIN_SLOT_DURATION_MILLIS,
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;

impl parachain_info::Config for Runtime {}

parameter_types! {
Expand Down Expand Up @@ -415,8 +417,7 @@ impl pallet_aura::Config for Runtime {
type DisabledValidators = ();
type MaxAuthorities = ConstU32<100_000>;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
#[cfg(feature = "experimental")]
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
type SlotDuration = ConstU64<SLOT_DURATION>;
}

parameter_types! {
Expand Down Expand Up @@ -551,14 +552,23 @@ mod benches {
impl_runtime_apis! {
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
fn slot_duration() -> sp_consensus_aura::SlotDuration {
sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
}

fn authorities() -> Vec<AuraId> {
Aura::authorities().into_inner()
}
}

impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
ConsensusHook::can_build_upon(included_hash, slot)
}
}

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

0 comments on commit c5f8556

Please sign in to comment.