mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 21:01:02 +00:00
Enable async backing on asset-hub-rococo (#2826)
The goal is to move all system chains on Rococo (+ other testnets?) to use async backing. Starting with `asset-hub-rococo` to get feedback, before I do the rest. ## Related Example: https://github.com/paritytech/polkadot-sdk/pull/1619/ Guide: https://github.com/w3f/polkadot-wiki/blob/master/docs/maintain/maintain-guides-async-backing.md --------- Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Dónal Murray <donal.murray@parity.io>
This commit is contained in:
Generated
+1
@@ -864,6 +864,7 @@ dependencies = [
|
|||||||
"cumulus-pallet-session-benchmarking",
|
"cumulus-pallet-session-benchmarking",
|
||||||
"cumulus-pallet-xcm",
|
"cumulus-pallet-xcm",
|
||||||
"cumulus-pallet-xcmp-queue",
|
"cumulus-pallet-xcmp-queue",
|
||||||
|
"cumulus-primitives-aura",
|
||||||
"cumulus-primitives-core",
|
"cumulus-primitives-core",
|
||||||
"cumulus-primitives-utility",
|
"cumulus-primitives-utility",
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
|
|||||||
@@ -242,17 +242,19 @@ pub async fn initialize_collator_subsystems(
|
|||||||
overseer_handle: &mut OverseerHandle,
|
overseer_handle: &mut OverseerHandle,
|
||||||
key: CollatorPair,
|
key: CollatorPair,
|
||||||
para_id: ParaId,
|
para_id: ParaId,
|
||||||
|
reinitialize: bool,
|
||||||
) {
|
) {
|
||||||
overseer_handle
|
let config = CollationGenerationConfig { key, para_id, collator: None };
|
||||||
.send_msg(
|
|
||||||
CollationGenerationMessage::Initialize(CollationGenerationConfig {
|
if reinitialize {
|
||||||
key,
|
overseer_handle
|
||||||
para_id,
|
.send_msg(CollationGenerationMessage::Reinitialize(config), "StartCollator")
|
||||||
collator: None,
|
.await;
|
||||||
}),
|
} else {
|
||||||
"StartCollator",
|
overseer_handle
|
||||||
)
|
.send_msg(CollationGenerationMessage::Initialize(config), "StartCollator")
|
||||||
.await;
|
.await;
|
||||||
|
}
|
||||||
|
|
||||||
overseer_handle
|
overseer_handle
|
||||||
.send_msg(CollatorProtocolMessage::CollateOn(para_id), "StartCollator")
|
.send_msg(CollatorProtocolMessage::CollateOn(para_id), "StartCollator")
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ pub struct Params<BI, CIDP, Client, Backend, RClient, CHP, SO, Proposer, CS> {
|
|||||||
pub collator_service: CS,
|
pub collator_service: CS,
|
||||||
/// The amount of time to spend authoring each block.
|
/// The amount of time to spend authoring each block.
|
||||||
pub authoring_duration: Duration,
|
pub authoring_duration: Duration,
|
||||||
|
/// Whether we should reinitialize the collator config (i.e. we are transitioning to aura).
|
||||||
|
pub reinitialize: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Run async-backing-friendly Aura.
|
/// Run async-backing-friendly Aura.
|
||||||
@@ -149,6 +151,7 @@ where
|
|||||||
&mut params.overseer_handle,
|
&mut params.overseer_handle,
|
||||||
params.collator_key,
|
params.collator_key,
|
||||||
params.para_id,
|
params.para_id,
|
||||||
|
params.reinitialize,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system
|
|||||||
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false }
|
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false }
|
||||||
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
|
||||||
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false, features = ["bridging"] }
|
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false, features = ["bridging"] }
|
||||||
|
cumulus-primitives-aura = { path = "../../../../primitives/aura", default-features = false }
|
||||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||||
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
||||||
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
||||||
@@ -188,6 +189,7 @@ std = [
|
|||||||
"cumulus-pallet-session-benchmarking/std",
|
"cumulus-pallet-session-benchmarking/std",
|
||||||
"cumulus-pallet-xcm/std",
|
"cumulus-pallet-xcm/std",
|
||||||
"cumulus-pallet-xcmp-queue/std",
|
"cumulus-pallet-xcmp-queue/std",
|
||||||
|
"cumulus-primitives-aura/std",
|
||||||
"cumulus-primitives-core/std",
|
"cumulus-primitives-core/std",
|
||||||
"cumulus-primitives-utility/std",
|
"cumulus-primitives-utility/std",
|
||||||
"frame-benchmarking?/std",
|
"frame-benchmarking?/std",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ use assets_common::{
|
|||||||
matching::{FromNetwork, FromSiblingParachain},
|
matching::{FromNetwork, FromSiblingParachain},
|
||||||
AssetIdForTrustBackedAssetsConvert,
|
AssetIdForTrustBackedAssetsConvert,
|
||||||
};
|
};
|
||||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||||
use cumulus_primitives_core::AggregateMessageOrigin;
|
use cumulus_primitives_core::AggregateMessageOrigin;
|
||||||
use parachains_common::rococo::snowbridge::EthereumNetwork;
|
use parachains_common::rococo::snowbridge::EthereumNetwork;
|
||||||
use sp_api::impl_runtime_apis;
|
use sp_api::impl_runtime_apis;
|
||||||
@@ -62,7 +62,7 @@ use frame_support::{
|
|||||||
ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Equals, InstanceFilter,
|
ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Equals, InstanceFilter,
|
||||||
TransformOrigin,
|
TransformOrigin,
|
||||||
},
|
},
|
||||||
weights::{ConstantMultiplier, Weight},
|
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight},
|
||||||
BoundedVec, PalletId,
|
BoundedVec, PalletId,
|
||||||
};
|
};
|
||||||
use frame_system::{
|
use frame_system::{
|
||||||
@@ -71,14 +71,13 @@ use frame_system::{
|
|||||||
};
|
};
|
||||||
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
|
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
|
||||||
use pallet_nfts::PalletFeatures;
|
use pallet_nfts::PalletFeatures;
|
||||||
pub use parachains_common as common;
|
|
||||||
use parachains_common::{
|
use parachains_common::{
|
||||||
impls::DealWithFees,
|
impls::DealWithFees,
|
||||||
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
|
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
|
||||||
rococo::{consensus::*, currency::*, fee::WeightToFee},
|
rococo::{consensus::*, currency::*, fee::WeightToFee},
|
||||||
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, CollectionId, Hash,
|
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, CollectionId, Hash,
|
||||||
Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS,
|
Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS,
|
||||||
MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
NORMAL_DISPATCH_RATIO,
|
||||||
};
|
};
|
||||||
use sp_runtime::{Perbill, RuntimeDebug};
|
use sp_runtime::{Perbill, RuntimeDebug};
|
||||||
use xcm_config::{
|
use xcm_config::{
|
||||||
@@ -141,6 +140,28 @@ pub fn native_version() -> NativeVersion {
|
|||||||
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// We allow for 2 seconds of compute with a 6 second average block.
|
||||||
|
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
|
||||||
|
WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2),
|
||||||
|
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
|
||||||
|
);
|
||||||
|
|
||||||
|
/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
|
||||||
|
/// into the relay chain.
|
||||||
|
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
|
||||||
|
/// How many parachain blocks are processed by the relay chain per parent. Limits the
|
||||||
|
/// number of blocks authored per slot.
|
||||||
|
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
|
||||||
|
|
||||||
|
/// This determines the average expected block time that we are targeting.
|
||||||
|
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
|
||||||
|
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
|
||||||
|
/// up by `pallet_aura` to implement `fn slot_duration()`.
|
||||||
|
///
|
||||||
|
/// Change this to adjust the block time.
|
||||||
|
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||||
|
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const Version: RuntimeVersion = VERSION;
|
pub const Version: RuntimeVersion = VERSION;
|
||||||
pub RuntimeBlockLength: BlockLength =
|
pub RuntimeBlockLength: BlockLength =
|
||||||
@@ -189,6 +210,9 @@ impl pallet_timestamp::Config for Runtime {
|
|||||||
/// A timestamp: milliseconds since the unix epoch.
|
/// A timestamp: milliseconds since the unix epoch.
|
||||||
type Moment = u64;
|
type Moment = u64;
|
||||||
type OnTimestampSet = Aura;
|
type OnTimestampSet = Aura;
|
||||||
|
#[cfg(feature = "experimental")]
|
||||||
|
type MinimumPeriod = ConstU64<0>;
|
||||||
|
#[cfg(not(feature = "experimental"))]
|
||||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||||
}
|
}
|
||||||
@@ -630,15 +654,17 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
|||||||
type OutboundXcmpMessageSource = XcmpQueue;
|
type OutboundXcmpMessageSource = XcmpQueue;
|
||||||
type XcmpMessageHandler = XcmpQueue;
|
type XcmpMessageHandler = XcmpQueue;
|
||||||
type ReservedXcmpWeight = ReservedXcmpWeight;
|
type ReservedXcmpWeight = ReservedXcmpWeight;
|
||||||
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
|
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
type ConsensusHook = ConsensusHook;
|
||||||
Runtime,
|
|
||||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
|
||||||
BLOCK_PROCESSING_VELOCITY,
|
|
||||||
UNINCLUDED_SEGMENT_CAPACITY,
|
|
||||||
>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||||
|
Runtime,
|
||||||
|
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||||
|
BLOCK_PROCESSING_VELOCITY,
|
||||||
|
UNINCLUDED_SEGMENT_CAPACITY,
|
||||||
|
>;
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
|
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
|
||||||
}
|
}
|
||||||
@@ -722,9 +748,9 @@ impl pallet_aura::Config for Runtime {
|
|||||||
type AuthorityId = AuraId;
|
type AuthorityId = AuraId;
|
||||||
type DisabledValidators = ();
|
type DisabledValidators = ();
|
||||||
type MaxAuthorities = ConstU32<100_000>;
|
type MaxAuthorities = ConstU32<100_000>;
|
||||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
type AllowMultipleBlocksPerSlot = ConstBool<true>;
|
||||||
#[cfg(feature = "experimental")]
|
#[cfg(feature = "experimental")]
|
||||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
type SlotDuration = ConstU64<SLOT_DURATION>;
|
||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
@@ -1067,7 +1093,7 @@ mod benches {
|
|||||||
impl_runtime_apis! {
|
impl_runtime_apis! {
|
||||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
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> {
|
fn authorities() -> Vec<AuraId> {
|
||||||
@@ -1075,6 +1101,15 @@ impl_runtime_apis! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
impl sp_api::Core<Block> for Runtime {
|
||||||
fn version() -> RuntimeVersion {
|
fn version() -> RuntimeVersion {
|
||||||
VERSION
|
VERSION
|
||||||
|
|||||||
@@ -28,10 +28,11 @@ use asset_hub_rococo_runtime::{
|
|||||||
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection,
|
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection,
|
||||||
ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, MetadataDepositBase,
|
ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, MetadataDepositBase,
|
||||||
MetadataDepositPerByte, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, SessionKeys,
|
MetadataDepositPerByte, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, SessionKeys,
|
||||||
ToWestendXcmRouterInstance, TrustBackedAssetsInstance, XcmpQueue,
|
ToWestendXcmRouterInstance, TrustBackedAssetsInstance, XcmpQueue, SLOT_DURATION,
|
||||||
};
|
};
|
||||||
use asset_test_utils::{
|
use asset_test_utils::{
|
||||||
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys, ExtBuilder,
|
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
|
||||||
|
ExtBuilder, SlotDurations,
|
||||||
};
|
};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use cumulus_primitives_utility::ChargeWeightInFungibles;
|
use cumulus_primitives_utility::ChargeWeightInFungibles;
|
||||||
@@ -46,9 +47,10 @@ use frame_support::{
|
|||||||
weights::{Weight, WeightToFee as WeightToFeeT},
|
weights::{Weight, WeightToFee as WeightToFeeT},
|
||||||
};
|
};
|
||||||
use parachains_common::{
|
use parachains_common::{
|
||||||
rococo::{currency::UNITS, fee::WeightToFee},
|
rococo::{consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, currency::UNITS, fee::WeightToFee},
|
||||||
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
|
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
|
||||||
};
|
};
|
||||||
|
use sp_consensus_aura::SlotDuration;
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||||
@@ -78,6 +80,13 @@ fn collator_session_keys() -> CollatorSessionKeys<Runtime> {
|
|||||||
CollatorSessionKeys::default().add(collator_session_key(ALICE))
|
CollatorSessionKeys::default().add(collator_session_key(ALICE))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn slot_durations() -> SlotDurations {
|
||||||
|
SlotDurations {
|
||||||
|
relay: SlotDuration::from_millis(RELAY_CHAIN_SLOT_DURATION_MILLIS.into()),
|
||||||
|
para: SlotDuration::from_millis(SLOT_DURATION),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_buy_and_refund_weight_in_native() {
|
fn test_buy_and_refund_weight_in_native() {
|
||||||
ExtBuilder::<Runtime>::default()
|
ExtBuilder::<Runtime>::default()
|
||||||
@@ -892,6 +901,7 @@ asset_test_utils::include_teleports_for_native_asset_works!(
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ParachainSystem,
|
ParachainSystem,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -912,6 +922,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!(
|
|||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -1023,6 +1034,7 @@ fn limited_reserve_transfer_assets_for_native_asset_over_bridge_works(
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AccountId::from(ALICE),
|
AccountId::from(ALICE),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
@@ -1194,6 +1206,7 @@ mod asset_hub_rococo_tests {
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AccountId::from(ALICE),
|
AccountId::from(ALICE),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ use frame_system::{
|
|||||||
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
|
use pallet_asset_conversion_tx_payment::AssetConversionAdapter;
|
||||||
use pallet_nfts::{DestroyWitness, PalletFeatures};
|
use pallet_nfts::{DestroyWitness, PalletFeatures};
|
||||||
use pallet_xcm::EnsureXcm;
|
use pallet_xcm::EnsureXcm;
|
||||||
pub use parachains_common as common;
|
|
||||||
use parachains_common::{
|
use parachains_common::{
|
||||||
impls::DealWithFees,
|
impls::DealWithFees,
|
||||||
message_queue::*,
|
message_queue::*,
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ use asset_hub_westend_runtime::{
|
|||||||
};
|
};
|
||||||
pub use asset_hub_westend_runtime::{AssetConversion, AssetDeposit, CollatorSelection, System};
|
pub use asset_hub_westend_runtime::{AssetConversion, AssetDeposit, CollatorSelection, System};
|
||||||
use asset_test_utils::{
|
use asset_test_utils::{
|
||||||
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys, ExtBuilder,
|
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
|
||||||
|
ExtBuilder, SlotDurations,
|
||||||
};
|
};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use cumulus_primitives_utility::ChargeWeightInFungibles;
|
use cumulus_primitives_utility::ChargeWeightInFungibles;
|
||||||
@@ -47,9 +48,10 @@ use frame_support::{
|
|||||||
weights::{Weight, WeightToFee as WeightToFeeT},
|
weights::{Weight, WeightToFee as WeightToFeeT},
|
||||||
};
|
};
|
||||||
use parachains_common::{
|
use parachains_common::{
|
||||||
westend::{currency::UNITS, fee::WeightToFee},
|
westend::{consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, currency::UNITS, fee::WeightToFee},
|
||||||
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
|
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, SLOT_DURATION,
|
||||||
};
|
};
|
||||||
|
use sp_consensus_aura::SlotDuration;
|
||||||
use sp_runtime::traits::MaybeEquivalence;
|
use sp_runtime::traits::MaybeEquivalence;
|
||||||
use std::convert::Into;
|
use std::convert::Into;
|
||||||
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||||
@@ -79,6 +81,13 @@ fn collator_session_keys() -> CollatorSessionKeys<Runtime> {
|
|||||||
CollatorSessionKeys::default().add(collator_session_key(ALICE))
|
CollatorSessionKeys::default().add(collator_session_key(ALICE))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn slot_durations() -> SlotDurations {
|
||||||
|
SlotDurations {
|
||||||
|
relay: SlotDuration::from_millis(RELAY_CHAIN_SLOT_DURATION_MILLIS.into()),
|
||||||
|
para: SlotDuration::from_millis(SLOT_DURATION),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_buy_and_refund_weight_in_native() {
|
fn test_buy_and_refund_weight_in_native() {
|
||||||
ExtBuilder::<Runtime>::default()
|
ExtBuilder::<Runtime>::default()
|
||||||
@@ -895,6 +904,7 @@ asset_test_utils::include_teleports_for_native_asset_works!(
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ParachainSystem,
|
ParachainSystem,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -915,6 +925,7 @@ asset_test_utils::include_teleports_for_foreign_assets_works!(
|
|||||||
ForeignCreatorsSovereignAccountOf,
|
ForeignCreatorsSovereignAccountOf,
|
||||||
ForeignAssetsInstance,
|
ForeignAssetsInstance,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -1041,6 +1052,7 @@ fn limited_reserve_transfer_assets_for_native_asset_to_asset_hub_rococo_works()
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AccountId::from(ALICE),
|
AccountId::from(ALICE),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
@@ -1208,6 +1220,7 @@ fn reserve_transfer_native_asset_to_non_teleport_para_works() {
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
AccountId::from(ALICE),
|
AccountId::from(ALICE),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use frame_system::pallet_prelude::BlockNumberFor;
|
|||||||
use parachains_common::{AccountId, Balance};
|
use parachains_common::{AccountId, Balance};
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
assert_metadata, assert_total, mock_open_hrmp_channel, AccountIdOf, BalanceOf,
|
assert_metadata, assert_total, mock_open_hrmp_channel, AccountIdOf, BalanceOf,
|
||||||
CollatorSessionKeys, ExtBuilder, ValidatorIdOf, XcmReceivedFrom,
|
CollatorSessionKeys, ExtBuilder, SlotDurations, ValidatorIdOf, XcmReceivedFrom,
|
||||||
};
|
};
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
traits::{MaybeEquivalence, StaticLookup, Zero},
|
traits::{MaybeEquivalence, StaticLookup, Zero},
|
||||||
@@ -57,6 +57,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
HrmpChannelOpener,
|
HrmpChannelOpener,
|
||||||
>(
|
>(
|
||||||
collator_session_keys: CollatorSessionKeys<Runtime>,
|
collator_session_keys: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
existential_deposit: BalanceOf<Runtime>,
|
existential_deposit: BalanceOf<Runtime>,
|
||||||
target_account: AccountIdOf<Runtime>,
|
target_account: AccountIdOf<Runtime>,
|
||||||
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
||||||
@@ -205,6 +206,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
None,
|
None,
|
||||||
included_head.clone(),
|
included_head.clone(),
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
));
|
));
|
||||||
|
|
||||||
// check balances
|
// check balances
|
||||||
@@ -257,6 +259,7 @@ pub fn teleports_for_native_asset_works<
|
|||||||
Some((runtime_para_id, other_para_id)),
|
Some((runtime_para_id, other_para_id)),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
),
|
),
|
||||||
Err(DispatchError::Module(sp_runtime::ModuleError {
|
Err(DispatchError::Module(sp_runtime::ModuleError {
|
||||||
index: 31,
|
index: 31,
|
||||||
@@ -288,6 +291,7 @@ macro_rules! include_teleports_for_native_asset_works(
|
|||||||
$weight_to_fee:path,
|
$weight_to_fee:path,
|
||||||
$hrmp_channel_opener:path,
|
$hrmp_channel_opener:path,
|
||||||
$collator_session_key:expr,
|
$collator_session_key:expr,
|
||||||
|
$slot_durations:expr,
|
||||||
$existential_deposit:expr,
|
$existential_deposit:expr,
|
||||||
$unwrap_pallet_xcm_event:expr,
|
$unwrap_pallet_xcm_event:expr,
|
||||||
$runtime_para_id:expr
|
$runtime_para_id:expr
|
||||||
@@ -306,6 +310,7 @@ macro_rules! include_teleports_for_native_asset_works(
|
|||||||
$hrmp_channel_opener
|
$hrmp_channel_opener
|
||||||
>(
|
>(
|
||||||
$collator_session_key,
|
$collator_session_key,
|
||||||
|
$slot_durations,
|
||||||
$existential_deposit,
|
$existential_deposit,
|
||||||
target_account,
|
target_account,
|
||||||
$unwrap_pallet_xcm_event,
|
$unwrap_pallet_xcm_event,
|
||||||
@@ -328,6 +333,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
ForeignAssetsPalletInstance,
|
ForeignAssetsPalletInstance,
|
||||||
>(
|
>(
|
||||||
collator_session_keys: CollatorSessionKeys<Runtime>,
|
collator_session_keys: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
target_account: AccountIdOf<Runtime>,
|
target_account: AccountIdOf<Runtime>,
|
||||||
existential_deposit: BalanceOf<Runtime>,
|
existential_deposit: BalanceOf<Runtime>,
|
||||||
asset_owner: AccountIdOf<Runtime>,
|
asset_owner: AccountIdOf<Runtime>,
|
||||||
@@ -592,6 +598,7 @@ pub fn teleports_for_foreign_assets_works<
|
|||||||
Some((runtime_para_id, foreign_para_id)),
|
Some((runtime_para_id, foreign_para_id)),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
));
|
));
|
||||||
|
|
||||||
// check balances
|
// check balances
|
||||||
@@ -644,6 +651,7 @@ macro_rules! include_teleports_for_foreign_assets_works(
|
|||||||
$sovereign_account_of:path,
|
$sovereign_account_of:path,
|
||||||
$assets_pallet_instance:path,
|
$assets_pallet_instance:path,
|
||||||
$collator_session_key:expr,
|
$collator_session_key:expr,
|
||||||
|
$slot_durations:expr,
|
||||||
$existential_deposit:expr,
|
$existential_deposit:expr,
|
||||||
$unwrap_pallet_xcm_event:expr,
|
$unwrap_pallet_xcm_event:expr,
|
||||||
$unwrap_xcmp_queue_event:expr
|
$unwrap_xcmp_queue_event:expr
|
||||||
@@ -666,6 +674,7 @@ macro_rules! include_teleports_for_foreign_assets_works(
|
|||||||
$assets_pallet_instance
|
$assets_pallet_instance
|
||||||
>(
|
>(
|
||||||
$collator_session_key,
|
$collator_session_key,
|
||||||
|
$slot_durations,
|
||||||
target_account,
|
target_account,
|
||||||
$existential_deposit,
|
$existential_deposit,
|
||||||
asset_owner,
|
asset_owner,
|
||||||
@@ -1397,6 +1406,7 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys: CollatorSessionKeys<Runtime>,
|
collator_session_keys: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
existential_deposit: BalanceOf<Runtime>,
|
existential_deposit: BalanceOf<Runtime>,
|
||||||
alice_account: AccountIdOf<Runtime>,
|
alice_account: AccountIdOf<Runtime>,
|
||||||
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
||||||
@@ -1470,6 +1480,7 @@ pub fn reserve_transfer_native_asset_to_non_teleport_para_works<
|
|||||||
other_para_id.into(),
|
other_para_id.into(),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
);
|
);
|
||||||
|
|
||||||
// we calculate exact delivery fees _after_ sending the message by weighing the sent
|
// we calculate exact delivery fees _after_ sending the message by weighing the sent
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ use frame_system::pallet_prelude::BlockNumberFor;
|
|||||||
use parachains_common::{AccountId, Balance};
|
use parachains_common::{AccountId, Balance};
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeHelper,
|
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeHelper,
|
||||||
ValidatorIdOf, XcmReceivedFrom,
|
SlotDurations, ValidatorIdOf, XcmReceivedFrom,
|
||||||
};
|
};
|
||||||
use sp_runtime::{traits::StaticLookup, Saturating};
|
use sp_runtime::{traits::StaticLookup, Saturating};
|
||||||
use sp_std::ops::Mul;
|
use sp_std::ops::Mul;
|
||||||
@@ -52,6 +52,7 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
|
|||||||
LocationToAccountId,
|
LocationToAccountId,
|
||||||
>(
|
>(
|
||||||
collator_session_keys: CollatorSessionKeys<Runtime>,
|
collator_session_keys: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
existential_deposit: BalanceOf<Runtime>,
|
existential_deposit: BalanceOf<Runtime>,
|
||||||
alice_account: AccountIdOf<Runtime>,
|
alice_account: AccountIdOf<Runtime>,
|
||||||
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
unwrap_pallet_xcm_event: Box<dyn Fn(Vec<u8>) -> Option<pallet_xcm::Event<Runtime>>>,
|
||||||
@@ -125,6 +126,7 @@ pub fn limited_reserve_transfer_assets_for_native_asset_works<
|
|||||||
local_bridge_hub_para_id.into(),
|
local_bridge_hub_para_id.into(),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
);
|
);
|
||||||
|
|
||||||
// we calculate exact delivery fees _after_ sending the message by weighing the sent
|
// we calculate exact delivery fees _after_ sending the message by weighing the sent
|
||||||
|
|||||||
@@ -24,9 +24,14 @@ use bridge_hub_rococo_runtime::{
|
|||||||
Executive, ExistentialDeposit, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
Executive, ExistentialDeposit, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall,
|
||||||
RuntimeEvent, RuntimeOrigin, SessionKeys, SignedExtra, TransactionPayment, UncheckedExtrinsic,
|
RuntimeEvent, RuntimeOrigin, SessionKeys, SignedExtra, TransactionPayment, UncheckedExtrinsic,
|
||||||
};
|
};
|
||||||
|
use bridge_hub_test_utils::SlotDurations;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
|
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
|
||||||
use parachains_common::{rococo::fee::WeightToFee, AccountId, AuraId, Balance};
|
use parachains_common::{
|
||||||
|
rococo::{consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, fee::WeightToFee},
|
||||||
|
AccountId, AuraId, Balance, SLOT_DURATION,
|
||||||
|
};
|
||||||
|
use sp_consensus_aura::SlotDuration;
|
||||||
use sp_core::H160;
|
use sp_core::H160;
|
||||||
use sp_keyring::AccountKeyring::Alice;
|
use sp_keyring::AccountKeyring::Alice;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -95,6 +100,13 @@ fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn slot_durations() -> SlotDurations {
|
||||||
|
SlotDurations {
|
||||||
|
relay: SlotDuration::from_millis(RELAY_CHAIN_SLOT_DURATION_MILLIS.into()),
|
||||||
|
para: SlotDuration::from_millis(SLOT_DURATION),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPalletsWithoutSystem,
|
AllPalletsWithoutSystem,
|
||||||
@@ -103,6 +115,7 @@ bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ParachainSystem,
|
ParachainSystem,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -264,6 +277,7 @@ mod bridge_hub_westend_tests {
|
|||||||
ConstU8<2>,
|
ConstU8<2>,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
@@ -288,6 +302,7 @@ mod bridge_hub_westend_tests {
|
|||||||
// from Westend
|
// from Westend
|
||||||
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||||
BridgeHubWestendChainId::get(),
|
BridgeHubWestendChainId::get(),
|
||||||
@@ -304,6 +319,7 @@ mod bridge_hub_westend_tests {
|
|||||||
// for Westend
|
// for Westend
|
||||||
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
@@ -459,6 +475,7 @@ mod bridge_hub_bulletin_tests {
|
|||||||
ConstU8<2>,
|
ConstU8<2>,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
@@ -483,6 +500,7 @@ mod bridge_hub_bulletin_tests {
|
|||||||
// from Bulletin
|
// from Bulletin
|
||||||
from_grandpa_chain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
from_grandpa_chain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
RococoBulletinChainId::get(),
|
RococoBulletinChainId::get(),
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
@@ -498,6 +516,7 @@ mod bridge_hub_bulletin_tests {
|
|||||||
// for Bulletin
|
// for Bulletin
|
||||||
from_grandpa_chain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
from_grandpa_chain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
RococoBulletinChainId::get(),
|
RococoBulletinChainId::get(),
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
use bp_polkadot_core::Signature;
|
use bp_polkadot_core::Signature;
|
||||||
use bridge_common_config::{DeliveryRewardInBalance, RequiredStakeForStakeAndSlash};
|
use bridge_common_config::{DeliveryRewardInBalance, RequiredStakeForStakeAndSlash};
|
||||||
use bridge_hub_test_utils::test_cases::from_parachain;
|
use bridge_hub_test_utils::{test_cases::from_parachain, SlotDurations};
|
||||||
use bridge_hub_westend_runtime::{
|
use bridge_hub_westend_runtime::{
|
||||||
bridge_common_config, bridge_to_rococo_config,
|
bridge_common_config, bridge_to_rococo_config,
|
||||||
xcm_config::{RelayNetwork, WestendLocation, XcmConfig},
|
xcm_config::{RelayNetwork, WestendLocation, XcmConfig},
|
||||||
@@ -33,7 +33,11 @@ use bridge_to_rococo_config::{
|
|||||||
};
|
};
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
|
use frame_support::{dispatch::GetDispatchInfo, parameter_types, traits::ConstU8};
|
||||||
use parachains_common::{westend::fee::WeightToFee, AccountId, AuraId, Balance};
|
use parachains_common::{
|
||||||
|
westend::{consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, fee::WeightToFee},
|
||||||
|
AccountId, AuraId, Balance, SLOT_DURATION,
|
||||||
|
};
|
||||||
|
use sp_consensus_aura::SlotDuration;
|
||||||
use sp_keyring::AccountKeyring::Alice;
|
use sp_keyring::AccountKeyring::Alice;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
generic::{Era, SignedPayload},
|
generic::{Era, SignedPayload},
|
||||||
@@ -111,6 +115,13 @@ fn collator_session_keys() -> bridge_hub_test_utils::CollatorSessionKeys<Runtime
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn slot_durations() -> SlotDurations {
|
||||||
|
SlotDurations {
|
||||||
|
relay: SlotDuration::from_millis(RELAY_CHAIN_SLOT_DURATION_MILLIS.into()),
|
||||||
|
para: SlotDuration::from_millis(SLOT_DURATION),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
||||||
Runtime,
|
Runtime,
|
||||||
AllPalletsWithoutSystem,
|
AllPalletsWithoutSystem,
|
||||||
@@ -119,6 +130,7 @@ bridge_hub_test_utils::test_cases::include_teleports_for_native_asset_works!(
|
|||||||
WeightToFee,
|
WeightToFee,
|
||||||
ParachainSystem,
|
ParachainSystem,
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
ExistentialDeposit::get(),
|
ExistentialDeposit::get(),
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
match RuntimeEvent::decode(&mut &runtime_event_encoded[..]) {
|
||||||
@@ -229,6 +241,7 @@ fn message_dispatch_routing_works() {
|
|||||||
ConstU8<2>,
|
ConstU8<2>,
|
||||||
>(
|
>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
Box::new(|runtime_event_encoded: Vec<u8>| {
|
Box::new(|runtime_event_encoded: Vec<u8>| {
|
||||||
@@ -252,6 +265,7 @@ fn message_dispatch_routing_works() {
|
|||||||
fn relayed_incoming_message_works() {
|
fn relayed_incoming_message_works() {
|
||||||
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
from_parachain::relayed_incoming_message_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
BridgeHubRococoChainId::get(),
|
BridgeHubRococoChainId::get(),
|
||||||
@@ -267,6 +281,7 @@ fn relayed_incoming_message_works() {
|
|||||||
pub fn complex_relay_extrinsic_works() {
|
pub fn complex_relay_extrinsic_works() {
|
||||||
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
from_parachain::complex_relay_extrinsic_works::<RuntimeTestsAdapter>(
|
||||||
collator_session_keys(),
|
collator_session_keys(),
|
||||||
|
slot_durations(),
|
||||||
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
bp_bridge_hub_westend::BRIDGE_HUB_WESTEND_PARACHAIN_ID,
|
||||||
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
bp_bridge_hub_rococo::BRIDGE_HUB_ROCOCO_PARACHAIN_ID,
|
||||||
SIBLING_PARACHAIN_ID,
|
SIBLING_PARACHAIN_ID,
|
||||||
|
|||||||
+5
-1
@@ -39,7 +39,7 @@ use bridge_runtime_common::{
|
|||||||
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
|
||||||
};
|
};
|
||||||
use sp_keyring::AccountKeyring::*;
|
use sp_keyring::AccountKeyring::*;
|
||||||
use sp_runtime::{traits::Header as HeaderT, AccountId32};
|
use sp_runtime::{traits::Header as HeaderT, AccountId32};
|
||||||
@@ -107,6 +107,7 @@ where
|
|||||||
/// Also verifies relayer transaction signed extensions work as intended.
|
/// Also verifies relayer transaction signed extensions work as intended.
|
||||||
pub fn relayed_incoming_message_works<RuntimeHelper>(
|
pub fn relayed_incoming_message_works<RuntimeHelper>(
|
||||||
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
bridged_chain_id: bp_runtime::ChainId,
|
bridged_chain_id: bp_runtime::ChainId,
|
||||||
sibling_parachain_id: u32,
|
sibling_parachain_id: u32,
|
||||||
@@ -136,6 +137,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
|
|||||||
RuntimeHelper::MPI,
|
RuntimeHelper::MPI,
|
||||||
>(
|
>(
|
||||||
collator_session_key,
|
collator_session_key,
|
||||||
|
slot_durations,
|
||||||
runtime_para_id,
|
runtime_para_id,
|
||||||
sibling_parachain_id,
|
sibling_parachain_id,
|
||||||
local_relay_chain_id,
|
local_relay_chain_id,
|
||||||
@@ -205,6 +207,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
|
|||||||
/// Also verifies relayer transaction signed extensions work as intended.
|
/// Also verifies relayer transaction signed extensions work as intended.
|
||||||
pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
||||||
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
sibling_parachain_id: u32,
|
sibling_parachain_id: u32,
|
||||||
bridged_chain_id: bp_runtime::ChainId,
|
bridged_chain_id: bp_runtime::ChainId,
|
||||||
@@ -237,6 +240,7 @@ pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
|||||||
RuntimeHelper::MPI,
|
RuntimeHelper::MPI,
|
||||||
>(
|
>(
|
||||||
collator_session_key,
|
collator_session_key,
|
||||||
|
slot_durations,
|
||||||
runtime_para_id,
|
runtime_para_id,
|
||||||
sibling_parachain_id,
|
sibling_parachain_id,
|
||||||
local_relay_chain_id,
|
local_relay_chain_id,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ use bridge_runtime_common::{
|
|||||||
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
use frame_support::traits::{Get, OnFinalize, OnInitialize};
|
||||||
use frame_system::pallet_prelude::BlockNumberFor;
|
use frame_system::pallet_prelude::BlockNumberFor;
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf,
|
AccountIdOf, BasicParachainRuntime, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
|
||||||
};
|
};
|
||||||
use sp_keyring::AccountKeyring::*;
|
use sp_keyring::AccountKeyring::*;
|
||||||
use sp_runtime::{traits::Header as HeaderT, AccountId32};
|
use sp_runtime::{traits::Header as HeaderT, AccountId32};
|
||||||
@@ -112,6 +112,7 @@ where
|
|||||||
/// Also verifies relayer transaction signed extensions work as intended.
|
/// Also verifies relayer transaction signed extensions work as intended.
|
||||||
pub fn relayed_incoming_message_works<RuntimeHelper>(
|
pub fn relayed_incoming_message_works<RuntimeHelper>(
|
||||||
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
bridged_para_id: u32,
|
bridged_para_id: u32,
|
||||||
bridged_chain_id: bp_runtime::ChainId,
|
bridged_chain_id: bp_runtime::ChainId,
|
||||||
@@ -146,6 +147,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
|
|||||||
RuntimeHelper::MPI,
|
RuntimeHelper::MPI,
|
||||||
>(
|
>(
|
||||||
collator_session_key,
|
collator_session_key,
|
||||||
|
slot_durations,
|
||||||
runtime_para_id,
|
runtime_para_id,
|
||||||
sibling_parachain_id,
|
sibling_parachain_id,
|
||||||
local_relay_chain_id,
|
local_relay_chain_id,
|
||||||
@@ -244,6 +246,7 @@ pub fn relayed_incoming_message_works<RuntimeHelper>(
|
|||||||
/// Also verifies relayer transaction signed extensions work as intended.
|
/// Also verifies relayer transaction signed extensions work as intended.
|
||||||
pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
||||||
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
collator_session_key: CollatorSessionKeys<RuntimeHelper::Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
bridged_para_id: u32,
|
bridged_para_id: u32,
|
||||||
sibling_parachain_id: u32,
|
sibling_parachain_id: u32,
|
||||||
@@ -281,6 +284,7 @@ pub fn complex_relay_extrinsic_works<RuntimeHelper>(
|
|||||||
RuntimeHelper::MPI,
|
RuntimeHelper::MPI,
|
||||||
>(
|
>(
|
||||||
collator_session_key,
|
collator_session_key,
|
||||||
|
slot_durations,
|
||||||
runtime_para_id,
|
runtime_para_id,
|
||||||
sibling_parachain_id,
|
sibling_parachain_id,
|
||||||
local_relay_chain_id,
|
local_relay_chain_id,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use frame_system::pallet_prelude::BlockNumberFor;
|
|||||||
use pallet_bridge_grandpa::{BridgedBlockHash, BridgedHeader};
|
use pallet_bridge_grandpa::{BridgedBlockHash, BridgedHeader};
|
||||||
use parachains_common::AccountId;
|
use parachains_common::AccountId;
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
mock_open_hrmp_channel, AccountIdOf, CollatorSessionKeys, RuntimeCallOf,
|
mock_open_hrmp_channel, AccountIdOf, CollatorSessionKeys, RuntimeCallOf, SlotDurations,
|
||||||
};
|
};
|
||||||
use sp_core::Get;
|
use sp_core::Get;
|
||||||
use sp_keyring::AccountKeyring::*;
|
use sp_keyring::AccountKeyring::*;
|
||||||
@@ -220,6 +220,7 @@ pub fn relayer_id_at_bridged_chain<Runtime: pallet_bridge_messages::Config<MPI>,
|
|||||||
/// with proofs (finality, message) independently submitted.
|
/// with proofs (finality, message) independently submitted.
|
||||||
pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
sibling_parachain_id: u32,
|
sibling_parachain_id: u32,
|
||||||
local_relay_chain_id: NetworkId,
|
local_relay_chain_id: NetworkId,
|
||||||
@@ -272,6 +273,7 @@ pub fn relayed_incoming_message_works<Runtime, AllPalletsWithoutSystem, MPI>(
|
|||||||
sibling_parachain_id.into(),
|
sibling_parachain_id.into(),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
);
|
);
|
||||||
|
|
||||||
// set up relayer details and proofs
|
// set up relayer details and proofs
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ use frame_system::pallet_prelude::BlockNumberFor;
|
|||||||
use parachains_common::AccountId;
|
use parachains_common::AccountId;
|
||||||
use parachains_runtimes_test_utils::{
|
use parachains_runtimes_test_utils::{
|
||||||
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeCallOf,
|
mock_open_hrmp_channel, AccountIdOf, BalanceOf, CollatorSessionKeys, ExtBuilder, RuntimeCallOf,
|
||||||
XcmReceivedFrom,
|
SlotDurations, XcmReceivedFrom,
|
||||||
};
|
};
|
||||||
use sp_runtime::{traits::Zero, AccountId32};
|
use sp_runtime::{traits::Zero, AccountId32};
|
||||||
use xcm::{latest::prelude::*, AlwaysLatest};
|
use xcm::{latest::prelude::*, AlwaysLatest};
|
||||||
@@ -419,6 +419,7 @@ pub fn message_dispatch_routing_works<
|
|||||||
NetworkDistanceAsParentCount,
|
NetworkDistanceAsParentCount,
|
||||||
>(
|
>(
|
||||||
collator_session_key: CollatorSessionKeys<Runtime>,
|
collator_session_key: CollatorSessionKeys<Runtime>,
|
||||||
|
slot_durations: SlotDurations,
|
||||||
runtime_para_id: u32,
|
runtime_para_id: u32,
|
||||||
sibling_parachain_id: u32,
|
sibling_parachain_id: u32,
|
||||||
unwrap_cumulus_pallet_parachain_system_event: Box<
|
unwrap_cumulus_pallet_parachain_system_event: Box<
|
||||||
@@ -529,6 +530,7 @@ pub fn message_dispatch_routing_works<
|
|||||||
sibling_parachain_id.into(),
|
sibling_parachain_id.into(),
|
||||||
included_head,
|
included_head,
|
||||||
&alice,
|
&alice,
|
||||||
|
&slot_durations,
|
||||||
);
|
);
|
||||||
let result =
|
let result =
|
||||||
<<Runtime as BridgeMessagesConfig<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
<<Runtime as BridgeMessagesConfig<MessagesPalletInstance>>::MessageDispatch>::dispatch(
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ use frame_support::{
|
|||||||
weights::Weight,
|
weights::Weight,
|
||||||
};
|
};
|
||||||
use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor};
|
use frame_system::pallet_prelude::{BlockNumberFor, HeaderFor};
|
||||||
use parachains_common::SLOT_DURATION;
|
|
||||||
use polkadot_parachain_primitives::primitives::{
|
use polkadot_parachain_primitives::primitives::{
|
||||||
HeadData, HrmpChannelId, RelayChainBlockNumber, XcmpMessageFormat,
|
HeadData, HrmpChannelId, RelayChainBlockNumber, XcmpMessageFormat,
|
||||||
};
|
};
|
||||||
@@ -115,6 +114,11 @@ impl<Runtime: frame_system::Config + pallet_balances::Config + pallet_session::C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct SlotDurations {
|
||||||
|
pub relay: SlotDuration,
|
||||||
|
pub para: SlotDuration,
|
||||||
|
}
|
||||||
|
|
||||||
/// A set of traits for a minimal parachain runtime, that may be used in conjunction with the
|
/// A set of traits for a minimal parachain runtime, that may be used in conjunction with the
|
||||||
/// `ExtBuilder` and the `RuntimeHelper`.
|
/// `ExtBuilder` and the `RuntimeHelper`.
|
||||||
pub trait BasicParachainRuntime:
|
pub trait BasicParachainRuntime:
|
||||||
@@ -335,6 +339,7 @@ impl<
|
|||||||
open_hrmp_channel: Option<(u32, u32)>,
|
open_hrmp_channel: Option<(u32, u32)>,
|
||||||
included_head: HeaderFor<Runtime>,
|
included_head: HeaderFor<Runtime>,
|
||||||
slot_digest: &[u8],
|
slot_digest: &[u8],
|
||||||
|
slot_durations: &SlotDurations,
|
||||||
) -> DispatchResult
|
) -> DispatchResult
|
||||||
where
|
where
|
||||||
HrmpChannelOpener: frame_support::inherent::ProvideInherent<
|
HrmpChannelOpener: frame_support::inherent::ProvideInherent<
|
||||||
@@ -348,6 +353,7 @@ impl<
|
|||||||
target_para_id.into(),
|
target_para_id.into(),
|
||||||
included_head,
|
included_head,
|
||||||
slot_digest,
|
slot_digest,
|
||||||
|
slot_durations,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,12 +499,12 @@ pub fn mock_open_hrmp_channel<
|
|||||||
recipient: ParaId,
|
recipient: ParaId,
|
||||||
included_head: HeaderFor<C>,
|
included_head: HeaderFor<C>,
|
||||||
mut slot_digest: &[u8],
|
mut slot_digest: &[u8],
|
||||||
|
slot_durations: &SlotDurations,
|
||||||
) {
|
) {
|
||||||
const RELAY_CHAIN_SLOT_DURATION: SlotDuration = SlotDuration::from_millis(6000);
|
|
||||||
let slot = Slot::decode(&mut slot_digest).expect("failed to decode digest");
|
let slot = Slot::decode(&mut slot_digest).expect("failed to decode digest");
|
||||||
// Convert para slot to relay chain.
|
// Convert para slot to relay chain.
|
||||||
let timestamp = slot.saturating_mul(SLOT_DURATION);
|
let timestamp = slot.saturating_mul(slot_durations.para.as_millis());
|
||||||
let relay_slot = Slot::from_timestamp(timestamp.into(), RELAY_CHAIN_SLOT_DURATION);
|
let relay_slot = Slot::from_timestamp(timestamp.into(), slot_durations.relay);
|
||||||
|
|
||||||
let n = 1_u32;
|
let n = 1_u32;
|
||||||
let mut sproof_builder = RelayStateSproofBuilder {
|
let mut sproof_builder = RelayStateSproofBuilder {
|
||||||
|
|||||||
@@ -695,9 +695,7 @@ pub fn run() -> Result<()> {
|
|||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
|
|
||||||
AssetHubKusama |
|
AssetHubKusama | AssetHubWestend =>
|
||||||
AssetHubRococo |
|
|
||||||
AssetHubWestend =>
|
|
||||||
crate::service::start_asset_hub_node::<
|
crate::service::start_asset_hub_node::<
|
||||||
RuntimeApi,
|
RuntimeApi,
|
||||||
AuraId,
|
AuraId,
|
||||||
@@ -706,6 +704,15 @@ pub fn run() -> Result<()> {
|
|||||||
.map(|r| r.0)
|
.map(|r| r.0)
|
||||||
.map_err(Into::into),
|
.map_err(Into::into),
|
||||||
|
|
||||||
|
AssetHubRococo =>
|
||||||
|
crate::service::start_asset_hub_lookahead_node::<
|
||||||
|
RuntimeApi,
|
||||||
|
AuraId,
|
||||||
|
>(config, polkadot_config, collator_options, id, hwbench)
|
||||||
|
.await
|
||||||
|
.map(|r| r.0)
|
||||||
|
.map_err(Into::into),
|
||||||
|
|
||||||
CollectivesPolkadot | CollectivesWestend =>
|
CollectivesPolkadot | CollectivesWestend =>
|
||||||
crate::service::start_generic_aura_node::<
|
crate::service::start_generic_aura_node::<
|
||||||
RuntimeApi,
|
RuntimeApi,
|
||||||
|
|||||||
@@ -976,6 +976,7 @@ pub async fn start_rococo_parachain_node(
|
|||||||
proposer,
|
proposer,
|
||||||
collator_service,
|
collator_service,
|
||||||
authoring_duration: Duration::from_millis(1500),
|
authoring_duration: Duration::from_millis(1500),
|
||||||
|
reinitialize: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let fut = aura::run::<
|
let fut = aura::run::<
|
||||||
@@ -1291,7 +1292,7 @@ where
|
|||||||
Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry))
|
Ok(BasicQueue::new(verifier, Box::new(block_import), None, &spawner, registry))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start an aura powered parachain node. Asset Hub and Collectives use this.
|
/// Start an aura powered parachain node. Collectives uses this.
|
||||||
pub async fn start_generic_aura_node<RuntimeApi, AuraId: AppCrypto>(
|
pub async fn start_generic_aura_node<RuntimeApi, AuraId: AppCrypto>(
|
||||||
parachain_config: Configuration,
|
parachain_config: Configuration,
|
||||||
polkadot_config: Configuration,
|
polkadot_config: Configuration,
|
||||||
@@ -1530,6 +1531,159 @@ where
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start a shell node which should later transition into an Aura powered parachain node. Asset Hub
|
||||||
|
/// uses this because at genesis, Asset Hub was on the `shell` runtime which didn't have Aura and
|
||||||
|
/// needs to sync and upgrade before it can run `AuraApi` functions.
|
||||||
|
///
|
||||||
|
/// Uses the lookahead collator to support async backing.
|
||||||
|
#[sc_tracing::logging::prefix_logs_with("Parachain")]
|
||||||
|
pub async fn start_asset_hub_lookahead_node<RuntimeApi, AuraId: AppCrypto + Send + Codec + Sync>(
|
||||||
|
parachain_config: Configuration,
|
||||||
|
polkadot_config: Configuration,
|
||||||
|
collator_options: CollatorOptions,
|
||||||
|
para_id: ParaId,
|
||||||
|
hwbench: Option<sc_sysinfo::HwBench>,
|
||||||
|
) -> sc_service::error::Result<(TaskManager, Arc<ParachainClient<RuntimeApi>>)>
|
||||||
|
where
|
||||||
|
RuntimeApi: ConstructRuntimeApi<Block, ParachainClient<RuntimeApi>> + Send + Sync + 'static,
|
||||||
|
RuntimeApi::RuntimeApi: sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block>
|
||||||
|
+ sp_api::Metadata<Block>
|
||||||
|
+ sp_session::SessionKeys<Block>
|
||||||
|
+ sp_api::ApiExt<Block>
|
||||||
|
+ sp_offchain::OffchainWorkerApi<Block>
|
||||||
|
+ sp_block_builder::BlockBuilder<Block>
|
||||||
|
+ cumulus_primitives_core::CollectCollationInfo<Block>
|
||||||
|
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppCrypto>::Pair as Pair>::Public>
|
||||||
|
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
||||||
|
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
|
||||||
|
+ cumulus_primitives_aura::AuraUnincludedSegmentApi<Block>,
|
||||||
|
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
|
||||||
|
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
|
||||||
|
{
|
||||||
|
start_node_impl::<RuntimeApi, _, _, _>(
|
||||||
|
parachain_config,
|
||||||
|
polkadot_config,
|
||||||
|
collator_options,
|
||||||
|
CollatorSybilResistance::Resistant, // Aura
|
||||||
|
para_id,
|
||||||
|
|_| Ok(RpcModule::new(())),
|
||||||
|
aura_build_import_queue::<_, AuraId>,
|
||||||
|
|client,
|
||||||
|
block_import,
|
||||||
|
prometheus_registry,
|
||||||
|
telemetry,
|
||||||
|
task_manager,
|
||||||
|
relay_chain_interface,
|
||||||
|
transaction_pool,
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
para_id,
|
||||||
|
collator_key,
|
||||||
|
overseer_handle,
|
||||||
|
announce_block,
|
||||||
|
backend| {
|
||||||
|
let relay_chain_interface2 = relay_chain_interface.clone();
|
||||||
|
|
||||||
|
let collator_service = CollatorService::new(
|
||||||
|
client.clone(),
|
||||||
|
Arc::new(task_manager.spawn_handle()),
|
||||||
|
announce_block,
|
||||||
|
client.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let spawner = task_manager.spawn_handle();
|
||||||
|
|
||||||
|
let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording(
|
||||||
|
spawner,
|
||||||
|
client.clone(),
|
||||||
|
transaction_pool,
|
||||||
|
prometheus_registry,
|
||||||
|
telemetry.clone(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let collation_future = Box::pin(async move {
|
||||||
|
// Start collating with the `shell` runtime while waiting for an upgrade to an Aura
|
||||||
|
// compatible runtime.
|
||||||
|
let mut request_stream = cumulus_client_collator::relay_chain_driven::init(
|
||||||
|
collator_key.clone(),
|
||||||
|
para_id,
|
||||||
|
overseer_handle.clone(),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
while let Some(request) = request_stream.next().await {
|
||||||
|
let pvd = request.persisted_validation_data().clone();
|
||||||
|
let last_head_hash =
|
||||||
|
match <Block as BlockT>::Header::decode(&mut &pvd.parent_head.0[..]) {
|
||||||
|
Ok(header) => header.hash(),
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Could not decode the head data: {e}");
|
||||||
|
request.complete(None);
|
||||||
|
continue
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check if we have upgraded to an Aura compatible runtime and transition if
|
||||||
|
// necessary.
|
||||||
|
if client
|
||||||
|
.runtime_api()
|
||||||
|
.has_api::<dyn AuraApi<Block, AuraId>>(last_head_hash)
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
|
// Respond to this request before transitioning to Aura.
|
||||||
|
request.complete(None);
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move to Aura consensus.
|
||||||
|
let slot_duration = match cumulus_client_consensus_aura::slot_duration(&*client) {
|
||||||
|
Ok(d) => d,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Could not get Aura slot duration: {e}");
|
||||||
|
return
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let proposer = Proposer::new(proposer_factory);
|
||||||
|
|
||||||
|
let params = AuraParams {
|
||||||
|
create_inherent_data_providers: move |_, ()| async move { Ok(()) },
|
||||||
|
block_import,
|
||||||
|
para_client: client.clone(),
|
||||||
|
para_backend: backend,
|
||||||
|
relay_client: relay_chain_interface2,
|
||||||
|
code_hash_provider: move |block_hash| {
|
||||||
|
client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash())
|
||||||
|
},
|
||||||
|
sync_oracle,
|
||||||
|
keystore,
|
||||||
|
collator_key,
|
||||||
|
para_id,
|
||||||
|
overseer_handle,
|
||||||
|
slot_duration,
|
||||||
|
relay_chain_slot_duration,
|
||||||
|
proposer,
|
||||||
|
collator_service,
|
||||||
|
authoring_duration: Duration::from_millis(1500),
|
||||||
|
reinitialize: true, /* we need to always re-initialize for asset-hub moving
|
||||||
|
* to aura */
|
||||||
|
};
|
||||||
|
|
||||||
|
aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _, _, _>(params)
|
||||||
|
.await
|
||||||
|
});
|
||||||
|
|
||||||
|
let spawner = task_manager.spawn_essential_handle();
|
||||||
|
spawner.spawn_essential("cumulus-asset-hub-collator", None, collation_future);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
hwbench,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
/// Start an aura powered parachain node which uses the lookahead collator to support async backing.
|
/// Start an aura powered parachain node which uses the lookahead collator to support async backing.
|
||||||
/// This node is basic in the sense that its runtime api doesn't include common contents such as
|
/// This node is basic in the sense that its runtime api doesn't include common contents such as
|
||||||
/// transaction payment. Used for aura glutton.
|
/// transaction payment. Used for aura glutton.
|
||||||
@@ -1615,6 +1769,7 @@ where
|
|||||||
proposer,
|
proposer,
|
||||||
collator_service,
|
collator_service,
|
||||||
authoring_duration: Duration::from_millis(1500),
|
authoring_duration: Duration::from_millis(1500),
|
||||||
|
reinitialize: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
let fut =
|
let fut =
|
||||||
|
|||||||
@@ -143,6 +143,16 @@ impl CollationGenerationSubsystem {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
},
|
},
|
||||||
|
Ok(FromOrchestra::Communication {
|
||||||
|
msg: CollationGenerationMessage::Reinitialize(config),
|
||||||
|
}) => {
|
||||||
|
if self.config.is_none() {
|
||||||
|
gum::error!(target: LOG_TARGET, "no initial initialization");
|
||||||
|
} else {
|
||||||
|
self.config = Some(Arc::new(config));
|
||||||
|
}
|
||||||
|
false
|
||||||
|
},
|
||||||
Ok(FromOrchestra::Communication {
|
Ok(FromOrchestra::Communication {
|
||||||
msg: CollationGenerationMessage::SubmitCollation(params),
|
msg: CollationGenerationMessage::SubmitCollation(params),
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
@@ -830,8 +830,10 @@ pub enum ProvisionerMessage {
|
|||||||
/// Message to the Collation Generation subsystem.
|
/// Message to the Collation Generation subsystem.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum CollationGenerationMessage {
|
pub enum CollationGenerationMessage {
|
||||||
/// Initialize the collation generation subsystem
|
/// Initialize the collation generation subsystem.
|
||||||
Initialize(CollationGenerationConfig),
|
Initialize(CollationGenerationConfig),
|
||||||
|
/// Reinitialize the collation generation subsystem, overriding the existing config.
|
||||||
|
Reinitialize(CollationGenerationConfig),
|
||||||
/// Submit a collation to the subsystem. This will package it into a signed
|
/// Submit a collation to the subsystem. This will package it into a signed
|
||||||
/// [`CommittedCandidateReceipt`] and distribute along the network to validators.
|
/// [`CommittedCandidateReceipt`] and distribute along the network to validators.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
title: Enable async backing on asset-hub-rococo
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Runtime User
|
||||||
|
description: |
|
||||||
|
Async backing has been enabled on Asset Hub Rococo, which now targets 6s block times.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: asset-hub-rococo-runtime
|
||||||
|
- name: polkadot-parachain-bin
|
||||||
Reference in New Issue
Block a user