From c5c45e757d67d4cb3dde6cf16e30143d52191efb Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Mon, 20 Apr 2020 21:19:17 +0200 Subject: [PATCH 1/2] Update vesting weights --- frame/vesting/src/lib.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index 6da92ea15a479..ea6f52ab00a38 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -190,11 +190,12 @@ decl_module! { /// /// # /// - `O(1)`. - /// - One balance-lock operation. - /// - One storage read (codec `O(1)`) and up to one removal. - /// - One event. + /// - DbWeight: 2 Reads, 2 Writes + /// - Reads: Vesting Storage, Balances Locks, [Sender Account] + /// - Writes: Vesting Storage, Balances Locks, [Sender Account] + /// - Benchmark: 147.5 µs (min square analysis) /// # - #[weight = MINIMUM_WEIGHT] + #[weight = 150_000_000 + T::DbWeight::get().reads_writes(2, 2)] fn vest(origin) -> DispatchResult { let who = ensure_signed(origin)?; Self::update_lock(who) @@ -211,12 +212,12 @@ decl_module! { /// /// # /// - `O(1)`. - /// - Up to one account lookup. - /// - One balance-lock operation. - /// - One storage read (codec `O(1)`) and up to one removal. - /// - One event. + /// - DbWeight: 3 Reads, 3 Writes + /// - Reads: Vesting Storage, Balances Locks, Target Account + /// - Writes: Vesting Storage, Balances Locks, Target Account + /// - Benchmark: 150.4 µs (min square analysis) /// # - #[weight = MINIMUM_WEIGHT] + #[weight = 150_000_000 + T::DbWeight::get().reads_writes(3, 3)] fn vest_other(origin, target: ::Source) -> DispatchResult { ensure_signed(origin)?; Self::update_lock(T::Lookup::lookup(target)?) @@ -233,10 +234,13 @@ decl_module! { /// Emits `VestingCreated`. /// /// # - /// - Creates a new storage entry, but is protected by a minimum transfer - /// amount needed to succeed. + /// - `O(1)`. + /// - DbWeight: 3 Reads, 3 Writes + /// - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account] + /// - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account] + /// - Benchmark: 263 µs (min square analysis) /// # - #[weight = 1_000_000_000] + #[weight = 260_000_000 + T::DbWeight::get().reads_writes(4, 4)] pub fn vested_transfer( origin, target: ::Source, From 613269c39f62f605aa85414e0baf3c4e58be0c96 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sat, 25 Apr 2020 17:07:24 +0200 Subject: [PATCH 2/2] Update weight numbers --- frame/vesting/src/lib.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frame/vesting/src/lib.rs b/frame/vesting/src/lib.rs index ea6f52ab00a38..b2941d7b8f6cf 100644 --- a/frame/vesting/src/lib.rs +++ b/frame/vesting/src/lib.rs @@ -194,8 +194,9 @@ decl_module! { /// - Reads: Vesting Storage, Balances Locks, [Sender Account] /// - Writes: Vesting Storage, Balances Locks, [Sender Account] /// - Benchmark: 147.5 µs (min square analysis) + /// - Assuming less than 50 locks on any user, else we may want factor in number of locks. /// # - #[weight = 150_000_000 + T::DbWeight::get().reads_writes(2, 2)] + #[weight = 150_000_000 + T::DbWeight::get().reads_writes(2, 2)] fn vest(origin) -> DispatchResult { let who = ensure_signed(origin)?; Self::update_lock(who) @@ -216,8 +217,9 @@ decl_module! { /// - Reads: Vesting Storage, Balances Locks, Target Account /// - Writes: Vesting Storage, Balances Locks, Target Account /// - Benchmark: 150.4 µs (min square analysis) + /// - Assuming less than 50 locks on any user, else we may want factor in number of locks. /// # - #[weight = 150_000_000 + T::DbWeight::get().reads_writes(3, 3)] + #[weight = 150_000_000 + T::DbWeight::get().reads_writes(3, 3)] fn vest_other(origin, target: ::Source) -> DispatchResult { ensure_signed(origin)?; Self::update_lock(T::Lookup::lookup(target)?) @@ -239,8 +241,9 @@ decl_module! { /// - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account] /// - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account] /// - Benchmark: 263 µs (min square analysis) + /// - Assuming less than 50 locks on any user, else we may want factor in number of locks. /// # - #[weight = 260_000_000 + T::DbWeight::get().reads_writes(4, 4)] + #[weight = 300_000_000 + T::DbWeight::get().reads_writes(3, 3)] pub fn vested_transfer( origin, target: ::Source,