Skip to content
Snippets Groups Projects
Commit f8256087 authored by Éloïs's avatar Éloïs
Browse files

feat(gdev): make param babe.epochDuration dynamic

parent 38dca822
No related branches found
No related tags found
1 merge request!28Smiths sub-wot
...@@ -67,7 +67,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { ...@@ -67,7 +67,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
"gdev", "gdev",
ChainType::Development, ChainType::Development,
move || { move || {
devnet_genesis( gen_genesis_conf(
wasm_binary, wasm_binary,
// Initial authorities len // Initial authorities len
1, 1,
...@@ -101,7 +101,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { ...@@ -101,7 +101,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
)) ))
} }
fn devnet_genesis( fn gen_genesis_conf(
wasm_binary: &[u8], wasm_binary: &[u8],
initial_authorities_len: usize, initial_authorities_len: usize,
initial_smiths_len: usize, initial_smiths_len: usize,
...@@ -113,6 +113,7 @@ fn devnet_genesis( ...@@ -113,6 +113,7 @@ fn devnet_genesis(
assert!(initial_smiths_len <= initial_identities_len); assert!(initial_smiths_len <= initial_identities_len);
assert!(initial_authorities_len <= initial_smiths_len); assert!(initial_authorities_len <= initial_smiths_len);
let babe_epoch_duration = get_env_u32("DUNITER_BABE_EPOCH_DURATION", 600) as u64;
let cert_validity_period = get_env_u32("DUNITER_CERT_VALIDITY_PERIOD", 1_000); let cert_validity_period = get_env_u32("DUNITER_CERT_VALIDITY_PERIOD", 1_000);
let membership_period = get_env_u32("DUNITER_MEMBERSHIP_PERIOD", 1_000); let membership_period = get_env_u32("DUNITER_MEMBERSHIP_PERIOD", 1_000);
let membership_renewable_period = get_env_u32("DUNITER_MEMBERSHIP_RENEWABLE_PERIOD", 50); let membership_renewable_period = get_env_u32("DUNITER_MEMBERSHIP_RENEWABLE_PERIOD", 50);
...@@ -140,6 +141,7 @@ fn devnet_genesis( ...@@ -140,6 +141,7 @@ fn devnet_genesis(
}, },
parameters: ParametersConfig { parameters: ParametersConfig {
parameters: GenesisParameters { parameters: GenesisParameters {
babe_epoch_duration,
cert_period: 15, cert_period: 15,
cert_max_by_issuer: 10, cert_max_by_issuer: 10,
cert_min_received_cert_to_issue_cert: 2, cert_min_received_cert_to_issue_cert: 2,
......
...@@ -36,6 +36,7 @@ pub mod types { ...@@ -36,6 +36,7 @@ pub mod types {
CertCount: Default + Parameter, CertCount: Default + Parameter,
PeriodCount: Default + Parameter, PeriodCount: Default + Parameter,
> { > {
pub babe_epoch_duration: PeriodCount,
pub cert_period: BlockNumber, pub cert_period: BlockNumber,
pub cert_max_by_issuer: CertCount, pub cert_max_by_issuer: CertCount,
pub cert_min_received_cert_to_issue_cert: CertCount, pub cert_min_received_cert_to_issue_cert: CertCount,
......
...@@ -33,6 +33,7 @@ macro_rules! runtime_apis { ...@@ -33,6 +33,7 @@ macro_rules! runtime_apis {
// slot duration and expected target block time, for safely // slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds. // resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results> // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
use frame_support::traits::Get as _;
sp_consensus_babe::BabeGenesisConfiguration { sp_consensus_babe::BabeGenesisConfiguration {
slot_duration: Babe::slot_duration(), slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(), epoch_length: EpochDuration::get(),
......
...@@ -150,6 +150,7 @@ impl frame_support::traits::Contains<Call> for BaseCallFilter { ...@@ -150,6 +150,7 @@ impl frame_support::traits::Contains<Call> for BaseCallFilter {
// Configure FRAME pallets to include in runtime. // Configure FRAME pallets to include in runtime.
common_runtime::pallets_config! { common_runtime::pallets_config! {
// Dynamic parameters // Dynamic parameters
pub type EpochDuration = pallet_duniter_test_parameters::BabeEpochDuration<Runtime>;
pub type CertPeriod = pallet_duniter_test_parameters::CertPeriod<Runtime>; pub type CertPeriod = pallet_duniter_test_parameters::CertPeriod<Runtime>;
pub type MaxByIssuer = pallet_duniter_test_parameters::CertMaxByIssuer<Runtime>; pub type MaxByIssuer = pallet_duniter_test_parameters::CertMaxByIssuer<Runtime>;
pub type MinReceivedCertToBeAbleToIssueCert = pallet_duniter_test_parameters::CertMinReceivedCertToIssueCert<Runtime>; pub type MinReceivedCertToBeAbleToIssueCert = pallet_duniter_test_parameters::CertMinReceivedCertToIssueCert<Runtime>;
......
...@@ -51,11 +51,9 @@ parameter_types! { ...@@ -51,11 +51,9 @@ parameter_types! {
} }
// Babe // Babe
pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = HOURS;
parameter_types! { parameter_types! {
pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64;
pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
pub const ReportLongevity: u64 = 168 * EpochDuration::get(); pub const ReportLongevity: u64 = 168 * HOURS as u64;
} }
// ImOnline // ImOnline
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment