From 1b7338629f737e5a73e91eec3a1bb2fcb5e17b8c Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Wed, 22 Jan 2025 16:38:12 +0100 Subject: [PATCH] refactor: :art: improve structure --- runtime/moonbase/src/genesis_config_preset.rs | 63 +++++++++++++++++++ runtime/moonbase/src/lib.rs | 40 +----------- 2 files changed, 65 insertions(+), 38 deletions(-) diff --git a/runtime/moonbase/src/genesis_config_preset.rs b/runtime/moonbase/src/genesis_config_preset.rs index 739be1ae7c..8b3568815c 100644 --- a/runtime/moonbase/src/genesis_config_preset.rs +++ b/runtime/moonbase/src/genesis_config_preset.rs @@ -13,6 +13,7 @@ use cumulus_primitives_core::ParaId; pub use fp_evm::GenesisAccount; use nimbus_primitives::NimbusId; use pallet_transaction_payment::Multiplier; +use parachains_common::genesis_config_helpers::get_from_seed; use sp_runtime::{traits::One, Perbill, Percent}; const COLLATOR_COMMISSION: Perbill = Perbill::from_percent(20); @@ -20,6 +21,7 @@ const PARACHAIN_BOND_RESERVE_PERCENT: Percent = Percent::from_percent(30); const BLOCKS_PER_ROUND: u32 = 2 * HOURS; const BLOCKS_PER_YEAR: u32 = 31_557_600 / 6; const NUM_SELECTED_CANDIDATES: u32 = 8; + pub fn moonbase_inflation_config() -> InflationInfo { fn to_round_inflation(annual: Range) -> Range { use pallet_parachain_staking::inflation::perbill_annual_to_perbill_round; @@ -164,3 +166,64 @@ pub fn testnet_genesis( serde_json::to_value(&config).expect("Could not build genesis config.") } + +pub fn development() -> serde_json::Value { + testnet_genesis( + // Alith is Sudo + AccountId::from(sp_core::hex2array!( + "f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" + )), + // Treasury Council members: Baltathar, Charleth and Dorothy + vec![ + AccountId::from(sp_core::hex2array!( + "3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0" + )), + AccountId::from(sp_core::hex2array!( + "798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc" + )), + AccountId::from(sp_core::hex2array!( + "773539d4Ac0e786233D90A233654ccEE26a613D9" + )), + ], + // Open Tech committee members: Alith and Baltathar + vec![ + AccountId::from(sp_core::hex2array!( + "f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" + )), + AccountId::from(sp_core::hex2array!( + "3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0" + )), + ], + // Collator Candidates + vec![ + // Alice -> Alith + ( + AccountId::from(sp_core::hex2array!( + "f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" + )), + get_from_seed::("Alice"), + 1_000 * UNIT, + ), + ], + // Delegations + vec![], + // Endowed: Alith, Baltathar, Charleth and Dorothy + vec![ + AccountId::from(sp_core::hex2array!( + "f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac" + )), + AccountId::from(sp_core::hex2array!( + "3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0" + )), + AccountId::from(sp_core::hex2array!( + "798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc" + )), + AccountId::from(sp_core::hex2array!( + "773539d4Ac0e786233D90A233654ccEE26a613D9" + )), + ], + 3_000_000 * UNIT, + Default::default(), // para_id + 1280, //ChainId + ) +} diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs index 53b52b0deb..7495107ad5 100644 --- a/runtime/moonbase/src/lib.rs +++ b/runtime/moonbase/src/lib.rs @@ -81,7 +81,7 @@ use frame_system::{EnsureRoot, EnsureSigned}; use governance::councils::*; use moonbeam_rpc_primitives_txpool::TxPoolResponse; use moonbeam_runtime_common::timestamp::{ConsensusHookWrapperForRelayTimestamp, RelayTimestamp}; -use nimbus_primitives::{CanAuthor, NimbusId}; +use nimbus_primitives::CanAuthor; use pallet_ethereum::Call::transact; use pallet_ethereum::{PostLogContent, Transaction as EthereumTransaction}; use pallet_evm::{ @@ -90,7 +90,6 @@ use pallet_evm::{ OnChargeEVMTransaction as OnChargeEVMTransactionT, Runner, }; use pallet_transaction_payment::{FungibleAdapter, Multiplier, TargetedFeeAdjustment}; -use parachains_common::genesis_config_helpers::get_from_seed; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use runtime_params::*; use scale_info::TypeInfo; @@ -1594,42 +1593,7 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! { fn get_preset(id: &Option) -> Option> { frame_support::genesis_builder_helper::get_preset::(id, |id| { let patch = match id.try_into() { - Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => genesis_config_preset::testnet_genesis( - // Alith is Sudo - AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - // Treasury Council members: Baltathar, Charleth and Dorothy - vec![ - AccountId::from(sp_core::hex2array!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(sp_core::hex2array!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(sp_core::hex2array!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - ], - // Open Tech committee members: Alith and Baltathar - vec![ - AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - AccountId::from(sp_core::hex2array!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - ], - // Collator Candidates - vec![ - // Alice -> Alith - ( - AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - get_from_seed::("Alice"), - 1_000 * currency::UNIT, - ), - ], - // Delegations - vec![], - // Endowed: Alith, Baltathar, Charleth and Dorothy - vec![ - AccountId::from(sp_core::hex2array!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - AccountId::from(sp_core::hex2array!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(sp_core::hex2array!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(sp_core::hex2array!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - ], - 3_000_000 * currency::UNIT, - Default::default(), // para_id - 1280, //ChainId - ), + Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => genesis_config_preset::development(), _ => return None, }; Some(