mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 22:11:02 +00:00
Enable async backing on all testnet system chains (#2949)
Built on top of https://github.com/paritytech/polkadot-sdk/pull/2826/ which was a trial run. Guide: https://github.com/w3f/polkadot-wiki/blob/master/docs/maintain/maintain-guides-async-backing.md --------- Signed-off-by: georgepisaltu <george.pisaltu@parity.io> Co-authored-by: Branislav Kontur <bkontur@gmail.com> Co-authored-by: Dónal Murray <donal.murray@parity.io> Co-authored-by: Dmitry Sinyavin <dmitry.sinyavin@parity.io> Co-authored-by: s0me0ne-unkn0wn <48632512+s0me0ne-unkn0wn@users.noreply.github.com> Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: georgepisaltu <52418509+georgepisaltu@users.noreply.github.com>
This commit is contained in:
@@ -62,7 +62,7 @@ use frame_support::{
|
||||
ConstU128, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Equals, InstanceFilter,
|
||||
TransformOrigin,
|
||||
},
|
||||
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight},
|
||||
weights::{ConstantMultiplier, Weight},
|
||||
BoundedVec, PalletId,
|
||||
};
|
||||
use frame_system::{
|
||||
@@ -75,11 +75,10 @@ use parachains_common::{
|
||||
impls::DealWithFees,
|
||||
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
|
||||
AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, CollectionId, Hash,
|
||||
Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS,
|
||||
NORMAL_DISPATCH_RATIO,
|
||||
Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
|
||||
};
|
||||
use sp_runtime::{Perbill, RuntimeDebug};
|
||||
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee};
|
||||
use testnet_parachains_constants::rococo::{consensus::*, currency::*, fee::WeightToFee, time::*};
|
||||
use xcm_config::{
|
||||
ForeignAssetsConvertedConcreteId, ForeignCreatorsSovereignAccountOf, GovernanceLocation,
|
||||
PoolAssetsConvertedConcreteId, TokenLocation, TokenLocationV3,
|
||||
@@ -140,28 +139,6 @@ pub fn native_version() -> NativeVersion {
|
||||
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! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub RuntimeBlockLength: BlockLength =
|
||||
|
||||
@@ -28,7 +28,7 @@ use asset_hub_rococo_runtime::{
|
||||
AllPalletsWithoutSystem, AssetConversion, AssetDeposit, Assets, Balances, CollatorSelection,
|
||||
ExistentialDeposit, ForeignAssets, ForeignAssetsInstance, MetadataDepositBase,
|
||||
MetadataDepositPerByte, ParachainSystem, Runtime, RuntimeCall, RuntimeEvent, SessionKeys,
|
||||
ToWestendXcmRouterInstance, TrustBackedAssetsInstance, XcmpQueue, SLOT_DURATION,
|
||||
ToWestendXcmRouterInstance, TrustBackedAssetsInstance, XcmpQueue,
|
||||
};
|
||||
use asset_test_utils::{
|
||||
test_cases_over_bridge::TestBridgingConfig, CollatorSessionKey, CollatorSessionKeys,
|
||||
@@ -50,9 +50,7 @@ use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance}
|
||||
use sp_consensus_aura::SlotDuration;
|
||||
use sp_runtime::traits::MaybeEquivalence;
|
||||
use std::convert::Into;
|
||||
use testnet_parachains_constants::rococo::{
|
||||
consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, currency::UNITS, fee::WeightToFee,
|
||||
};
|
||||
use testnet_parachains_constants::rococo::{consensus::*, currency::UNITS, fee::WeightToFee};
|
||||
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||
use xcm_builder::V4V3LocationConverter;
|
||||
use xcm_executor::traits::{JustTry, WeightTrader};
|
||||
|
||||
@@ -73,6 +73,7 @@ cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system
|
||||
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", 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-primitives-aura = { path = "../../../../primitives/aura", default-features = false }
|
||||
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
|
||||
cumulus-primitives-utility = { path = "../../../../primitives/utility", default-features = false }
|
||||
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
|
||||
@@ -175,6 +176,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",
|
||||
|
||||
@@ -32,7 +32,7 @@ use assets_common::{
|
||||
AssetIdForTrustBackedAssetsConvert,
|
||||
};
|
||||
use codec::{Decode, Encode, MaxEncodedLen};
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
|
||||
use frame_support::{
|
||||
construct_runtime, derive_impl,
|
||||
@@ -58,7 +58,7 @@ use pallet_xcm::EnsureXcm;
|
||||
use parachains_common::{
|
||||
impls::DealWithFees, message_queue::*, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance,
|
||||
BlockNumber, CollectionId, Hash, Header, ItemId, Nonce, Signature, AVERAGE_ON_INITIALIZE_RATIO,
|
||||
DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
|
||||
NORMAL_DISPATCH_RATIO,
|
||||
};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
@@ -72,7 +72,7 @@ use sp_std::prelude::*;
|
||||
#[cfg(feature = "std")]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee};
|
||||
use testnet_parachains_constants::westend::{consensus::*, currency::*, fee::WeightToFee, time::*};
|
||||
use xcm_config::{
|
||||
ForeignAssetsConvertedConcreteId, PoolAssetsConvertedConcreteId,
|
||||
TrustBackedAssetsConvertedConcreteId, TrustBackedAssetsPalletLocationV3, WestendLocation,
|
||||
@@ -171,6 +171,9 @@ impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
#[cfg(feature = "experimental")]
|
||||
type MinimumPeriod = ConstU64<0>;
|
||||
#[cfg(not(feature = "experimental"))]
|
||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||
}
|
||||
@@ -604,15 +607,17 @@ 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 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! {
|
||||
@@ -697,9 +702,9 @@ impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<100_000>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<false>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<true>;
|
||||
#[cfg(feature = "experimental")]
|
||||
type SlotDuration = pallet_aura::MinimumPeriodTimesTwo<Self>;
|
||||
type SlotDuration = ConstU64<SLOT_DURATION>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -980,7 +985,7 @@ impl frame_support::traits::OnRuntimeUpgrade for DeleteUndecodableStorage {
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("Failed to destroy undecodable NFT item: {:?}", e);
|
||||
return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes)
|
||||
return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -992,7 +997,7 @@ impl frame_support::traits::OnRuntimeUpgrade for DeleteUndecodableStorage {
|
||||
},
|
||||
Err(e) => {
|
||||
log::error!("Failed to destroy undecodable NFT item: {:?}", e);
|
||||
return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes)
|
||||
return <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0, writes);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1090,7 +1095,7 @@ 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> {
|
||||
@@ -1098,6 +1103,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 {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
|
||||
@@ -47,13 +47,11 @@ use frame_support::{
|
||||
},
|
||||
weights::{Weight, WeightToFee as WeightToFeeT},
|
||||
};
|
||||
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, SLOT_DURATION};
|
||||
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
|
||||
use sp_consensus_aura::SlotDuration;
|
||||
use sp_runtime::traits::MaybeEquivalence;
|
||||
use std::convert::Into;
|
||||
use testnet_parachains_constants::westend::{
|
||||
consensus::RELAY_CHAIN_SLOT_DURATION_MILLIS, currency::UNITS, fee::WeightToFee,
|
||||
};
|
||||
use testnet_parachains_constants::westend::{consensus::*, currency::UNITS, fee::WeightToFee};
|
||||
use xcm::latest::prelude::{Assets as XcmAssets, *};
|
||||
use xcm_builder::V4V3LocationConverter;
|
||||
use xcm_executor::traits::{JustTry, WeightTrader};
|
||||
|
||||
Reference in New Issue
Block a user