Weights to u64 + Balances Weights (#5446)

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
Shawn Tabrizi
2020-04-16 10:43:18 +02:00
committed by GitHub
parent 1c7525fd4b
commit 980b635c8d
82 changed files with 636 additions and 428 deletions
+10 -9
View File
@@ -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 = ();