diff --git a/polkadot/runtime/src/constants.rs b/polkadot/runtime/src/constants.rs index 46e6ea0b8dbb4cad05c16d72224d4b55ea68e54a..2a7663a0fd2e0b7b6edf5ea1539c569097eacab7 100644 --- a/polkadot/runtime/src/constants.rs +++ b/polkadot/runtime/src/constants.rs @@ -24,25 +24,26 @@ pub mod currency { pub const MILLICENTS: Balance = CENTS / 1_000; } - -/// Time. +/// Time and blocks. pub mod time { use primitives::{Moment, BlockNumber}; - pub const MILLISECS_PER_BLOCK: Moment = 6000; - - pub const SLOT_DURATION: Moment = 1650; - + // Kusama & mainnet +// pub const MILLISECS_PER_BLOCK: Moment = 6000; + // Testnet + pub const MILLISECS_PER_BLOCK: Moment = 1000; + pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; + // Kusama & mainnet +// pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 4 * HOURS; + // Testnet pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; - pub const EPOCH_DURATION_IN_SLOTS: u64 = { - const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; - - (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64 - }; // These time units are defined in number of blocks. pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); pub const HOURS: BlockNumber = MINUTES * 60; pub const DAYS: BlockNumber = HOURS * 24; + + // 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks. + pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); } /// Fee-related. diff --git a/polkadot/runtime/src/lib.rs b/polkadot/runtime/src/lib.rs index 3a4fe08e5e7820329fd3eff2dc9f4b9971f9ea1d..f98d78ea9aef52a0fa94c860e21a57a74121c52c 100644 --- a/polkadot/runtime/src/lib.rs +++ b/polkadot/runtime/src/lib.rs @@ -162,7 +162,7 @@ impl system::Trait for Runtime { } parameter_types! { - pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS; + pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64; pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; } @@ -647,7 +647,7 @@ impl_runtime_apis! { babe_primitives::BabeConfiguration { median_required_blocks: 1000, slot_duration: Babe::slot_duration(), - c: (278, 1000), + c: PRIMARY_PROBABILITY, } } diff --git a/polkadot/runtime/src/parachains.rs b/polkadot/runtime/src/parachains.rs index e6d4b92e45d09cb92100789141bf25ad2607b14f..84c838319bc8b625d903f96816b0b0f0492a4e8f 100644 --- a/polkadot/runtime/src/parachains.rs +++ b/polkadot/runtime/src/parachains.rs @@ -969,7 +969,7 @@ mod tests { } parameter_types! { - pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS; + pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64; pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; }