diff --git a/prdoc/pr_6267.prdoc b/prdoc/pr_6267.prdoc new file mode 100644 index 000000000000..c218e2a5093b --- /dev/null +++ b/prdoc/pr_6267.prdoc @@ -0,0 +1,135 @@ +# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0 +# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json + +title: Allow configurable number of genesis accounts with specified balances for benchmarking. + +doc: + - audience: Runtime Dev + description: | + This pull request adds an additional field `dev_accounts` to the `GenesisConfig` + of the balances pallet, feature gated by `runtime-benchmarks`. + + Bringing about an abitrary number of derived dev accounts when building the genesis + state. Runtime developers should supply a derivation path that includes an index placeholder + (i.e. "//Sender/{}") to generate multiple accounts from the same root in a consistent + manner. + +crates: + - name: substrate-test-runtime + bump: minor + - name: pallet-vesting + bump: minor + - name: pallet-utility + bump: minor + - name: pallet-tx-pause + bump: minor + - name: pallet-treasury + bump: minor + - name: pallet-transaction-storage + bump: minor + - name: pallet-transaction-payment + bump: minor + - name: pallet-asset-conversion-tx-payment + bump: minor + - name: pallet-asset-tx-payment + bump: minor + - name: pallet-tips + bump: minor + - name: pallet-state-trie-migration + bump: minor + - name: pallet-staking + bump: minor + - name: pallet-society + bump: minor + - name: pallet-safe-mode + bump: minor + - name: pallet-root-offences + bump: minor + - name: pallet-revive + bump: minor + - name: pallet-revive-mock-network + bump: minor + - name: pallet-referenda + bump: minor + - name: pallet-recovery + bump: minor + - name: pallet-proxy + bump: minor + - name: pallet-preimage + bump: minor + - name: pallet-nis + bump: minor + - name: pallet-multisig + bump: minor + - name: pallet-lottery + bump: minor + - name: pallet-indices + bump: minor + - name: pallet-identity + bump: minor + - name: pallet-grandpa + bump: minor + - name: pallet-fast-unstake + bump: minor + - name: pallet-elections-phragmen + bump: minor + - name: pallet-election-provider-multi-phase + bump: minor + - name: pallet-democracy + bump: minor + - name: pallet-delegated-staking + bump: minor + - name: pallet-conviction-voting + bump: minor + - name: pallet-contracts + bump: minor + - name: pallet-contracts-mock-network + bump: minor + - name: pallet-collective + bump: minor + - name: pallet-child-bounties + bump: minor + - name: pallet-bounties + bump: minor + - name: pallet-balances + bump: minor + - name: pallet-babe + bump: minor + - name: pallet-asset-conversion + bump: minor + - name: pallet-alliance + bump: minor + - name: node-testing + bump: minor + - name: xcm-simulator-fuzzer + bump: minor + - name: xcm-simulator-example + bump: minor + - name: xcm-runtime-apis + bump: minor + - name: staging-xcm-builder + bump: minor + - name: pallet-xcm + bump: minor + - name: westend-runtime + bump: minor + - name: rococo-runtime + bump: minor + - name: polkadot-runtime-common + bump: minor + - name: parachains-runtimes-test-utils + bump: minor + - name: collectives-westend-runtime + bump: minor + - name: bridge-hub-westend-runtime + bump: minor + - name: bridge-hub-rococo-runtime + bump: minor + - name: asset-hub-westend-runtime + bump: minor + - name: asset-hub-rococo-runtime + bump: minor + - name: pallet-collator-selection + bump: minor + - name: pallet-bridge-messages + bump: minor diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 26154ae66793..c79ea186487a 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -183,6 +183,7 @@ use sp_runtime::{ #[cfg(feature = "runtime-benchmarks")] use sp_core::{sr25519::Pair as SrPair, Pair}; +use alloc::{format, string::{String, ToString}}; pub use types::{ AccountData, AdjustmentDirection, BalanceLock, DustCleaner, ExtraFlags, Reasons, ReserveData, @@ -1288,6 +1289,11 @@ pub mod pallet { "the balance of any account should always be at least the existential deposit.", ); + assert!( + derivation.contains("{}"), + "Invalid derivation string" + ); + for index in 0..num_accounts { // Replace "{}" in the derivation string with the index. let derivation_string = derivation.replace("{}", &index.to_string()); @@ -1298,10 +1304,10 @@ pub mod pallet { // Convert the public key to AccountId. let who = T::AccountId::decode(&mut &pair.public().encode()[..]) - .expect(&format!("Failed to decode public key from pair: {}", pair.public())); + .expect(&format!("Failed to decode public key from pair: {:?}", pair.public())); frame_system::Pallet::::inc_providers(&who); - // Insert the account into the store and ensure it succeeds. + // Insert the account into the store and ensure it succeeds(uri). assert!(T::AccountStore::insert( &who, AccountData { free: balance, ..Default::default() } diff --git a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs index 6ce4652fd42f..76d46aa16471 100644 --- a/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/asset-conversion-tx-payment/src/tests.rs @@ -86,6 +86,7 @@ impl ExtBuilder { } else { vec![] }, + ..Default::default() } .assimilate_storage(&mut t) .unwrap(); diff --git a/substrate/frame/transaction-payment/src/tests.rs b/substrate/frame/transaction-payment/src/tests.rs index 572c1d4961dd..1132aa4cf84a 100644 --- a/substrate/frame/transaction-payment/src/tests.rs +++ b/substrate/frame/transaction-payment/src/tests.rs @@ -99,6 +99,7 @@ impl ExtBuilder { } else { vec![] }, + ..Default::default() } .assimilate_storage(&mut t) .unwrap();