mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Updating glutton for async backing (#1619)
Applied changes from the [User Update Guide](https://docs.google.com/document/d/1WQijD3bZTCsudOyPcDvugv659nCa2hEp2b_8eRU0h-Q), diverging in the node side where service.rs is different for `polkadot-parachain` than in the parachain template.
This commit is contained in:
@@ -81,12 +81,7 @@ use frame_system::{
|
||||
limits::{BlockLength, BlockWeights},
|
||||
EnsureRoot,
|
||||
};
|
||||
use parachains_common::{
|
||||
kusama::consensus::{
|
||||
BLOCK_PROCESSING_VELOCITY, RELAY_CHAIN_SLOT_DURATION_MILLIS, UNINCLUDED_SEGMENT_CAPACITY,
|
||||
},
|
||||
AccountId, Signature, SLOT_DURATION,
|
||||
};
|
||||
use parachains_common::{AccountId, Signature};
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use sp_runtime::{Perbill, Permill};
|
||||
@@ -123,10 +118,28 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
/// We allow for .5 seconds of compute with a 12 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.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 = 2;
|
||||
/// Relay chain slot duration, in milliseconds.
|
||||
const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000;
|
||||
|
||||
/// 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 BlockHashCount: BlockNumber = 4096;
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
@@ -184,6 +197,13 @@ parameter_types! {
|
||||
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(2);
|
||||
}
|
||||
|
||||
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 RuntimeEvent = RuntimeEvent;
|
||||
type OnSystemEvent = ();
|
||||
@@ -194,12 +214,7 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type XcmpMessageHandler = ();
|
||||
type ReservedXcmpWeight = ();
|
||||
type CheckAssociatedRelayNumber = RelayNumberMonotonicallyIncreases;
|
||||
type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
|
||||
Runtime,
|
||||
RELAY_CHAIN_SLOT_DURATION_MILLIS,
|
||||
BLOCK_PROCESSING_VELOCITY,
|
||||
UNINCLUDED_SEGMENT_CAPACITY,
|
||||
>;
|
||||
type ConsensusHook = ConsensusHook;
|
||||
}
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
@@ -209,7 +224,7 @@ impl cumulus_pallet_aura_ext::Config for Runtime {}
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>;
|
||||
type MinimumPeriod = ConstU64<0>;
|
||||
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
|
||||
}
|
||||
|
||||
@@ -217,9 +232,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>;
|
||||
}
|
||||
|
||||
impl pallet_glutton::Config for Runtime {
|
||||
@@ -340,7 +355,7 @@ 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> {
|
||||
@@ -348,6 +363,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_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(
|
||||
extrinsic: <Block as BlockT>::Extrinsic,
|
||||
|
||||
Reference in New Issue
Block a user