Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 89f6547

Browse files
committed
Revert "Add storage size component to weights (#12277)"
This reverts commit 17c07af.
1 parent 40e113b commit 89f6547

File tree

20 files changed

+128
-531
lines changed

20 files changed

+128
-531
lines changed

frame/alliance/src/lib.rs

+11-51
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ use frame_support::{
120120
ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced,
121121
ReservableCurrency,
122122
},
123-
weights::{OldWeight, Weight},
123+
weights::Weight,
124124
};
125125
use pallet_identity::IdentityField;
126126

@@ -620,22 +620,25 @@ pub mod pallet {
620620
.max(T::WeightInfo::close_early_disapproved(x, y, p2))
621621
.max(T::WeightInfo::close_approved(b, x, y, p2))
622622
.max(T::WeightInfo::close_disapproved(x, y, p2))
623-
.saturating_add(p1.into())
623+
.saturating_add(p1)
624624
})]
625-
#[allow(deprecated)]
626-
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to use `close`")]
627-
pub fn close_old_weight(
625+
pub fn close(
628626
origin: OriginFor<T>,
629627
proposal_hash: T::Hash,
630628
#[pallet::compact] index: ProposalIndex,
631-
#[pallet::compact] proposal_weight_bound: OldWeight,
629+
#[pallet::compact] proposal_weight_bound: Weight,
632630
#[pallet::compact] length_bound: u32,
633631
) -> DispatchResultWithPostInfo {
634-
let proposal_weight_bound: Weight = proposal_weight_bound.into();
635632
let who = ensure_signed(origin)?;
636633
ensure!(Self::has_voting_rights(&who), Error::<T, I>::NoVotingRights);
637634

638-
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
635+
let info = T::ProposalProvider::close_proposal(
636+
proposal_hash,
637+
index,
638+
proposal_weight_bound,
639+
length_bound,
640+
)?;
641+
Ok(info.into())
639642
}
640643

641644
/// Initialize the Alliance, onboard founders, fellows, and allies.
@@ -982,34 +985,6 @@ pub mod pallet {
982985
Self::deposit_event(Event::UnscrupulousItemRemoved { items });
983986
Ok(())
984987
}
985-
986-
/// Close a vote that is either approved, disapproved, or whose voting period has ended.
987-
///
988-
/// Requires the sender to be a founder or fellow.
989-
#[pallet::weight({
990-
let b = *length_bound;
991-
let x = T::MaxFounders::get();
992-
let y = T::MaxFellows::get();
993-
let p1 = *proposal_weight_bound;
994-
let p2 = T::MaxProposals::get();
995-
T::WeightInfo::close_early_approved(b, x, y, p2)
996-
.max(T::WeightInfo::close_early_disapproved(x, y, p2))
997-
.max(T::WeightInfo::close_approved(b, x, y, p2))
998-
.max(T::WeightInfo::close_disapproved(x, y, p2))
999-
.saturating_add(p1)
1000-
})]
1001-
pub fn close(
1002-
origin: OriginFor<T>,
1003-
proposal_hash: T::Hash,
1004-
#[pallet::compact] index: ProposalIndex,
1005-
proposal_weight_bound: Weight,
1006-
#[pallet::compact] length_bound: u32,
1007-
) -> DispatchResultWithPostInfo {
1008-
let who = ensure_signed(origin)?;
1009-
ensure!(Self::has_voting_rights(&who), Error::<T, I>::NoVotingRights);
1010-
1011-
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
1012-
}
1013988
}
1014989
}
1015990

@@ -1222,19 +1197,4 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
12221197
}
12231198
res
12241199
}
1225-
1226-
fn do_close(
1227-
proposal_hash: T::Hash,
1228-
index: ProposalIndex,
1229-
proposal_weight_bound: Weight,
1230-
length_bound: u32,
1231-
) -> DispatchResultWithPostInfo {
1232-
let info = T::ProposalProvider::close_proposal(
1233-
proposal_hash,
1234-
index,
1235-
proposal_weight_bound,
1236-
length_bound,
1237-
)?;
1238-
Ok(info.into())
1239-
}
12401200
}

frame/babe/src/tests.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,7 @@ fn valid_equivocation_reports_dont_pay_fees() {
852852
.get_dispatch_info();
853853

854854
// it should have non-zero weight and the fee has to be paid.
855-
// TODO: account for proof size weight
856-
assert!(info.weight.ref_time() > 0);
855+
assert!(info.weight.all_gt(Weight::zero()));
857856
assert_eq!(info.pays_fee, Pays::Yes);
858857

859858
// report the equivocation.

frame/collective/src/lib.rs

+4-65
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use frame_support::{
5757
traits::{
5858
Backing, ChangeMembers, EnsureOrigin, Get, GetBacking, InitializeMembers, StorageVersion,
5959
},
60-
weights::{OldWeight, Weight},
60+
weights::Weight,
6161
};
6262

6363
#[cfg(test)]
@@ -620,20 +620,17 @@ pub mod pallet {
620620
.max(T::WeightInfo::close_early_disapproved(m, p2))
621621
.max(T::WeightInfo::close_approved(b, m, p2))
622622
.max(T::WeightInfo::close_disapproved(m, p2))
623-
.saturating_add(p1.into())
623+
.saturating_add(p1)
624624
},
625625
DispatchClass::Operational
626626
))]
627-
#[allow(deprecated)]
628-
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to `close`")]
629-
pub fn close_old_weight(
627+
pub fn close(
630628
origin: OriginFor<T>,
631629
proposal_hash: T::Hash,
632630
#[pallet::compact] index: ProposalIndex,
633-
#[pallet::compact] proposal_weight_bound: OldWeight,
631+
#[pallet::compact] proposal_weight_bound: Weight,
634632
#[pallet::compact] length_bound: u32,
635633
) -> DispatchResultWithPostInfo {
636-
let proposal_weight_bound: Weight = proposal_weight_bound.into();
637634
let _ = ensure_signed(origin)?;
638635

639636
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
@@ -662,64 +659,6 @@ pub mod pallet {
662659
let proposal_count = Self::do_disapprove_proposal(proposal_hash);
663660
Ok(Some(T::WeightInfo::disapprove_proposal(proposal_count)).into())
664661
}
665-
666-
/// Close a vote that is either approved, disapproved or whose voting period has ended.
667-
///
668-
/// May be called by any signed account in order to finish voting and close the proposal.
669-
///
670-
/// If called before the end of the voting period it will only close the vote if it is
671-
/// has enough votes to be approved or disapproved.
672-
///
673-
/// If called after the end of the voting period abstentions are counted as rejections
674-
/// unless there is a prime member set and the prime member cast an approval.
675-
///
676-
/// If the close operation completes successfully with disapproval, the transaction fee will
677-
/// be waived. Otherwise execution of the approved operation will be charged to the caller.
678-
///
679-
/// + `proposal_weight_bound`: The maximum amount of weight consumed by executing the closed
680-
/// proposal.
681-
/// + `length_bound`: The upper bound for the length of the proposal in storage. Checked via
682-
/// `storage::read` so it is `size_of::<u32>() == 4` larger than the pure length.
683-
///
684-
/// # <weight>
685-
/// ## Weight
686-
/// - `O(B + M + P1 + P2)` where:
687-
/// - `B` is `proposal` size in bytes (length-fee-bounded)
688-
/// - `M` is members-count (code- and governance-bounded)
689-
/// - `P1` is the complexity of `proposal` preimage.
690-
/// - `P2` is proposal-count (code-bounded)
691-
/// - DB:
692-
/// - 2 storage reads (`Members`: codec `O(M)`, `Prime`: codec `O(1)`)
693-
/// - 3 mutations (`Voting`: codec `O(M)`, `ProposalOf`: codec `O(B)`, `Proposals`: codec
694-
/// `O(P2)`)
695-
/// - any mutations done while executing `proposal` (`P1`)
696-
/// - up to 3 events
697-
/// # </weight>
698-
#[pallet::weight((
699-
{
700-
let b = *length_bound;
701-
let m = T::MaxMembers::get();
702-
let p1 = *proposal_weight_bound;
703-
let p2 = T::MaxProposals::get();
704-
T::WeightInfo::close_early_approved(b, m, p2)
705-
.max(T::WeightInfo::close_early_disapproved(m, p2))
706-
.max(T::WeightInfo::close_approved(b, m, p2))
707-
.max(T::WeightInfo::close_disapproved(m, p2))
708-
.saturating_add(p1)
709-
},
710-
DispatchClass::Operational
711-
))]
712-
pub fn close(
713-
origin: OriginFor<T>,
714-
proposal_hash: T::Hash,
715-
#[pallet::compact] index: ProposalIndex,
716-
proposal_weight_bound: Weight,
717-
#[pallet::compact] length_bound: u32,
718-
) -> DispatchResultWithPostInfo {
719-
let _ = ensure_signed(origin)?;
720-
721-
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
722-
}
723662
}
724663
}
725664

0 commit comments

Comments
 (0)