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
This commit is part of merge request !28. Comments created here will be created in the context of that merge request.
......@@ -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,
......
......@@ -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());
}
......
......@@ -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,
......
......@@ -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(),
......
......@@ -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>;
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment