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

chore: bump weights for 1020 #1533

Merged
merged 4 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions pallets/transfer-allowlist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub mod weights;

pub use cfg_traits::TransferAllowance;
pub use pallet::*;
pub use weights::Weights;
pub use weights::WeightInfo;

#[frame_support::pallet]
pub mod pallet {
Expand Down Expand Up @@ -116,7 +116,7 @@ pub mod pallet {
+ MaxEncodedLen;

/// Type for pallet weights
type Weights: Weights;
type WeightInfo: WeightInfo;
}

//
Expand Down Expand Up @@ -324,7 +324,7 @@ pub mod pallet {
/// Running this for an existing allowance generates a new allowance
/// based on the current delay, or lack thereof
#[pallet::call_index(0)]
#[pallet::weight(T::Weights::add_transfer_allowance_no_existing_metadata().max(T::Weights::add_transfer_allowance_existing_metadata()))]
#[pallet::weight(T::WeightInfo::add_transfer_allowance_no_existing_metadata().max(T::WeightInfo::add_transfer_allowance_existing_metadata()))]
pub fn add_transfer_allowance(
origin: OriginFor<T>,
currency_id: T::CurrencyId,
Expand Down Expand Up @@ -377,7 +377,7 @@ pub mod pallet {
/// - either the current block + delay if a delay is set
/// - or the current block if no delay is set
#[pallet::call_index(1)]
#[pallet::weight(T::Weights::remove_transfer_allowance_missing_allowance().max(T::Weights::remove_transfer_allowance_delay_present()))]
#[pallet::weight(T::WeightInfo::remove_transfer_allowance_missing_allowance().max(T::WeightInfo::remove_transfer_allowance_delay_present()))]
pub fn remove_transfer_allowance(
origin: OriginFor<T>,
currency_id: T::CurrencyId,
Expand Down Expand Up @@ -423,7 +423,7 @@ pub mod pallet {
/// receiving location Decrements or removes the sending
/// account/currency count.
#[pallet::call_index(2)]
#[pallet::weight(T::Weights::purge_transfer_allowance_no_remaining_metadata().max(T::Weights::purge_allowance_delay_remaining_metadata()))]
#[pallet::weight(T::WeightInfo::purge_transfer_allowance_no_remaining_metadata().max(T::WeightInfo::purge_allowance_delay_remaining_metadata()))]
pub fn purge_transfer_allowance(
origin: OriginFor<T>,
currency_id: T::CurrencyId,
Expand Down Expand Up @@ -457,7 +457,7 @@ pub mod pallet {
}

#[pallet::call_index(3)]
#[pallet::weight(T::Weights::add_allowance_delay_existing_metadata().max(T::Weights::add_allowance_delay_no_existing_metadata()))]
#[pallet::weight(T::WeightInfo::add_allowance_delay_existing_metadata().max(T::WeightInfo::add_allowance_delay_no_existing_metadata()))]
/// Adds an account/currency delay
/// Calling on an account/currency with an existing delay will fail.
/// To update a delay the delay has to be set to future modifiable.
Expand Down Expand Up @@ -502,7 +502,7 @@ pub mod pallet {
}

#[pallet::call_index(4)]
#[pallet::weight(T::Weights::update_allowance_delay())]
#[pallet::weight(T::WeightInfo::update_allowance_delay())]
/// Updates an allowance delay, only callable if the delay has been set
/// to allow future modifications and the delay modifiable_at block has
/// been passed.
Expand Down Expand Up @@ -550,7 +550,7 @@ pub mod pallet {
}

#[pallet::call_index(5)]
#[pallet::weight(T::Weights::toggle_allowance_delay_once_future_modifiable())]
#[pallet::weight(T::WeightInfo::toggle_allowance_delay_once_future_modifiable())]
/// This allows the delay value to be modified after the current delay
/// has passed since the current block Or sets the delay value to be not
/// modifiable iff modifiable at has already passed
Expand Down Expand Up @@ -602,7 +602,7 @@ pub mod pallet {
}

#[pallet::call_index(6)]
#[pallet::weight(T::Weights::purge_allowance_delay_remaining_metadata().max(T::Weights::purge_allowance_delay_no_remaining_metadata()))]
#[pallet::weight(T::WeightInfo::purge_allowance_delay_remaining_metadata().max(T::WeightInfo::purge_allowance_delay_no_remaining_metadata()))]
/// Removes an existing sending account/currency delay
pub fn purge_allowance_delay(
origin: OriginFor<T>,
Expand Down
2 changes: 1 addition & 1 deletion pallets/transfer-allowlist/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl transfer_allowlist::Config for Runtime {
type Location = Location;
type ReserveCurrency = Balances;
type RuntimeEvent = RuntimeEvent;
type Weights = ();
type WeightInfo = ();
}

pub fn new_test_ext() -> sp_io::TestExternalities {
Expand Down
230 changes: 214 additions & 16 deletions pallets/transfer-allowlist/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

pub use frame_support::weights::Weight;
#![allow(unused_parens)]
#![allow(unused_imports)]

pub trait Weights {
use frame_support::{
traits::Get,
weights::{constants::RocksDbWeight, Weight},
};
use sp_std::marker::PhantomData;

pub trait WeightInfo {
fn add_transfer_allowance_no_existing_metadata() -> Weight;
fn add_transfer_allowance_existing_metadata() -> Weight;
fn add_allowance_delay_no_existing_metadata() -> Weight;
Expand All @@ -28,56 +35,247 @@ pub trait Weights {
fn purge_transfer_allowance_remaining_metadata() -> Weight;
}

impl Weights for () {
/// Weights for pallet_transfer_allowlist using the Substrate node and
/// recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
fn add_transfer_allowance_no_existing_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 40_000 nanoseconds.
Weight::from_ref_time(41_000_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
fn add_transfer_allowance_existing_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(43_000_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn add_allowance_delay_no_existing_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 18_000 nanoseconds.
Weight::from_ref_time(18_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn add_allowance_delay_existing_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 19_000 nanoseconds.
Weight::from_ref_time(20_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn toggle_allowance_delay_once_future_modifiable() -> Weight {
Weight::zero()
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(20_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn update_allowance_delay() -> Weight {
Weight::zero()
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_allowance_delay_no_remaining_metadata() -> Weight {
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_allowance_delay_remaining_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_missing_allowance() -> Weight {
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_delay_present() -> Weight {
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_no_delay() -> Weight {
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_transfer_allowance_no_remaining_metadata() -> Weight {
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(43_000_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_transfer_allowance_remaining_metadata() -> Weight {
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(44_000_000)
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
}

impl WeightInfo for () {
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
fn add_transfer_allowance_no_existing_metadata() -> Weight {
// Minimum execution time: 40_000 nanoseconds.
Weight::from_ref_time(41_000_000)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
fn add_transfer_allowance_existing_metadata() -> Weight {
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(43_000_000)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn add_allowance_delay_no_existing_metadata() -> Weight {
// Minimum execution time: 18_000 nanoseconds.
Weight::from_ref_time(18_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn add_allowance_delay_existing_metadata() -> Weight {
// Minimum execution time: 19_000 nanoseconds.
Weight::from_ref_time(20_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn toggle_allowance_delay_once_future_modifiable() -> Weight {
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(20_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn update_allowance_delay() -> Weight {
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_allowance_delay_no_remaining_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_allowance_delay_remaining_metadata() -> Weight {
// Minimum execution time: 20_000 nanoseconds.
Weight::from_ref_time(21_000_000)
.saturating_add(RocksDbWeight::get().reads(1))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_missing_allowance() -> Weight {
Weight::zero()
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_delay_present() -> Weight {
Weight::zero()
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:0)
// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
fn remove_transfer_allowance_no_delay() -> Weight {
Weight::zero()
// Minimum execution time: 26_000 nanoseconds.
Weight::from_ref_time(27_000_000)
.saturating_add(RocksDbWeight::get().reads(2))
.saturating_add(RocksDbWeight::get().writes(1))
}

// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_transfer_allowance_no_remaining_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(43_000_000)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}

// Storage: TransferAllowList AccountCurrencyTransferAllowance (r:1 w:1)
// Storage: Fees FeeBalances (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: TransferAllowList AccountCurrencyTransferCountDelay (r:1 w:1)
fn purge_transfer_allowance_remaining_metadata() -> Weight {
Weight::zero()
// Minimum execution time: 43_000 nanoseconds.
Weight::from_ref_time(44_000_000)
.saturating_add(RocksDbWeight::get().reads(4))
.saturating_add(RocksDbWeight::get().writes(3))
}
}
Loading