Skip to content

Commit

Permalink
Add fast-runtime feature for dev runtimes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardo-xxnet committed Jun 6, 2022
1 parent 91ea0f6 commit f2007ae
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,7 @@ try-runtime = [
xxnetwork = ["xxnetwork-runtime", "node-executor/xxnetwork"]
protonet = ["protonet-runtime", "node-executor/protonet"]
phoenixx = ["phoenixx-runtime", "node-executor/phoenixx"]

fast-runtime = [
"xxnetwork-runtime/fast-runtime",
]
1 change: 1 addition & 0 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ std = [
"pallet-staking/std",
"pallet-election-provider-multi-phase/std",
]
fast-runtime = []
5 changes: 4 additions & 1 deletion runtime/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub mod currency {
/// Time.
pub mod time {
use node_primitives::{Moment, BlockNumber};
use crate::prod_or_fast;

/// Since BABE is probabilistic this is the average expected block time that
/// we are targeting. Blocks will be produced at a minimum duration defined
Expand Down Expand Up @@ -84,7 +85,9 @@ pub mod time {

// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
// For fast runtimes, redefine the hours constanst to be 120x faster (5 blocks instead of 600)
// This will propragate to other time constants
pub const HOURS: BlockNumber = prod_or_fast!(MINUTES * 60, 5);
pub const DAYS: BlockNumber = HOURS * 24;
pub const WEEKS: BlockNumber = 7 * DAYS;
pub const YEARS: BlockNumber = 365 * DAYS + 6*HOURS;
Expand Down
1 change: 1 addition & 0 deletions runtime/xxnetwork/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,4 @@ try-runtime = [
"pallet-uniques/try-runtime",
"migrations/try-runtime"
]
fast-runtime = ["runtime-common/fast-runtime"]

0 comments on commit f2007ae

Please sign in to comment.