Skip to content

Commit

Permalink
refactor: 🎨 improve structure
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelmauro committed Jan 22, 2025
1 parent dc562fa commit 1b73386
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 38 deletions.
63 changes: 63 additions & 0 deletions runtime/moonbase/src/genesis_config_preset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ 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);
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<Balance> {
fn to_round_inflation(annual: Range<Perbill>) -> Range<Perbill> {
use pallet_parachain_staking::inflation::perbill_annual_to_perbill_round;
Expand Down Expand Up @@ -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::<NimbusId>("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
)
}
40 changes: 2 additions & 38 deletions runtime/moonbase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -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;
Expand Down Expand Up @@ -1594,42 +1593,7 @@ moonbeam_runtime_common::impl_runtime_apis_plus_common! {
fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
frame_support::genesis_builder_helper::get_preset::<RuntimeGenesisConfig>(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::<NimbusId>("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(
Expand Down

0 comments on commit 1b73386

Please sign in to comment.