Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: set babe epoch config at genesis #241

Merged
merged 2 commits into from
May 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage = 'https://github.com/galacticcouncil/hydradx-node'
license = 'Apache 2.0'
name = 'hydra-dx'
repository = 'https://github.com/galacticcouncil/hydradx-node'
version = '3.2.0'
version = '3.3.0'

[[bin]]
name = 'hydra-dx'
Expand Down
4 changes: 2 additions & 2 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ fn testnet_genesis(
},
pallet_babe: BabeConfig {
authorities: vec![],
epoch_config: Default::default(), //TODO: epoch config value ???
epoch_config: Some(hydra_dx_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
pallet_authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
pallet_im_online: Default::default(),
Expand Down Expand Up @@ -480,7 +480,7 @@ fn lerna_genesis(
},
pallet_babe: BabeConfig {
authorities: vec![],
epoch_config: Default::default(),
epoch_config: Some(hydra_dx_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
pallet_authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
pallet_im_online: ImOnlineConfig { keys: vec![] },
Expand Down
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ homepage = 'https://github.com/galacticcouncil/hydradx-node'
license = 'Apache 2.0'
name = 'hydra-dx-runtime'
repository = 'https://github.com/galacticcouncil/hydradx-node'
version = '11.0.0'
version = '11.1.0'
jak-pan marked this conversation as resolved.
Show resolved Hide resolved

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
Expand Down
3 changes: 3 additions & 0 deletions runtime/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pub mod time {
pub const INFINITY: u32 = u32::MAX;
}

pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);

#[cfg(test)]
mod tests {
use super::time::{DAYS, EPOCH_DURATION_IN_BLOCKS, HOURS, MILLISECS_PER_BLOCK, MINUTES, SECS_PER_BLOCK};
Expand All @@ -68,6 +70,7 @@ mod tests {
// 6s per block
assert_eq!(SECS_PER_BLOCK, 6);
// 1s = 1000ms
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
assert_eq!(MILLISECS_PER_BLOCK / 1000, SECS_PER_BLOCK);
// Extra check for epoch time because changing it bricks the block production and requires regenesis
assert_eq!(EPOCH_DURATION_IN_BLOCKS, 4 * HOURS);
Expand Down
9 changes: 8 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,19 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("hydra-dx"),
impl_name: create_runtime_str!("hydra-dx"),
authoring_version: 1,
spec_version: 11,
spec_version: 12,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
};

/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: sp_consensus_babe::BabeEpochConfiguration =
sp_consensus_babe::BabeEpochConfiguration {
c: PRIMARY_PROBABILITY,
allowed_slots: sp_consensus_babe::AllowedSlots::PrimaryAndSecondaryPlainSlots,
};

/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic
/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_perthousand(25);
Expand Down