mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
Blocktime and epoch length tweaks. (#379)
* Blocktime and epoch length tweaks. * Tweak probabilities. * Deduplication. * Add testnet values.
This commit is contained in:
@@ -24,25 +24,26 @@ pub mod currency {
|
|||||||
pub const MILLICENTS: Balance = CENTS / 1_000;
|
pub const MILLICENTS: Balance = CENTS / 1_000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Time and blocks.
|
||||||
/// Time.
|
|
||||||
pub mod time {
|
pub mod time {
|
||||||
use primitives::{Moment, BlockNumber};
|
use primitives::{Moment, BlockNumber};
|
||||||
pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
// Kusama & mainnet
|
||||||
|
// pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
||||||
pub const SLOT_DURATION: Moment = 1650;
|
// 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_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.
|
// These time units are defined in number of blocks.
|
||||||
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
||||||
pub const HOURS: BlockNumber = MINUTES * 60;
|
pub const HOURS: BlockNumber = MINUTES * 60;
|
||||||
pub const DAYS: BlockNumber = HOURS * 24;
|
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.
|
/// Fee-related.
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ impl system::Trait for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
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;
|
pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ impl_runtime_apis! {
|
|||||||
babe_primitives::BabeConfiguration {
|
babe_primitives::BabeConfiguration {
|
||||||
median_required_blocks: 1000,
|
median_required_blocks: 1000,
|
||||||
slot_duration: Babe::slot_duration(),
|
slot_duration: Babe::slot_duration(),
|
||||||
c: (278, 1000),
|
c: PRIMARY_PROBABILITY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -969,7 +969,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
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;
|
pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user