Blocktime and epoch length tweaks. (#379)

* Blocktime and epoch length tweaks.

* Tweak probabilities.

* Deduplication.

* Add testnet values.
This commit is contained in:
Gavin Wood
2019-08-16 21:48:42 +02:00
committed by GitHub
parent da39da8a04
commit 406aad0f9b
3 changed files with 15 additions and 14 deletions
+12 -11
View File
@@ -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.
+2 -2
View File
@@ -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,
}
}
+1 -1
View File
@@ -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;
}