mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 20:01:03 +00:00
Weights to u64 + Balances Weights (#5446)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -133,6 +133,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use frame_support::{Parameter, decl_module, decl_event, decl_storage, decl_error, ensure};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use sp_runtime::traits::{Member, AtLeast32Bit, Zero, StaticLookup};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use sp_runtime::traits::One;
|
||||
@@ -157,7 +158,7 @@ decl_module! {
|
||||
/// Issue a new class of fungible assets. There are, and will only ever be, `total`
|
||||
/// such assets and they'll all belong to the `origin` initially. It will have an
|
||||
/// identifier `AssetId` instance: this will be specified in the `Issued` event.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn issue(origin, #[compact] total: T::Balance) {
|
||||
let origin = ensure_signed(origin)?;
|
||||
|
||||
@@ -171,7 +172,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Move some assets from one holder to another.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn transfer(origin,
|
||||
#[compact] id: T::AssetId,
|
||||
target: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -190,7 +191,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Destroy any assets of `id` owned by `origin`.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn destroy(origin, #[compact] id: T::AssetId) {
|
||||
let origin = ensure_signed(origin)?;
|
||||
let balance = <Balances<T>>::take((id, &origin));
|
||||
@@ -292,6 +293,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -57,6 +57,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -154,6 +154,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -27,7 +27,7 @@ use frame_support::traits::{FindAuthor, VerifySeal, Get};
|
||||
use codec::{Encode, Decode};
|
||||
use frame_system::ensure_none;
|
||||
use sp_runtime::traits::{Header as HeaderT, One, Zero};
|
||||
use frame_support::weights::{Weight, SimpleDispatchInfo, WeighData};
|
||||
use frame_support::weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo};
|
||||
use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData};
|
||||
use sp_authorship::{INHERENT_IDENTIFIER, UnclesInherentData, InherentError};
|
||||
|
||||
@@ -197,7 +197,7 @@ decl_module! {
|
||||
|
||||
T::EventHandler::note_author(Self::author());
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
fn on_finalize() {
|
||||
@@ -207,7 +207,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Provide a set of uncles.
|
||||
#[weight = SimpleDispatchInfo::FixedMandatory(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedMandatory(MINIMUM_WEIGHT)]
|
||||
fn set_uncles(origin, new_uncles: Vec<T::Header>) -> dispatch::DispatchResult {
|
||||
ensure_none(origin)?;
|
||||
ensure!(new_uncles.len() <= MAX_UNCLES, Error::<T>::TooManyUncles);
|
||||
@@ -429,6 +429,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -25,7 +25,7 @@ use pallet_timestamp;
|
||||
use sp_std::{result, prelude::*};
|
||||
use frame_support::{
|
||||
decl_storage, decl_module, traits::{FindAuthor, Get, Randomness as RandomnessT},
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData},
|
||||
weights::{Weight, MINIMUM_WEIGHT},
|
||||
};
|
||||
use sp_timestamp::OnTimestampSet;
|
||||
use sp_runtime::{generic::DigestItem, ConsensusEngineId, Perbill};
|
||||
@@ -184,7 +184,7 @@ decl_module! {
|
||||
fn on_initialize(now: T::BlockNumber) -> Weight {
|
||||
Self::do_initialize(now);
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
/// Block finalization
|
||||
|
||||
@@ -68,6 +68,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type ModuleToIndex = ();
|
||||
|
||||
@@ -159,7 +159,7 @@ use sp_std::{cmp, result, mem, fmt::Debug, ops::BitOr, convert::Infallible};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use frame_support::{
|
||||
StorageValue, Parameter, decl_event, decl_storage, decl_module, decl_error, ensure,
|
||||
weights::SimpleDispatchInfo, traits::{
|
||||
traits::{
|
||||
Currency, OnKilledAccount, OnUnbalanced, TryDrop, StoredMap,
|
||||
WithdrawReason, WithdrawReasons, LockIdentifier, LockableCurrency, ExistenceRequirement,
|
||||
Imbalance, SignedImbalance, ReservableCurrency, Get, ExistenceRequirement::KeepAlive,
|
||||
@@ -433,7 +433,7 @@ decl_module! {
|
||||
/// check that the transfer will not kill the origin account.
|
||||
///
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
#[weight = T::DbWeight::get().reads_writes(1, 1) + 200_000_000]
|
||||
pub fn transfer(
|
||||
origin,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -457,7 +457,7 @@ decl_module! {
|
||||
/// - Independent of the arguments.
|
||||
/// - Contains a limited number of reads and writes.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(50_000)]
|
||||
#[weight = T::DbWeight::get().reads_writes(1, 1) + 100_000_000]
|
||||
fn set_balance(
|
||||
origin,
|
||||
who: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -495,7 +495,11 @@ decl_module! {
|
||||
|
||||
/// Exactly as `transfer`, except the origin must be root and the source account may be
|
||||
/// specified.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
/// # <weight>
|
||||
/// - Same as transfer, but additional read and write because the source account is
|
||||
/// not assumed to be in the overlay.
|
||||
/// # </weight>
|
||||
#[weight = T::DbWeight::get().reads_writes(2, 2) + 200_000_000]
|
||||
pub fn force_transfer(
|
||||
origin,
|
||||
source: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -514,7 +518,7 @@ decl_module! {
|
||||
/// 99% of the time you want [`transfer`] instead.
|
||||
///
|
||||
/// [`transfer`]: struct.Module.html#method.transfer
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
#[weight = T::DbWeight::get().reads_writes(1, 1) + 150_000_000]
|
||||
pub fn transfer_keep_alive(
|
||||
origin,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -842,6 +846,7 @@ impl<T: Subtrait<I>, I: Instance> frame_system::Trait for ElevatedTrait<T, I> {
|
||||
type Event = ();
|
||||
type BlockHashCount = T::BlockHashCount;
|
||||
type MaximumBlockWeight = T::MaximumBlockWeight;
|
||||
type DbWeight = T::DbWeight;
|
||||
type MaximumBlockLength = T::MaximumBlockLength;
|
||||
type AvailableBlockRatio = T::AvailableBlockRatio;
|
||||
type Version = T::Version;
|
||||
|
||||
@@ -36,7 +36,7 @@ macro_rules! decl_tests {
|
||||
($test:ty, $ext_builder:ty, $existential_deposit:expr) => {
|
||||
|
||||
use crate::*;
|
||||
use sp_runtime::{Fixed64, traits::{SignedExtension, BadOrigin}};
|
||||
use sp_runtime::{Fixed128, traits::{SignedExtension, BadOrigin}};
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, assert_err,
|
||||
traits::{
|
||||
@@ -153,7 +153,7 @@ macro_rules! decl_tests {
|
||||
.monied(true)
|
||||
.build()
|
||||
.execute_with(|| {
|
||||
pallet_transaction_payment::NextFeeMultiplier::put(Fixed64::from_natural(1));
|
||||
pallet_transaction_payment::NextFeeMultiplier::put(Fixed128::from_natural(1));
|
||||
Balances::set_lock(ID_1, &1, 10, WithdrawReason::Reserve.into());
|
||||
assert_noop!(
|
||||
<Balances as Currency<_>>::transfer(&1, &2, 1, AllowDeath),
|
||||
|
||||
@@ -67,6 +67,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -67,6 +67,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use frame_support::{decl_module, decl_storage, decl_event, decl_error};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use frame_support::traits::Currency;
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use codec::{Encode, Decode};
|
||||
@@ -70,7 +71,7 @@ decl_module! {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Do nothing.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn do_nothing(_origin, input: u32) {
|
||||
if input > 0 {
|
||||
return Ok(());
|
||||
@@ -82,7 +83,7 @@ decl_module! {
|
||||
/// storage database, however, the `repeat` calls will all pull from the
|
||||
/// storage overlay cache. You must consider this when analyzing the
|
||||
/// results of the benchmark.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn read_value(_origin, repeat: u32) {
|
||||
for _ in 0..repeat {
|
||||
MyValue::get();
|
||||
@@ -90,7 +91,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Put a value into a storage value.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn put_value(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyValue::put(r);
|
||||
@@ -102,7 +103,7 @@ decl_module! {
|
||||
/// storage database, however, the `repeat` calls will all pull from the
|
||||
/// storage overlay cache. You must consider this when analyzing the
|
||||
/// results of the benchmark.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn exists_value(_origin, repeat: u32) {
|
||||
for _ in 0..repeat {
|
||||
MyValue::exists();
|
||||
@@ -110,7 +111,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Remove a value from storage `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn remove_value(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::remove(r);
|
||||
@@ -118,7 +119,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Read a value from storage map `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn read_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::get(r);
|
||||
@@ -126,7 +127,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Insert a value into a map.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn insert_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::insert(r, r);
|
||||
@@ -134,7 +135,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Check is a map contains a value `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn contains_key_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::contains_key(r);
|
||||
@@ -142,7 +143,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Read a value from storage `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn remove_prefix(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyDoubleMap::remove_prefix(r);
|
||||
@@ -150,21 +151,21 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Add user to the list.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn add_member_list(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
MyMemberList::<T>::mutate(|x| x.push(who));
|
||||
}
|
||||
|
||||
/// Append user to the list.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn append_member_list(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
MyMemberList::<T>::append(&[who])?;
|
||||
}
|
||||
|
||||
/// Encode a vector of accounts to bytes.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn encode_accounts(_origin, accounts: Vec<T::AccountId>) {
|
||||
let bytes = accounts.encode();
|
||||
|
||||
@@ -176,7 +177,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Decode bytes into a vector of accounts.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn decode_accounts(_origin, bytes: Vec<u8>) {
|
||||
let accounts: Vec<T::AccountId> = Decode::decode(&mut bytes.as_slice()).map_err(|_| "Could not decode")?;
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ use codec::Decode;
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::{H256, Header}};
|
||||
use frame_support::{
|
||||
dispatch::DispatchResult, decl_module, decl_storage, impl_outer_origin,
|
||||
assert_ok, assert_err, ensure
|
||||
dispatch::DispatchResult,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
decl_module, decl_storage, impl_outer_origin, assert_ok, assert_err, ensure
|
||||
};
|
||||
use frame_system::{RawOrigin, ensure_signed, ensure_none};
|
||||
|
||||
@@ -36,14 +37,14 @@ decl_storage! {
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn set_value(origin, n: u32) -> DispatchResult {
|
||||
let _sender = ensure_signed(origin)?;
|
||||
Value::put(n);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn dummy(origin, _n: u32) -> DispatchResult {
|
||||
let _sender = ensure_none(origin)?;
|
||||
Ok(())
|
||||
@@ -78,6 +79,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = ();
|
||||
type MaximumBlockWeight = ();
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = ();
|
||||
type AvailableBlockRatio = ();
|
||||
type Version = ();
|
||||
|
||||
@@ -187,7 +187,7 @@ decl_module! {
|
||||
/// - `prime`: The prime member whose vote sets the default.
|
||||
///
|
||||
/// Requires root origin.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000_000)]
|
||||
fn set_members(origin, new_members: Vec<T::AccountId>, prime: Option<T::AccountId>) {
|
||||
ensure_root(origin)?;
|
||||
let mut new_members = new_members;
|
||||
@@ -200,7 +200,7 @@ decl_module! {
|
||||
/// Dispatch a proposal from a member using the `Member` origin.
|
||||
///
|
||||
/// Origin must be a member of the collective.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000_000)]
|
||||
fn execute(origin, proposal: Box<<T as Trait<I>>::Proposal>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(Self::is_member(&who), Error::<T, I>::NotMember);
|
||||
@@ -214,7 +214,7 @@ decl_module! {
|
||||
/// - Bounded storage reads and writes.
|
||||
/// - Argument `threshold` has bearing on weight.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(5_000_000_000)]
|
||||
fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<<T as Trait<I>>::Proposal>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(Self::is_member(&who), Error::<T, I>::NotMember);
|
||||
@@ -244,7 +244,7 @@ decl_module! {
|
||||
/// - Bounded storage read and writes.
|
||||
/// - Will be slightly heavier if the proposal is approved / disapproved after the vote.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
fn vote(origin, proposal: T::Hash, #[compact] index: ProposalIndex, approve: bool) {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(Self::is_member(&who), Error::<T, I>::NotMember);
|
||||
@@ -303,7 +303,7 @@ decl_module! {
|
||||
/// - `M` is number of members,
|
||||
/// - `P` is number of active proposals,
|
||||
/// - `L` is the encoded length of `proposal` preimage.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
fn close(origin, proposal: T::Hash, #[compact] index: ProposalIndex) {
|
||||
let _ = ensure_signed(origin)?;
|
||||
|
||||
@@ -553,6 +553,7 @@ mod tests {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -123,6 +123,7 @@ use sp_runtime::{
|
||||
RuntimeDebug,
|
||||
};
|
||||
use frame_support::dispatch::{DispatchResult, Dispatchable};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use frame_support::{
|
||||
Parameter, decl_module, decl_event, decl_storage, decl_error, storage::child,
|
||||
parameter_types, IsSubType,
|
||||
@@ -550,7 +551,7 @@ decl_module! {
|
||||
/// Updates the schedule for metering contracts.
|
||||
///
|
||||
/// The schedule must have a greater version than the stored schedule.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn update_schedule(origin, schedule: Schedule) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
if <Module<T>>::current_schedule().version >= schedule.version {
|
||||
@@ -565,7 +566,7 @@ decl_module! {
|
||||
|
||||
/// Stores the given binary Wasm code into the chain's storage and returns its `codehash`.
|
||||
/// You can instantiate contracts only with stored code.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn put_code(
|
||||
origin,
|
||||
#[compact] gas_limit: Gas,
|
||||
@@ -593,7 +594,7 @@ decl_module! {
|
||||
/// * If the account is a regular account, any value will be transferred.
|
||||
/// * If no account exists and the call value is not less than `existential_deposit`,
|
||||
/// a regular account will be created and any value will be transferred.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn call(
|
||||
origin,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -619,7 +620,7 @@ decl_module! {
|
||||
/// after the execution is saved as the `code` of the account. That code will be invoked
|
||||
/// upon any call received by this account.
|
||||
/// - The contract is initialized.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn instantiate(
|
||||
origin,
|
||||
#[compact] endowment: BalanceOf<T>,
|
||||
@@ -642,7 +643,7 @@ decl_module! {
|
||||
///
|
||||
/// If contract is not evicted as a result of this call, no actions are taken and
|
||||
/// the sender is not eligible for the reward.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn claim_surcharge(origin, dest: T::AccountId, aux_sender: Option<T::AccountId>) {
|
||||
let origin = origin.into();
|
||||
let (signed, rewarded) = match (origin, aux_sender) {
|
||||
|
||||
@@ -111,6 +111,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = MetaEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -171,7 +171,7 @@ use sp_runtime::{
|
||||
use codec::{Ref, Encode, Decode};
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event, decl_error, ensure, Parameter,
|
||||
weights::{SimpleDispatchInfo, Weight, WeighData},
|
||||
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT},
|
||||
traits::{
|
||||
Currency, ReservableCurrency, LockableCurrency, WithdrawReason, LockIdentifier, Get,
|
||||
OnUnbalanced, BalanceStatus, schedule::Named as ScheduleNamed, EnsureOrigin
|
||||
@@ -528,7 +528,7 @@ decl_module! {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
Self::migrate();
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
/// Propose a sensitive action to be taken.
|
||||
@@ -546,7 +546,7 @@ decl_module! {
|
||||
/// - P is the number proposals in the `PublicProps` vec.
|
||||
/// - Two DB changes, one DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)]
|
||||
fn propose(origin,
|
||||
proposal_hash: T::Hash,
|
||||
#[compact] value: BalanceOf<T>
|
||||
@@ -577,7 +577,7 @@ decl_module! {
|
||||
/// - S is the number of seconds a proposal already has.
|
||||
/// - One DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)]
|
||||
fn second(origin, #[compact] proposal: PropIndex) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let mut deposit = Self::deposit_of(proposal)
|
||||
@@ -600,7 +600,7 @@ decl_module! {
|
||||
/// - R is the number of referendums the voter has voted on.
|
||||
/// - One DB change, one DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000_000)]
|
||||
fn vote(origin,
|
||||
#[compact] ref_index: ReferendumIndex,
|
||||
vote: AccountVote<BalanceOf<T>>,
|
||||
@@ -621,7 +621,7 @@ decl_module! {
|
||||
/// - `O(1)`.
|
||||
/// - One DB change, one DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000_000)]
|
||||
fn proxy_vote(origin,
|
||||
#[compact] ref_index: ReferendumIndex,
|
||||
vote: AccountVote<BalanceOf<T>>,
|
||||
@@ -641,7 +641,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(500_000_000)]
|
||||
fn emergency_cancel(origin, ref_index: ReferendumIndex) {
|
||||
T::CancellationOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -664,7 +664,7 @@ decl_module! {
|
||||
/// - `O(1)`.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)]
|
||||
fn external_propose(origin, proposal_hash: T::Hash) {
|
||||
T::ExternalOrigin::ensure_origin(origin)?;
|
||||
ensure!(!<NextExternal<T>>::exists(), Error::<T>::DuplicateProposal);
|
||||
@@ -691,7 +691,7 @@ decl_module! {
|
||||
/// - `O(1)`.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)]
|
||||
fn external_propose_majority(origin, proposal_hash: T::Hash) {
|
||||
T::ExternalMajorityOrigin::ensure_origin(origin)?;
|
||||
<NextExternal<T>>::put((proposal_hash, VoteThreshold::SimpleMajority));
|
||||
@@ -711,7 +711,7 @@ decl_module! {
|
||||
/// - `O(1)`.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000_000)]
|
||||
fn external_propose_default(origin, proposal_hash: T::Hash) {
|
||||
T::ExternalDefaultOrigin::ensure_origin(origin)?;
|
||||
<NextExternal<T>>::put((proposal_hash, VoteThreshold::SuperMajorityAgainst));
|
||||
@@ -736,7 +736,7 @@ decl_module! {
|
||||
/// - One DB change.
|
||||
/// - One extra DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000_000)]
|
||||
fn fast_track(origin,
|
||||
proposal_hash: T::Hash,
|
||||
voting_period: T::BlockNumber,
|
||||
@@ -787,7 +787,7 @@ decl_module! {
|
||||
/// be very large.
|
||||
/// - O(log v), v is number of `existing_vetoers`
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(200_000_000)]
|
||||
fn veto_external(origin, proposal_hash: T::Hash) {
|
||||
let who = T::VetoOrigin::ensure_origin(origin)?;
|
||||
|
||||
@@ -820,7 +820,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn cancel_referendum(origin, #[compact] ref_index: ReferendumIndex) {
|
||||
ensure_root(origin)?;
|
||||
Self::internal_cancel_referendum(ref_index);
|
||||
@@ -836,7 +836,7 @@ decl_module! {
|
||||
/// - One DB change.
|
||||
/// - O(d) where d is the items in the dispatch queue.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn cancel_queued(origin, which: ReferendumIndex) {
|
||||
ensure_root(origin)?;
|
||||
T::Scheduler::cancel_named((DEMOCRACY_ID, which))
|
||||
@@ -848,7 +848,7 @@ decl_module! {
|
||||
sp_runtime::print(e);
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
/// Specify a proxy that is already open to us. Called by the stash.
|
||||
@@ -862,7 +862,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One extra DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn activate_proxy(origin, proxy: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Proxy::<T>::try_mutate(&proxy, |a| match a.take() {
|
||||
@@ -885,7 +885,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One DB clear.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn close_proxy(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Proxy::<T>::mutate(&who, |a| {
|
||||
@@ -909,7 +909,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One DB clear.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn deactivate_proxy(origin, proxy: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Proxy::<T>::try_mutate(&proxy, |a| match a.take() {
|
||||
@@ -942,7 +942,7 @@ decl_module! {
|
||||
///
|
||||
/// # <weight>
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
pub fn delegate(origin, to: T::AccountId, conviction: Conviction, balance: BalanceOf<T>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::try_delegate(who, to, conviction, balance)?;
|
||||
@@ -961,7 +961,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - O(1).
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn undelegate(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::try_undelegate(who)?;
|
||||
@@ -975,7 +975,7 @@ decl_module! {
|
||||
/// - `O(1)`.
|
||||
/// - One DB clear.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn clear_public_proposals(origin) {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -995,7 +995,7 @@ decl_module! {
|
||||
/// - Dependent on the size of `encoded_proposal` but protected by a
|
||||
/// required deposit.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn note_preimage(origin, encoded_proposal: Vec<u8>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
|
||||
@@ -1030,7 +1030,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - Dependent on the size of `encoded_proposal` and length of dispatch queue.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn note_imminent_preimage(origin, encoded_proposal: Vec<u8>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
|
||||
@@ -1066,7 +1066,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One DB clear.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn reap_preimage(origin, proposal_hash: T::Hash) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let (provider, deposit, since, expiry) = <Preimages<T>>::get(&proposal_hash)
|
||||
@@ -1096,7 +1096,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(1)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn unlock(origin, target: T::AccountId) {
|
||||
ensure_signed(origin)?;
|
||||
Self::update_lock(&target);
|
||||
@@ -1115,7 +1115,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One extra DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn open_proxy(origin, target: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Proxy::<T>::mutate(&who, |a| {
|
||||
@@ -1154,7 +1154,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn remove_vote(origin, index: ReferendumIndex) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::try_remove_vote(&who, index, UnvoteScope::Any)
|
||||
@@ -1176,7 +1176,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn remove_other_vote(origin, target: T::AccountId, index: ReferendumIndex) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let scope = if target == who { UnvoteScope::Any } else { UnvoteScope::OnlyExpired };
|
||||
@@ -1207,7 +1207,7 @@ decl_module! {
|
||||
///
|
||||
/// # <weight>
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
pub fn proxy_delegate(origin,
|
||||
to: T::AccountId,
|
||||
conviction: Conviction,
|
||||
@@ -1231,7 +1231,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - O(1).
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn proxy_undelegate(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let target = Self::proxy(who).and_then(|a| a.as_active()).ok_or(Error::<T>::NotProxy)?;
|
||||
@@ -1251,7 +1251,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - `O(R + log R)` where R is the number of referenda that `target` has voted on.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn proxy_remove_vote(origin, index: ReferendumIndex) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
let target = Self::proxy(who).and_then(|a| a.as_active()).ok_or(Error::<T>::NotProxy)?;
|
||||
|
||||
@@ -80,6 +80,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -88,7 +88,7 @@ use sp_runtime::{
|
||||
};
|
||||
use frame_support::{
|
||||
decl_storage, decl_event, ensure, decl_module, decl_error,
|
||||
weights::{SimpleDispatchInfo, Weight, WeighData}, storage::{StorageMap, IterableStorageMap},
|
||||
weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT}, storage::{StorageMap, IterableStorageMap},
|
||||
traits::{
|
||||
Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons,
|
||||
ChangeMembers, OnUnbalanced, WithdrawReason, Contains, BalanceStatus, InitializeMembers,
|
||||
@@ -267,7 +267,7 @@ decl_module! {
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
migration::migrate::<T>();
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
const CandidacyBond: BalanceOf<T> = T::CandidacyBond::get();
|
||||
@@ -291,7 +291,7 @@ decl_module! {
|
||||
/// Reads: O(1)
|
||||
/// Writes: O(V) given `V` votes. V is bounded by 16.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn vote(origin, votes: Vec<T::AccountId>, #[compact] value: BalanceOf<T>) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -336,7 +336,7 @@ decl_module! {
|
||||
/// Reads: O(1)
|
||||
/// Writes: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn remove_voter(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -358,7 +358,7 @@ decl_module! {
|
||||
/// Reads: O(NLogM) given M current candidates and N votes for `target`.
|
||||
/// Writes: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)]
|
||||
fn report_defunct_voter(origin, target: <T::Lookup as StaticLookup>::Source) {
|
||||
let reporter = ensure_signed(origin)?;
|
||||
let target = T::Lookup::lookup(target)?;
|
||||
@@ -401,7 +401,7 @@ decl_module! {
|
||||
/// Reads: O(LogN) Given N candidates.
|
||||
/// Writes: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn submit_candidacy(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -428,7 +428,7 @@ decl_module! {
|
||||
/// - `origin` is a current member. In this case, the bond is unreserved and origin is
|
||||
/// removed as a member, consequently not being a candidate for the next round anymore.
|
||||
/// Similar to [`remove_voter`], if replacement runners exists, they are immediately used.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(2_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(2_000_000_000)]
|
||||
fn renounce_candidacy(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -487,7 +487,7 @@ decl_module! {
|
||||
/// Reads: O(do_phragmen)
|
||||
/// Writes: O(do_phragmen)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(2_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(2_000_000_000)]
|
||||
fn remove_member(origin, who: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
@@ -510,7 +510,7 @@ decl_module! {
|
||||
print(e);
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -907,6 +907,7 @@ mod tests {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -30,7 +30,7 @@ use sp_runtime::{
|
||||
};
|
||||
use frame_support::{
|
||||
decl_storage, decl_event, ensure, decl_module, decl_error,
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData},
|
||||
weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo},
|
||||
traits::{
|
||||
Currency, ExistenceRequirement, Get, LockableCurrency, LockIdentifier, BalanceStatus,
|
||||
OnUnbalanced, ReservableCurrency, WithdrawReason, WithdrawReasons, ChangeMembers
|
||||
@@ -405,7 +405,7 @@ decl_module! {
|
||||
/// - Two extra DB entries, one DB change.
|
||||
/// - Argument `votes` is limited in length to number of candidates.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000_000)]
|
||||
fn set_approvals(
|
||||
origin,
|
||||
votes: Vec<bool>,
|
||||
@@ -423,7 +423,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - Same as `set_approvals` with one additional storage read.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000_000)]
|
||||
fn proxy_set_approvals(origin,
|
||||
votes: Vec<bool>,
|
||||
#[compact] index: VoteIndex,
|
||||
@@ -446,7 +446,7 @@ decl_module! {
|
||||
/// - O(1).
|
||||
/// - Two fewer DB entries, one DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000_000)]
|
||||
fn reap_inactive_voter(
|
||||
origin,
|
||||
#[compact] reporter_index: u32,
|
||||
@@ -520,7 +520,7 @@ decl_module! {
|
||||
/// - O(1).
|
||||
/// - Two fewer DB entries, one DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_250_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_250_000_000)]
|
||||
fn retract_voter(origin, #[compact] index: u32) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -548,7 +548,7 @@ decl_module! {
|
||||
/// - Independent of input.
|
||||
/// - Three DB changes.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(2_500_000_000)]
|
||||
fn submit_candidacy(origin, #[compact] slot: u32) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -585,7 +585,7 @@ decl_module! {
|
||||
/// - O(voters) compute.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000_000_000)]
|
||||
fn present_winner(
|
||||
origin,
|
||||
candidate: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -659,7 +659,7 @@ decl_module! {
|
||||
/// Set the desired member count; if lower than the current count, then seats will not be up
|
||||
/// election when they expire. If more, then a new vote will be started if one is not
|
||||
/// already in progress.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn set_desired_seats(origin, #[compact] count: u32) {
|
||||
ensure_root(origin)?;
|
||||
DesiredSeats::put(count);
|
||||
@@ -669,7 +669,7 @@ decl_module! {
|
||||
///
|
||||
/// Note: A tally should happen instantly (if not already in a presentation
|
||||
/// period) to fill the seat if removal means that the desired members are not met.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn remove_member(origin, who: <T::Lookup as StaticLookup>::Source) {
|
||||
ensure_root(origin)?;
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
@@ -684,7 +684,7 @@ decl_module! {
|
||||
|
||||
/// Set the presentation duration. If there is currently a vote being presented for, will
|
||||
/// invoke `finalize_vote`.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn set_presentation_duration(origin, #[compact] count: T::BlockNumber) {
|
||||
ensure_root(origin)?;
|
||||
<PresentationDuration<T>>::put(count);
|
||||
@@ -692,7 +692,7 @@ decl_module! {
|
||||
|
||||
/// Set the presentation duration. If there is current a vote being presented for, will
|
||||
/// invoke `finalize_vote`.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn set_term_duration(origin, #[compact] count: T::BlockNumber) {
|
||||
ensure_root(origin)?;
|
||||
<TermDuration<T>>::put(count);
|
||||
@@ -703,7 +703,7 @@ decl_module! {
|
||||
print("Guru meditation");
|
||||
print(e);
|
||||
}
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -25,7 +25,7 @@ pub use crate::backend::{Account, Log, Vicinity, Backend};
|
||||
|
||||
use sp_std::{vec::Vec, marker::PhantomData};
|
||||
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
|
||||
use frame_support::weights::{Weight, DispatchClass, FunctionOf};
|
||||
use frame_support::weights::{Weight, MINIMUM_WEIGHT, DispatchClass, FunctionOf};
|
||||
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use sp_runtime::ModuleId;
|
||||
@@ -191,7 +191,7 @@ decl_module! {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Deposit balance from currency/balances module into EVM.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn deposit_balance(origin, value: BalanceOf<T>) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
@@ -212,7 +212,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Withdraw balance from EVM into currency/balances module.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn withdraw_balance(origin, value: BalanceOf<T>) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
let address = T::ConvertAccountId::convert_account_id(&sender);
|
||||
@@ -236,7 +236,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Issue an EVM call operation. This is similar to a message call transaction in Ethereum.
|
||||
#[weight = FunctionOf(|(_, _, _, gas_limit, gas_price, _): (&H160, &Vec<u8>, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit), DispatchClass::Normal, true)]
|
||||
#[weight = FunctionOf(|(_, _, _, gas_limit, gas_price, _): (&H160, &Vec<u8>, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit as Weight), DispatchClass::Normal, true)]
|
||||
fn call(
|
||||
origin,
|
||||
target: H160,
|
||||
@@ -267,7 +267,7 @@ decl_module! {
|
||||
|
||||
/// Issue an EVM create operation. This is similar to a contract creation transaction in
|
||||
/// Ethereum.
|
||||
#[weight = FunctionOf(|(_, _, gas_limit, gas_price, _): (&Vec<u8>, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit), DispatchClass::Normal, true)]
|
||||
#[weight = FunctionOf(|(_, _, gas_limit, gas_price, _): (&Vec<u8>, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit as Weight), DispatchClass::Normal, true)]
|
||||
fn create(
|
||||
origin,
|
||||
init: Vec<u8>,
|
||||
@@ -302,7 +302,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Issue an EVM create2 operation.
|
||||
#[weight = FunctionOf(|(_, _, _, gas_limit, gas_price, _): (&Vec<u8>, &H256, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit), DispatchClass::Normal, true)]
|
||||
#[weight = FunctionOf(|(_, _, _, gas_limit, gas_price, _): (&Vec<u8>, &H256, &U256, &u32, &U256, &Option<U256>)| (*gas_price).saturated_into::<Weight>().saturating_mul(*gas_limit as Weight), DispatchClass::Normal, true)]
|
||||
fn create2(
|
||||
origin,
|
||||
init: Vec<u8>,
|
||||
|
||||
@@ -44,7 +44,7 @@ use frame_support::{
|
||||
debug,
|
||||
dispatch::DispatchResult, decl_module, decl_storage, decl_event,
|
||||
traits::Get,
|
||||
weights::SimpleDispatchInfo,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed, ensure_none, offchain};
|
||||
use sp_core::crypto::KeyTypeId;
|
||||
@@ -157,7 +157,7 @@ decl_module! {
|
||||
/// working and receives (and provides) meaningful data.
|
||||
/// This example is not focused on correctness of the oracle itself, but rather its
|
||||
/// purpose is to showcase offchain worker capabilities.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn submit_price(origin, price: u32) -> DispatchResult {
|
||||
// Retrieve sender of the transaction.
|
||||
let who = ensure_signed(origin)?;
|
||||
@@ -182,7 +182,7 @@ decl_module! {
|
||||
///
|
||||
/// This example is not focused on correctness of the oracle itself, but rather its
|
||||
/// purpose is to showcase offchain worker capabilities.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn submit_price_unsigned(origin, _block_number: T::BlockNumber, price: u32)
|
||||
-> DispatchResult
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::*;
|
||||
use codec::Decode;
|
||||
use frame_support::{
|
||||
assert_ok, impl_outer_origin, parameter_types,
|
||||
weights::{GetDispatchInfo, Weight},
|
||||
weights::Weight,
|
||||
};
|
||||
use sp_core::{
|
||||
H256,
|
||||
@@ -61,6 +61,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
@@ -192,15 +193,6 @@ fn should_submit_unsigned_transaction_on_chain() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weights_work() {
|
||||
// must have a default weight.
|
||||
let default_call = <Call<Test>>::submit_price(10);
|
||||
let info = default_call.get_dispatch_info();
|
||||
// aka. `let info = <Call<Test> as GetDispatchInfo>::get_dispatch_info(&default_call);`
|
||||
assert_eq!(info.weight, 10_000);
|
||||
}
|
||||
|
||||
fn price_oracle_response(state: &mut testing::OffchainState) {
|
||||
state.expect_request(0, testing::PendingRequest {
|
||||
method: "GET".into(),
|
||||
|
||||
@@ -258,6 +258,7 @@ use frame_support::{
|
||||
dispatch::DispatchResult, decl_module, decl_storage, decl_event,
|
||||
weights::{
|
||||
SimpleDispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee,
|
||||
MINIMUM_WEIGHT,
|
||||
},
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
@@ -468,7 +469,7 @@ decl_module! {
|
||||
// weight (a numeric representation of pure execution time and difficulty) of the
|
||||
// transaction and the latter demonstrates the [`DispatchClass`] of the call. A higher
|
||||
// weight means a larger transaction (less of which can be placed in a single block).
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn accumulate_dummy(origin, increase_by: T::Balance) -> DispatchResult {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let _sender = ensure_signed(origin)?;
|
||||
@@ -523,7 +524,7 @@ decl_module! {
|
||||
// Anything that needs to be done at the start of the block.
|
||||
// We don't do anything here.
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
// The signature could also look like: `fn on_finalize()`
|
||||
@@ -753,6 +754,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
@@ -843,11 +845,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn weights_work() {
|
||||
// must have a default weight.
|
||||
// must have a defined weight.
|
||||
let default_call = <Call<Test>>::accumulate_dummy(10);
|
||||
let info = default_call.get_dispatch_info();
|
||||
// aka. `let info = <Call<Test> as GetDispatchInfo>::get_dispatch_info(&default_call);`
|
||||
assert_eq!(info.weight, 10_000);
|
||||
assert_eq!(info.weight, 10_000_000);
|
||||
|
||||
// must have a custom weight of `100 * arg = 2000`
|
||||
let custom_call = <Call<Test>>::set_dummy(20);
|
||||
|
||||
@@ -476,6 +476,7 @@ mod tests {
|
||||
type Event = MetaEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = RuntimeVersion;
|
||||
|
||||
@@ -23,6 +23,7 @@ use sp_runtime::traits::{One, Zero, SaturatedConversion};
|
||||
use sp_std::{prelude::*, result, cmp, vec};
|
||||
use frame_support::{decl_module, decl_storage, decl_error, ensure};
|
||||
use frame_support::traits::Get;
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use frame_system::{ensure_none, Trait as SystemTrait};
|
||||
use sp_finality_tracker::{INHERENT_IDENTIFIER, FinalizedInherentData};
|
||||
|
||||
@@ -76,7 +77,7 @@ decl_module! {
|
||||
|
||||
/// Hint that the author of this block thinks the best finalized
|
||||
/// block is the given number.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::FixedMandatory(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedMandatory(MINIMUM_WEIGHT)]
|
||||
fn final_hint(origin, #[compact] hint: T::BlockNumber) {
|
||||
ensure_none(origin)?;
|
||||
ensure!(!<Self as Store>::Update::exists(), Error::<T>::AlreadyUpdated);
|
||||
@@ -260,6 +261,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -164,6 +164,7 @@ use sp_std::prelude::*;
|
||||
use sp_std::{cmp, result, fmt::Debug};
|
||||
use frame_support::{
|
||||
decl_event, decl_module, decl_storage, ensure, decl_error,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
traits::{
|
||||
Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, ReservableCurrency,
|
||||
SignedImbalance, WithdrawReason, WithdrawReasons, TryDrop, BalanceStatus,
|
||||
@@ -360,14 +361,14 @@ decl_module! {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Create a new kind of asset.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn create(origin, options: AssetOptions<T::Balance, T::AccountId>) -> DispatchResult {
|
||||
let origin = ensure_signed(origin)?;
|
||||
Self::create_asset(None, Some(origin), options)
|
||||
}
|
||||
|
||||
/// Transfer some liquid free balance to another account.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn transfer(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, #[compact] amount: T::Balance) {
|
||||
let origin = ensure_signed(origin)?;
|
||||
ensure!(!amount.is_zero(), Error::<T>::ZeroAmount);
|
||||
@@ -377,7 +378,7 @@ decl_module! {
|
||||
/// Updates permission for a given `asset_id` and an account.
|
||||
///
|
||||
/// The `origin` must have `update` permission.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn update_permission(
|
||||
origin,
|
||||
#[compact] asset_id: T::AssetId,
|
||||
@@ -400,7 +401,7 @@ decl_module! {
|
||||
|
||||
/// Mints an asset, increases its total issuance.
|
||||
/// The origin must have `mint` permissions.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::mint_free(&asset_id, &who, &to, &amount)?;
|
||||
@@ -410,7 +411,7 @@ decl_module! {
|
||||
|
||||
/// Burns an asset, decreases its total issuance.
|
||||
/// The `origin` must have `burn` permissions.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::burn_free(&asset_id, &who, &to, &amount)?;
|
||||
@@ -420,7 +421,7 @@ decl_module! {
|
||||
|
||||
/// Can be used to create reserved tokens.
|
||||
/// Requires Root call.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn create_reserved(
|
||||
origin,
|
||||
asset_id: T::AssetId,
|
||||
@@ -1124,6 +1125,7 @@ impl<T: Subtrait> frame_system::Trait for ElevatedTrait<T> {
|
||||
type Event = ();
|
||||
type BlockHashCount = T::BlockHashCount;
|
||||
type MaximumBlockWeight = T::MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = T::MaximumBlockLength;
|
||||
type AvailableBlockRatio = T::AvailableBlockRatio;
|
||||
type Version = T::Version;
|
||||
|
||||
@@ -57,6 +57,7 @@ impl frame_system::Trait for Test {
|
||||
type Header = Header;
|
||||
type Event = TestEvent;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
|
||||
@@ -33,6 +33,7 @@ pub use sp_finality_grandpa as fg_primitives;
|
||||
use sp_std::prelude::*;
|
||||
use codec::{self as codec, Encode, Decode};
|
||||
use frame_support::{decl_event, decl_storage, decl_module, decl_error, storage};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use sp_runtime::{
|
||||
DispatchResult, generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill,
|
||||
};
|
||||
@@ -184,7 +185,7 @@ decl_module! {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Report some misbehavior.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn report_misbehavior(origin, _report: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
// FIXME: https://github.com/paritytech/substrate/issues/1112
|
||||
|
||||
@@ -61,6 +61,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = TestEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -74,7 +74,7 @@ use sp_runtime::traits::{StaticLookup, Zero, AppendZerosInput};
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, ensure, decl_error,
|
||||
traits::{Currency, ReservableCurrency, OnUnbalanced, Get, BalanceStatus, EnsureOrigin},
|
||||
weights::SimpleDispatchInfo,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
@@ -474,7 +474,7 @@ decl_module! {
|
||||
/// - One storage mutation (codec `O(R)`).
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn add_registrar(origin, account: T::AccountId) {
|
||||
T::RegistrarOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -506,7 +506,7 @@ decl_module! {
|
||||
/// - One storage mutation (codec-read `O(X' + R)`, codec-write `O(X + R)`).
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_identity(origin, info: IdentityInfo) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
let extra_fields = info.additional.len() as u32;
|
||||
@@ -552,7 +552,7 @@ decl_module! {
|
||||
/// - At most O(2 * S + 1) storage mutations; codec complexity `O(1 * S + S * 1)`);
|
||||
/// one storage-exists.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_subs(origin, subs: Vec<(T::AccountId, Data)>) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
ensure!(<IdentityOf<T>>::contains_key(&sender), Error::<T>::NotFound);
|
||||
@@ -599,7 +599,7 @@ decl_module! {
|
||||
/// - `S + 2` storage deletions.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn clear_identity(origin) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
@@ -638,7 +638,7 @@ decl_module! {
|
||||
/// - Storage: 1 read `O(R)`, 1 mutate `O(X + R)`.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn request_judgement(origin,
|
||||
#[compact] reg_index: RegistrarIndex,
|
||||
#[compact] max_fee: BalanceOf<T>,
|
||||
@@ -684,7 +684,7 @@ decl_module! {
|
||||
/// - One storage mutation `O(R + X)`.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn cancel_request(origin, reg_index: RegistrarIndex) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
let mut id = <IdentityOf<T>>::get(&sender).ok_or(Error::<T>::NoIdentity)?;
|
||||
@@ -715,7 +715,7 @@ decl_module! {
|
||||
/// - `O(R)`.
|
||||
/// - One storage mutation `O(R)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_fee(origin,
|
||||
#[compact] index: RegistrarIndex,
|
||||
#[compact] fee: BalanceOf<T>,
|
||||
@@ -742,7 +742,7 @@ decl_module! {
|
||||
/// - `O(R)`.
|
||||
/// - One storage mutation `O(R)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_account_id(origin,
|
||||
#[compact] index: RegistrarIndex,
|
||||
new: T::AccountId,
|
||||
@@ -769,7 +769,7 @@ decl_module! {
|
||||
/// - `O(R)`.
|
||||
/// - One storage mutation `O(R)`.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_fields(origin,
|
||||
#[compact] index: RegistrarIndex,
|
||||
fields: IdentityFields,
|
||||
@@ -803,7 +803,7 @@ decl_module! {
|
||||
/// - Storage: 1 read `O(R)`, 1 mutate `O(R + X)`.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn provide_judgement(origin,
|
||||
#[compact] reg_index: RegistrarIndex,
|
||||
target: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -852,7 +852,7 @@ decl_module! {
|
||||
/// - `S + 2` storage mutations.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn kill_identity(origin, target: <T::Lookup as StaticLookup>::Source) {
|
||||
T::ForceOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -930,6 +930,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_im_online::{self as im_online};
|
||||
//!
|
||||
@@ -50,7 +51,7 @@
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn is_online(origin, authority_index: u32) -> dispatch::DispatchResult {
|
||||
//! let _sender = ensure_signed(origin)?;
|
||||
//! let _is_online = <im_online::Module<T>>::is_online(authority_index);
|
||||
@@ -94,6 +95,7 @@ use sp_staking::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, Parameter, debug, decl_error,
|
||||
traits::Get,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
};
|
||||
use frame_system::{self as system, ensure_none};
|
||||
use frame_system::offchain::SubmitUnsignedTransaction;
|
||||
@@ -316,7 +318,7 @@ decl_module! {
|
||||
|
||||
fn deposit_event() = default;
|
||||
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn heartbeat(
|
||||
origin,
|
||||
heartbeat: Heartbeat<T::BlockNumber>,
|
||||
|
||||
@@ -114,6 +114,7 @@ impl frame_system::Trait for Runtime {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -25,7 +25,7 @@ use sp_runtime::traits::{
|
||||
StaticLookup, Member, LookupError, Zero, One, BlakeTwo256, Hash, Saturating, AtLeast32Bit
|
||||
};
|
||||
use frame_support::{Parameter, decl_module, decl_error, decl_event, decl_storage, ensure};
|
||||
use frame_support::weights::{Weight, SimpleDispatchInfo, WeighData};
|
||||
use frame_support::weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo};
|
||||
use frame_support::dispatch::DispatchResult;
|
||||
use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Reserved};
|
||||
use frame_support::storage::migration::take_storage_value;
|
||||
@@ -102,7 +102,7 @@ decl_module! {
|
||||
fn on_initialize() -> Weight {
|
||||
Self::migrations();
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
/// Assign an previously unassigned index.
|
||||
@@ -121,7 +121,7 @@ decl_module! {
|
||||
/// - One reserve operation.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn claim(origin, index: T::AccountIndex) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -149,7 +149,7 @@ decl_module! {
|
||||
/// - One transfer operation.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn transfer(origin, new: T::AccountId, index: T::AccountIndex) {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(who != new, Error::<T>::NotTransfer);
|
||||
@@ -180,7 +180,7 @@ decl_module! {
|
||||
/// - One reserve operation.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn free(origin, index: T::AccountIndex) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -209,7 +209,7 @@ decl_module! {
|
||||
/// - Up to one reserve operation.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn force_transfer(origin, new: T::AccountId, index: T::AccountIndex) {
|
||||
ensure_root(origin)?;
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = MetaEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -118,7 +118,7 @@ decl_module! {
|
||||
/// Add a member `who` to the set.
|
||||
///
|
||||
/// May only be called from `AddOrigin` or root.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn add_member(origin, who: T::AccountId) {
|
||||
T::AddOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -137,7 +137,7 @@ decl_module! {
|
||||
/// Remove a member `who` from the set.
|
||||
///
|
||||
/// May only be called from `RemoveOrigin` or root.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn remove_member(origin, who: T::AccountId) {
|
||||
T::RemoveOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -159,7 +159,7 @@ decl_module! {
|
||||
/// May only be called from `SwapOrigin` or root.
|
||||
///
|
||||
/// Prime membership is *not* passed from `remove` to `add`, if extant.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn swap_member(origin, remove: T::AccountId, add: T::AccountId) {
|
||||
T::SwapOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -188,7 +188,7 @@ decl_module! {
|
||||
/// pass `members` pre-sorted.
|
||||
///
|
||||
/// May only be called from `ResetOrigin` or root.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn reset_members(origin, members: Vec<T::AccountId>) {
|
||||
T::ResetOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -211,7 +211,7 @@ decl_module! {
|
||||
/// May only be called from `Signed` origin of a current member.
|
||||
///
|
||||
/// Prime membership is passed from the origin account to `new`, if extant.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn change_key(origin, new: T::AccountId) {
|
||||
let remove = ensure_signed(origin)?;
|
||||
|
||||
@@ -239,7 +239,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set the prime member. Must be a current member.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_prime(origin, who: T::AccountId) {
|
||||
T::PrimeOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -250,7 +250,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Remove the prime member if it exists.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn clear_prime(origin) {
|
||||
T::PrimeOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -315,6 +315,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -141,7 +141,7 @@ decl_module! {
|
||||
/// - One storage read/write.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn set_name(origin, name: Vec<u8>) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
@@ -171,7 +171,7 @@ decl_module! {
|
||||
/// - One storage read/write.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000_000)]
|
||||
fn clear_name(origin) {
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
@@ -195,7 +195,7 @@ decl_module! {
|
||||
/// - One storage read/write.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000_000)]
|
||||
fn kill_name(origin, target: <T::Lookup as StaticLookup>::Source) {
|
||||
T::ForceOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -223,7 +223,7 @@ decl_module! {
|
||||
/// - One storage read/write.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(70_000_000)]
|
||||
fn force_name(origin, target: <T::Lookup as StaticLookup>::Source, name: Vec<u8>) {
|
||||
T::ForceOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -282,6 +282,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -27,7 +27,7 @@ mod tests;
|
||||
use sp_std::vec::Vec;
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, Parameter, debug,
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData},
|
||||
weights::{Weight, MINIMUM_WEIGHT},
|
||||
};
|
||||
use sp_runtime::{traits::Hash, Perbill};
|
||||
use sp_staking::{
|
||||
@@ -104,7 +104,7 @@ decl_module! {
|
||||
ConcurrentReportsIndex::<T>::remove_all();
|
||||
ReportsByKindIndex::remove_all();
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
fn on_initialize(now: T::BlockNumber) -> Weight {
|
||||
@@ -125,7 +125,7 @@ decl_module! {
|
||||
})
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ impl frame_system::Trait for Runtime {
|
||||
type Event = TestEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -35,13 +35,13 @@
|
||||
//! ### Example - Get random seed for the current block
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch, traits::Randomness, weights::SimpleDispatchInfo};
|
||||
//! use frame_support::{decl_module, dispatch, traits::Randomness, weights::{SimpleDispatchInfo, MINIMUM_WEIGHT}};
|
||||
//!
|
||||
//! pub trait Trait: frame_system::Trait {}
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn random_module_example(origin) -> dispatch::DispatchResult {
|
||||
//! let _random_seed = <pallet_randomness_collective_flip::Module<T>>::random_seed();
|
||||
//! Ok(())
|
||||
@@ -57,7 +57,7 @@ use sp_std::{prelude::*, convert::TryInto};
|
||||
use sp_runtime::traits::Hash;
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, traits::Randomness,
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData}
|
||||
weights::{Weight, MINIMUM_WEIGHT}
|
||||
};
|
||||
use safe_mix::TripletMix;
|
||||
use codec::Encode;
|
||||
@@ -83,7 +83,7 @@ decl_module! {
|
||||
values[index] = parent_hash;
|
||||
});
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -159,7 +159,7 @@ use codec::{Encode, Decode};
|
||||
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, decl_error, ensure,
|
||||
Parameter, RuntimeDebug, weights::{GetDispatchInfo, SimpleDispatchInfo, FunctionOf},
|
||||
Parameter, RuntimeDebug, weights::{MINIMUM_WEIGHT, GetDispatchInfo, SimpleDispatchInfo, FunctionOf},
|
||||
traits::{Currency, ReservableCurrency, Get, BalanceStatus},
|
||||
dispatch::PostDispatchInfo,
|
||||
};
|
||||
@@ -365,7 +365,7 @@ decl_module! {
|
||||
/// - One storage write O(1)
|
||||
/// - One event
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn set_recovered(origin, lost: T::AccountId, rescuer: T::AccountId) {
|
||||
ensure_root(origin)?;
|
||||
// Create the recovery storage item.
|
||||
@@ -400,7 +400,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(F + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn create_recovery(origin,
|
||||
friends: Vec<T::AccountId>,
|
||||
threshold: u16,
|
||||
@@ -460,7 +460,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(F + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn initiate_recovery(origin, account: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Check that the account is recoverable
|
||||
@@ -506,7 +506,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(F + logF + V + logV)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn vouch_recovery(origin, lost: T::AccountId, rescuer: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Get the recovery configuration for the lost account.
|
||||
@@ -545,7 +545,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(F + V)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn claim_recovery(origin, account: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Get the recovery configuration for the lost account
|
||||
@@ -590,7 +590,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(V + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
|
||||
fn close_recovery(origin, rescuer: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Take the active recovery process started by the rescuer for this account.
|
||||
@@ -622,7 +622,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(F + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
|
||||
fn remove_recovery(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Check there are no active recoveries
|
||||
@@ -647,7 +647,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One storage mutation to check account is recovered by `who`. O(1)
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn cancel_recovered(origin, account: T::AccountId) {
|
||||
let who = ensure_signed(origin)?;
|
||||
// Check `who` is allowed to make a call on behalf of `account`
|
||||
|
||||
@@ -75,6 +75,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = TestEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -348,6 +348,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_scored_pool::{self as scored_pool};
|
||||
//!
|
||||
@@ -61,7 +62,7 @@
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn candidate(origin) -> dispatch::DispatchResult {
|
||||
//! let who = ensure_signed(origin)?;
|
||||
//!
|
||||
@@ -97,7 +98,7 @@ use sp_std::{
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event, ensure, decl_error,
|
||||
traits::{EnsureOrigin, ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData},
|
||||
weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo},
|
||||
};
|
||||
use frame_system::{self as system, ensure_root, ensure_signed};
|
||||
use sp_runtime::{
|
||||
@@ -252,7 +253,7 @@ decl_module! {
|
||||
let pool = <Pool<T, I>>::get();
|
||||
<Module<T, I>>::refresh_members(pool, ChangeReceiver::MembershipChanged);
|
||||
}
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
|
||||
/// Add `origin` to the pool of candidates.
|
||||
@@ -266,7 +267,7 @@ decl_module! {
|
||||
///
|
||||
/// The `index` parameter of this function must be set to
|
||||
/// the index of the transactor in the `Pool`.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn submit_candidacy(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(!<CandidateExists<T, I>>::contains_key(&who), Error::<T, I>::AlreadyInPool);
|
||||
@@ -296,7 +297,7 @@ decl_module! {
|
||||
///
|
||||
/// The `index` parameter of this function must be set to
|
||||
/// the index of the transactor in the `Pool`.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn withdraw_candidacy(
|
||||
origin,
|
||||
index: u32
|
||||
@@ -316,7 +317,7 @@ decl_module! {
|
||||
///
|
||||
/// The `index` parameter of this function must be set to
|
||||
/// the index of `dest` in the `Pool`.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn kick(
|
||||
origin,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -341,7 +342,7 @@ decl_module! {
|
||||
///
|
||||
/// The `index` parameter of this function must be set to
|
||||
/// the index of the `dest` in the `Pool`.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn score(
|
||||
origin,
|
||||
dest: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -382,7 +383,7 @@ decl_module! {
|
||||
/// (this happens each `Period`).
|
||||
///
|
||||
/// May only be called from root.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn change_member_count(origin, count: u32) {
|
||||
ensure_root(origin)?;
|
||||
<MemberCount<I>>::put(&count);
|
||||
|
||||
@@ -66,6 +66,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -69,6 +69,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = ();
|
||||
type MaximumBlockWeight = ();
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = ();
|
||||
type MaximumBlockLength = ();
|
||||
type Version = ();
|
||||
|
||||
@@ -110,7 +110,7 @@ use frame_support::{
|
||||
Get, FindAuthor, ValidatorRegistration, EstimateNextSessionRotation, EstimateNextNewSession,
|
||||
},
|
||||
dispatch::{self, DispatchResult, DispatchError},
|
||||
weights::{Weight, SimpleDispatchInfo, WeighData},
|
||||
weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo},
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
@@ -498,7 +498,7 @@ decl_module! {
|
||||
/// - Increases system account refs by one on success iff there were previously no keys set.
|
||||
/// In this case, purge_keys will need to be called before the account can be removed.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000_000)]
|
||||
pub fn set_keys(origin, keys: T::Keys, proof: Vec<u8>) -> dispatch::DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -519,7 +519,7 @@ decl_module! {
|
||||
/// - Removes N + 1 DB entries.
|
||||
/// - Reduces system account refs by one on success.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000_000)]
|
||||
pub fn purge_keys(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::do_purge_keys(&who)?;
|
||||
@@ -532,7 +532,7 @@ decl_module! {
|
||||
Self::rotate_session();
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -260,7 +260,7 @@ use sp_runtime::{Percent, ModuleId, RuntimeDebug,
|
||||
}
|
||||
};
|
||||
use frame_support::{decl_error, decl_module, decl_storage, decl_event, ensure, dispatch::DispatchResult};
|
||||
use frame_support::weights::{SimpleDispatchInfo, Weight, WeighData};
|
||||
use frame_support::weights::{SimpleDispatchInfo, Weight, MINIMUM_WEIGHT};
|
||||
use frame_support::traits::{
|
||||
Currency, ReservableCurrency, Randomness, Get, ChangeMembers, BalanceStatus,
|
||||
ExistenceRequirement::AllowDeath, EnsureOrigin
|
||||
@@ -527,7 +527,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + B + C + logM + logB + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
pub fn bid(origin, value: BalanceOf<T, I>) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
ensure!(!<SuspendedCandidates<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
|
||||
@@ -566,7 +566,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(B + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000_000)]
|
||||
pub fn unbid(origin, pos: u32) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -636,7 +636,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + B + C + logM + logB + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
pub fn vouch(origin, who: T::AccountId, value: BalanceOf<T, I>, tip: BalanceOf<T, I>) -> DispatchResult {
|
||||
let voucher = ensure_signed(origin)?;
|
||||
// Check user is not suspended.
|
||||
@@ -677,7 +677,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(B)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000_000)]
|
||||
pub fn unvouch(origin, pos: u32) -> DispatchResult {
|
||||
let voucher = ensure_signed(origin)?;
|
||||
ensure!(Self::vouching(&voucher) == Some(VouchingStatus::Vouching), Error::<T, I>::NotVouching);
|
||||
@@ -715,7 +715,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + logM + C)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
|
||||
pub fn vote(origin, candidate: <T::Lookup as StaticLookup>::Source, approve: bool) {
|
||||
let voter = ensure_signed(origin)?;
|
||||
let candidate = T::Lookup::lookup(candidate)?;
|
||||
@@ -746,7 +746,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + logM)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000_000)]
|
||||
pub fn defender_vote(origin, approve: bool) {
|
||||
let voter = ensure_signed(origin)?;
|
||||
let members = <Members<T, I>>::get();
|
||||
@@ -778,7 +778,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + logM + P + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
|
||||
pub fn payout(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
@@ -820,7 +820,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn found(origin, founder: T::AccountId, max_members: u32, rules: Vec<u8>) {
|
||||
T::FounderSetOrigin::ensure_origin(origin)?;
|
||||
ensure!(!<Head<T, I>>::exists(), Error::<T, I>::AlreadyFounded);
|
||||
@@ -847,7 +847,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(20_000_000)]
|
||||
fn unfound(origin) {
|
||||
let founder = ensure_signed(origin)?;
|
||||
ensure!(Founder::<T, I>::get() == Some(founder.clone()), Error::<T, I>::NotFounder);
|
||||
@@ -889,7 +889,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + logM + B)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000_000)]
|
||||
fn judge_suspended_member(origin, who: T::AccountId, forgive: bool) {
|
||||
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
||||
ensure!(<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::NotSuspended);
|
||||
@@ -960,7 +960,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(M + logM + B + X)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn judge_suspended_candidate(origin, who: T::AccountId, judgement: Judgement) {
|
||||
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
|
||||
if let Some((value, kind)) = <SuspendedCandidates<T, I>>::get(&who) {
|
||||
@@ -1020,7 +1020,7 @@ decl_module! {
|
||||
///
|
||||
/// Total Complexity: O(1)
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn set_max_members(origin, max: u32) {
|
||||
ensure_root(origin)?;
|
||||
ensure!(max > 1, Error::<T, I>::MaxMembers);
|
||||
@@ -1046,7 +1046,7 @@ decl_module! {
|
||||
Self::rotate_challenge(&mut members);
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_staking::{self as staking};
|
||||
//!
|
||||
@@ -158,7 +159,7 @@
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! /// Reward a validator.
|
||||
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn reward_myself(origin) -> dispatch::DispatchResult {
|
||||
//! let reported = ensure_signed(origin)?;
|
||||
//! <staking::Module<T>>::reward_by_ids(vec![(reported, 10)]);
|
||||
@@ -274,7 +275,7 @@ use sp_std::{
|
||||
use codec::{HasCompact, Encode, Decode};
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, ensure, decl_error, debug,
|
||||
weights::{SimpleDispatchInfo, Weight},
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT, Weight},
|
||||
storage::IterableStorageMap,
|
||||
dispatch::{IsSubType, DispatchResult},
|
||||
traits::{
|
||||
@@ -1250,7 +1251,7 @@ decl_module! {
|
||||
/// NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned
|
||||
/// unless the `origin` falls below _existential deposit_ and gets removed as dust.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
pub fn bond(origin,
|
||||
controller: <T::Lookup as StaticLookup>::Source,
|
||||
#[compact] value: BalanceOf<T>,
|
||||
@@ -1314,7 +1315,7 @@ decl_module! {
|
||||
/// - O(1).
|
||||
/// - One DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn bond_extra(origin, #[compact] max_additional: BalanceOf<T>) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let stash = ensure_signed(origin)?;
|
||||
@@ -1360,7 +1361,7 @@ decl_module! {
|
||||
/// `withdraw_unbonded`.
|
||||
/// - One DB entry.
|
||||
/// </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(400_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(400_000_000)]
|
||||
fn unbond(origin, #[compact] value: BalanceOf<T>) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1408,7 +1409,7 @@ decl_module! {
|
||||
/// - Contains a limited number of reads, yet the size of which could be large based on `ledger`.
|
||||
/// - Writes are limited to the `origin` account key.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(400_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(400_000_000)]
|
||||
fn withdraw_unbonded(origin) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1451,7 +1452,7 @@ decl_module! {
|
||||
/// - Contains a limited number of reads.
|
||||
/// - Writes are limited to the `origin` account key.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000_000)]
|
||||
pub fn validate(origin, prefs: ValidatorPrefs) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1474,7 +1475,7 @@ decl_module! {
|
||||
/// which is capped at CompactAssignments::LIMIT.
|
||||
/// - Both the reads and writes follow a similar pattern.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000_000)]
|
||||
pub fn nominate(origin, targets: Vec<<T::Lookup as StaticLookup>::Source>) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1509,7 +1510,7 @@ decl_module! {
|
||||
/// - Contains one read.
|
||||
/// - Writes are limited to the `origin` account key.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn chill(origin) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1528,7 +1529,7 @@ decl_module! {
|
||||
/// - Contains a limited number of reads.
|
||||
/// - Writes are limited to the `origin` account key.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn set_payee(origin, payee: RewardDestination) {
|
||||
let controller = ensure_signed(origin)?;
|
||||
let ledger = Self::ledger(&controller).ok_or(Error::<T>::NotController)?;
|
||||
@@ -1547,7 +1548,7 @@ decl_module! {
|
||||
/// - Contains a limited number of reads.
|
||||
/// - Writes are limited to the `origin` account key.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(750_000_000)]
|
||||
fn set_controller(origin, controller: <T::Lookup as StaticLookup>::Source) {
|
||||
let stash = ensure_signed(origin)?;
|
||||
let old_controller = Self::bonded(&stash).ok_or(Error::<T>::NotStash)?;
|
||||
@@ -1564,7 +1565,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// The ideal number of validators.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
fn set_validator_count(origin, #[compact] new: u32) {
|
||||
ensure_root(origin)?;
|
||||
ValidatorCount::put(new);
|
||||
@@ -1575,7 +1576,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - No arguments.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
fn force_no_eras(origin) {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::put(Forcing::ForceNone);
|
||||
@@ -1587,21 +1588,21 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - No arguments.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
fn force_new_era(origin) {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::put(Forcing::ForceNew);
|
||||
}
|
||||
|
||||
/// Set the validators who cannot be slashed (if any).
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
fn set_invulnerables(origin, validators: Vec<T::AccountId>) {
|
||||
ensure_root(origin)?;
|
||||
<Invulnerables<T>>::put(validators);
|
||||
}
|
||||
|
||||
/// Force a current staker to become completely unstaked, immediately.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn force_unstake(origin, stash: T::AccountId) {
|
||||
ensure_root(origin)?;
|
||||
|
||||
@@ -1617,7 +1618,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One storage write
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(5_000_000)]
|
||||
fn force_new_era_always(origin) {
|
||||
ensure_root(origin)?;
|
||||
ForceEra::put(Forcing::ForceAlways);
|
||||
@@ -1630,7 +1631,7 @@ decl_module! {
|
||||
/// # <weight>
|
||||
/// - One storage write.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)]
|
||||
fn cancel_deferred_slash(origin, era: EraIndex, slash_indices: Vec<u32>) {
|
||||
T::SlashCancelOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -1681,7 +1682,7 @@ decl_module! {
|
||||
/// maximum number of validators that may be nominated by a single nominator, it is
|
||||
/// bounded only economically (all nominators are required to place a minimum stake).
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn payout_nominator(origin, era: EraIndex, validators: Vec<(T::AccountId, u32)>)
|
||||
-> DispatchResult
|
||||
{
|
||||
@@ -1708,7 +1709,7 @@ decl_module! {
|
||||
/// - Time complexity: O(1).
|
||||
/// - Contains a limited number of reads and writes.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn payout_validator(origin, era: EraIndex) -> DispatchResult {
|
||||
let ctrl = ensure_signed(origin)?;
|
||||
Self::do_payout_validator(ctrl, era)
|
||||
@@ -1729,7 +1730,7 @@ decl_module! {
|
||||
/// - Time complexity: at most O(MaxNominatorRewardedPerValidator).
|
||||
/// - Contains a limited number of reads and writes.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn payout_stakers(origin, validator_stash: T::AccountId, era: EraIndex) -> DispatchResult {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
ensure_signed(origin)?;
|
||||
@@ -1745,7 +1746,7 @@ decl_module! {
|
||||
/// - Time complexity: O(1). Bounded by `MAX_UNLOCKING_CHUNKS`.
|
||||
/// - Storage changes: Can't increase storage, only decrease it.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn rebond(origin, #[compact] value: BalanceOf<T>) {
|
||||
ensure!(Self::era_election_status().is_closed(), Error::<T>::CallNotAllowed);
|
||||
let controller = ensure_signed(origin)?;
|
||||
@@ -1759,7 +1760,7 @@ decl_module! {
|
||||
/// Set history_depth value.
|
||||
///
|
||||
/// Origin must be root.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(500_000_000)]
|
||||
fn set_history_depth(origin, #[compact] new_history_depth: EraIndex) {
|
||||
ensure_root(origin)?;
|
||||
if let Some(current_era) = Self::current_era() {
|
||||
@@ -1781,7 +1782,7 @@ decl_module! {
|
||||
/// This can be called from any origin.
|
||||
///
|
||||
/// - `stash`: The stash account to reap. Its balance must be zero.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn reap_stash(_origin, stash: T::AccountId) {
|
||||
ensure!(T::Currency::total_balance(&stash).is_zero(), Error::<T>::FundedTarget);
|
||||
Self::kill_stash(&stash)?;
|
||||
@@ -1862,7 +1863,7 @@ decl_module! {
|
||||
///
|
||||
/// The weight of this call is 1/10th of the blocks total weight.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000_000)]
|
||||
pub fn submit_election_solution(
|
||||
origin,
|
||||
winners: Vec<ValidatorIndex>,
|
||||
@@ -1885,7 +1886,7 @@ decl_module! {
|
||||
/// Note that this must pass the [`ValidateUnsigned`] check which only allows transactions
|
||||
/// from the local node to be included. In other words, only the block author can include a
|
||||
/// transaction in the block.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000_000)]
|
||||
pub fn submit_election_solution_unsigned(
|
||||
origin,
|
||||
winners: Vec<ValidatorIndex>,
|
||||
|
||||
@@ -203,6 +203,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = MetaEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -52,13 +52,14 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
//! use frame_system::{self as system, ensure_root};
|
||||
//!
|
||||
//! pub trait Trait: frame_system::Trait {}
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn privileged_function(origin) -> dispatch::DispatchResult {
|
||||
//! ensure_root(origin)?;
|
||||
//!
|
||||
@@ -92,7 +93,7 @@ use sp_runtime::traits::{StaticLookup, Dispatchable};
|
||||
use frame_support::{
|
||||
Parameter, decl_module, decl_event, decl_storage, decl_error, ensure,
|
||||
};
|
||||
use frame_support::weights::{GetDispatchInfo, FunctionOf};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT, GetDispatchInfo, FunctionOf};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
pub trait Trait: frame_system::Trait {
|
||||
@@ -150,7 +151,7 @@ decl_module! {
|
||||
/// - Limited storage reads.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn set_key(origin, new: <T::Lookup as StaticLookup>::Source) {
|
||||
// This is a public call, so we ensure that the origin is some signed account.
|
||||
let sender = ensure_signed(origin)?;
|
||||
|
||||
@@ -74,14 +74,14 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_support::weights::SimpleDispatchInfo;
|
||||
/// # use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
/// # use frame_system::{self as system, Trait, ensure_signed};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
///
|
||||
/// // Private functions are dispatchable, but not available to other
|
||||
/// // FRAME pallets.
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// fn my_function(origin, var: u64) -> dispatch::DispatchResult {
|
||||
/// // Your implementation
|
||||
/// Ok(())
|
||||
@@ -89,7 +89,7 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
///
|
||||
/// // Public functions are both dispatchable and available to other
|
||||
/// // FRAME pallets.
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// pub fn my_public_function(origin) -> dispatch::DispatchResult {
|
||||
/// // Your implementation
|
||||
/// Ok(())
|
||||
@@ -117,17 +117,17 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_support::weights::SimpleDispatchInfo;
|
||||
/// # use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
/// # use frame_system::{self as system, Trait, ensure_signed};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// fn my_long_function(origin) -> dispatch::DispatchResult {
|
||||
/// // Your implementation
|
||||
/// Ok(())
|
||||
/// }
|
||||
///
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// fn my_short_function(origin) {
|
||||
/// // Your implementation
|
||||
/// }
|
||||
@@ -182,11 +182,11 @@ impl<T> Parameter for T where T: Codec + EncodeLike + Clone + Eq + fmt::Debug {}
|
||||
/// # #[macro_use]
|
||||
/// # extern crate frame_support;
|
||||
/// # use frame_support::dispatch;
|
||||
/// # use frame_support::weights::SimpleDispatchInfo;
|
||||
/// # use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
/// # use frame_system::{self as system, Trait, ensure_signed, ensure_root};
|
||||
/// decl_module! {
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// fn my_privileged_function(origin) -> dispatch::DispatchResult {
|
||||
/// ensure_root(origin)?;
|
||||
/// // Your implementation
|
||||
@@ -2086,7 +2086,7 @@ macro_rules! __check_reserved_fn_name {
|
||||
#[allow(dead_code)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::weights::{DispatchInfo, DispatchClass};
|
||||
use crate::weights::{MINIMUM_WEIGHT, DispatchInfo, DispatchClass};
|
||||
use crate::traits::{
|
||||
CallMetadata, GetCallMetadata, GetCallName, OnInitialize, OnFinalize, OnRuntimeUpgrade
|
||||
};
|
||||
@@ -2112,22 +2112,22 @@ mod tests {
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, T::AccountId: From<u32> {
|
||||
/// Hi, this is a comment.
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_0(_origin) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_1(_origin, #[compact] _data: u32,) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_2(_origin, _data: i32, _data2: String) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(3)]
|
||||
fn aux_3(_origin) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_4(_origin, _data: i32) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_5(_origin, _data: i32, #[compact] _data2: u32,) -> DispatchResult { unreachable!() }
|
||||
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(5)]
|
||||
@@ -2291,11 +2291,6 @@ mod tests {
|
||||
Call::<TraitImpl>::operational().get_dispatch_info(),
|
||||
DispatchInfo { weight: 5, class: DispatchClass::Operational, pays_fee: true },
|
||||
);
|
||||
// default weight.
|
||||
assert_eq!(
|
||||
Call::<TraitImpl>::aux_0().get_dispatch_info(),
|
||||
DispatchInfo { weight: 10_000, class: DispatchClass::Normal, pays_fee: true },
|
||||
);
|
||||
// custom basic
|
||||
assert_eq!(
|
||||
Call::<TraitImpl>::aux_3().get_dispatch_info(),
|
||||
|
||||
@@ -35,7 +35,7 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent};
|
||||
///
|
||||
/// ```
|
||||
/// # use frame_support::{decl_error, decl_module};
|
||||
/// # use frame_support::weights::SimpleDispatchInfo;
|
||||
/// # use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
/// decl_error! {
|
||||
/// /// Errors that can occur in my module.
|
||||
/// pub enum MyError for Module<T: Trait> {
|
||||
@@ -55,7 +55,7 @@ pub use frame_metadata::{ModuleErrorMetadata, ErrorMetadata, DecodeDifferent};
|
||||
/// pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
/// type Error = MyError<T>;
|
||||
///
|
||||
/// #[weight = SimpleDispatchInfo::default()]
|
||||
/// #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
/// fn do_something(origin) -> frame_support::dispatch::DispatchResult {
|
||||
/// Err(MyError::<T>::YouAreNotCoolEnough.into())
|
||||
/// }
|
||||
|
||||
@@ -334,7 +334,7 @@ mod tests {
|
||||
|
||||
mod event_module {
|
||||
use crate::dispatch::DispatchResult;
|
||||
use crate::weights::SimpleDispatchInfo;
|
||||
use crate::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
|
||||
pub trait Trait: super::system::Trait {
|
||||
type Balance;
|
||||
@@ -352,7 +352,7 @@ mod tests {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
type Error = Error<T>;
|
||||
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn aux_0(_origin) -> DispatchResult { unreachable!() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,13 @@ use crate::dispatch::{DispatchErrorWithPostInfo, DispatchError};
|
||||
pub use sp_runtime::transaction_validity::TransactionPriority;
|
||||
|
||||
/// Numeric range of a transaction weight.
|
||||
pub type Weight = u32;
|
||||
///
|
||||
/// FRAME assumes a weight of `1_000_000_000_000` equals 1 second of compute on a standard
|
||||
/// machine: (TODO: DEFINE STANDARD MACHINE SPECIFICATIONS)
|
||||
pub type Weight = u64;
|
||||
|
||||
/// The smallest total weight an extrinsic should have.
|
||||
pub const MINIMUM_WEIGHT: Weight = 10_000_000;
|
||||
|
||||
/// Means of weighing some particular kind of data (`T`).
|
||||
pub trait WeighData<T> {
|
||||
@@ -106,6 +112,25 @@ impl Default for DispatchClass {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement traits for raw Weight value
|
||||
impl<T> WeighData<T> for Weight {
|
||||
fn weigh_data(&self, _: T) -> Weight {
|
||||
return *self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ClassifyDispatch<T> for Weight {
|
||||
fn classify_dispatch(&self, _: T) -> DispatchClass {
|
||||
DispatchClass::default()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> PaysFee<T> for Weight {
|
||||
fn pays_fee(&self, _: T) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SimpleDispatchInfo> for DispatchClass {
|
||||
fn from(tx: SimpleDispatchInfo) -> Self {
|
||||
match tx {
|
||||
@@ -281,13 +306,6 @@ impl<T> PaysFee<T> for SimpleDispatchInfo {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SimpleDispatchInfo {
|
||||
fn default() -> Self {
|
||||
// Default weight of all transactions.
|
||||
SimpleDispatchInfo::FixedNormal(10_000)
|
||||
}
|
||||
}
|
||||
|
||||
impl SimpleDispatchInfo {
|
||||
/// An _additive zero_ variant of SimpleDispatchInfo.
|
||||
pub fn zero() -> Self {
|
||||
@@ -390,24 +408,56 @@ impl<Call: Encode, Extra: Encode> GetDispatchInfo for sp_runtime::testing::TestX
|
||||
}
|
||||
}
|
||||
|
||||
/// The weight of database operations that the runtime can invoke.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode)]
|
||||
pub struct RuntimeDbWeight {
|
||||
pub read: Weight,
|
||||
pub write: Weight,
|
||||
}
|
||||
|
||||
impl RuntimeDbWeight {
|
||||
pub fn reads(self, r: Weight) -> Weight {
|
||||
self.read.saturating_mul(r)
|
||||
}
|
||||
|
||||
pub fn writes(self, w: Weight) -> Weight {
|
||||
self.write.saturating_mul(w)
|
||||
}
|
||||
|
||||
pub fn reads_writes(self, r: Weight, w: Weight) -> Weight {
|
||||
let read_weight = self.read.saturating_mul(r);
|
||||
let write_weight = self.write.saturating_mul(w);
|
||||
read_weight.saturating_add(write_weight)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[allow(dead_code)]
|
||||
mod tests {
|
||||
use crate::decl_module;
|
||||
use crate::{decl_module, parameter_types, traits::Get};
|
||||
use super::*;
|
||||
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
type Balance;
|
||||
type BlockNumber;
|
||||
type DbWeight: Get<RuntimeDbWeight>;
|
||||
}
|
||||
|
||||
pub struct TraitImpl {}
|
||||
|
||||
parameter_types! {
|
||||
pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight {
|
||||
read: 100,
|
||||
write: 1000,
|
||||
};
|
||||
}
|
||||
|
||||
impl Trait for TraitImpl {
|
||||
type Origin = u32;
|
||||
type BlockNumber = u32;
|
||||
type Balance = u32;
|
||||
type DbWeight = DbWeight;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
@@ -417,18 +467,30 @@ mod tests {
|
||||
fn f0(_origin) { unimplemented!(); }
|
||||
|
||||
// weight = a x 10 + b
|
||||
#[weight = FunctionOf(|args: (&u32, &u32)| args.0 * 10 + args.1, DispatchClass::Normal, true)]
|
||||
#[weight = FunctionOf(|args: (&u32, &u32)| (args.0 * 10 + args.1) as Weight, DispatchClass::Normal, true)]
|
||||
fn f11(_origin, _a: u32, _eb: u32) { unimplemented!(); }
|
||||
|
||||
#[weight = FunctionOf(|_: (&u32, &u32)| 0, DispatchClass::Operational, true)]
|
||||
fn f12(_origin, _a: u32, _eb: u32) { unimplemented!(); }
|
||||
|
||||
#[weight = T::DbWeight::get().reads(3) + T::DbWeight::get().writes(2) + 10_000]
|
||||
fn f2(_origin) { unimplemented!(); }
|
||||
|
||||
#[weight = T::DbWeight::get().reads_writes(6, 5) + 40_000]
|
||||
fn f21(_origin) { unimplemented!(); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn weights_are_correct() {
|
||||
assert_eq!(Call::<TraitImpl>::f0().get_dispatch_info().weight, 1000);
|
||||
assert_eq!(Call::<TraitImpl>::f11(10, 20).get_dispatch_info().weight, 120);
|
||||
assert_eq!(Call::<TraitImpl>::f11(10, 20).get_dispatch_info().class, DispatchClass::Normal);
|
||||
assert_eq!(Call::<TraitImpl>::f0().get_dispatch_info().weight, 1000);
|
||||
assert_eq!(Call::<TraitImpl>::f12(10, 20).get_dispatch_info().weight, 0);
|
||||
assert_eq!(Call::<TraitImpl>::f12(10, 20).get_dispatch_info().class, DispatchClass::Operational);
|
||||
assert_eq!(Call::<TraitImpl>::f2().get_dispatch_info().weight, 12300);
|
||||
assert_eq!(Call::<TraitImpl>::f21().get_dispatch_info().weight, 45600);
|
||||
assert_eq!(Call::<TraitImpl>::f2().get_dispatch_info().class, DispatchClass::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
use sp_runtime::{generic, traits::{BlakeTwo256, Block as _, Verify}, DispatchError};
|
||||
use sp_core::{H256, sr25519};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
|
||||
mod system;
|
||||
|
||||
@@ -32,7 +33,7 @@ mod module1 {
|
||||
pub struct Module<T: Trait<I>, I: Instance = DefaultInstance> for enum Call
|
||||
where origin: <T as system::Trait>::Origin
|
||||
{
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
Err(Error::<T, I>::Something.into())
|
||||
}
|
||||
@@ -59,7 +60,7 @@ mod module2 {
|
||||
pub struct Module<T: Trait> for enum Call
|
||||
where origin: <T as system::Trait>::Origin
|
||||
{
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn fail(_origin) -> frame_support::dispatch::DispatchResult {
|
||||
Err(Error::<T>::Something.into())
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ use frame_support::{
|
||||
DecodeDifferent, StorageMetadata, StorageEntryModifier, StorageEntryType, DefaultByteGetter,
|
||||
StorageEntryMetadata, StorageHasher,
|
||||
},
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
StorageValue, StorageMap, StorageDoubleMap,
|
||||
};
|
||||
use sp_inherents::{ProvideInherent, InherentData, InherentIdentifier, MakeFatalError};
|
||||
@@ -55,7 +56,7 @@ mod module1 {
|
||||
|
||||
fn deposit_event() = default;
|
||||
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn one(origin) {
|
||||
system::ensure_root(origin)?;
|
||||
Self::deposit_event(RawEvent::AnotherVariant(3));
|
||||
|
||||
@@ -2,7 +2,7 @@ macro_rules! reserved {
|
||||
($($reserved:ident)*) => {
|
||||
$(
|
||||
mod $reserved {
|
||||
pub use frame_support::dispatch;
|
||||
pub use frame_support::{dispatch, weights::{SimpleDispatchInfo, MINIMUM_WEIGHT}};
|
||||
|
||||
pub trait Trait {
|
||||
type Origin;
|
||||
@@ -19,7 +19,7 @@ macro_rules! reserved {
|
||||
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn $reserved(_origin) -> dispatch::DispatchResult { unreachable!() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ impl system::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -68,14 +68,14 @@
|
||||
//! ### Example - Get extrinsic count and parent hash for the current block
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch, weights::SimpleDispatchInfo};
|
||||
//! use frame_support::{decl_module, dispatch, weights::{SimpleDispatchInfo, MINIMUM_WEIGHT}};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//!
|
||||
//! pub trait Trait: system::Trait {}
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn system_module_example(origin) -> dispatch::DispatchResult {
|
||||
//! let _sender = ensure_signed(origin)?;
|
||||
//! let _extrinsic_count = <system::Module<T>>::extrinsic_count();
|
||||
@@ -120,7 +120,7 @@ use frame_support::{
|
||||
Contains, Get, ModuleToIndex, OnNewAccount, OnKilledAccount, IsDeadAccount, Happened,
|
||||
StoredMap, EnsureOrigin,
|
||||
},
|
||||
weights::{Weight, DispatchInfo, PostDispatchInfo, DispatchClass, SimpleDispatchInfo, FunctionOf}
|
||||
weights::{Weight, MINIMUM_WEIGHT, RuntimeDbWeight, DispatchInfo, PostDispatchInfo, DispatchClass, SimpleDispatchInfo, FunctionOf}
|
||||
};
|
||||
use codec::{Encode, Decode, FullCodec, EncodeLike};
|
||||
|
||||
@@ -195,6 +195,9 @@ pub trait Trait: 'static + Eq + Clone {
|
||||
/// The maximum weight of a block.
|
||||
type MaximumBlockWeight: Get<Weight>;
|
||||
|
||||
/// The weight of runtime database operations the runtime can invoke.
|
||||
type DbWeight: Get<RuntimeDbWeight>;
|
||||
|
||||
/// The maximum length of a block (in bytes).
|
||||
type MaximumBlockLength: Get<u32>;
|
||||
|
||||
@@ -482,20 +485,20 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Make some on-chain remark.
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn remark(origin, _remark: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
}
|
||||
|
||||
/// Set the number of pages in the WebAssembly environment's heap.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn set_heap_pages(origin, pages: u64) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::put_raw(well_known_keys::HEAP_PAGES, &pages.encode());
|
||||
}
|
||||
|
||||
/// Set the new runtime code.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
pub fn set_code(origin, code: Vec<u8>) {
|
||||
Self::can_set_code(origin, &code)?;
|
||||
|
||||
@@ -504,7 +507,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set the new runtime code without doing any checks of the given `code`.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200_000_000)]
|
||||
pub fn set_code_without_checks(origin, code: Vec<u8>) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::put_raw(well_known_keys::CODE, &code);
|
||||
@@ -512,7 +515,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set the new changes trie configuration.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(20_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(20_000_000)]
|
||||
pub fn set_changes_trie_config(origin, changes_trie_config: Option<ChangesTrieConfiguration>) {
|
||||
ensure_root(origin)?;
|
||||
match changes_trie_config.clone() {
|
||||
@@ -530,7 +533,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Set some items of storage.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn set_storage(origin, items: Vec<KeyValue>) {
|
||||
ensure_root(origin)?;
|
||||
for i in &items {
|
||||
@@ -539,7 +542,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Kill some items from storage.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn kill_storage(origin, keys: Vec<Key>) {
|
||||
ensure_root(origin)?;
|
||||
for key in &keys {
|
||||
@@ -548,7 +551,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Kill all storage items with a key that starts with the given prefix.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(MINIMUM_WEIGHT)]
|
||||
fn kill_prefix(origin, prefix: Key) {
|
||||
ensure_root(origin)?;
|
||||
storage::unhashed::kill_prefix(&prefix);
|
||||
@@ -556,7 +559,7 @@ decl_module! {
|
||||
|
||||
/// Kill the sending account, assuming there are no references outstanding and the composite
|
||||
/// data is equal to its default value.
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(25_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(25_000_000)]
|
||||
fn suicide(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let account = Account::<T>::get(&who);
|
||||
@@ -1652,6 +1655,7 @@ mod tests {
|
||||
type Event = u16;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = Version;
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
//!
|
||||
//! ```
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
//! # use pallet_timestamp as timestamp;
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//!
|
||||
@@ -69,7 +70,7 @@
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
//! #[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
//! pub fn get_time(origin) -> dispatch::DispatchResult {
|
||||
//! let _sender = ensure_signed(origin)?;
|
||||
//! let _now = <timestamp::Module<T>>::get();
|
||||
@@ -100,7 +101,7 @@ use frame_support::debug;
|
||||
use frame_support::{
|
||||
Parameter, decl_storage, decl_module,
|
||||
traits::{Time, UnixTime, Get},
|
||||
weights::SimpleDispatchInfo,
|
||||
weights::{SimpleDispatchInfo, MINIMUM_WEIGHT},
|
||||
};
|
||||
use sp_runtime::{
|
||||
RuntimeString,
|
||||
@@ -147,7 +148,7 @@ decl_module! {
|
||||
/// `MinimumPeriod`.
|
||||
///
|
||||
/// The dispatch origin for this call must be `Inherent`.
|
||||
#[weight = SimpleDispatchInfo::FixedMandatory(10_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedMandatory(MINIMUM_WEIGHT)]
|
||||
fn set(origin, #[compact] now: T::Moment) {
|
||||
ensure_none(origin)?;
|
||||
assert!(!<Self as Store>::DidUpdate::exists(), "Timestamp must be updated only once in the block");
|
||||
@@ -301,6 +302,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -40,7 +40,7 @@ use frame_support::{
|
||||
dispatch::DispatchResult,
|
||||
};
|
||||
use sp_runtime::{
|
||||
Fixed64,
|
||||
Fixed128,
|
||||
transaction_validity::{
|
||||
TransactionPriority, ValidTransaction, InvalidTransaction, TransactionValidityError,
|
||||
TransactionValidity,
|
||||
@@ -52,7 +52,7 @@ use sp_runtime::{
|
||||
};
|
||||
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
|
||||
type Multiplier = Fixed64;
|
||||
type Multiplier = Fixed128;
|
||||
type BalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> =
|
||||
@@ -178,10 +178,10 @@ impl<T: Trait + Send + Sync> ChargeTransactionPayment<T> where
|
||||
let adjustable_fee = len_fee.saturating_add(weight_fee);
|
||||
let targeted_fee_adjustment = NextFeeMultiplier::get();
|
||||
// adjusted_fee = adjustable_fee + (adjustable_fee * targeted_fee_adjustment)
|
||||
let adjusted_fee = targeted_fee_adjustment.saturated_multiply_accumulate(adjustable_fee);
|
||||
let adjusted_fee = targeted_fee_adjustment.saturated_multiply_accumulate(adjustable_fee.saturated_into());
|
||||
|
||||
let base_fee = T::TransactionBaseFee::get();
|
||||
base_fee.saturating_add(adjusted_fee).saturating_add(tip)
|
||||
base_fee.saturating_add(adjusted_fee.saturated_into()).saturating_add(tip)
|
||||
} else {
|
||||
tip
|
||||
}
|
||||
@@ -307,6 +307,7 @@ impl<T: Trait + Send + Sync> SignedExtension for ChargeTransactionPayment<T> whe
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use core::num::NonZeroI128;
|
||||
use codec::Encode;
|
||||
use frame_support::{
|
||||
impl_outer_dispatch, impl_outer_origin, parameter_types,
|
||||
@@ -360,6 +361,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
@@ -595,7 +597,7 @@ mod tests {
|
||||
.execute_with(||
|
||||
{
|
||||
// all fees should be x1.5
|
||||
NextFeeMultiplier::put(Fixed64::from_rational(1, 2));
|
||||
NextFeeMultiplier::put(Fixed128::from_rational(1, NonZeroI128::new(2).unwrap()));
|
||||
let len = 10;
|
||||
|
||||
assert!(
|
||||
@@ -623,7 +625,7 @@ mod tests {
|
||||
.execute_with(||
|
||||
{
|
||||
// all fees should be x1.5
|
||||
NextFeeMultiplier::put(Fixed64::from_rational(1, 2));
|
||||
NextFeeMultiplier::put(Fixed128::from_rational(1, NonZeroI128::new(2).unwrap()));
|
||||
|
||||
assert_eq!(
|
||||
TransactionPayment::query_info(xt, len),
|
||||
@@ -652,7 +654,7 @@ mod tests {
|
||||
.execute_with(||
|
||||
{
|
||||
// Next fee multiplier is zero
|
||||
assert_eq!(NextFeeMultiplier::get(), Fixed64::from_natural(0));
|
||||
assert_eq!(NextFeeMultiplier::get(), Fixed128::from_natural(0));
|
||||
|
||||
// Tip only, no fees works
|
||||
let dispatch_info = DispatchInfo {
|
||||
@@ -692,7 +694,7 @@ mod tests {
|
||||
.execute_with(||
|
||||
{
|
||||
// Add a next fee multiplier
|
||||
NextFeeMultiplier::put(Fixed64::from_rational(1, 2)); // = 1/2 = .5
|
||||
NextFeeMultiplier::put(Fixed128::from_rational(1, NonZeroI128::new(2).unwrap())); // = 1/2 = .5
|
||||
// Base fee is unaffected by multiplier
|
||||
let dispatch_info = DispatchInfo {
|
||||
weight: 0,
|
||||
@@ -726,7 +728,7 @@ mod tests {
|
||||
{
|
||||
// Overflow is handled
|
||||
let dispatch_info = DispatchInfo {
|
||||
weight: <u32>::max_value(),
|
||||
weight: Weight::max_value(),
|
||||
class: DispatchClass::Operational,
|
||||
pays_fee: true,
|
||||
};
|
||||
|
||||
@@ -98,7 +98,7 @@ use frame_support::traits::{
|
||||
use sp_runtime::{Permill, ModuleId, Percent, RuntimeDebug, traits::{
|
||||
Zero, StaticLookup, AccountIdConversion, Saturating, Hash, BadOrigin
|
||||
}};
|
||||
use frame_support::weights::{Weight, WeighData, SimpleDispatchInfo};
|
||||
use frame_support::weights::{Weight, MINIMUM_WEIGHT, SimpleDispatchInfo};
|
||||
use frame_support::traits::{Contains, EnsureOrigin};
|
||||
use codec::{Encode, Decode};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
@@ -327,7 +327,7 @@ decl_module! {
|
||||
/// - Limited storage reads.
|
||||
/// - One DB change, one extra DB entry.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(500_000_000)]
|
||||
fn propose_spend(
|
||||
origin,
|
||||
#[compact] value: BalanceOf<T>,
|
||||
@@ -354,7 +354,7 @@ decl_module! {
|
||||
/// - Limited storage reads.
|
||||
/// - One DB clear.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000_000)]
|
||||
fn reject_proposal(origin, #[compact] proposal_id: ProposalIndex) {
|
||||
T::RejectOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -376,7 +376,7 @@ decl_module! {
|
||||
/// - Limited storage reads.
|
||||
/// - One DB change.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(100_000_000)]
|
||||
fn approve_proposal(origin, #[compact] proposal_id: ProposalIndex) {
|
||||
T::ApproveOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
@@ -405,7 +405,7 @@ decl_module! {
|
||||
/// - One storage mutation (codec `O(R)`).
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100_000_000)]
|
||||
fn report_awesome(origin, reason: Vec<u8>, who: T::AccountId) {
|
||||
let finder = ensure_signed(origin)?;
|
||||
|
||||
@@ -447,7 +447,7 @@ decl_module! {
|
||||
/// - Two storage removals (one read, codec `O(T)`).
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn retract_tip(origin, hash: T::Hash) {
|
||||
let who = ensure_signed(origin)?;
|
||||
let tip = Tips::<T>::get(&hash).ok_or(Error::<T>::UnknownTip)?;
|
||||
@@ -479,7 +479,7 @@ decl_module! {
|
||||
/// - Two storage insertions (codecs `O(R)`, `O(T)`), one read `O(1)`.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(150_000_000)]
|
||||
fn tip_new(origin, reason: Vec<u8>, who: T::AccountId, tip_value: BalanceOf<T>) {
|
||||
let tipper = ensure_signed(origin)?;
|
||||
ensure!(T::Tippers::contains(&tipper), BadOrigin);
|
||||
@@ -513,7 +513,7 @@ decl_module! {
|
||||
/// - One storage mutation (codec `O(T)`), one storage read `O(1)`.
|
||||
/// - Up to one event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn tip(origin, hash: T::Hash, tip_value: BalanceOf<T>) {
|
||||
let tipper = ensure_signed(origin)?;
|
||||
ensure!(T::Tippers::contains(&tipper), BadOrigin);
|
||||
@@ -539,7 +539,7 @@ decl_module! {
|
||||
/// - One storage retrieval (codec `O(T)`) and two removals.
|
||||
/// - Up to three balance operations.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(50_000_000)]
|
||||
fn close_tip(origin, hash: T::Hash) {
|
||||
ensure_signed(origin)?;
|
||||
|
||||
@@ -558,7 +558,7 @@ decl_module! {
|
||||
Self::spend_funds();
|
||||
}
|
||||
|
||||
SimpleDispatchInfo::default().weigh_data(())
|
||||
MINIMUM_WEIGHT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +56,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
|
||||
@@ -67,7 +67,7 @@ use sp_core::TypeId;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use frame_support::{decl_module, decl_event, decl_error, decl_storage, Parameter, ensure, RuntimeDebug};
|
||||
use frame_support::{traits::{Get, ReservableCurrency, Currency},
|
||||
weights::{GetDispatchInfo, DispatchClass,FunctionOf},
|
||||
weights::{Weight, GetDispatchInfo, DispatchClass, FunctionOf},
|
||||
dispatch::PostDispatchInfo,
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
@@ -317,7 +317,7 @@ decl_module! {
|
||||
/// # </weight>
|
||||
#[weight = FunctionOf(
|
||||
|args: (&u16, &Vec<T::AccountId>, &Option<Timepoint<T::BlockNumber>>, &Box<<T as Trait>::Call>)| {
|
||||
args.3.get_dispatch_info().weight + 10_000 * (args.1.len() as u32 + 1)
|
||||
args.3.get_dispatch_info().weight + 10_000 * (args.1.len() as Weight + 1)
|
||||
},
|
||||
|args: (&u16, &Vec<T::AccountId>, &Option<Timepoint<T::BlockNumber>>, &Box<<T as Trait>::Call>)| {
|
||||
args.3.get_dispatch_info().class
|
||||
@@ -418,7 +418,7 @@ decl_module! {
|
||||
/// # </weight>
|
||||
#[weight = FunctionOf(
|
||||
|args: (&u16, &Vec<T::AccountId>, &Option<Timepoint<T::BlockNumber>>, &[u8; 32])| {
|
||||
10_000 * (args.1.len() as u32 + 1)
|
||||
10_000 * (args.1.len() as Weight + 1)
|
||||
},
|
||||
DispatchClass::Normal,
|
||||
true
|
||||
@@ -493,7 +493,7 @@ decl_module! {
|
||||
/// # </weight>
|
||||
#[weight = FunctionOf(
|
||||
|args: (&u16, &Vec<T::AccountId>, &Timepoint<T::BlockNumber>, &[u8; 32])| {
|
||||
10_000 * (args.1.len() as u32 + 1)
|
||||
10_000 * (args.1.len() as Weight + 1)
|
||||
},
|
||||
DispatchClass::Normal,
|
||||
true
|
||||
|
||||
@@ -71,6 +71,7 @@ impl frame_system::Trait for Test {
|
||||
type Event = TestEvent;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
@@ -57,7 +57,7 @@ use frame_support::traits::{
|
||||
Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier,
|
||||
ExistenceRequirement, Get
|
||||
};
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
mod benchmarking;
|
||||
@@ -194,7 +194,7 @@ decl_module! {
|
||||
/// - One storage read (codec `O(1)`) and up to one removal.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn vest(origin) -> DispatchResult {
|
||||
let who = ensure_signed(origin)?;
|
||||
Self::update_lock(who)
|
||||
@@ -216,7 +216,7 @@ decl_module! {
|
||||
/// - One storage read (codec `O(1)`) and up to one removal.
|
||||
/// - One event.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
fn vest_other(origin, target: <T::Lookup as StaticLookup>::Source) -> DispatchResult {
|
||||
ensure_signed(origin)?;
|
||||
Self::update_lock(T::Lookup::lookup(target)?)
|
||||
@@ -236,7 +236,7 @@ decl_module! {
|
||||
/// - Creates a new storage entry, but is protected by a minimum transfer
|
||||
/// amount needed to succeed.
|
||||
/// # </weight>
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000_000)]
|
||||
pub fn vested_transfer(
|
||||
origin,
|
||||
target: <T::Lookup as StaticLookup>::Source,
|
||||
@@ -381,6 +381,7 @@ mod tests {
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
|
||||
Reference in New Issue
Block a user