mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 02:01:02 +00:00
Benchmark Transfer PoV Size with Increasing Numbers of Users (#8571)
* write benchmark for transfer increasing users * cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_balances --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/balances/src/weights.rs --template=./.maintain/frame-weight-template.hbs Co-authored-by: Parity Benchmarking Bot <admin@parity.io>
This commit is contained in:
@@ -143,6 +143,39 @@ benchmarks_instance_pallet! {
|
||||
assert_eq!(Balances::<T, I>::free_balance(&source), Zero::zero());
|
||||
assert_eq!(Balances::<T, I>::free_balance(&recipient), transfer_amount);
|
||||
}
|
||||
|
||||
// This benchmark performs the same operation as `transfer` in the worst case scenario,
|
||||
// but additionally introduces many new users into the storage, increasing the the merkle
|
||||
// trie and PoV size.
|
||||
#[extra]
|
||||
transfer_increasing_users {
|
||||
// 1_000 is not very much, but this upper bound can be controlled by the CLI.
|
||||
let u in 0 .. 1_000;
|
||||
let existential_deposit = T::ExistentialDeposit::get();
|
||||
let caller = whitelisted_caller();
|
||||
|
||||
// Give some multiple of the existential deposit + creation fee + transfer fee
|
||||
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
|
||||
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, balance);
|
||||
|
||||
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
|
||||
// and reap this user.
|
||||
let recipient: T::AccountId = account("recipient", 0, SEED);
|
||||
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
|
||||
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
|
||||
|
||||
// Create a bunch of users in storage.
|
||||
for i in 0 .. u {
|
||||
// The `account` function uses `blake2_256` to generate unique accounts, so these
|
||||
// should be quite random and evenly distributed in the trie.
|
||||
let new_user: T::AccountId = account("new_user", i, SEED);
|
||||
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&new_user, balance);
|
||||
}
|
||||
}: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount)
|
||||
verify {
|
||||
assert_eq!(Balances::<T, I>::free_balance(&caller), Zero::zero());
|
||||
assert_eq!(Balances::<T, I>::free_balance(&recipient), transfer_amount);
|
||||
}
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
|
||||
Reference in New Issue
Block a user