diff --git a/node/src/chain_spec/gdev.rs b/node/src/chain_spec/gdev.rs index 56a250e978cab448dd1f7f8697202f4c29c61d69..e8f1b157f5bca6bb72912b74b964fe5d609aa47c 100644 --- a/node/src/chain_spec/gdev.rs +++ b/node/src/chain_spec/gdev.rs @@ -67,7 +67,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { "gdev", ChainType::Development, move || { - devnet_genesis( + gen_genesis_conf( wasm_binary, // Initial authorities len 1, @@ -101,7 +101,7 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> { )) } -fn devnet_genesis( +fn gen_genesis_conf( wasm_binary: &[u8], initial_authorities_len: usize, initial_smiths_len: usize, @@ -113,6 +113,7 @@ fn devnet_genesis( assert!(initial_smiths_len <= initial_identities_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 membership_period = get_env_u32("DUNITER_MEMBERSHIP_PERIOD", 1_000); let membership_renewable_period = get_env_u32("DUNITER_MEMBERSHIP_RENEWABLE_PERIOD", 50); @@ -140,6 +141,7 @@ fn devnet_genesis( }, parameters: ParametersConfig { parameters: GenesisParameters { + babe_epoch_duration, cert_period: 15, cert_max_by_issuer: 10, cert_min_received_cert_to_issue_cert: 2, diff --git a/pallets/authority-members/src/lib.rs b/pallets/authority-members/src/lib.rs index 44a26d9496cf00b40b00185822112b21a3030095..6510b29265347a521438c8c84a9f47b4c87c13fd 100644 --- a/pallets/authority-members/src/lib.rs +++ b/pallets/authority-members/src/lib.rs @@ -234,10 +234,10 @@ pub mod pallet { return Err(Error::<T>::SessionKeysNotProvided.into()); } - if Self::is_incoming(member_id) { + if Self::is_incoming(member_id) { return Err(Error::<T>::AlreadyIncoming.into()); } - let is_outgoing = Self::is_outgoing(member_id); + let is_outgoing = Self::is_outgoing(member_id); if Self::is_online(member_id) && !is_outgoing { return Err(Error::<T>::AlreadyOnline.into()); } diff --git a/pallets/duniter-test-parameters/src/lib.rs b/pallets/duniter-test-parameters/src/lib.rs index 3f310c5525dab7ead1f9c42f2a8d57ab0f46f271..4f5df4b75acf2e5342ef3ad9597d04614aeb75a2 100644 --- a/pallets/duniter-test-parameters/src/lib.rs +++ b/pallets/duniter-test-parameters/src/lib.rs @@ -36,6 +36,7 @@ pub mod types { CertCount: Default + Parameter, PeriodCount: Default + Parameter, > { + pub babe_epoch_duration: PeriodCount, pub cert_period: BlockNumber, pub cert_max_by_issuer: CertCount, pub cert_min_received_cert_to_issue_cert: CertCount, diff --git a/runtime/common/src/apis.rs b/runtime/common/src/apis.rs index 88dd18485c8ff7c8f775c274428676488fb2a0f3..41edbb02f59ad866e96223f7a1e38f0eca6018fb 100644 --- a/runtime/common/src/apis.rs +++ b/runtime/common/src/apis.rs @@ -33,6 +33,7 @@ macro_rules! runtime_apis { // slot duration and expected target block time, for safely // resisting network delays of maximum two seconds. // <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results> + use frame_support::traits::Get as _; sp_consensus_babe::BabeGenesisConfiguration { slot_duration: Babe::slot_duration(), epoch_length: EpochDuration::get(), diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index 26e05354edefec1f3ae182e1bc0a76015320867a..a26e98bc75baa8ccb289faff677f901182cb78f7 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -150,6 +150,7 @@ impl frame_support::traits::Contains<Call> for BaseCallFilter { // Configure FRAME pallets to include in runtime. common_runtime::pallets_config! { // Dynamic parameters + pub type EpochDuration = pallet_duniter_test_parameters::BabeEpochDuration<Runtime>; pub type CertPeriod = pallet_duniter_test_parameters::CertPeriod<Runtime>; pub type MaxByIssuer = pallet_duniter_test_parameters::CertMaxByIssuer<Runtime>; pub type MinReceivedCertToBeAbleToIssueCert = pallet_duniter_test_parameters::CertMinReceivedCertToIssueCert<Runtime>; diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs index 83ed87e36d4664e89ad5fb2e43ad91de792225e8..95a18530c8cd639eb0e17b35851c414699756032 100644 --- a/runtime/gdev/src/parameters.rs +++ b/runtime/gdev/src/parameters.rs @@ -51,11 +51,9 @@ parameter_types! { } // Babe -pub const EPOCH_DURATION_IN_SLOTS: BlockNumber = HOURS; parameter_types! { - pub const EpochDuration: u64 = EPOCH_DURATION_IN_SLOTS as u64; pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK; - pub const ReportLongevity: u64 = 168 * EpochDuration::get(); + pub const ReportLongevity: u64 = 168 * HOURS as u64; } // ImOnline