Skip to content

Commit

Permalink
6 second block time
Browse files Browse the repository at this point in the history
  • Loading branch information
enddynayn committed Aug 19, 2024
1 parent e03bfb2 commit 0862140
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions node/service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
16 changes: 16 additions & 0 deletions runtime/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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 ---
Expand Down
16 changes: 14 additions & 2 deletions runtime/frequency/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<true>;
#[cfg(feature = "frequency")]
type AllowMultipleBlocksPerSlot = ConstBool<false>;
type SlotDuration = ConstU64<SLOT_DURATION>;
}
Expand Down

0 comments on commit 0862140

Please sign in to comment.