Use explicit call indices (#12891)

* frame-system: explicit call index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Use explicit call indices

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* pallet-template: explicit call index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* DNM: Temporarily require call_index

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Revert "DNM: Temporarily require call_index"

This reverts commit c4934e312e12af72ca05a8029d7da753a9c99346.

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Oliver Tale-Yazdi
2022-12-12 15:32:41 +01:00
committed by GitHub
parent 6e0453a298
commit 31f5119ecd
67 changed files with 403 additions and 0 deletions
+25
View File
@@ -831,6 +831,7 @@ pub mod pallet {
/// unless the `origin` falls below _existential deposit_ and gets removed as dust.
/// ------------------
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::bond())]
pub fn bond(
origin: OriginFor<T>,
@@ -900,6 +901,7 @@ pub mod pallet {
/// - Independent of the arguments. Insignificant complexity.
/// - O(1).
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::bond_extra())]
pub fn bond_extra(
origin: OriginFor<T>,
@@ -953,6 +955,7 @@ pub mod pallet {
/// Emits `Unbonded`.
///
/// See also [`Call::withdraw_unbonded`].
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::unbond())]
pub fn unbond(
origin: OriginFor<T>,
@@ -1032,6 +1035,7 @@ pub mod pallet {
/// Complexity O(S) where S is the number of slashing spans to remove
/// NOTE: Weight annotation is the kill scenario, we refund otherwise.
/// # </weight>
#[pallet::call_index(3)]
#[pallet::weight(T::WeightInfo::withdraw_unbonded_kill(*num_slashing_spans))]
pub fn withdraw_unbonded(
origin: OriginFor<T>,
@@ -1079,6 +1083,7 @@ pub mod pallet {
/// Effects will be felt at the beginning of the next era.
///
/// The dispatch origin for this call must be _Signed_ by the controller, not the stash.
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::validate())]
pub fn validate(origin: OriginFor<T>, prefs: ValidatorPrefs) -> DispatchResult {
let controller = ensure_signed(origin)?;
@@ -1122,6 +1127,7 @@ pub mod pallet {
/// which is capped at CompactAssignments::LIMIT (T::MaxNominations).
/// - Both the reads and writes follow a similar pattern.
/// # </weight>
#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::nominate(targets.len() as u32))]
pub fn nominate(
origin: OriginFor<T>,
@@ -1190,6 +1196,7 @@ pub mod pallet {
/// - Contains one read.
/// - Writes are limited to the `origin` account key.
/// # </weight>
#[pallet::call_index(6)]
#[pallet::weight(T::WeightInfo::chill())]
pub fn chill(origin: OriginFor<T>) -> DispatchResult {
let controller = ensure_signed(origin)?;
@@ -1214,6 +1221,7 @@ pub mod pallet {
/// - Read: Ledger
/// - Write: Payee
/// # </weight>
#[pallet::call_index(7)]
#[pallet::weight(T::WeightInfo::set_payee())]
pub fn set_payee(
origin: OriginFor<T>,
@@ -1242,6 +1250,7 @@ pub mod pallet {
/// - Read: Bonded, Ledger New Controller, Ledger Old Controller
/// - Write: Bonded, Ledger New Controller, Ledger Old Controller
/// # </weight>
#[pallet::call_index(8)]
#[pallet::weight(T::WeightInfo::set_controller())]
pub fn set_controller(
origin: OriginFor<T>,
@@ -1270,6 +1279,7 @@ pub mod pallet {
/// Weight: O(1)
/// Write: Validator Count
/// # </weight>
#[pallet::call_index(9)]
#[pallet::weight(T::WeightInfo::set_validator_count())]
pub fn set_validator_count(
origin: OriginFor<T>,
@@ -1294,6 +1304,7 @@ pub mod pallet {
/// # <weight>
/// Same as [`Self::set_validator_count`].
/// # </weight>
#[pallet::call_index(10)]
#[pallet::weight(T::WeightInfo::set_validator_count())]
pub fn increase_validator_count(
origin: OriginFor<T>,
@@ -1319,6 +1330,7 @@ pub mod pallet {
/// # <weight>
/// Same as [`Self::set_validator_count`].
/// # </weight>
#[pallet::call_index(11)]
#[pallet::weight(T::WeightInfo::set_validator_count())]
pub fn scale_validator_count(origin: OriginFor<T>, factor: Percent) -> DispatchResult {
ensure_root(origin)?;
@@ -1349,6 +1361,7 @@ pub mod pallet {
/// - Weight: O(1)
/// - Write: ForceEra
/// # </weight>
#[pallet::call_index(12)]
#[pallet::weight(T::WeightInfo::force_no_eras())]
pub fn force_no_eras(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
@@ -1372,6 +1385,7 @@ pub mod pallet {
/// - Weight: O(1)
/// - Write ForceEra
/// # </weight>
#[pallet::call_index(13)]
#[pallet::weight(T::WeightInfo::force_new_era())]
pub fn force_new_era(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
@@ -1382,6 +1396,7 @@ pub mod pallet {
/// Set the validators who cannot be slashed (if any).
///
/// The dispatch origin must be Root.
#[pallet::call_index(14)]
#[pallet::weight(T::WeightInfo::set_invulnerables(invulnerables.len() as u32))]
pub fn set_invulnerables(
origin: OriginFor<T>,
@@ -1395,6 +1410,7 @@ pub mod pallet {
/// Force a current staker to become completely unstaked, immediately.
///
/// The dispatch origin must be Root.
#[pallet::call_index(15)]
#[pallet::weight(T::WeightInfo::force_unstake(*num_slashing_spans))]
pub fn force_unstake(
origin: OriginFor<T>,
@@ -1420,6 +1436,7 @@ pub mod pallet {
/// The election process starts multiple blocks before the end of the era.
/// If this is called just before a new era is triggered, the election process may not
/// have enough blocks to get a result.
#[pallet::call_index(16)]
#[pallet::weight(T::WeightInfo::force_new_era_always())]
pub fn force_new_era_always(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
@@ -1432,6 +1449,7 @@ pub mod pallet {
/// Can be called by the `T::SlashCancelOrigin`.
///
/// Parameters: era and indices of the slashes for that era to kill.
#[pallet::call_index(17)]
#[pallet::weight(T::WeightInfo::cancel_deferred_slash(slash_indices.len() as u32))]
pub fn cancel_deferred_slash(
origin: OriginFor<T>,
@@ -1477,6 +1495,7 @@ pub mod pallet {
/// NOTE: weights are assuming that payouts are made to alive stash account (Staked).
/// Paying even a dead controller is cheaper weight-wise. We don't do any refunds here.
/// # </weight>
#[pallet::call_index(18)]
#[pallet::weight(T::WeightInfo::payout_stakers_alive_staked(
T::MaxNominatorRewardedPerValidator::get()
))]
@@ -1498,6 +1517,7 @@ pub mod pallet {
/// - Bounded by `MaxUnlockingChunks`.
/// - Storage changes: Can't increase storage, only decrease it.
/// # </weight>
#[pallet::call_index(19)]
#[pallet::weight(T::WeightInfo::rebond(T::MaxUnlockingChunks::get() as u32))]
pub fn rebond(
origin: OriginFor<T>,
@@ -1542,6 +1562,7 @@ pub mod pallet {
/// It can be called by anyone, as long as `stash` meets the above requirements.
///
/// Refunds the transaction fees upon successful execution.
#[pallet::call_index(20)]
#[pallet::weight(T::WeightInfo::reap_stash(*num_slashing_spans))]
pub fn reap_stash(
origin: OriginFor<T>,
@@ -1574,6 +1595,7 @@ pub mod pallet {
///
/// Note: Making this call only makes sense if you first set the validator preferences to
/// block any further nominations.
#[pallet::call_index(21)]
#[pallet::weight(T::WeightInfo::kick(who.len() as u32))]
pub fn kick(origin: OriginFor<T>, who: Vec<AccountIdLookupOf<T>>) -> DispatchResult {
let controller = ensure_signed(origin)?;
@@ -1621,6 +1643,7 @@ pub mod pallet {
/// to kick people under the new limits, `chill_other` should be called.
// We assume the worst case for this call is either: all items are set or all items are
// removed.
#[pallet::call_index(22)]
#[pallet::weight(
T::WeightInfo::set_staking_configs_all_set()
.max(T::WeightInfo::set_staking_configs_all_remove())
@@ -1681,6 +1704,7 @@ pub mod pallet {
///
/// This can be helpful if bond requirements are updated, and we need to remove old users
/// who do not satisfy these requirements.
#[pallet::call_index(23)]
#[pallet::weight(T::WeightInfo::chill_other())]
pub fn chill_other(origin: OriginFor<T>, controller: T::AccountId) -> DispatchResult {
// Anyone can call this function.
@@ -1743,6 +1767,7 @@ pub mod pallet {
/// Force a validator to have at least the minimum commission. This will not affect a
/// validator who already has a commission greater than or equal to the minimum. Any account
/// can call this.
#[pallet::call_index(24)]
#[pallet::weight(T::WeightInfo::force_apply_min_commission())]
pub fn force_apply_min_commission(
origin: OriginFor<T>,