Files
pezkuwi-subxt/substrate/frame/vesting/src/weights.rs
T
Zeke Mostov ede36408a9 pallet-vesting: Support multiple, merge-able vesting schedules (#9202)
* Support multiple, mergable vesting schedules

* Update node runtime

* Remove some TODO design questions and put them as commennts

* Update frame/vesting/src/benchmarking.rs

* Syntax and comment clean up

* Create filter enum for removing schedules

* Dry vesting calls with do_vest

* Improve old benchmarks to account for max schedules

* Update WeightInfo trait and make dummy fns

* Add merge_schedule weights

* Explicitly test multiple vesting scheudles

* Make new vesting tests more more clear

* Apply suggestions from code review

* Update remove_vesting_schedule to error with no index

* Try reduce spacing diff

* Apply suggestions from code review

* Use get on vesting for bounds check; check origin first

* No filter tuple; various simplifications

* unwrap or default when getting user schedules

* spaces be gone

* ReadMe fixes

* Update frame/vesting/src/lib.rs

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* address some comments for docs

* merge sched docs

* Apply suggestions from code review

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* log error when trying to push to vesting vec

* use let Some, not is_some

* remove_vesting_schedule u32, not optin

* new not try_new, create validate builder; VestingInfo

* Merge prep: break out tests and mock

* Add files forgot to include in merge

* revert some accidental changes to merged files

* Revert remaining accidental file changes

* More revert of accidental file change

* Try to reduce diff on tests

* namespace Vesting; check key when key should not exist;

* ending_block throws error on per_block of 0

* Try improve merge vesting info comment

* Update frame/vesting/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* add validate + correct; handle duration > blocknumber

* Move vesting_info module to its own file

* Seperate Vesting/locks updates from writing

* Add can_add_vesting schedule

* Adjust min vested transfer to be greater than all ED

* Initial integrity test impl

* merge_finished_and_yet_to_be_started_schedules

* Make sure to assert storage items are cleaned up

* Migration initial impl (not tested)

* Correct try-runtime hooks

* Apply suggestions from code review

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* header

* WIP: improve benchmarks

* Benchmarking working

* benchmarking: step over max schedules

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_vesting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/vesting/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Simplify APIs by accepting vec; convert to bounded on write

* Test:  build_genesis_has_storage_version_v1

* Test more error cases

* Hack to get polkadot weights to work; should revert later

* Improve benchmarking; works on polkadot

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_vesting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/vesting/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* WIP override storage

* Set storage not working example

* Remove unused tests

* VestingInfo: make public, derive MaxEndcodedLen

* Rename ending_block to ending_block_as_balance

* Superificial improvements

* Check for end block infinite, not just duration

* More superficial update

* Update tests

* Test vest with multi schedule

* Don't use half max balance in benchmarks

* Use debug_assert when locked is unexpected 0

* Implement exec_action

* Simplify per_block calc in vesting_info

* VestingInfo.validate in add_vesting_schedule & can_add_vesting_schedule

* Simplify post migrate check

* Remove merge event

* Minor benchmarking updates

* Remove VestingInfo.correct

* per_block accesor max with 1

* Improve comment

* Remoe debug

* Fix add schedule comment

* Apply suggestions from code review

Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>

* no ref for should_remove param

* Remove unused vestingaction derive

* Asserts to show balance unlock in merge benchmark

* Remove unused imports

* trivial

* Fix benchmark asserts to handle non-multiple of 20 locked

* Add generate_storage_info

* migration :facepalm

* Remove per_block 0 logic

* Update frame/vesting/src/lib.rs

* Do not check for ending later than greatest block

* Apply suggestions from code review

* Benchmarks: simplify vesting schedule creation

* Add log back for migration

* Add note in ext docs explaining that all schedules will vest

* Make integrity test work

* Improve integrity test

* Remove unnescary type param from VestingInfo::new

* Remove unnescary resut for ending_block_as_balance

* Remove T param from ending_block_as_balance

* Reduce visibility of raw_per_block

* Remove unused type param for validate

* update old comment

* Make log a dep; log warn in migrate

* VestingInfo.validate returns Err(()), no T type param

* Try improve report_schedule_updates

* is_valid, not validate

* revert node runtime reorg;

* change schedule validity check to just warning

* Simplify merge_vesting_info return type

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Add warning for migration

* Fix indentation

* Delete duplicate warnings

* Reduce diff in node runtime

* Fix benchmark build

* Upgrade cargo.toml to use 4.0.0-dev

* Cleanup

* MaxVestingSchedulesGetter initial impl

* MinVestedTransfer getter inintial impl

* Test MaxVestingSchedules & MinVestedTransfer getters; use getters in benchmarks

* Run cargo fmt

* Revert MinVestedTransfer & MaxVestingSchedules getters; Add integrity test

* Make MAX_VESTING_SCHEDULES a const

* fmt

* WIP: benchmark improvements

* Finish benchmark update

* Add test for transfer to account with less than ed

* Rm min_new_account_transfer; move sp-io to dev-dep

* Reduce cargo.toml diff

* Explain MAX_VESTING_SCHEDULES choice

* Fix after merge

* Try fix CI complaints

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_vesting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/vesting/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_vesting --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/vesting/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* fmt

* trigger

* fmt

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: kianenigma <kian@parity.io>
2021-08-24 00:15:27 +00:00

254 lines
10 KiB
Rust

// This file is part of Substrate.
// Copyright (C) 2021 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for pallet_vesting
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2021-08-10, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
// Executed Command:
// target/release/substrate
// benchmark
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_vesting
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./frame/vesting/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_vesting.
pub trait WeightInfo {
fn vest_locked(l: u32, s: u32, ) -> Weight;
fn vest_unlocked(l: u32, s: u32, ) -> Weight;
fn vest_other_locked(l: u32, s: u32, ) -> Weight;
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight;
fn vested_transfer(l: u32, s: u32, ) -> Weight;
fn force_vested_transfer(l: u32, s: u32, ) -> Weight;
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight;
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight;
}
/// Weights for pallet_vesting using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vest_locked(l: u32, s: u32, ) -> Weight {
(50_642_000 as Weight)
// Standard Error: 1_000
.saturating_add((144_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((177_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vest_unlocked(l: u32, s: u32, ) -> Weight {
(50_830_000 as Weight)
// Standard Error: 1_000
.saturating_add((115_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((112_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
(52_151_000 as Weight)
// Standard Error: 1_000
.saturating_add((130_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((162_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
(51_009_000 as Weight)
// Standard Error: 4_000
.saturating_add((123_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 9_000
.saturating_add((118_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vested_transfer(l: u32, s: u32, ) -> Weight {
(89_517_000 as Weight)
// Standard Error: 5_000
.saturating_add((114_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 10_000
.saturating_add((23_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:2 w:2)
// Storage: Balances Locks (r:1 w:1)
fn force_vested_transfer(l: u32, s: u32, ) -> Weight {
(87_903_000 as Weight)
// Standard Error: 6_000
.saturating_add((121_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 12_000
.saturating_add((56_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(54_463_000 as Weight)
// Standard Error: 2_000
.saturating_add((123_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 5_000
.saturating_add((149_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(53_674_000 as Weight)
// Standard Error: 1_000
.saturating_add((137_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 4_000
.saturating_add((152_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vest_locked(l: u32, s: u32, ) -> Weight {
(50_642_000 as Weight)
// Standard Error: 1_000
.saturating_add((144_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((177_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vest_unlocked(l: u32, s: u32, ) -> Weight {
(50_830_000 as Weight)
// Standard Error: 1_000
.saturating_add((115_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((112_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
(52_151_000 as Weight)
// Standard Error: 1_000
.saturating_add((130_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 3_000
.saturating_add((162_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
(51_009_000 as Weight)
// Standard Error: 4_000
.saturating_add((123_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 9_000
.saturating_add((118_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
fn vested_transfer(l: u32, s: u32, ) -> Weight {
(89_517_000 as Weight)
// Standard Error: 5_000
.saturating_add((114_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 10_000
.saturating_add((23_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: System Account (r:2 w:2)
// Storage: Balances Locks (r:1 w:1)
fn force_vested_transfer(l: u32, s: u32, ) -> Weight {
(87_903_000 as Weight)
// Standard Error: 6_000
.saturating_add((121_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 12_000
.saturating_add((56_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(54_463_000 as Weight)
// Standard Error: 2_000
.saturating_add((123_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 5_000
.saturating_add((149_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
// Storage: Vesting Vesting (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(53_674_000 as Weight)
// Standard Error: 1_000
.saturating_add((137_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 4_000
.saturating_add((152_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
}