From 0862140e3ed3121f5c678ac0752d2846aa4181a2 Mon Sep 17 00:00:00 2001 From: eNDdy Date: Mon, 19 Aug 2024 12:51:40 -0600 Subject: [PATCH] 6 second block time --- node/service/src/service.rs | 3 +++ runtime/common/src/constants.rs | 16 ++++++++++++++++ runtime/frequency/src/lib.rs | 16 ++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/node/service/src/service.rs b/node/service/src/service.rs index 5da1c4fc86..e7b850be9e 100644 --- a/node/service/src/service.rs +++ b/node/service/src/service.rs @@ -466,7 +466,10 @@ fn start_consensus( relay_chain_slot_duration, proposer, collator_service, + #[cfg(feature = "frequency-testnet")] // Very limited proposal time. + authoring_duration: Duration::from_millis(2000), + #[cfg(not(feature = "frequency-testnet"))] authoring_duration: Duration::from_millis(500), reinitialize: false, }; diff --git a/runtime/common/src/constants.rs b/runtime/common/src/constants.rs index aece71a10d..1d9d4d95b1 100644 --- a/runtime/common/src/constants.rs +++ b/runtime/common/src/constants.rs @@ -18,6 +18,7 @@ pub const TOKEN_DECIMALS: u8 = 8; /// The maximum number of schema grants allowed per delegation pub type MaxSchemaGrants = ConstU32<30>; +#[cfg(not(feature = "frequency-testnet"))] /// 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 @@ -26,6 +27,9 @@ pub type MaxSchemaGrants = ConstU32<30>; /// Change this to adjust the block time. pub const MILLISECS_PER_BLOCK: u64 = 12000; +#[cfg(feature = "frequency-testnet")] +pub const MILLISECS_PER_BLOCK: u64 = 6000; + // NOTE: Currently it is not possible to change the slot duration after the chain has started. // Attempting to do so will brick block production. pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; @@ -63,10 +67,17 @@ pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); /// `Operational` extrinsics. pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); +#[cfg(feature = "frequency-testnet")] /// We allow for 0.5 of a second of compute with a 12 second average block time. pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND, 0) .saturating_div(2) .set_proof_size(cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64); + +#[cfg(not(feature = "frequency-testnet"))] +pub const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND, 0) + .saturating_mul(2) + .set_proof_size(cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64); + pub type ZERO = ConstU32<0>; pub type TWO = ConstU32<2>; pub type FIFTY = ConstU32<50>; @@ -125,6 +136,11 @@ pub type MinReleaseTransfer = ConstU128<0>; pub const MAX_RELEASE_SCHEDULES: u32 = 50; // -end- TimeRelease Pallet --- +#[cfg(feature = "frequency-testnet")] +// --- Timestamp Pallet --- +pub type MinimumPeriod = ConstU64<0>; + +#[cfg(not(feature = "frequency-testnet"))] // --- Timestamp Pallet --- pub type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; // -end- Timestamp Pallet --- diff --git a/runtime/frequency/src/lib.rs b/runtime/frequency/src/lib.rs index eb5cbe4115..936bf7620a 100644 --- a/runtime/frequency/src/lib.rs +++ b/runtime/frequency/src/lib.rs @@ -946,11 +946,20 @@ impl pallet_passkey::Config for Runtime { type Currency = Balances; } -#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))] +#[cfg(feature = "frequency-testnet")] +/// Maximum number of blocks simultaneously accepted by the Runtime, not yet included +/// into the relay chain. +const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; +#[cfg(feature = "frequency-testnet")] +/// 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; + +#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check", not(feature = "frequency-testnet")))] /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included /// into the relay chain. const UNINCLUDED_SEGMENT_CAPACITY: u32 = 1; -#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check"))] +#[cfg(any(not(feature = "frequency-no-relay"), feature = "frequency-lint-check", not(feature = "frequency-testnet")))] /// 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; @@ -1010,6 +1019,9 @@ impl pallet_aura::Config for Runtime { type AuthorityId = AuraId; type DisabledValidators = (); type MaxAuthorities = AuraMaxAuthorities; + #[cfg(any(not(feature = "frequency"), feature = "frequency-lint-check"))] + type AllowMultipleBlocksPerSlot = ConstBool; + #[cfg(feature = "frequency")] type AllowMultipleBlocksPerSlot = ConstBool; type SlotDuration = ConstU64; }