mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Weights to u64 + Balances Weights (#5446)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -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 = ();
|
||||
|
||||
Reference in New Issue
Block a user