From bf8a1d8a1aa331b92f352f07296c8e58937ff725 Mon Sep 17 00:00:00 2001 From: Alexander Popiak Date: Tue, 6 Apr 2021 12:09:04 +0200 Subject: [PATCH] add more notes on changing epoch duration (#8491) * add more notes on changing epoch duration * add note about changing slot duration --- substrate/bin/node-template/runtime/src/lib.rs | 2 ++ substrate/bin/node/runtime/src/constants.rs | 4 ++++ substrate/bin/node/runtime/src/lib.rs | 2 ++ 3 files changed, 8 insertions(+) diff --git a/substrate/bin/node-template/runtime/src/lib.rs b/substrate/bin/node-template/runtime/src/lib.rs index 1453b54309..d72a558e1d 100644 --- a/substrate/bin/node-template/runtime/src/lib.rs +++ b/substrate/bin/node-template/runtime/src/lib.rs @@ -117,6 +117,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { /// Change this to adjust the block time. 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; // Time is measured by number of blocks. diff --git a/substrate/bin/node/runtime/src/constants.rs b/substrate/bin/node/runtime/src/constants.rs index c549b1977d..2f6ad002a9 100644 --- a/substrate/bin/node/runtime/src/constants.rs +++ b/substrate/bin/node/runtime/src/constants.rs @@ -54,11 +54,15 @@ pub mod time { pub const MILLISECS_PER_BLOCK: Moment = 3000; pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000; + // 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: Moment = MILLISECS_PER_BLOCK; // 1 in 4 blocks (on average, not counting collisions) will be primary BABE blocks. pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); + // NOTE: Currently it is not possible to change the epoch duration after the chain has started. + // Attempting to do so will brick block production. 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; diff --git a/substrate/bin/node/runtime/src/lib.rs b/substrate/bin/node/runtime/src/lib.rs index 2d763979c7..448867b25c 100644 --- a/substrate/bin/node/runtime/src/lib.rs +++ b/substrate/bin/node/runtime/src/lib.rs @@ -326,6 +326,8 @@ impl pallet_scheduler::Config for Runtime { } parameter_types! { + // NOTE: Currently it is not possible to change the epoch duration after the chain has started. + // Attempting to do so will brick block production. pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS; pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK; pub const ReportLongevity: u64 =