mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Move cumulus zombienet tests to aura & async backing (#3568)
Cumulus test-parachain node and test runtime were still using relay chain consensus and 12s blocktimes. With async backing around the corner on the major chains we should switch our tests too. Also needed to nicely test the changes coming to collators in #3168. ### Changes Overview - Followed the [migration guide](https://wiki.polkadot.network/docs/maintain-guides-async-backing) for async backing for the cumulus-test-runtime - Adjusted the cumulus-test-service to use the correct import-queue, lookahead collator etc. - The block validation function now uses the Aura Ext Executor so that the seal of the block is validated - Previous point requires that we seal block before calling into `validate_block`, I introduced a helper function for that - Test client adjusted to provide a slot to the relay chain proof and the aura pre-digest
This commit is contained in:
@@ -28,10 +28,11 @@ pub mod wasm_spec_version_incremented {
|
||||
}
|
||||
|
||||
mod test_pallet;
|
||||
|
||||
use frame_support::{derive_impl, traits::OnRuntimeUpgrade};
|
||||
use frame_support::{derive_impl, traits::OnRuntimeUpgrade, PalletId};
|
||||
use sp_api::{decl_runtime_apis, impl_runtime_apis};
|
||||
use sp_core::{ConstU32, OpaqueMetadata};
|
||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
use sp_core::{ConstBool, ConstU32, ConstU64, OpaqueMetadata};
|
||||
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, Verify},
|
||||
@@ -74,12 +75,18 @@ pub use test_pallet::Call as TestPalletCall;
|
||||
pub type SessionHandlers = ();
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {}
|
||||
pub struct SessionKeys {
|
||||
pub aura: Aura,
|
||||
}
|
||||
}
|
||||
|
||||
/// The para-id used in this runtime.
|
||||
pub const PARACHAIN_ID: u32 = 100;
|
||||
|
||||
const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3;
|
||||
const BLOCK_PROCESSING_VELOCITY: u32 = 1;
|
||||
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
|
||||
|
||||
// The only difference between the two declarations below is the `spec_version`. With the
|
||||
// `increment-spec-version` feature enabled `spec_version` should be greater than the one of without
|
||||
// the `increment-spec-version` feature.
|
||||
@@ -119,7 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
state_version: 1,
|
||||
};
|
||||
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 12000;
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||
|
||||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||
|
||||
@@ -145,9 +152,9 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
|
||||
/// by Operational extrinsics.
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
/// We allow for .5 seconds of compute with a 12 second average block time.
|
||||
/// We allow for 1 second of compute with a 6 second average block time.
|
||||
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(
|
||||
WEIGHT_REF_TIME_PER_SECOND.saturating_div(2),
|
||||
WEIGHT_REF_TIME_PER_SECOND,
|
||||
cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64,
|
||||
);
|
||||
|
||||
@@ -203,12 +210,17 @@ impl frame_system::Config for Runtime {
|
||||
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
pub const PotId: PalletId = PalletId(*b"PotStake");
|
||||
pub const SessionLength: BlockNumber = 10 * MINUTES;
|
||||
pub const Offset: u32 = 0;
|
||||
}
|
||||
|
||||
impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
@@ -260,6 +272,12 @@ impl pallet_glutton::Config for Runtime {
|
||||
type WeightInfo = pallet_glutton::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||
Runtime,
|
||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||
BLOCK_PROCESSING_VELOCITY,
|
||||
UNINCLUDED_SEGMENT_CAPACITY,
|
||||
>;
|
||||
impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type WeightInfo = ();
|
||||
type SelfParaId = ParachainId;
|
||||
@@ -271,8 +289,17 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type ReservedDmpWeight = ();
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::AnyRelayNumber;
|
||||
type ConsensusHook = cumulus_pallet_parachain_system::consensus_hook::RequireParentIncluded;
|
||||
type CheckAssociatedRelayNumber =
|
||||
cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
|
||||
type ConsensusHook = ConsensusHook;
|
||||
}
|
||||
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
type DisabledValidators = ();
|
||||
type MaxAuthorities = ConstU32<32>;
|
||||
type AllowMultipleBlocksPerSlot = ConstBool<true>;
|
||||
type SlotDuration = ConstU64<SLOT_DURATION>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -293,6 +320,8 @@ construct_runtime! {
|
||||
TransactionPayment: pallet_transaction_payment,
|
||||
TestPallet: test_pallet,
|
||||
Glutton: pallet_glutton,
|
||||
Aura: pallet_aura,
|
||||
AuraExt: cumulus_pallet_aura_ext,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,6 +411,26 @@ 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_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> sp_consensus_aura::SlotDuration {
|
||||
sp_consensus_aura::SlotDuration::from_millis(SLOT_DURATION)
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
pallet_aura::Authorities::<Runtime>::get().into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
OpaqueMetadata::new(Runtime::metadata().into())
|
||||
@@ -479,5 +528,5 @@ impl_runtime_apis! {
|
||||
|
||||
cumulus_pallet_parachain_system::register_validate_block! {
|
||||
Runtime = Runtime,
|
||||
BlockExecutor = Executive,
|
||||
BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user