Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AHM] Poke deposits: Indices pallet #7587

Merged
merged 31 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cea198b
add reconsider deposit extrinsic for pallet-indices
UtkarshBhardwaj007 Feb 14, 2025
0ebd596
Merge branch 'paritytech:master' into poke-deposits
UtkarshBhardwaj007 Feb 14, 2025
9675694
Merge branch 'paritytech:master' into poke-deposits
UtkarshBhardwaj007 Feb 16, 2025
045dd00
add benchmark
UtkarshBhardwaj007 Feb 16, 2025
99e4644
Update from UtkarshBhardwaj007 running command 'prdoc'
github-actions[bot] Feb 17, 2025
2e5cd44
add prdoc
UtkarshBhardwaj007 Feb 17, 2025
9334502
exit early in reconsider if deposit is unchanged
UtkarshBhardwaj007 Feb 17, 2025
ce8ac6f
Merge branch 'paritytech:master' into poke-deposits
UtkarshBhardwaj007 Feb 17, 2025
2db6c3a
fix reconsider benchmark
UtkarshBhardwaj007 Feb 17, 2025
6a6c013
Merge branch 'paritytech:master' into poke-deposits
UtkarshBhardwaj007 Feb 17, 2025
b7f2345
add dummy weights to allow benchmarking to run in CI
UtkarshBhardwaj007 Feb 17, 2025
3aa10dd
add dummy weights to allow benchmarking to run in CI
UtkarshBhardwaj007 Feb 17, 2025
0495c20
Update from UtkarshBhardwaj007 running command 'bench --pallet pallet…
github-actions[bot] Feb 17, 2025
634b981
revert benching xcm pallets
UtkarshBhardwaj007 Feb 18, 2025
a3f95b4
Update from UtkarshBhardwaj007 running command 'fmt'
github-actions[bot] Feb 18, 2025
b81f6a8
Revert changes in pallet_xcm_benchmarks_generic.rs
UtkarshBhardwaj007 Feb 18, 2025
8b059d2
delete prdoc to allow CI cmd bot to create new prdoc
UtkarshBhardwaj007 Feb 18, 2025
b7de8d2
Update from UtkarshBhardwaj007 running command 'prdoc'
github-actions[bot] Feb 18, 2025
0975fe7
update prdoc
UtkarshBhardwaj007 Feb 18, 2025
b07bd14
address comments
UtkarshBhardwaj007 Feb 18, 2025
423cdf2
Update from UtkarshBhardwaj007 running command 'fmt'
github-actions[bot] Feb 18, 2025
b8f22a0
Update from UtkarshBhardwaj007 running command 'bench --pallet pallet…
github-actions[bot] Feb 18, 2025
4e5a611
minor fixes
UtkarshBhardwaj007 Feb 18, 2025
b4e52f9
add defensive logging
UtkarshBhardwaj007 Feb 19, 2025
acc67ef
change extrinsic name to poke_deposit
UtkarshBhardwaj007 Feb 19, 2025
65d2291
Update from UtkarshBhardwaj007 running command 'fmt'
github-actions[bot] Feb 19, 2025
9a890f6
Merge branch 'paritytech:master' into poke-deposits
UtkarshBhardwaj007 Feb 19, 2025
d9e94a9
minor: fix defensive logging
UtkarshBhardwaj007 Feb 19, 2025
325bc14
Update from UtkarshBhardwaj007 running command 'fmt'
github-actions[bot] Feb 19, 2025
d07362f
reserve additional funds in poke_deposit benchmark
UtkarshBhardwaj007 Feb 19, 2025
7abe8c8
Update from UtkarshBhardwaj007 running command 'bench --pallet pallet…
github-actions[bot] Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions polkadot/runtime/rococo/src/weights/pallet_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,28 @@
//! Autogenerated weights for `pallet_indices`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2025-02-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("rococo-dev")`, DB CACHE: 1024
//! HOSTNAME: `52baa5cae416`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
// ./target/production/polkadot
// frame-omni-bencher
// v1
// benchmark
// pallet
// --chain=rococo-dev
// --extrinsic=*
// --runtime=target/production/wbuild/rococo-runtime/rococo_runtime.wasm
// --pallet=pallet_indices
// --header=/__w/polkadot-sdk/polkadot-sdk/polkadot/file_header.txt
// --output=./polkadot/runtime/rococo/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_indices
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --header=./polkadot/file_header.txt
// --output=./polkadot/runtime/rococo/src/weights/
// --no-median-slopes

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -56,8 +57,8 @@ impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3534`
// Minimum execution time: 18_092_000 picoseconds.
Weight::from_parts(18_533_000, 0)
// Minimum execution time: 22_250_000 picoseconds.
Weight::from_parts(23_442_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -70,8 +71,8 @@ impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 31_616_000 picoseconds.
Weight::from_parts(32_556_000, 0)
// Minimum execution time: 35_315_000 picoseconds.
Weight::from_parts(37_456_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -82,8 +83,8 @@ impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 19_593_000 picoseconds.
Weight::from_parts(20_100_000, 0)
// Minimum execution time: 23_413_000 picoseconds.
Weight::from_parts(24_307_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand All @@ -96,8 +97,8 @@ impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 21_429_000 picoseconds.
Weight::from_parts(22_146_000, 0)
// Minimum execution time: 25_799_000 picoseconds.
Weight::from_parts(26_614_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
Expand All @@ -108,8 +109,20 @@ impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 20_425_000 picoseconds.
Weight::from_parts(21_023_000, 0)
// Minimum execution time: 26_905_000 picoseconds.
Weight::from_parts(27_574_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn poke_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 23_596_000 picoseconds.
Weight::from_parts(24_227_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down
97 changes: 55 additions & 42 deletions polkadot/runtime/westend/src/weights/pallet_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@

//! Autogenerated weights for `pallet_indices`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-06-14, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner--ss9ysm1-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("westend-dev"), DB CACHE: 1024
//! HOSTNAME: `52baa5cae416`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: 1024

// Executed Command:
// ./target/production/polkadot
// frame-omni-bencher
// v1
// benchmark
// pallet
// --chain=westend-dev
// --extrinsic=*
// --runtime=target/production/wbuild/westend-runtime/westend_runtime.wasm
// --pallet=pallet_indices
// --header=/__w/polkadot-sdk/polkadot-sdk/polkadot/file_header.txt
// --output=./polkadot/runtime/westend/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_indices
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --header=./file_header.txt
// --output=./runtime/westend/src/weights/
// --no-median-slopes

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand All @@ -50,66 +51,78 @@ use core::marker::PhantomData;
/// Weight functions for `pallet_indices`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
/// Storage: Indices Accounts (r:1 w:1)
/// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen)
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn claim() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Measured: `4`
// Estimated: `3534`
// Minimum execution time: 24_553_000 picoseconds.
Weight::from_parts(25_288_000, 0)
// Minimum execution time: 25_952_000 picoseconds.
Weight::from_parts(27_224_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Indices Accounts (r:1 w:1)
/// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 35_932_000 picoseconds.
Weight::from_parts(36_801_000, 0)
// Minimum execution time: 38_643_000 picoseconds.
Weight::from_parts(39_612_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Indices Accounts (r:1 w:1)
/// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen)
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn free() -> Weight {
// Proof Size summary in bytes:
// Measured: `238`
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 25_574_000 picoseconds.
Weight::from_parts(26_123_000, 0)
// Minimum execution time: 26_744_000 picoseconds.
Weight::from_parts(28_195_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Indices Accounts (r:1 w:1)
/// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen)
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 27_605_000 picoseconds.
Weight::from_parts(28_569_000, 0)
// Minimum execution time: 29_213_000 picoseconds.
Weight::from_parts(30_369_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: Indices Accounts (r:1 w:1)
/// Proof: Indices Accounts (max_values: None, max_size: Some(69), added: 2544, mode: MaxEncodedLen)
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn freeze() -> Weight {
// Proof Size summary in bytes:
// Measured: `238`
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 30_370_000 picoseconds.
Weight::from_parts(31_164_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn poke_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 27_447_000 picoseconds.
Weight::from_parts(28_136_000, 0)
// Minimum execution time: 27_134_000 picoseconds.
Weight::from_parts(28_175_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
Expand Down
11 changes: 11 additions & 0 deletions prdoc/pr_7587.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: '[AHM] Poke deposits: Indices pallet'
doc:
- audience: Runtime Dev
description: Add a new extrinsic `poke_deposit` to `pallet-indices`. This extrinsic will be used to re-adjust the deposits made in the pallet after Asset Hub Migration.
crates:
- name: pallet-indices
bump: major
- name: rococo-runtime
bump: major
- name: westend-runtime
bump: major
54 changes: 54 additions & 0 deletions substrate/frame/indices/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

use crate::*;
use frame_benchmarking::v2::*;
use frame_support::traits::Get;
use frame_system::RawOrigin;
use sp_runtime::traits::Bounded;

Expand Down Expand Up @@ -112,6 +113,59 @@ mod benchmarks {
Ok(())
}

#[benchmark]
fn poke_deposit() -> Result<(), BenchmarkError> {
let account_index = T::AccountIndex::from(SEED);
// Setup accounts
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());

let original_deposit = T::Deposit::get();

// Claim the index
Pallet::<T>::claim(RawOrigin::Signed(caller.clone()).into(), account_index)?;

// Verify the initial deposit amount in storage and reserved balance
assert_eq!(Accounts::<T>::get(account_index).unwrap().1, original_deposit);
assert_eq!(T::Currency::reserved_balance(&caller), original_deposit);

// The additional amount we'll add to the deposit for the index
let additional_amount = 2u32.into();

// Reserve the additional amount from the caller's balance
T::Currency::reserve(&caller, additional_amount)?;

// Verify the additional amount was reserved
assert_eq!(
T::Currency::reserved_balance(&caller),
original_deposit.saturating_add(additional_amount)
);

// Increase the deposited amount in storage by additional_amount
Accounts::<T>::try_mutate(account_index, |maybe_value| -> Result<(), BenchmarkError> {
let (account, amount, perm) = maybe_value
.take()
.ok_or(BenchmarkError::Stop("Mutating storage to change deposits failed"))?;
*maybe_value = Some((account, amount.saturating_add(additional_amount), perm));
Ok(())
})?;

// Verify the deposit was increased by additional_amount
assert_eq!(
Accounts::<T>::get(account_index).unwrap().1,
original_deposit.saturating_add(additional_amount)
);

#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), account_index);

assert!(Accounts::<T>::contains_key(account_index));
assert_eq!(Accounts::<T>::get(account_index).unwrap().0, caller);
assert_eq!(Accounts::<T>::get(account_index).unwrap().1, original_deposit);
assert_eq!(T::Currency::reserved_balance(&caller), original_deposit);
Ok(())
}

// TODO in another PR: lookup and unlookup trait weights (not critical)

impl_benchmark_test_suite!(Pallet, mock::new_test_ext(), mock::Test);
Expand Down
Loading
Loading