From f3bc3048acdf7c326574cb0ed7af35e9d511849b Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 28 Oct 2024 15:21:43 -0700 Subject: [PATCH 1/6] add dev_accounts field --- substrate/frame/balances/Cargo.toml | 2 +- substrate/frame/balances/src/lib.rs | 35 ++++++++++++++++++- .../balances/src/tests/currency_tests.rs | 14 ++++++-- substrate/frame/balances/src/tests/mod.rs | 2 ++ 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/substrate/frame/balances/Cargo.toml b/substrate/frame/balances/Cargo.toml index 44899e5b7d8d..9341ea924451 100644 --- a/substrate/frame/balances/Cargo.toml +++ b/substrate/frame/balances/Cargo.toml @@ -24,11 +24,11 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } docify = { workspace = true } +sp-core = { workspace = true, default-features = true } [dev-dependencies] pallet-transaction-payment = { workspace = true, default-features = true } frame-support = { features = ["experimental"], workspace = true, default-features = true } -sp-core = { workspace = true, default-features = true } sp-io = { workspace = true, default-features = true } paste = { workspace = true, default-features = true } diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 65e594a904f9..0bf48a0aa5f5 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -180,6 +180,10 @@ use sp_runtime::{ }, ArithmeticError, DispatchError, FixedPointOperand, Perbill, RuntimeDebug, TokenError, }; + +#[cfg(feature = "runtime-benchmarks")] +use sp_core::{sr25519::Pair as SrPair, Pair}; + pub use types::{ AccountData, AdjustmentDirection, BalanceLock, DustCleaner, ExtraFlags, Reasons, ReserveData, }; @@ -505,11 +509,19 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig, I: 'static = ()> { pub balances: Vec<(T::AccountId, T::Balance)>, + + #[cfg(feature = "runtime-benchmarks")] + pub dev_accounts: (u32, T::Balance, String), } impl, I: 'static> Default for GenesisConfig { fn default() -> Self { - Self { balances: Default::default() } + Self { + balances: Default::default(), + + #[cfg(feature = "runtime-benchmarks")] + dev_accounts: (Default::default(), Default::default(), String::new()), + } } } @@ -540,6 +552,27 @@ pub mod pallet { "duplicate balances in genesis." ); + // Generate additional dev accounts. + #[cfg(feature = "runtime-benchmarks")] + { + let (num_accounts, balance, ref derivation) = self.dev_accounts; + for index in 0..num_accounts { + assert!( + balance >= >::ExistentialDeposit::get(), + "the balance of any account should always be at least the existential deposit.", + ); + // Create key pair from the derivation string + let derivation_string = &derivation.replace("{}", &index.to_string()); + let pair: SrPair = Pair::from_string(&derivation_string, None).expect("Invalid derivation string"); + + // Convert the public key to AccountId + let who = T::AccountId::decode(&mut &pair.public().encode()[..]).unwrap(); + frame_system::Pallet::::inc_providers(&who); + assert!(T::AccountStore::insert(&who, AccountData { free: balance, ..Default::default() }) + .is_ok()); + } + } + for &(ref who, free) in self.balances.iter() { frame_system::Pallet::::inc_providers(who); assert!(T::AccountStore::insert(who, AccountData { free, ..Default::default() }) diff --git a/substrate/frame/balances/src/tests/currency_tests.rs b/substrate/frame/balances/src/tests/currency_tests.rs index a4984b34f6db..e935b50c0c4c 100644 --- a/substrate/frame/balances/src/tests/currency_tests.rs +++ b/substrate/frame/balances/src/tests/currency_tests.rs @@ -716,7 +716,12 @@ fn burn_must_work() { fn cannot_set_genesis_value_below_ed() { EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - let _ = crate::GenesisConfig:: { balances: vec![(1, 10)] } + let _ = crate::GenesisConfig:: { + balances: vec![(1, 10)], + + #[cfg(feature = "runtime-benchmarks")] + dev_accounts: (1000000, 500, "//Sender/{}".to_string()) + } .assimilate_storage(&mut t) .unwrap(); } @@ -725,7 +730,12 @@ fn cannot_set_genesis_value_below_ed() { #[should_panic = "duplicate balances in genesis."] fn cannot_set_genesis_value_twice() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - let _ = crate::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (1, 15)] } + let _ = crate::GenesisConfig:: { + balances: vec![(1, 10), (2, 20), (1, 15)], + + #[cfg(feature = "runtime-benchmarks")] + dev_accounts: (1000000, 500, "//Sender/{}".to_string()) + } .assimilate_storage(&mut t) .unwrap(); } diff --git a/substrate/frame/balances/src/tests/mod.rs b/substrate/frame/balances/src/tests/mod.rs index ba0cdabdabbb..747af9f8cfca 100644 --- a/substrate/frame/balances/src/tests/mod.rs +++ b/substrate/frame/balances/src/tests/mod.rs @@ -170,6 +170,8 @@ impl ExtBuilder { } else { vec![] }, + #[cfg(feature = "runtime-benchmarks")] + dev_accounts: (1000000, self.existential_deposit, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); From cb0d3bad20d3d71075d4f3483cbc3badf95f759e Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 4 Nov 2024 06:46:56 -0800 Subject: [PATCH 2/6] populate dev_accounts field --- bridges/modules/messages/src/tests/mock.rs | 2 +- cumulus/pallets/collator-selection/src/mock.rs | 2 +- .../asset-hub-rococo/src/genesis_config_presets.rs | 3 ++- .../asset-hub-westend/src/genesis_config_presets.rs | 3 ++- .../bridge-hub-rococo/src/genesis_config_presets.rs | 3 ++- .../src/genesis_config_presets.rs | 3 ++- .../src/genesis_config_presets.rs | 3 ++- cumulus/parachains/runtimes/test-utils/src/lib.rs | 2 +- polkadot/runtime/common/src/assigned_slots/mod.rs | 1 + polkadot/runtime/common/src/auctions.rs | 1 + polkadot/runtime/common/src/crowdloan/mod.rs | 1 + polkadot/runtime/common/src/paras_registrar/mod.rs | 1 + polkadot/runtime/common/src/slots/mod.rs | 1 + .../runtime/rococo/src/genesis_config_presets.rs | 4 +++- .../runtime/westend/src/genesis_config_presets.rs | 4 +++- polkadot/xcm/pallet-xcm/src/mock.rs | 2 +- .../src/asset_exchange/single_asset_adapter/mock.rs | 1 + polkadot/xcm/xcm-builder/tests/mock/mod.rs | 2 +- polkadot/xcm/xcm-runtime-apis/tests/mock.rs | 4 ++-- polkadot/xcm/xcm-simulator/example/src/lib.rs | 2 ++ polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs | 3 ++- substrate/bin/node/testing/src/genesis.rs | 2 +- substrate/frame/alliance/src/mock.rs | 1 + substrate/frame/asset-conversion/ops/src/mock.rs | 1 + substrate/frame/asset-conversion/src/mock.rs | 1 + substrate/frame/babe/src/mock.rs | 2 +- substrate/frame/balances/Cargo.toml | 2 +- substrate/frame/balances/src/lib.rs | 10 +++++++++- substrate/frame/balances/src/tests/general_tests.rs | 13 +++++++++++++ substrate/frame/balances/src/tests/mod.rs | 2 +- substrate/frame/bounties/src/tests.rs | 5 +++-- substrate/frame/child-bounties/src/tests.rs | 1 + substrate/frame/collective/src/tests.rs | 2 +- substrate/frame/contracts/mock-network/src/lib.rs | 2 ++ substrate/frame/contracts/src/tests.rs | 2 +- substrate/frame/conviction-voting/src/tests.rs | 1 + substrate/frame/delegated-staking/src/mock.rs | 1 + substrate/frame/democracy/src/tests.rs | 1 + .../frame/election-provider-multi-phase/src/mock.rs | 1 + substrate/frame/elections-phragmen/src/lib.rs | 1 + substrate/frame/fast-unstake/src/mock.rs | 1 + substrate/frame/grandpa/src/mock.rs | 2 +- substrate/frame/identity/src/tests.rs | 1 + substrate/frame/indices/src/mock.rs | 1 + substrate/frame/lottery/src/mock.rs | 1 + substrate/frame/multisig/src/tests.rs | 1 + substrate/frame/nis/src/mock.rs | 1 + substrate/frame/preimage/src/mock.rs | 1 + substrate/frame/proxy/src/tests.rs | 1 + substrate/frame/recovery/src/mock.rs | 1 + substrate/frame/referenda/src/mock.rs | 2 +- substrate/frame/revive/mock-network/src/lib.rs | 2 ++ substrate/frame/revive/src/tests.rs | 2 +- substrate/frame/root-offences/src/mock.rs | 1 + substrate/frame/safe-mode/src/mock.rs | 2 +- substrate/frame/society/src/mock.rs | 2 +- substrate/frame/staking/src/mock.rs | 1 + substrate/frame/state-trie-migration/src/lib.rs | 2 +- substrate/frame/tips/src/tests.rs | 3 ++- .../asset-tx-payment/src/tests.rs | 1 + substrate/frame/transaction-storage/src/mock.rs | 1 + substrate/frame/treasury/src/tests.rs | 4 +++- substrate/frame/tx-pause/src/mock.rs | 1 + substrate/frame/utility/src/tests.rs | 1 + substrate/frame/vesting/src/mock.rs | 1 + substrate/test-utils/runtime/src/genesismap.rs | 2 +- 66 files changed, 105 insertions(+), 33 deletions(-) diff --git a/bridges/modules/messages/src/tests/mock.rs b/bridges/modules/messages/src/tests/mock.rs index 2935ebd69610..60d0f60957b4 100644 --- a/bridges/modules/messages/src/tests/mock.rs +++ b/bridges/modules/messages/src/tests/mock.rs @@ -461,7 +461,7 @@ pub fn inbound_unrewarded_relayers_state(lane: TestLaneIdType) -> UnrewardedRela /// Return test externalities to use in tests. pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)] } + pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)], dev_accounts: (10, 1_000_000, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); sp_io::TestExternalities::new(t) diff --git a/cumulus/pallets/collator-selection/src/mock.rs b/cumulus/pallets/collator-selection/src/mock.rs index d13f9e9d8c44..6a97525c4f57 100644 --- a/cumulus/pallets/collator-selection/src/mock.rs +++ b/cumulus/pallets/collator-selection/src/mock.rs @@ -188,7 +188,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { invulnerables, }; let session = pallet_session::GenesisConfig:: { keys, ..Default::default() }; - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); // collator selection must be initialized before session. diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs index 1dbd92d6bff0..e45a5203512f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Asset Hub Rococo Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use cumulus_primitives_core::ParaId; use hex_literal::hex; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; @@ -35,6 +35,7 @@ fn asset_hub_rococo_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(), + dev_accounts: (10, ASSET_HUB_ROCOCO_ED, "//Sender/{}".to_string()), }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs index b287dcd56219..fe0054625240 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Asset Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use cumulus_primitives_core::ParaId; use hex_literal::hex; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; @@ -37,6 +37,7 @@ fn asset_hub_westend_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(), + dev_accounts: (10, ASSET_HUB_WESTEND_ED, "//Sender/{}".to_string()) }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs index 07048d54ab1b..4b0f929612a6 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Rococo Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -40,6 +40,7 @@ fn bridge_hub_rococo_genesis( .cloned() .map(|k| (k, 1u128 << 60)) .collect::>(), + dev_accounts: (10, BRIDGE_HUB_ROCOCO_ED, "//Sender/{}".to_string()), }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs index 0b270e584339..2714e17a2109 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -40,6 +40,7 @@ fn bridge_hub_westend_genesis( .cloned() .map(|k| (k, 1u128 << 60)) .collect::>(), + dev_accounts: (10, BRIDGE_HUB_WESTEND_ED, "//Sender/{}".to_string()) }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs index 30a23d7aaea4..ebff423b8b67 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -37,6 +37,7 @@ fn collectives_westend_genesis( .cloned() .map(|k| (k, COLLECTIVES_WESTEND_ED * 4096)) .collect::>(), + dev_accounts: (10, COLLECTIVES_WESTEND_ED, "//Sender/{}".to_string()) }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/test-utils/src/lib.rs b/cumulus/parachains/runtimes/test-utils/src/lib.rs index 3b38eee244f1..9a8632df7cfe 100644 --- a/cumulus/parachains/runtimes/test-utils/src/lib.rs +++ b/cumulus/parachains/runtimes/test-utils/src/lib.rs @@ -230,7 +230,7 @@ impl ExtBuilder { .unwrap(); } - pallet_balances::GenesisConfig:: { balances: self.balances } + pallet_balances::GenesisConfig:: { balances: self.balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index 96c98c45954d..f4c7f2403708 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -764,6 +764,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/auctions.rs b/polkadot/runtime/common/src/auctions.rs index 78f20d918bab..9404ee73ab6c 100644 --- a/polkadot/runtime/common/src/auctions.rs +++ b/polkadot/runtime/common/src/auctions.rs @@ -866,6 +866,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index 8cf288197e3d..f258efc8a771 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -1085,6 +1085,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)], + dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index 07f02e926561..be964ee7406f 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -860,6 +860,7 @@ mod tests { pallet_balances::GenesisConfig:: { balances: vec![(1, 10_000_000), (2, 10_000_000), (3, 10_000_000)], + dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index 333f14c6608a..d970918b2611 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -578,6 +578,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/rococo/src/genesis_config_presets.rs b/polkadot/runtime/rococo/src/genesis_config_presets.rs index c237dfd967f6..58d890b68cd1 100644 --- a/polkadot/runtime/rococo/src/genesis_config_presets.rs +++ b/polkadot/runtime/rococo/src/genesis_config_presets.rs @@ -22,7 +22,7 @@ use crate::{ }; #[cfg(not(feature = "std"))] use alloc::format; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId}; use rococo_runtime_constants::currency::UNITS as ROC; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -185,6 +185,7 @@ fn rococo_testnet_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect::>(), + dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) }, session: SessionConfig { keys: initial_authorities @@ -453,6 +454,7 @@ fn rococo_staging_testnet_config_genesis() -> serde_json::Value { .map(|k: &AccountId| (k.clone(), ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect::>(), + dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) }, session: SessionConfig { keys: initial_authorities diff --git a/polkadot/runtime/westend/src/genesis_config_presets.rs b/polkadot/runtime/westend/src/genesis_config_presets.rs index f59bacce31bd..ae21c06c0603 100644 --- a/polkadot/runtime/westend/src/genesis_config_presets.rs +++ b/polkadot/runtime/westend/src/genesis_config_presets.rs @@ -22,7 +22,7 @@ use crate::{ }; #[cfg(not(feature = "std"))] use alloc::format; -use alloc::{vec, vec::Vec}; +use alloc::{vec, vec::Vec, string::ToString}; use pallet_staking::{Forcing, StakerStatus}; use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId}; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -191,6 +191,7 @@ fn westend_testnet_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect::>(), + dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) }, session: SessionConfig { keys: initial_authorities @@ -370,6 +371,7 @@ fn westend_staging_testnet_config_genesis() -> serde_json::Value { .map(|k: &AccountId| (k.clone(), ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect::>(), + dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()), }, session: SessionConfig { keys: initial_authorities diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 8d0476b0e70d..8e3c255ca79b 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -700,7 +700,7 @@ pub(crate) fn new_test_ext_with_balances_and_xcm_version( ) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, ExistentialDeposit::get(), "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs index 4d9809e84f88..04c63b78fa73 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs @@ -339,6 +339,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(0, INITIAL_BALANCE), (1, INITIAL_BALANCE), (2, INITIAL_BALANCE)], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index 0468b0a5410c..ecd9512b76d6 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -243,7 +243,7 @@ construct_runtime!( pub fn kusama_like_with_balances(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 1_000_000_000u32.into(), "//Sender/{}".into()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index 6575feccf8a3..500086bc3436 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -357,7 +357,7 @@ impl pallet_xcm::Config for TestRuntime { pub fn new_test_ext_with_balances(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); @@ -373,7 +373,7 @@ pub fn new_test_ext_with_balances_and_assets( ) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-simulator/example/src/lib.rs b/polkadot/xcm/xcm-simulator/example/src/lib.rs index 6fb9a69770ea..908d0054a7d1 100644 --- a/polkadot/xcm/xcm-simulator/example/src/lib.rs +++ b/polkadot/xcm/xcm-simulator/example/src/lib.rs @@ -101,6 +101,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(ALICE, INITIAL_BALANCE), (parent_account_id(), INITIAL_BALANCE)], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); @@ -125,6 +126,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (child_account_id(1), INITIAL_BALANCE), (child_account_id(2), INITIAL_BALANCE), ], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs index adf6cacd278b..37c7bcbcc0a5 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs @@ -117,6 +117,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: (0..6).map(|i| ([i; 32].into(), INITIAL_BALANCE)).collect(), + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); @@ -138,7 +139,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { balances.append(&mut (1..=3).map(|i| (para_account_id(i), INITIAL_BALANCE)).collect()); balances.append(&mut (0..6).map(|i| ([i; 32].into(), INITIAL_BALANCE)).collect()); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/bin/node/testing/src/genesis.rs b/substrate/bin/node/testing/src/genesis.rs index 7f5364744c66..7ec5c5bb506e 100644 --- a/substrate/bin/node/testing/src/genesis.rs +++ b/substrate/bin/node/testing/src/genesis.rs @@ -47,7 +47,7 @@ pub fn config_endowed(extra_endowed: Vec) -> RuntimeGenesisConfig { RuntimeGenesisConfig { indices: IndicesConfig { indices: vec![] }, - balances: BalancesConfig { balances: endowed }, + balances: BalancesConfig { balances: endowed, dev_accounts: (10, 100 * DOLLARS, "//Sender/{}".to_string()) }, session: SessionConfig { keys: vec![ (alice(), dave(), session_keys_from_seed(Ed25519Keyring::Alice.into())), diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 5442e8779020..1fa1d90d63b4 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -279,6 +279,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (8, 1000), (9, 1000), ], + dev-accounts: (10, 1000, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/asset-conversion/ops/src/mock.rs b/substrate/frame/asset-conversion/ops/src/mock.rs index 5c05faa6aa88..a85bc291799c 100644 --- a/substrate/frame/asset-conversion/ops/src/mock.rs +++ b/substrate/frame/asset-conversion/ops/src/mock.rs @@ -135,6 +135,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)], + dev_accounts: (10, 10000, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/asset-conversion/src/mock.rs b/substrate/frame/asset-conversion/src/mock.rs index d8832d70488a..268bd5634353 100644 --- a/substrate/frame/asset-conversion/src/mock.rs +++ b/substrate/frame/asset-conversion/src/mock.rs @@ -162,6 +162,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)], + dev_accounts: (10, 10000, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index 4e4052b2b566..c77b8691b753 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -304,7 +304,7 @@ pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::Tes let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 10_000_000, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/balances/Cargo.toml b/substrate/frame/balances/Cargo.toml index 9341ea924451..8091edcb94f7 100644 --- a/substrate/frame/balances/Cargo.toml +++ b/substrate/frame/balances/Cargo.toml @@ -24,7 +24,7 @@ frame-support = { workspace = true } frame-system = { workspace = true } sp-runtime = { workspace = true } docify = { workspace = true } -sp-core = { workspace = true, default-features = true } +sp-core = { workspace = true } [dev-dependencies] pallet-transaction-payment = { workspace = true, default-features = true } diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 0bf48a0aa5f5..4a431f76d783 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -152,7 +152,7 @@ pub mod weights; extern crate alloc; -use alloc::vec::Vec; +use alloc::{vec::Vec, string::{String, ToString}}; use codec::{Codec, MaxEncodedLen}; use core::{cmp, fmt::Debug, mem, result}; use frame_support::{ @@ -556,11 +556,19 @@ pub mod pallet { #[cfg(feature = "runtime-benchmarks")] { let (num_accounts, balance, ref derivation) = self.dev_accounts; + let num_balance = >::Balance::from(num_accounts); for index in 0..num_accounts { assert!( balance >= >::ExistentialDeposit::get(), "the balance of any account should always be at least the existential deposit.", ); + // Check if the derivation string follows the pattern "//character/{}" + assert!( + derivation.starts_with("//") && + derivation[2..].contains('/') && // There should be a character after "//" and before "{}" + derivation.ends_with("{}"), + "Invalid derivation string" + ); // Create key pair from the derivation string let derivation_string = &derivation.replace("{}", &index.to_string()); let pair: SrPair = Pair::from_string(&derivation_string, None).expect("Invalid derivation string"); diff --git a/substrate/frame/balances/src/tests/general_tests.rs b/substrate/frame/balances/src/tests/general_tests.rs index a855fae5616a..d062d8862914 100644 --- a/substrate/frame/balances/src/tests/general_tests.rs +++ b/substrate/frame/balances/src/tests/general_tests.rs @@ -141,3 +141,16 @@ fn try_state_works() { .contains("Found `Freeze` with too many elements")); }); } + +#[cfg(feature = "runtime-benchmarks")] +#[test] +fn dev_accounts_populated() { + ExtBuilder::default().build_and_execute_with(|| { + UseSystem::set(true); // copmment this out and uncomment this from time to time to check stuff. + // Print total issuance for debugging + let ti = TotalIssuance::::get(); + println!("Total Issuance after genesis: {}", ti); + println!("Why are you printing twice?"); + ensure_ti_valid(); + }); +} diff --git a/substrate/frame/balances/src/tests/mod.rs b/substrate/frame/balances/src/tests/mod.rs index 747af9f8cfca..63c8416eef21 100644 --- a/substrate/frame/balances/src/tests/mod.rs +++ b/substrate/frame/balances/src/tests/mod.rs @@ -171,7 +171,7 @@ impl ExtBuilder { vec![] }, #[cfg(feature = "runtime-benchmarks")] - dev_accounts: (1000000, self.existential_deposit, "//Sender/{}".to_string()) + dev_accounts: (10, self.existential_deposit, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/bounties/src/tests.rs b/substrate/frame/bounties/src/tests.rs index c152391d807a..b0c7f4f43f2c 100644 --- a/substrate/frame/bounties/src/tests.rs +++ b/substrate/frame/bounties/src/tests.rs @@ -179,7 +179,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)] }, + balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], dev_accounts: (10, 100, "//Sender/{}".to_string()) }, treasury: Default::default(), treasury_1: Default::default(), } @@ -310,7 +310,7 @@ fn treasury_account_doesnt_get_deleted() { #[test] fn inexistent_account_works() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)] } + pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); // Treasury genesis config is not build thus treasury account does not exist @@ -976,6 +976,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], + dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/child-bounties/src/tests.rs b/substrate/frame/child-bounties/src/tests.rs index 125844fa70e2..cc596e3bc916 100644 --- a/substrate/frame/child-bounties/src/tests.rs +++ b/substrate/frame/child-bounties/src/tests.rs @@ -135,6 +135,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], + dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/collective/src/tests.rs b/substrate/frame/collective/src/tests.rs index 70ce221f10d0..6e9cf310fa95 100644 --- a/substrate/frame/collective/src/tests.rs +++ b/substrate/frame/collective/src/tests.rs @@ -203,7 +203,7 @@ impl ExtBuilder { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), // balances: pallet_balances::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(1, 100), (2, 200)] }, + balances: pallet_balances::GenesisConfig { balances: vec![(1, 100), (2, 200)], dev_accounts: (10, 100, "//Sender/{}".to_string()) }, collective: pallet_collective::GenesisConfig { members: self.collective_members, phantom: Default::default(), diff --git a/substrate/frame/contracts/mock-network/src/lib.rs b/substrate/frame/contracts/mock-network/src/lib.rs index cb9e22439b76..bce533e8c4c3 100644 --- a/substrate/frame/contracts/mock-network/src/lib.rs +++ b/substrate/frame/contracts/mock-network/src/lib.rs @@ -99,6 +99,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { (relay_sovereign_account_id(), INITIAL_BALANCE), (BOB, INITIAL_BALANCE), ], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); @@ -137,6 +138,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (parachain_sovereign_account_id(1), INITIAL_BALANCE), (parachain_account_sovereign_account_id(1, ALICE), INITIAL_BALANCE), ], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index c3b6e3273f34..72e615190c54 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -552,7 +552,7 @@ impl ExtBuilder { sp_tracing::try_init_simple(); self.set_associated_consts(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![] } + pallet_balances::GenesisConfig:: { balances: vec![], dev_accounts: (10, self.existential_deposit, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/conviction-voting/src/tests.rs b/substrate/frame/conviction-voting/src/tests.rs index 37cdd7a5b338..b3aa7ea400ab 100644 --- a/substrate/frame/conviction-voting/src/tests.rs +++ b/substrate/frame/conviction-voting/src/tests.rs @@ -160,6 +160,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, 20, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/delegated-staking/src/mock.rs b/substrate/frame/delegated-staking/src/mock.rs index 811d5739f4e9..fc75b03787ea 100644 --- a/substrate/frame/delegated-staking/src/mock.rs +++ b/substrate/frame/delegated-staking/src/mock.rs @@ -188,6 +188,7 @@ impl ExtBuilder { (GENESIS_NOMINATOR_ONE, 1000), (GENESIS_NOMINATOR_TWO, 2000), ], + dev_accounts: (10, 1000, "//Sender/{}".to_string()) } .assimilate_storage(&mut storage); diff --git a/substrate/frame/democracy/src/tests.rs b/substrate/frame/democracy/src/tests.rs index 10e5ee75611d..901b16c3e0cd 100644 --- a/substrate/frame/democracy/src/tests.rs +++ b/substrate/frame/democracy/src/tests.rs @@ -169,6 +169,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, 10, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/election-provider-multi-phase/src/mock.rs b/substrate/frame/election-provider-multi-phase/src/mock.rs index 32a099e1a26f..648fe2b7ffe4 100644 --- a/substrate/frame/election-provider-multi-phase/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/src/mock.rs @@ -591,6 +591,7 @@ impl ExtBuilder { (999, 100), (9999, 100), ], + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut storage); diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index a1c5f69e1b65..1538a53cf8df 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -1476,6 +1476,7 @@ mod tests { (5, 50 * self.balance_factor), (6, 60 * self.balance_factor), ], + dev_accounts: (10, 10 * self.balance_factor, "//Sender/{}".to_string()), }, elections: elections_phragmen::GenesisConfig:: { members: self.genesis_members, diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 757052e230a1..650e2aefcab6 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -226,6 +226,7 @@ impl ExtBuilder { .chain(validators_range.clone().map(|x| (x, 7 + 100))) .chain(nominators_range.clone().map(|x| (x, 7 + 100))) .collect::>(), + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut storage); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index caac4107cfb7..92dd386beb00 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -216,7 +216,7 @@ pub fn new_test_ext_raw_authorities(authorities: AuthorityList) -> sp_io::TestEx let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 10_000_000, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 3adb823ad5da..17f3842bf735 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -103,6 +103,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (account(20), 1000), (account(30), 1000), ], + dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/indices/src/mock.rs b/substrate/frame/indices/src/mock.rs index 72bbc6dab4a4..d53d071e8710 100644 --- a/substrate/frame/indices/src/mock.rs +++ b/substrate/frame/indices/src/mock.rs @@ -59,6 +59,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], + dev_accounts: (10, 10, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/lottery/src/mock.rs b/substrate/frame/lottery/src/mock.rs index d2c442e2ac6e..f880729b8700 100644 --- a/substrate/frame/lottery/src/mock.rs +++ b/substrate/frame/lottery/src/mock.rs @@ -78,6 +78,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], + dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/multisig/src/tests.rs b/substrate/frame/multisig/src/tests.rs index cfdd33f7dfcc..f5ead2e85ae6 100644 --- a/substrate/frame/multisig/src/tests.rs +++ b/substrate/frame/multisig/src/tests.rs @@ -79,6 +79,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/nis/src/mock.rs b/substrate/frame/nis/src/mock.rs index 2b008f8ec2a4..298649f08e62 100644 --- a/substrate/frame/nis/src/mock.rs +++ b/substrate/frame/nis/src/mock.rs @@ -133,6 +133,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100)], + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/preimage/src/mock.rs b/substrate/frame/preimage/src/mock.rs index 9c72d09cae14..1573ecb8d4ab 100644 --- a/substrate/frame/preimage/src/mock.rs +++ b/substrate/frame/preimage/src/mock.rs @@ -81,6 +81,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], + dev_accounts: (10, 100, "//Sender/{}".to_string()) }; balances.assimilate_storage(&mut t).unwrap(); t.into() diff --git a/substrate/frame/proxy/src/tests.rs b/substrate/frame/proxy/src/tests.rs index 3edb96026a82..140dea692c47 100644 --- a/substrate/frame/proxy/src/tests.rs +++ b/substrate/frame/proxy/src/tests.rs @@ -140,6 +140,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 3)], + dev_accounts: (10, 10, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index 8e30cbe997e1..45f1323522dc 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -80,6 +80,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/referenda/src/mock.rs b/substrate/frame/referenda/src/mock.rs index c96a50af8658..26205abc83f6 100644 --- a/substrate/frame/referenda/src/mock.rs +++ b/substrate/frame/referenda/src/mock.rs @@ -219,7 +219,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]; - pallet_balances::GenesisConfig:: { balances } + pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/revive/mock-network/src/lib.rs b/substrate/frame/revive/mock-network/src/lib.rs index 848994653972..d1f1241878bd 100644 --- a/substrate/frame/revive/mock-network/src/lib.rs +++ b/substrate/frame/revive/mock-network/src/lib.rs @@ -99,6 +99,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { (relay_sovereign_account_id(), INITIAL_BALANCE), (BOB, INITIAL_BALANCE), ], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); @@ -137,6 +138,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (parachain_sovereign_account_id(1), INITIAL_BALANCE), (parachain_account_sovereign_account_id(1, ALICE), INITIAL_BALANCE), ], + dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/revive/src/tests.rs b/substrate/frame/revive/src/tests.rs index c7d1a8b2cf0d..171bba47e923 100644 --- a/substrate/frame/revive/src/tests.rs +++ b/substrate/frame/revive/src/tests.rs @@ -541,7 +541,7 @@ impl ExtBuilder { sp_tracing::try_init_simple(); self.set_associated_consts(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![] } + pallet_balances::GenesisConfig:: { balances: vec![], dev_accounts: (10, 1000, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index af073d7672cf..c37df85d6e61 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -211,6 +211,7 @@ impl ExtBuilder { (31, self.balance_factor * 500), (41, self.balance_factor * 1000), ], + dev_accounts: (10, 1000, "//Sender/{}".to_string()) } .assimilate_storage(&mut storage) .unwrap(); diff --git a/substrate/frame/safe-mode/src/mock.rs b/substrate/frame/safe-mode/src/mock.rs index ec1ad8249514..71c5201b14f3 100644 --- a/substrate/frame/safe-mode/src/mock.rs +++ b/substrate/frame/safe-mode/src/mock.rs @@ -231,7 +231,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // The 0 account is NOT a special origin, the rest may be. - balances: vec![(0, BAL_ACC0), (1, BAL_ACC1), (2, 5678), (3, 5678), (4, 5678)], + balances: vec![(0, BAL_ACC0), (1, BAL_ACC1), (2, 5678), (3, 5678), (4, 5678)], dev_accounts: (10, 100, "//String/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/society/src/mock.rs b/substrate/frame/society/src/mock.rs index 3c27c08a1061..e6d12739eb5c 100644 --- a/substrate/frame/society/src/mock.rs +++ b/substrate/frame/society/src/mock.rs @@ -115,7 +115,7 @@ impl EnvBuilder { pub fn execute R>(mut self, f: F) -> R { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); self.balances.push((Society::account_id(), self.balance.max(self.pot))); - pallet_balances::GenesisConfig:: { balances: self.balances } + pallet_balances::GenesisConfig:: { balances: self.balances, dev_accounts: (10, 100000, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); pallet_society::GenesisConfig:: { pot: self.pot } diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index 4a0209fc5b08..f5ff01fbb0dd 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -464,6 +464,7 @@ impl ExtBuilder { // This allows us to have a total_payout different from 0. (999, 1_000_000_000_000), ], + dev_accounts: (10, self.balance_factor, "//Sender/{}".to_string()), } .assimilate_storage(&mut storage); diff --git a/substrate/frame/state-trie-migration/src/lib.rs b/substrate/frame/state-trie-migration/src/lib.rs index 3fe5abb81031..83af1264e713 100644 --- a/substrate/frame/state-trie-migration/src/lib.rs +++ b/substrate/frame/state-trie-migration/src/lib.rs @@ -1257,7 +1257,7 @@ mod mock { frame_system::GenesisConfig::::default() .assimilate_storage(&mut custom_storage) .unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(1, 1000)] } + pallet_balances::GenesisConfig:: { balances: vec![(1, 1000)], dev_accounts: (10, 1000, "//Sender/{}".to_string()) } .assimilate_storage(&mut custom_storage) .unwrap(); } diff --git a/substrate/frame/tips/src/tests.rs b/substrate/frame/tips/src/tests.rs index 7e4a9368ad0c..5394c05f88e7 100644 --- a/substrate/frame/tips/src/tests.rs +++ b/substrate/frame/tips/src/tests.rs @@ -178,7 +178,7 @@ impl Config for Test { pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)] }, + balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], dev_accounts: (10, 1000, "//Sender/{}".to_string()) }, treasury: Default::default(), treasury_1: Default::default(), } @@ -580,6 +580,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], + dev_accounts: (10, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs index 098ecf11dd92..5b844030cab9 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -78,6 +78,7 @@ impl ExtBuilder { } else { vec![] }, + dev_accounts: (10, self.balance_factor, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/transaction-storage/src/mock.rs b/substrate/frame/transaction-storage/src/mock.rs index 73174b73dbac..591622f90dfc 100644 --- a/substrate/frame/transaction-storage/src/mock.rs +++ b/substrate/frame/transaction-storage/src/mock.rs @@ -68,6 +68,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { system: Default::default(), balances: pallet_balances::GenesisConfig:: { balances: vec![(1, 1000000000), (2, 100), (3, 100), (4, 100)], + dev_accounts: (1, 100000000, "//Sender/{}".to_string()), }, transaction_storage: pallet_transaction_storage::GenesisConfig:: { storage_period: 10, diff --git a/substrate/frame/treasury/src/tests.rs b/substrate/frame/treasury/src/tests.rs index 106bfb530a88..ca18803e4431 100644 --- a/substrate/frame/treasury/src/tests.rs +++ b/substrate/frame/treasury/src/tests.rs @@ -214,6 +214,7 @@ impl ExtBuilder { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], + dev_accounts: (1, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); @@ -382,7 +383,7 @@ fn treasury_account_doesnt_get_deleted() { #[test] fn inexistent_account_works() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)] } + pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], dev_accounts: (1, 999, "//Sender/{}".to_string()) } .assimilate_storage(&mut t) .unwrap(); // Treasury genesis config is not build thus treasury account does not exist @@ -417,6 +418,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], + dev_accounts: (1, 100, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 84ce45e83528..b997ae013583 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -156,6 +156,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // The 0 account is NOT a special origin. The rest may be: balances: vec![(0, 1234), (1, 5678), (2, 5678), (3, 5678), (4, 5678)], + dev_accounts: (1, 1000, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 9755efaea41a..bba0ff1aeb2a 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -237,6 +237,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], + dev_accounts: (1, 10, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/vesting/src/mock.rs b/substrate/frame/vesting/src/mock.rs index f0954a5b989c..4b0902906948 100644 --- a/substrate/frame/vesting/src/mock.rs +++ b/substrate/frame/vesting/src/mock.rs @@ -94,6 +94,7 @@ impl ExtBuilder { (12, 10 * self.existential_deposit), (13, 9999 * self.existential_deposit), ], + dev_accounts: (10, self.existential_deposit, "//Sender/{}".to_string()), } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/test-utils/runtime/src/genesismap.rs b/substrate/test-utils/runtime/src/genesismap.rs index 9e972886b377..5d1e972e1231 100644 --- a/substrate/test-utils/runtime/src/genesismap.rs +++ b/substrate/test-utils/runtime/src/genesismap.rs @@ -130,7 +130,7 @@ impl GenesisStorageBuilder { authorities: authorities_sr25519.clone(), ..Default::default() }, - balances: pallet_balances::GenesisConfig { balances: self.balances.clone() }, + balances: pallet_balances::GenesisConfig { balances: self.balances.clone(), dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) }, } } From 78fa5fc94f94ca1e40c6887f1cbaec43a6bea033 Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 4 Nov 2024 08:17:27 -0800 Subject: [PATCH 3/6] use default dev_accounts --- bridges/modules/messages/src/tests/mock.rs | 2 +- cumulus/parachains/runtimes/test-utils/src/lib.rs | 2 +- polkadot/runtime/common/src/assigned_slots/mod.rs | 2 +- polkadot/runtime/common/src/auctions.rs | 2 +- polkadot/runtime/common/src/crowdloan/mod.rs | 2 +- polkadot/runtime/common/src/paras_registrar/mod.rs | 2 +- polkadot/runtime/common/src/slots/mod.rs | 2 +- polkadot/xcm/pallet-xcm/src/mock.rs | 2 +- .../src/asset_exchange/single_asset_adapter/mock.rs | 2 +- polkadot/xcm/xcm-builder/tests/mock/mod.rs | 2 +- polkadot/xcm/xcm-runtime-apis/tests/mock.rs | 4 ++-- polkadot/xcm/xcm-simulator/example/src/lib.rs | 4 ++-- polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs | 4 ++-- substrate/frame/alliance/src/mock.rs | 2 +- substrate/frame/asset-conversion/ops/src/mock.rs | 2 +- substrate/frame/asset-conversion/src/mock.rs | 2 +- substrate/frame/babe/src/mock.rs | 2 +- substrate/frame/bounties/src/tests.rs | 6 +++--- substrate/frame/child-bounties/src/tests.rs | 2 +- substrate/frame/collective/src/tests.rs | 2 +- substrate/frame/contracts/mock-network/src/lib.rs | 4 ++-- substrate/frame/contracts/src/tests.rs | 2 +- substrate/frame/conviction-voting/src/tests.rs | 2 +- substrate/frame/delegated-staking/src/mock.rs | 2 +- substrate/frame/democracy/src/tests.rs | 2 +- substrate/frame/election-provider-multi-phase/src/mock.rs | 2 +- substrate/frame/elections-phragmen/src/lib.rs | 2 +- substrate/frame/fast-unstake/src/mock.rs | 2 +- substrate/frame/grandpa/src/mock.rs | 2 +- substrate/frame/identity/src/tests.rs | 2 +- substrate/frame/indices/src/mock.rs | 2 +- substrate/frame/lottery/src/mock.rs | 2 +- substrate/frame/multisig/src/tests.rs | 2 +- substrate/frame/nis/src/mock.rs | 2 +- substrate/frame/preimage/src/mock.rs | 2 +- substrate/frame/proxy/src/tests.rs | 2 +- substrate/frame/recovery/src/mock.rs | 2 +- substrate/frame/referenda/src/mock.rs | 2 +- substrate/frame/revive/mock-network/src/lib.rs | 4 ++-- substrate/frame/revive/src/tests.rs | 2 +- substrate/frame/root-offences/src/mock.rs | 2 +- substrate/frame/safe-mode/src/mock.rs | 2 +- substrate/frame/society/src/mock.rs | 2 +- substrate/frame/staking/src/mock.rs | 2 +- substrate/frame/state-trie-migration/src/lib.rs | 2 +- substrate/frame/tips/src/tests.rs | 4 ++-- .../frame/transaction-payment/asset-tx-payment/src/tests.rs | 2 +- substrate/frame/transaction-storage/src/mock.rs | 2 +- substrate/frame/treasury/src/tests.rs | 6 +++--- substrate/frame/tx-pause/src/mock.rs | 2 +- substrate/frame/utility/src/tests.rs | 2 +- substrate/frame/vesting/src/mock.rs | 2 +- substrate/test-utils/runtime/src/genesismap.rs | 2 +- 53 files changed, 63 insertions(+), 63 deletions(-) diff --git a/bridges/modules/messages/src/tests/mock.rs b/bridges/modules/messages/src/tests/mock.rs index 60d0f60957b4..d962fc1dc928 100644 --- a/bridges/modules/messages/src/tests/mock.rs +++ b/bridges/modules/messages/src/tests/mock.rs @@ -461,7 +461,7 @@ pub fn inbound_unrewarded_relayers_state(lane: TestLaneIdType) -> UnrewardedRela /// Return test externalities to use in tests. pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)], dev_accounts: (10, 1_000_000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![(ENDOWED_ACCOUNT, 1_000_000)], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); sp_io::TestExternalities::new(t) diff --git a/cumulus/parachains/runtimes/test-utils/src/lib.rs b/cumulus/parachains/runtimes/test-utils/src/lib.rs index 9a8632df7cfe..92e1a147df5f 100644 --- a/cumulus/parachains/runtimes/test-utils/src/lib.rs +++ b/cumulus/parachains/runtimes/test-utils/src/lib.rs @@ -230,7 +230,7 @@ impl ExtBuilder { .unwrap(); } - pallet_balances::GenesisConfig:: { balances: self.balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: self.balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/assigned_slots/mod.rs b/polkadot/runtime/common/src/assigned_slots/mod.rs index f4c7f2403708..0c7c6faa6f69 100644 --- a/polkadot/runtime/common/src/assigned_slots/mod.rs +++ b/polkadot/runtime/common/src/assigned_slots/mod.rs @@ -764,7 +764,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/auctions.rs b/polkadot/runtime/common/src/auctions.rs index 9404ee73ab6c..b0674ddc501a 100644 --- a/polkadot/runtime/common/src/auctions.rs +++ b/polkadot/runtime/common/src/auctions.rs @@ -866,7 +866,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/crowdloan/mod.rs b/polkadot/runtime/common/src/crowdloan/mod.rs index f258efc8a771..20476042f0be 100644 --- a/polkadot/runtime/common/src/crowdloan/mod.rs +++ b/polkadot/runtime/common/src/crowdloan/mod.rs @@ -1085,7 +1085,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 1000), (2, 2000), (3, 3000), (4, 4000)], - dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/paras_registrar/mod.rs b/polkadot/runtime/common/src/paras_registrar/mod.rs index be964ee7406f..008cc82dba32 100644 --- a/polkadot/runtime/common/src/paras_registrar/mod.rs +++ b/polkadot/runtime/common/src/paras_registrar/mod.rs @@ -860,7 +860,7 @@ mod tests { pallet_balances::GenesisConfig:: { balances: vec![(1, 10_000_000), (2, 10_000_000), (3, 10_000_000)], - dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/runtime/common/src/slots/mod.rs b/polkadot/runtime/common/src/slots/mod.rs index d970918b2611..4ed7f0f2ab83 100644 --- a/polkadot/runtime/common/src/slots/mod.rs +++ b/polkadot/runtime/common/src/slots/mod.rs @@ -578,7 +578,7 @@ mod tests { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, crate::integration_tests::ExistentialDeposit::get().into(), "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/pallet-xcm/src/mock.rs b/polkadot/xcm/pallet-xcm/src/mock.rs index 8e3c255ca79b..58b4226ccf19 100644 --- a/polkadot/xcm/pallet-xcm/src/mock.rs +++ b/polkadot/xcm/pallet-xcm/src/mock.rs @@ -700,7 +700,7 @@ pub(crate) fn new_test_ext_with_balances_and_xcm_version( ) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, ExistentialDeposit::get(), "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs index 04c63b78fa73..2e41e86e9f41 100644 --- a/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs +++ b/polkadot/xcm/xcm-builder/src/asset_exchange/single_asset_adapter/mock.rs @@ -339,7 +339,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(0, INITIAL_BALANCE), (1, INITIAL_BALANCE), (2, INITIAL_BALANCE)], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-builder/tests/mock/mod.rs b/polkadot/xcm/xcm-builder/tests/mock/mod.rs index ecd9512b76d6..c3e532845082 100644 --- a/polkadot/xcm/xcm-builder/tests/mock/mod.rs +++ b/polkadot/xcm/xcm-builder/tests/mock/mod.rs @@ -243,7 +243,7 @@ construct_runtime!( pub fn kusama_like_with_balances(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 1_000_000_000u32.into(), "//Sender/{}".into()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs index 500086bc3436..90cb5156e3c8 100644 --- a/polkadot/xcm/xcm-runtime-apis/tests/mock.rs +++ b/polkadot/xcm/xcm-runtime-apis/tests/mock.rs @@ -357,7 +357,7 @@ impl pallet_xcm::Config for TestRuntime { pub fn new_test_ext_with_balances(balances: Vec<(AccountId, Balance)>) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -373,7 +373,7 @@ pub fn new_test_ext_with_balances_and_assets( ) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-simulator/example/src/lib.rs b/polkadot/xcm/xcm-simulator/example/src/lib.rs index 908d0054a7d1..8a05569831b5 100644 --- a/polkadot/xcm/xcm-simulator/example/src/lib.rs +++ b/polkadot/xcm/xcm-simulator/example/src/lib.rs @@ -101,7 +101,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(ALICE, INITIAL_BALANCE), (parent_account_id(), INITIAL_BALANCE)], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -126,7 +126,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (child_account_id(1), INITIAL_BALANCE), (child_account_id(2), INITIAL_BALANCE), ], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs index 37c7bcbcc0a5..8ea5e033f3ad 100644 --- a/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs +++ b/polkadot/xcm/xcm-simulator/fuzzer/src/fuzz.rs @@ -117,7 +117,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: (0..6).map(|i| ([i; 32].into(), INITIAL_BALANCE)).collect(), - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -139,7 +139,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { balances.append(&mut (1..=3).map(|i| (para_account_id(i), INITIAL_BALANCE)).collect()); balances.append(&mut (0..6).map(|i| ([i; 32].into(), INITIAL_BALANCE)).collect()); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/alliance/src/mock.rs b/substrate/frame/alliance/src/mock.rs index 1fa1d90d63b4..0d9185648450 100644 --- a/substrate/frame/alliance/src/mock.rs +++ b/substrate/frame/alliance/src/mock.rs @@ -279,7 +279,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (8, 1000), (9, 1000), ], - dev-accounts: (10, 1000, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/asset-conversion/ops/src/mock.rs b/substrate/frame/asset-conversion/ops/src/mock.rs index a85bc291799c..576b266b39c1 100644 --- a/substrate/frame/asset-conversion/ops/src/mock.rs +++ b/substrate/frame/asset-conversion/ops/src/mock.rs @@ -135,7 +135,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)], - dev_accounts: (10, 10000, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/asset-conversion/src/mock.rs b/substrate/frame/asset-conversion/src/mock.rs index 268bd5634353..313d9f9857e4 100644 --- a/substrate/frame/asset-conversion/src/mock.rs +++ b/substrate/frame/asset-conversion/src/mock.rs @@ -162,7 +162,7 @@ pub(crate) fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)], - dev_accounts: (10, 10000, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/babe/src/mock.rs b/substrate/frame/babe/src/mock.rs index c77b8691b753..d34d5441d1bb 100644 --- a/substrate/frame/babe/src/mock.rs +++ b/substrate/frame/babe/src/mock.rs @@ -304,7 +304,7 @@ pub fn new_test_ext_raw_authorities(authorities: Vec) -> sp_io::Tes let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 10_000_000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/bounties/src/tests.rs b/substrate/frame/bounties/src/tests.rs index b0c7f4f43f2c..1053ec660655 100644 --- a/substrate/frame/bounties/src/tests.rs +++ b/substrate/frame/bounties/src/tests.rs @@ -179,7 +179,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], dev_accounts: (10, 100, "//Sender/{}".to_string()) }, + balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], ..Default::default() }, treasury: Default::default(), treasury_1: Default::default(), } @@ -310,7 +310,7 @@ fn treasury_account_doesnt_get_deleted() { #[test] fn inexistent_account_works() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], dev_accounts: (10, 100, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); // Treasury genesis config is not build thus treasury account does not exist @@ -976,7 +976,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], - dev_accounts: (10, 100, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/child-bounties/src/tests.rs b/substrate/frame/child-bounties/src/tests.rs index cc596e3bc916..197bc414d3ac 100644 --- a/substrate/frame/child-bounties/src/tests.rs +++ b/substrate/frame/child-bounties/src/tests.rs @@ -135,7 +135,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], - dev_accounts: (10, 100, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/collective/src/tests.rs b/substrate/frame/collective/src/tests.rs index 6e9cf310fa95..2bad3c1a08d9 100644 --- a/substrate/frame/collective/src/tests.rs +++ b/substrate/frame/collective/src/tests.rs @@ -203,7 +203,7 @@ impl ExtBuilder { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), // balances: pallet_balances::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(1, 100), (2, 200)], dev_accounts: (10, 100, "//Sender/{}".to_string()) }, + balances: pallet_balances::GenesisConfig { balances: vec![(1, 100), (2, 200)], ..Default::default() }, collective: pallet_collective::GenesisConfig { members: self.collective_members, phantom: Default::default(), diff --git a/substrate/frame/contracts/mock-network/src/lib.rs b/substrate/frame/contracts/mock-network/src/lib.rs index bce533e8c4c3..c918cd39ed91 100644 --- a/substrate/frame/contracts/mock-network/src/lib.rs +++ b/substrate/frame/contracts/mock-network/src/lib.rs @@ -99,7 +99,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { (relay_sovereign_account_id(), INITIAL_BALANCE), (BOB, INITIAL_BALANCE), ], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -138,7 +138,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (parachain_sovereign_account_id(1), INITIAL_BALANCE), (parachain_account_sovereign_account_id(1, ALICE), INITIAL_BALANCE), ], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/contracts/src/tests.rs b/substrate/frame/contracts/src/tests.rs index 72e615190c54..eed8076e8861 100644 --- a/substrate/frame/contracts/src/tests.rs +++ b/substrate/frame/contracts/src/tests.rs @@ -552,7 +552,7 @@ impl ExtBuilder { sp_tracing::try_init_simple(); self.set_associated_consts(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![], dev_accounts: (10, self.existential_deposit, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/conviction-voting/src/tests.rs b/substrate/frame/conviction-voting/src/tests.rs index b3aa7ea400ab..17f967dd143d 100644 --- a/substrate/frame/conviction-voting/src/tests.rs +++ b/substrate/frame/conviction-voting/src/tests.rs @@ -160,7 +160,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, 20, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/delegated-staking/src/mock.rs b/substrate/frame/delegated-staking/src/mock.rs index fc75b03787ea..7550d0c463f3 100644 --- a/substrate/frame/delegated-staking/src/mock.rs +++ b/substrate/frame/delegated-staking/src/mock.rs @@ -188,7 +188,7 @@ impl ExtBuilder { (GENESIS_NOMINATOR_ONE, 1000), (GENESIS_NOMINATOR_TWO, 2000), ], - dev_accounts: (10, 1000, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut storage); diff --git a/substrate/frame/democracy/src/tests.rs b/substrate/frame/democracy/src/tests.rs index 901b16c3e0cd..777744800684 100644 --- a/substrate/frame/democracy/src/tests.rs +++ b/substrate/frame/democracy/src/tests.rs @@ -169,7 +169,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, 10, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/election-provider-multi-phase/src/mock.rs b/substrate/frame/election-provider-multi-phase/src/mock.rs index 648fe2b7ffe4..9323e3533f10 100644 --- a/substrate/frame/election-provider-multi-phase/src/mock.rs +++ b/substrate/frame/election-provider-multi-phase/src/mock.rs @@ -591,7 +591,7 @@ impl ExtBuilder { (999, 100), (9999, 100), ], - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut storage); diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index 1538a53cf8df..c74ee920a4fc 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -1476,7 +1476,7 @@ mod tests { (5, 50 * self.balance_factor), (6, 60 * self.balance_factor), ], - dev_accounts: (10, 10 * self.balance_factor, "//Sender/{}".to_string()), + ..Default::default() }, elections: elections_phragmen::GenesisConfig:: { members: self.genesis_members, diff --git a/substrate/frame/fast-unstake/src/mock.rs b/substrate/frame/fast-unstake/src/mock.rs index 650e2aefcab6..5546221b2337 100644 --- a/substrate/frame/fast-unstake/src/mock.rs +++ b/substrate/frame/fast-unstake/src/mock.rs @@ -226,7 +226,7 @@ impl ExtBuilder { .chain(validators_range.clone().map(|x| (x, 7 + 100))) .chain(nominators_range.clone().map(|x| (x, 7 + 100))) .collect::>(), - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut storage); diff --git a/substrate/frame/grandpa/src/mock.rs b/substrate/frame/grandpa/src/mock.rs index 92dd386beb00..be4d1b68e152 100644 --- a/substrate/frame/grandpa/src/mock.rs +++ b/substrate/frame/grandpa/src/mock.rs @@ -216,7 +216,7 @@ pub fn new_test_ext_raw_authorities(authorities: AuthorityList) -> sp_io::TestEx let balances: Vec<_> = (0..authorities.len()).map(|i| (i as u64, 10_000_000)).collect(); - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 10_000_000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/identity/src/tests.rs b/substrate/frame/identity/src/tests.rs index 17f3842bf735..6c3cf331f578 100644 --- a/substrate/frame/identity/src/tests.rs +++ b/substrate/frame/identity/src/tests.rs @@ -103,7 +103,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { (account(20), 1000), (account(30), 1000), ], - dev_accounts: (10, 100, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/indices/src/mock.rs b/substrate/frame/indices/src/mock.rs index d53d071e8710..80d0a88881f9 100644 --- a/substrate/frame/indices/src/mock.rs +++ b/substrate/frame/indices/src/mock.rs @@ -59,7 +59,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)], - dev_accounts: (10, 10, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/lottery/src/mock.rs b/substrate/frame/lottery/src/mock.rs index f880729b8700..98bbdd045cbf 100644 --- a/substrate/frame/lottery/src/mock.rs +++ b/substrate/frame/lottery/src/mock.rs @@ -78,7 +78,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], - dev_accounts: (10, 100, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/multisig/src/tests.rs b/substrate/frame/multisig/src/tests.rs index f5ead2e85ae6..3956a735177d 100644 --- a/substrate/frame/multisig/src/tests.rs +++ b/substrate/frame/multisig/src/tests.rs @@ -79,7 +79,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/nis/src/mock.rs b/substrate/frame/nis/src/mock.rs index 298649f08e62..e00378f8387c 100644 --- a/substrate/frame/nis/src/mock.rs +++ b/substrate/frame/nis/src/mock.rs @@ -133,7 +133,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100)], - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/preimage/src/mock.rs b/substrate/frame/preimage/src/mock.rs index 1573ecb8d4ab..dec590c6a197 100644 --- a/substrate/frame/preimage/src/mock.rs +++ b/substrate/frame/preimage/src/mock.rs @@ -81,7 +81,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], - dev_accounts: (10, 100, "//Sender/{}".to_string()) + ..Default::default() }; balances.assimilate_storage(&mut t).unwrap(); t.into() diff --git a/substrate/frame/proxy/src/tests.rs b/substrate/frame/proxy/src/tests.rs index 140dea692c47..386a7c2bae63 100644 --- a/substrate/frame/proxy/src/tests.rs +++ b/substrate/frame/proxy/src/tests.rs @@ -140,7 +140,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 3)], - dev_accounts: (10, 10, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/recovery/src/mock.rs b/substrate/frame/recovery/src/mock.rs index 45f1323522dc..8a0ac37b00d5 100644 --- a/substrate/frame/recovery/src/mock.rs +++ b/substrate/frame/recovery/src/mock.rs @@ -80,7 +80,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)], - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/referenda/src/mock.rs b/substrate/frame/referenda/src/mock.rs index 26205abc83f6..5d36ce137d46 100644 --- a/substrate/frame/referenda/src/mock.rs +++ b/substrate/frame/referenda/src/mock.rs @@ -219,7 +219,7 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let balances = vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]; - pallet_balances::GenesisConfig:: { balances, dev_accounts: (10, 100, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/revive/mock-network/src/lib.rs b/substrate/frame/revive/mock-network/src/lib.rs index d1f1241878bd..b57c4f76212b 100644 --- a/substrate/frame/revive/mock-network/src/lib.rs +++ b/substrate/frame/revive/mock-network/src/lib.rs @@ -99,7 +99,7 @@ pub fn para_ext(para_id: u32) -> sp_io::TestExternalities { (relay_sovereign_account_id(), INITIAL_BALANCE), (BOB, INITIAL_BALANCE), ], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -138,7 +138,7 @@ pub fn relay_ext() -> sp_io::TestExternalities { (parachain_sovereign_account_id(1), INITIAL_BALANCE), (parachain_account_sovereign_account_id(1, ALICE), INITIAL_BALANCE), ], - dev_accounts: (10, INITIAL_BALANCE, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/revive/src/tests.rs b/substrate/frame/revive/src/tests.rs index 171bba47e923..6c3f81652267 100644 --- a/substrate/frame/revive/src/tests.rs +++ b/substrate/frame/revive/src/tests.rs @@ -541,7 +541,7 @@ impl ExtBuilder { sp_tracing::try_init_simple(); self.set_associated_consts(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![], dev_accounts: (10, 1000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); let mut ext = sp_io::TestExternalities::new(t); diff --git a/substrate/frame/root-offences/src/mock.rs b/substrate/frame/root-offences/src/mock.rs index c37df85d6e61..efa22c25e284 100644 --- a/substrate/frame/root-offences/src/mock.rs +++ b/substrate/frame/root-offences/src/mock.rs @@ -211,7 +211,7 @@ impl ExtBuilder { (31, self.balance_factor * 500), (41, self.balance_factor * 1000), ], - dev_accounts: (10, 1000, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut storage) .unwrap(); diff --git a/substrate/frame/safe-mode/src/mock.rs b/substrate/frame/safe-mode/src/mock.rs index 71c5201b14f3..784eee450390 100644 --- a/substrate/frame/safe-mode/src/mock.rs +++ b/substrate/frame/safe-mode/src/mock.rs @@ -231,7 +231,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // The 0 account is NOT a special origin, the rest may be. - balances: vec![(0, BAL_ACC0), (1, BAL_ACC1), (2, 5678), (3, 5678), (4, 5678)], dev_accounts: (10, 100, "//String/{}".to_string()), + balances: vec![(0, BAL_ACC0), (1, BAL_ACC1), (2, 5678), (3, 5678), (4, 5678)], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/society/src/mock.rs b/substrate/frame/society/src/mock.rs index e6d12739eb5c..a717aace767d 100644 --- a/substrate/frame/society/src/mock.rs +++ b/substrate/frame/society/src/mock.rs @@ -115,7 +115,7 @@ impl EnvBuilder { pub fn execute R>(mut self, f: F) -> R { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); self.balances.push((Society::account_id(), self.balance.max(self.pot))); - pallet_balances::GenesisConfig:: { balances: self.balances, dev_accounts: (10, 100000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: self.balances, ..Default::default() } .assimilate_storage(&mut t) .unwrap(); pallet_society::GenesisConfig:: { pot: self.pot } diff --git a/substrate/frame/staking/src/mock.rs b/substrate/frame/staking/src/mock.rs index f5ff01fbb0dd..91793276645f 100644 --- a/substrate/frame/staking/src/mock.rs +++ b/substrate/frame/staking/src/mock.rs @@ -464,7 +464,7 @@ impl ExtBuilder { // This allows us to have a total_payout different from 0. (999, 1_000_000_000_000), ], - dev_accounts: (10, self.balance_factor, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut storage); diff --git a/substrate/frame/state-trie-migration/src/lib.rs b/substrate/frame/state-trie-migration/src/lib.rs index 83af1264e713..eaaaf2c19fc1 100644 --- a/substrate/frame/state-trie-migration/src/lib.rs +++ b/substrate/frame/state-trie-migration/src/lib.rs @@ -1257,7 +1257,7 @@ mod mock { frame_system::GenesisConfig::::default() .assimilate_storage(&mut custom_storage) .unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(1, 1000)], dev_accounts: (10, 1000, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![(1, 1000)], ..Default::default() } .assimilate_storage(&mut custom_storage) .unwrap(); } diff --git a/substrate/frame/tips/src/tests.rs b/substrate/frame/tips/src/tests.rs index 5394c05f88e7..697b269d6022 100644 --- a/substrate/frame/tips/src/tests.rs +++ b/substrate/frame/tips/src/tests.rs @@ -178,7 +178,7 @@ impl Config for Test { pub fn new_test_ext() -> sp_io::TestExternalities { let mut ext: sp_io::TestExternalities = RuntimeGenesisConfig { system: frame_system::GenesisConfig::default(), - balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], dev_accounts: (10, 1000, "//Sender/{}".to_string()) }, + balances: pallet_balances::GenesisConfig { balances: vec![(0, 100), (1, 98), (2, 1)], ..Default::default() }, treasury: Default::default(), treasury_1: Default::default(), } @@ -580,7 +580,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], - dev_accounts: (10, 100, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs index 5b844030cab9..5fb88bf20e8e 100644 --- a/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/asset-tx-payment/src/tests.rs @@ -78,7 +78,7 @@ impl ExtBuilder { } else { vec![] }, - dev_accounts: (10, self.balance_factor, "//Sender/{}".to_string()), + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/transaction-storage/src/mock.rs b/substrate/frame/transaction-storage/src/mock.rs index 591622f90dfc..6df6692e71ad 100644 --- a/substrate/frame/transaction-storage/src/mock.rs +++ b/substrate/frame/transaction-storage/src/mock.rs @@ -68,7 +68,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { system: Default::default(), balances: pallet_balances::GenesisConfig:: { balances: vec![(1, 1000000000), (2, 100), (3, 100), (4, 100)], - dev_accounts: (1, 100000000, "//Sender/{}".to_string()), + ..Defualt::default() }, transaction_storage: pallet_transaction_storage::GenesisConfig:: { storage_period: 10, diff --git a/substrate/frame/treasury/src/tests.rs b/substrate/frame/treasury/src/tests.rs index ca18803e4431..57ea000485f8 100644 --- a/substrate/frame/treasury/src/tests.rs +++ b/substrate/frame/treasury/src/tests.rs @@ -214,7 +214,7 @@ impl ExtBuilder { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], - dev_accounts: (1, 100, "//Sender/{}".to_string()), + ..Defualt::default() } .assimilate_storage(&mut t) .unwrap(); @@ -383,7 +383,7 @@ fn treasury_account_doesnt_get_deleted() { #[test] fn inexistent_account_works() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], dev_accounts: (1, 999, "//Sender/{}".to_string()) } + pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], ..Defualt::default() } .assimilate_storage(&mut t) .unwrap(); // Treasury genesis config is not build thus treasury account does not exist @@ -418,7 +418,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], - dev_accounts: (1, 100, "//Sender/{}".to_string()), + ..Defualt::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index b997ae013583..11ed9afd6f33 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -156,7 +156,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // The 0 account is NOT a special origin. The rest may be: balances: vec![(0, 1234), (1, 5678), (2, 5678), (3, 5678), (4, 5678)], - dev_accounts: (1, 1000, "//Sender/{}".to_string()), + ..Defualt::defualt() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index bba0ff1aeb2a..729902ed3976 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -237,7 +237,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], - dev_accounts: (1, 10, "//Sender/{}".to_string()), + ..Defualt::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/vesting/src/mock.rs b/substrate/frame/vesting/src/mock.rs index 4b0902906948..9adab76e30c8 100644 --- a/substrate/frame/vesting/src/mock.rs +++ b/substrate/frame/vesting/src/mock.rs @@ -94,7 +94,7 @@ impl ExtBuilder { (12, 10 * self.existential_deposit), (13, 9999 * self.existential_deposit), ], - dev_accounts: (10, self.existential_deposit, "//Sender/{}".to_string()), + ..Defualt::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/test-utils/runtime/src/genesismap.rs b/substrate/test-utils/runtime/src/genesismap.rs index 5d1e972e1231..1e20699e2faa 100644 --- a/substrate/test-utils/runtime/src/genesismap.rs +++ b/substrate/test-utils/runtime/src/genesismap.rs @@ -130,7 +130,7 @@ impl GenesisStorageBuilder { authorities: authorities_sr25519.clone(), ..Default::default() }, - balances: pallet_balances::GenesisConfig { balances: self.balances.clone(), dev_accounts: (10, 100u32.into(), "//Sender/{}".to_string()) }, + balances: pallet_balances::GenesisConfig { balances: self.balances.clone(), ..Default::default() }, } } From a4a1effae44f2cac7e6eab4c236ef2d6bedd9a85 Mon Sep 17 00:00:00 2001 From: runcomet Date: Mon, 4 Nov 2024 09:50:06 -0800 Subject: [PATCH 4/6] BalancesConfig --- .../assets/asset-hub-rococo/src/genesis_config_presets.rs | 4 ++-- .../assets/asset-hub-westend/src/genesis_config_presets.rs | 4 ++-- .../bridge-hub-rococo/src/genesis_config_presets.rs | 4 ++-- .../bridge-hub-westend/src/genesis_config_presets.rs | 4 ++-- .../collectives-westend/src/genesis_config_presets.rs | 4 ++-- polkadot/runtime/rococo/src/genesis_config_presets.rs | 6 +++--- polkadot/runtime/westend/src/genesis_config_presets.rs | 6 +++--- substrate/bin/node/testing/src/genesis.rs | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs index e45a5203512f..72ed53ed5720 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Asset Hub Rococo Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use hex_literal::hex; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; @@ -35,7 +35,7 @@ fn asset_hub_rococo_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(), - dev_accounts: (10, ASSET_HUB_ROCOCO_ED, "//Sender/{}".to_string()), + ..Default::default() }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs index fe0054625240..3cd95567732b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Asset Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use hex_literal::hex; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; @@ -37,7 +37,7 @@ fn asset_hub_westend_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(), - dev_accounts: (10, ASSET_HUB_WESTEND_ED, "//Sender/{}".to_string()) + ..Default::default() }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs index 4b0f929612a6..c0f22c442120 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Rococo Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -40,7 +40,7 @@ fn bridge_hub_rococo_genesis( .cloned() .map(|k| (k, 1u128 << 60)) .collect::>(), - dev_accounts: (10, BRIDGE_HUB_ROCOCO_ED, "//Sender/{}".to_string()), + ..Default::default() }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs index 2714e17a2109..51d97e78c510 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -40,7 +40,7 @@ fn bridge_hub_westend_genesis( .cloned() .map(|k| (k, 1u128 << 60)) .collect::>(), - dev_accounts: (10, BRIDGE_HUB_WESTEND_ED, "//Sender/{}".to_string()) + ..Default::default() }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs index ebff423b8b67..8eded3bb975d 100644 --- a/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/collectives/collectives-westend/src/genesis_config_presets.rs @@ -16,7 +16,7 @@ //! # Bridge Hub Westend Runtime genesis config presets use crate::*; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use cumulus_primitives_core::ParaId; use parachains_common::{genesis_config_helpers::*, AccountId, AuraId}; use sp_core::sr25519; @@ -37,7 +37,7 @@ fn collectives_westend_genesis( .cloned() .map(|k| (k, COLLECTIVES_WESTEND_ED * 4096)) .collect::>(), - dev_accounts: (10, COLLECTIVES_WESTEND_ED, "//Sender/{}".to_string()) + ..Default::default() }, parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, collator_selection: CollatorSelectionConfig { diff --git a/polkadot/runtime/rococo/src/genesis_config_presets.rs b/polkadot/runtime/rococo/src/genesis_config_presets.rs index 58d890b68cd1..c2e3971e9a97 100644 --- a/polkadot/runtime/rococo/src/genesis_config_presets.rs +++ b/polkadot/runtime/rococo/src/genesis_config_presets.rs @@ -22,7 +22,7 @@ use crate::{ }; #[cfg(not(feature = "std"))] use alloc::format; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId}; use rococo_runtime_constants::currency::UNITS as ROC; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -185,7 +185,7 @@ fn rococo_testnet_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect::>(), - dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) + ..Default::default() }, session: SessionConfig { keys: initial_authorities @@ -454,7 +454,7 @@ fn rococo_staging_testnet_config_genesis() -> serde_json::Value { .map(|k: &AccountId| (k.clone(), ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect::>(), - dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) + ..Default::default() }, session: SessionConfig { keys: initial_authorities diff --git a/polkadot/runtime/westend/src/genesis_config_presets.rs b/polkadot/runtime/westend/src/genesis_config_presets.rs index ae21c06c0603..02d4fc14e56f 100644 --- a/polkadot/runtime/westend/src/genesis_config_presets.rs +++ b/polkadot/runtime/westend/src/genesis_config_presets.rs @@ -22,7 +22,7 @@ use crate::{ }; #[cfg(not(feature = "std"))] use alloc::format; -use alloc::{vec, vec::Vec, string::ToString}; +use alloc::{vec, vec::Vec}; use pallet_staking::{Forcing, StakerStatus}; use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId}; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; @@ -191,7 +191,7 @@ fn westend_testnet_genesis( let config = RuntimeGenesisConfig { balances: BalancesConfig { balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect::>(), - dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()) + ..Default::default() }, session: SessionConfig { keys: initial_authorities @@ -371,7 +371,7 @@ fn westend_staging_testnet_config_genesis() -> serde_json::Value { .map(|k: &AccountId| (k.clone(), ENDOWMENT)) .chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH))) .collect::>(), - dev_accounts: (10, ENDOWMENT, "//Sender/{}".to_string()), + ..Default::default() }, session: SessionConfig { keys: initial_authorities diff --git a/substrate/bin/node/testing/src/genesis.rs b/substrate/bin/node/testing/src/genesis.rs index 7ec5c5bb506e..606349e0bd6b 100644 --- a/substrate/bin/node/testing/src/genesis.rs +++ b/substrate/bin/node/testing/src/genesis.rs @@ -47,7 +47,7 @@ pub fn config_endowed(extra_endowed: Vec) -> RuntimeGenesisConfig { RuntimeGenesisConfig { indices: IndicesConfig { indices: vec![] }, - balances: BalancesConfig { balances: endowed, dev_accounts: (10, 100 * DOLLARS, "//Sender/{}".to_string()) }, + balances: BalancesConfig { balances: endowed, ..Default::default() }, session: SessionConfig { keys: vec![ (alice(), dave(), session_keys_from_seed(Ed25519Keyring::Alice.into())), From 3163d5f4e62728a4ff5aa312b4302ec38bec6d4c Mon Sep 17 00:00:00 2001 From: runcomet Date: Tue, 12 Nov 2024 18:48:08 -0800 Subject: [PATCH 5/6] configure ensure_ti_valid awareness of dev_accounts --- .../frame/balances/src/tests/general_tests.rs | 13 ----- substrate/frame/balances/src/tests/mod.rs | 53 +++++++++++++++---- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/substrate/frame/balances/src/tests/general_tests.rs b/substrate/frame/balances/src/tests/general_tests.rs index d062d8862914..a855fae5616a 100644 --- a/substrate/frame/balances/src/tests/general_tests.rs +++ b/substrate/frame/balances/src/tests/general_tests.rs @@ -141,16 +141,3 @@ fn try_state_works() { .contains("Found `Freeze` with too many elements")); }); } - -#[cfg(feature = "runtime-benchmarks")] -#[test] -fn dev_accounts_populated() { - ExtBuilder::default().build_and_execute_with(|| { - UseSystem::set(true); // copmment this out and uncomment this from time to time to check stuff. - // Print total issuance for debugging - let ti = TotalIssuance::::get(); - println!("Total Issuance after genesis: {}", ti); - println!("Why are you printing twice?"); - ensure_ti_valid(); - }); -} diff --git a/substrate/frame/balances/src/tests/mod.rs b/substrate/frame/balances/src/tests/mod.rs index a621b8c21f9f..8b953b957291 100644 --- a/substrate/frame/balances/src/tests/mod.rs +++ b/substrate/frame/balances/src/tests/mod.rs @@ -43,6 +43,11 @@ use sp_runtime::{ }; use std::collections::BTreeSet; +#[cfg(feature = "runtime-benchmarks")] +use sp_core::{sr25519::Pair as SrPair, Pair}; + +use frame_support::traits::BuildGenesisConfig; + mod currency_tests; mod dispatchable_tests; mod fungible_conformance_tests; @@ -281,19 +286,45 @@ pub fn info_from_weight(w: Weight) -> DispatchInfo { /// Check that the total-issuance matches the sum of all accounts' total balances. pub fn ensure_ti_valid() { - let mut sum = 0; + let mut sum = 0; - for acc in frame_system::Account::::iter_keys() { - if UseSystem::get() { - let data = frame_system::Pallet::::account(acc); - sum += data.data.total(); - } else { - let data = crate::Account::::get(acc); - sum += data.total(); - } - } + // Fetch the dev accounts from the GenesisConfig. + #[cfg(feature = "runtime-benchmarks")] + let dev_accounts = (10, 100, "//Sender/{}".to_string()); // You can customize this as needed + #[cfg(feature = "runtime-benchmarks")] + let (num_accounts, balance, ref derivation) = dev_accounts; + + // Generate the dev account public keys. + #[cfg(feature = "runtime-benchmarks")] + let dev_account_ids: Vec<_> = (0..num_accounts) + .map(|index| { + let derivation_string = derivation.replace("{}", &index.to_string()); + let pair: SrPair = Pair::from_string(&derivation_string, None).expect("Invalid derivation string"); + ::AccountId::decode(&mut &pair.public().encode()[..]).unwrap() + }) + .collect(); + + // Iterate over all account keys (i.e., the account IDs). + for acc in frame_system::Account::::iter_keys() { + // Skip dev accounts by checking if the account is in the dev_account_ids list. + // This also proves dev_accounts exists in storage. + #[cfg(feature = "runtime-benchmarks")] + if dev_account_ids.contains(&acc) { + continue; + } + + // Check if we are using the system pallet or some other custom storage for accounts. + if UseSystem::get() { + let data = frame_system::Pallet::::account(acc); + sum += data.data.total(); + } else { + let data = crate::Account::::get(acc); + sum += data.total(); + } + } - assert_eq!(TotalIssuance::::get(), sum, "Total Issuance wrong"); + // Ensure the total issuance matches the sum of the account balances + assert_eq!(TotalIssuance::::get(), sum, "Total Issuance is incorrect"); } #[test] From 25ca49c0ee7a2e895a9d41539f8b54b1c13794fb Mon Sep 17 00:00:00 2001 From: runcomet Date: Thu, 14 Nov 2024 00:35:29 -0800 Subject: [PATCH 6/6] nit --- substrate/frame/balances/src/lib.rs | 3 +-- substrate/frame/balances/src/tests/currency_tests.rs | 8 ++------ substrate/frame/balances/src/tests/mod.rs | 4 +--- substrate/frame/transaction-storage/src/mock.rs | 2 +- substrate/frame/treasury/src/tests.rs | 6 +++--- substrate/frame/tx-pause/src/mock.rs | 2 +- substrate/frame/utility/src/tests.rs | 2 +- substrate/frame/vesting/src/mock.rs | 2 +- 8 files changed, 11 insertions(+), 18 deletions(-) diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 030b4ffa0b67..fe3612af1a2f 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -152,7 +152,7 @@ pub mod weights; extern crate alloc; -use alloc::{vec::Vec, string::{String, ToString}}; +use alloc::vec::Vec; use codec::{Codec, MaxEncodedLen}; use core::{cmp, fmt::Debug, mem, result}; use frame_support::{ @@ -556,7 +556,6 @@ pub mod pallet { #[cfg(feature = "runtime-benchmarks")] { let (num_accounts, balance, ref derivation) = self.dev_accounts; - let num_balance = >::Balance::from(num_accounts); for index in 0..num_accounts { assert!( balance >= >::ExistentialDeposit::get(), diff --git a/substrate/frame/balances/src/tests/currency_tests.rs b/substrate/frame/balances/src/tests/currency_tests.rs index 2566d07f6a18..d6d9b5538e13 100644 --- a/substrate/frame/balances/src/tests/currency_tests.rs +++ b/substrate/frame/balances/src/tests/currency_tests.rs @@ -719,9 +719,7 @@ fn cannot_set_genesis_value_below_ed() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = crate::GenesisConfig:: { balances: vec![(1, 10)], - - #[cfg(feature = "runtime-benchmarks")] - dev_accounts: (1000000, 500, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -733,9 +731,7 @@ fn cannot_set_genesis_value_twice() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); let _ = crate::GenesisConfig:: { balances: vec![(1, 10), (2, 20), (1, 15)], - - #[cfg(feature = "runtime-benchmarks")] - dev_accounts: (1000000, 500, "//Sender/{}".to_string()) + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/balances/src/tests/mod.rs b/substrate/frame/balances/src/tests/mod.rs index 8b953b957291..cb28ec253949 100644 --- a/substrate/frame/balances/src/tests/mod.rs +++ b/substrate/frame/balances/src/tests/mod.rs @@ -46,8 +46,6 @@ use std::collections::BTreeSet; #[cfg(feature = "runtime-benchmarks")] use sp_core::{sr25519::Pair as SrPair, Pair}; -use frame_support::traits::BuildGenesisConfig; - mod currency_tests; mod dispatchable_tests; mod fungible_conformance_tests; @@ -292,7 +290,7 @@ pub fn ensure_ti_valid() { #[cfg(feature = "runtime-benchmarks")] let dev_accounts = (10, 100, "//Sender/{}".to_string()); // You can customize this as needed #[cfg(feature = "runtime-benchmarks")] - let (num_accounts, balance, ref derivation) = dev_accounts; + let (num_accounts, _balance, ref derivation) = dev_accounts; // Generate the dev account public keys. #[cfg(feature = "runtime-benchmarks")] diff --git a/substrate/frame/transaction-storage/src/mock.rs b/substrate/frame/transaction-storage/src/mock.rs index 6df6692e71ad..1eee1de6ecac 100644 --- a/substrate/frame/transaction-storage/src/mock.rs +++ b/substrate/frame/transaction-storage/src/mock.rs @@ -68,7 +68,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { system: Default::default(), balances: pallet_balances::GenesisConfig:: { balances: vec![(1, 1000000000), (2, 100), (3, 100), (4, 100)], - ..Defualt::default() + ..Default::default() }, transaction_storage: pallet_transaction_storage::GenesisConfig:: { storage_period: 10, diff --git a/substrate/frame/treasury/src/tests.rs b/substrate/frame/treasury/src/tests.rs index 4a0e99528b04..6f9f3dc68af2 100644 --- a/substrate/frame/treasury/src/tests.rs +++ b/substrate/frame/treasury/src/tests.rs @@ -221,7 +221,7 @@ impl ExtBuilder { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized at ED. balances: vec![(0, 100), (1, 98), (2, 1)], - ..Defualt::default() + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); @@ -407,7 +407,7 @@ fn treasury_account_doesnt_get_deleted() { #[test] fn inexistent_account_works() { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], ..Defualt::default() } + pallet_balances::GenesisConfig:: { balances: vec![(0, 100), (1, 99), (2, 1)], ..Default::default() } .assimilate_storage(&mut t) .unwrap(); // Treasury genesis config is not build thus treasury account does not exist @@ -446,7 +446,7 @@ fn genesis_funding_works() { pallet_balances::GenesisConfig:: { // Total issuance will be 200 with treasury account initialized with 100. balances: vec![(0, 100), (Treasury::account_id(), initial_funding)], - ..Defualt::default() + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/tx-pause/src/mock.rs b/substrate/frame/tx-pause/src/mock.rs index 11ed9afd6f33..09294645db0b 100644 --- a/substrate/frame/tx-pause/src/mock.rs +++ b/substrate/frame/tx-pause/src/mock.rs @@ -156,7 +156,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { pallet_balances::GenesisConfig:: { // The 0 account is NOT a special origin. The rest may be: balances: vec![(0, 1234), (1, 5678), (2, 5678), (3, 5678), (4, 5678)], - ..Defualt::defualt() + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/utility/src/tests.rs b/substrate/frame/utility/src/tests.rs index 8add1733b396..d075ec1ff82e 100644 --- a/substrate/frame/utility/src/tests.rs +++ b/substrate/frame/utility/src/tests.rs @@ -237,7 +237,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { balances: vec![(1, 10), (2, 10), (3, 10), (4, 10), (5, 2)], - ..Defualt::default() + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/vesting/src/mock.rs b/substrate/frame/vesting/src/mock.rs index 9adab76e30c8..8fae9bbf7497 100644 --- a/substrate/frame/vesting/src/mock.rs +++ b/substrate/frame/vesting/src/mock.rs @@ -94,7 +94,7 @@ impl ExtBuilder { (12, 10 * self.existential_deposit), (13, 9999 * self.existential_deposit), ], - ..Defualt::default() + ..Default::default() } .assimilate_storage(&mut t) .unwrap();