Skip to content

Commit

Permalink
fix: enable throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Oct 16, 2023
1 parent 8c199c3 commit 875945f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions primitives/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use sp_runtime::Perbill;

use crate::types::{Balance, BlockNumber};

#[cfg(not(feature = "lookahead"))]
pub const MILLISECS_PER_BLOCK: u64 = 12000;
#[cfg(feature = "lookahead")]
pub const MILLISECS_PER_BLOCK: u64 = 3000;
pub const MILLISECS_PER_RELAY_BLOCK: u64 = 6000;

pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
Expand Down
19 changes: 19 additions & 0 deletions runtime/common/config/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,28 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
type ReservedDmpWeight = ReservedDmpWeight;
type ReservedXcmpWeight = ReservedXcmpWeight;
type XcmpMessageHandler = XcmpQueue;
#[cfg(not(feature = "lookahead"))]
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
#[cfg(feature = "lookahead")]
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
}

impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included
/// into the relay chain.
#[cfg(feature = "lookahead")]
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.
#[cfg(feature = "lookahead")]
const BLOCK_PROCESSING_VELOCITY: u32 = 2;
#[cfg(feature = "lookahead")]
pub type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook<
Runtime,
{MILLISECS_PER_RELAY_BLOCK as u32},
BLOCK_PROCESSING_VELOCITY,
UNINCLUDED_SEGMENT_CAPACITY,
>;
7 changes: 3 additions & 4 deletions runtime/common/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,10 @@ macro_rules! impl_common_runtime_apis {
#[cfg(feature = "lookahead")]
impl cumulus_primitives_aura::AuraUnincludedSegmentApi<Block> for Runtime {
fn can_build_upon(
_included_hash: <Block as BlockT>::Hash,
_slot: cumulus_primitives_aura::Slot,
included_hash: <Block as BlockT>::Hash,
slot: cumulus_primitives_aura::Slot,
) -> bool {
// FIXME: Limit velocity
true
crate::config::parachain::ConsensusHook::can_build_upon(included_hash, slot)
}
}

Expand Down

0 comments on commit 875945f

Please sign in to comment.