Deprecate V1 Weights (#13699)

* Remove deprecated pallet calls

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

* Deprecate old weight

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

* Update Runtime API

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

* Fix tests

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

* Delete shitty code

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

* Fix doctest

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

* Update frame/alliance/src/lib.rs

Co-authored-by: Koute <koute@users.noreply.github.com>

* Add doc

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

* contracts: Use u64 as old weight type

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

* Update frame/contracts/src/lib.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Koute <koute@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-04-04 20:57:21 +02:00
committed by GitHub
parent 0766072393
commit 36957d6760
10 changed files with 107 additions and 171 deletions
+2 -54
View File
@@ -57,7 +57,7 @@ use frame_support::{
traits::{
Backing, ChangeMembers, EnsureOrigin, Get, GetBacking, InitializeMembers, StorageVersion,
},
weights::{OldWeight, Weight},
weights::Weight,
};
#[cfg(test)]
@@ -557,59 +557,7 @@ pub mod pallet {
}
}
/// Close a vote that is either approved, disapproved or whose voting period has ended.
///
/// May be called by any signed account in order to finish voting and close the proposal.
///
/// If called before the end of the voting period it will only close the vote if it is
/// has enough votes to be approved or disapproved.
///
/// If called after the end of the voting period abstentions are counted as rejections
/// unless there is a prime member set and the prime member cast an approval.
///
/// If the close operation completes successfully with disapproval, the transaction fee will
/// be waived. Otherwise execution of the approved operation will be charged to the caller.
///
/// + `proposal_weight_bound`: The maximum amount of weight consumed by executing the closed
/// proposal.
/// + `length_bound`: The upper bound for the length of the proposal in storage. Checked via
/// `storage::read` so it is `size_of::<u32>() == 4` larger than the pure length.
///
/// ## Complexity
/// - `O(B + M + P1 + P2)` where:
/// - `B` is `proposal` size in bytes (length-fee-bounded)
/// - `M` is members-count (code- and governance-bounded)
/// - `P1` is the complexity of `proposal` preimage.
/// - `P2` is proposal-count (code-bounded)
#[pallet::call_index(4)]
#[pallet::weight((
{
let b = *length_bound;
let m = T::MaxMembers::get();
let p1 = *proposal_weight_bound;
let p2 = T::MaxProposals::get();
T::WeightInfo::close_early_approved(b, m, p2)
.max(T::WeightInfo::close_early_disapproved(m, p2))
.max(T::WeightInfo::close_approved(b, m, p2))
.max(T::WeightInfo::close_disapproved(m, p2))
.saturating_add(p1.into())
},
DispatchClass::Operational
))]
#[allow(deprecated)]
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to `close`")]
pub fn close_old_weight(
origin: OriginFor<T>,
proposal_hash: T::Hash,
#[pallet::compact] index: ProposalIndex,
#[pallet::compact] proposal_weight_bound: OldWeight,
#[pallet::compact] length_bound: u32,
) -> DispatchResultWithPostInfo {
let proposal_weight_bound: Weight = proposal_weight_bound.into();
let _ = ensure_signed(origin)?;
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
}
// Index 4 was `close_old_weight`; it was removed due to weights v1 deprecation.
/// Disapprove a proposal, close, and remove it from the system, regardless of its current
/// state.