From 6ef78e33b5f89ecdb53d07da071a3f7de6f1091a Mon Sep 17 00:00:00 2001 From: Manuel Mauro Date: Thu, 23 Jan 2025 13:28:21 +0100 Subject: [PATCH] refactor: :recycle: use with_genesis_config_preset_name in test_spec --- node/cli/src/command.rs | 3 +- node/service/src/chain_spec/test_spec.rs | 102 ++--------------------- node/service/src/lazy_loading/backend.rs | 2 +- 3 files changed, 7 insertions(+), 100 deletions(-) diff --git a/node/cli/src/command.rs b/node/cli/src/command.rs index d3a5f4141b..1961516a7d 100644 --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -866,8 +866,7 @@ pub fn run() -> Result<()> { max_retries_per_request: cli.run.lazy_loading_max_retries_per_request, }; - let spec_builder = - chain_spec::test_spec::lazy_loading_spec_builder(Default::default()); + let spec_builder = chain_spec::test_spec::lazy_loading_spec_builder(); config.chain_spec = Box::new(spec_builder.build()); // TODO: create a tokio runtime inside offchain_worker thread (otherwise it will panic) diff --git a/node/service/src/chain_spec/test_spec.rs b/node/service/src/chain_spec/test_spec.rs index 2bba38cefd..1a1ebf305f 100644 --- a/node/service/src/chain_spec/test_spec.rs +++ b/node/service/src/chain_spec/test_spec.rs @@ -16,18 +16,15 @@ //! Embedded specs for testing purposes, must be compiled with --features=test-spec use crate::chain_spec::moonbase::ChainSpec; -use crate::chain_spec::{get_from_seed, Extensions}; +use crate::chain_spec::Extensions; use cumulus_primitives_core::ParaId; -use hex_literal::hex; -use moonbase_runtime::{currency::UNIT, AccountId, WASM_BINARY}; -use nimbus_primitives::NimbusId; use sc_service::ChainType; /// Generate testing chain_spec for staking integration tests with accounts initialized for /// collating and nominating. pub fn staking_spec(para_id: ParaId) -> ChainSpec { ChainSpec::builder( - WASM_BINARY.expect("WASM binary was not build, please build it!"), + moonbase_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"), Extensions { relay_chain: "westend_local".into(), para_id: para_id.into(), @@ -39,58 +36,12 @@ pub fn staking_spec(para_id: ParaId) -> ChainSpec { .with_properties( serde_json::from_str("{\"tokenDecimals\": 18}").expect("Provided valid json map"), ) - .with_genesis_config(moonbase_runtime::genesis_config_preset::testnet_genesis( - // Root - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - // Treasury Council members: Baltathar, Charleth and Dorothy - vec![ - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - ], - // Open Tech Committee members: Alith and Baltathar - vec![ - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - ], - // Collators - vec![ - ( - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - get_from_seed::("Alice"), - 1_000 * UNIT, - ), - ( - AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")), - get_from_seed::("Faith"), - 1_000 * UNIT, - ), - ], - // Delegations - vec![], - // Endowed accounts (each minted 1 << 80 balance) - vec![ - // Alith, Baltathar, Charleth, Dorothy and Faith - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")), - // Additional accounts - AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")), - AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - ], - 3_000_000 * UNIT, - para_id, - // Chain ID - 1280, - )) + .with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET) .build() } #[cfg(feature = "lazy-loading")] -pub fn lazy_loading_spec_builder(para_id: ParaId) -> sc_chain_spec::ChainSpecBuilder { - use moonbeam_runtime::currency::{GLMR, SUPPLY_FACTOR}; +pub fn lazy_loading_spec_builder() -> sc_chain_spec::ChainSpecBuilder { crate::chain_spec::moonbeam::ChainSpec::builder( moonbeam_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!"), Default::default(), @@ -104,48 +55,5 @@ pub fn lazy_loading_spec_builder(para_id: ParaId) -> sc_chain_spec::ChainSpecBui ) .expect("Provided valid json map"), ) - .with_genesis_config(moonbeam_runtime::genesis_config_preset::testnet_genesis( - // Treasury Council members: Baltathar, Charleth and Dorothy - vec![ - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - ], - // Open Tech Committee members: Alith and Baltathar - vec![ - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - ], - // Collators - vec![ - ( - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - get_from_seed::("Alice"), - 20_000 * GLMR * SUPPLY_FACTOR, - ), - ( - AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")), - get_from_seed::("Faith"), - 20_000 * GLMR * SUPPLY_FACTOR, - ), - ], - // Delegations - vec![], - // Endowed accounts (each minted 1 << 80 balance) - vec![ - // Alith, Baltathar, Charleth, Dorothy and Faith - AccountId::from(hex!("6Be02d1d3665660d22FF9624b7BE0551ee1Ac91b")), - AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), - AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), - AccountId::from(hex!("773539d4Ac0e786233D90A233654ccEE26a613D9")), - AccountId::from(hex!("C0F0f4ab324C46e55D02D0033343B4Be8A55532d")), - // Additional accounts - AccountId::from(hex!("Ff64d3F6efE2317EE2807d223a0Bdc4c0c49dfDB")), - AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), - ], - 1_500_000 * GLMR * SUPPLY_FACTOR, - para_id, - // Chain ID - 1280, - )) + .with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET) } diff --git a/node/service/src/lazy_loading/backend.rs b/node/service/src/lazy_loading/backend.rs index 623498aec6..06c21755c7 100644 --- a/node/service/src/lazy_loading/backend.rs +++ b/node/service/src/lazy_loading/backend.rs @@ -1737,7 +1737,7 @@ where .system_properties() .expect("Should fetch chain properties"); - let spec_builder = chain_spec::test_spec::lazy_loading_spec_builder(Default::default()) + let spec_builder = chain_spec::test_spec::lazy_loading_spec_builder() .with_name(chain_name.as_str()) .with_properties(chain_properties); config.chain_spec = Box::new(spec_builder.build());