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

substrate #9202 companion: Multiple vesting schedules #3407

Merged
23 commits merged into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
885bc80
substrate #9202 companion: Multiple vesting schedules
emostov Jul 5, 2021
28582bc
Update weights inline with substrate updates
emostov Jul 5, 2021
e878dae
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Jul 5, 2021
c29c285
Use 28 vesting schedules
emostov Jul 6, 2021
064b708
Add MaxSchedulesParam everywhere
emostov Jul 6, 2021
93554b3
Fix var name errors
emostov Jul 6, 2021
5a0716e
rever accidental changes to test-runtime
emostov Jul 6, 2021
398d65d
try merge origin master
emostov Jul 6, 2021
de9ed26
Revert "try merge origin master"
emostov Jul 6, 2021
81b0999
Merge branch 'master' into zeke-companion-multi-vest
emostov Jul 6, 2021
f9c8457
update to pass integrity test
emostov Jul 7, 2021
ed5d8a9
Make integrity tests work
emostov Jul 8, 2021
d6cdb92
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Jul 14, 2021
5dc2b53
Revert const to storage MinVestedTransfer
emostov Jul 18, 2021
0d32657
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Jul 20, 2021
f08d467
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Jul 22, 2021
8d25615
Use MAX_VESTING_SCHEDULES const
emostov Jul 22, 2021
681f4a8
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Jul 23, 2021
140d88a
Try merge origin master
emostov Aug 9, 2021
827e8ab
Merge remote-tracking branch 'origin' into zeke-companion-multi-vest
emostov Aug 19, 2021
91ba773
Update Cargo.lock to make it compile
emostov Aug 19, 2021
eaaa42d
Merge remote-tracking branch 'origin/master' into zeke-companion-mult…
Aug 24, 2021
cecc4c1
update Substrate
Aug 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ impl pallet_society::Config for Runtime {

parameter_types! {
pub const MinVestedTransfer: Balance = 100 * CENTS;
emostov marked this conversation as resolved.
Show resolved Hide resolved
pub const MaxVestingSchedules: u32 = 28;
}

impl pallet_vesting::Config for Runtime {
Expand All @@ -957,6 +958,7 @@ impl pallet_vesting::Config for Runtime {
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
type MaxVestingSchedules = MaxVestingSchedules;
}

parameter_types! {
Expand Down
76 changes: 50 additions & 26 deletions runtime/kusama/src/weights/pallet_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,70 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_vesting.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_vesting::WeightInfo for WeightInfo<T> {
fn vest_locked(l: u32, ) -> Weight {
(41_675_000 as Weight)
// Standard Error: 7_000
.saturating_add((159_000 as Weight).saturating_mul(l as Weight))
fn vest_locked(l: u32, s: u32, ) -> Weight {
(93_789_000 as Weight)
// Standard Error: 70_000
.saturating_add((41_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 182_000
.saturating_add((211_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vest_unlocked(l: u32, ) -> Weight {
(44_454_000 as Weight)
// Standard Error: 4_000
.saturating_add((129_000 as Weight).saturating_mul(l as Weight))
fn vest_unlocked(_l: u32, s: u32, ) -> Weight {
(90_737_000 as Weight)
// Standard Error: 0
.saturating_add((263_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))
}
fn vest_other_locked(l: u32, ) -> Weight {
(41_313_000 as Weight)
// Standard Error: 7_000
.saturating_add((161_000 as Weight).saturating_mul(l as Weight))
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
(85_211_000 as Weight)
// Standard Error: 17_000
.saturating_add((153_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((289_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn vest_other_unlocked(l: u32, ) -> Weight {
(44_088_000 as Weight)
// Standard Error: 4_000
.saturating_add((131_000 as Weight).saturating_mul(l as Weight))
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
(90_368_000 as Weight)
// Standard Error: 17_000
.saturating_add((31_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((132_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))
}
fn vested_transfer(l: u32, ) -> Weight {
(95_360_000 as Weight)
// Standard Error: 6_000
.saturating_add((152_000 as Weight).saturating_mul(l as Weight))
fn vested_transfer(l: u32, _s: u32, ) -> Weight {
(167_500_000 as Weight)
// Standard Error: 194_000
.saturating_add((255_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn force_vested_transfer(l: u32, ) -> Weight {
(94_577_000 as Weight)
// Standard Error: 6_000
.saturating_add((149_000 as Weight).saturating_mul(l as Weight))
fn force_vested_transfer(l: u32, _s: u32, ) -> Weight {
(174_000_000 as Weight)
// Standard Error: 70_000
.saturating_add((143_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(101_778_000 as Weight)
// Standard Error: 17_000
.saturating_add((194_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 48_000
.saturating_add((361_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))
}
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(104_111_000 as Weight)
// Standard Error: 88_000
.saturating_add((276_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 240_000
.saturating_add((194_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))
}
}
16 changes: 16 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ impl claims::Config for Runtime {

parameter_types! {
pub const MinVestedTransfer: Balance = 1 * DOLLARS;
pub const MaxVestingSchedules: u32 = 28;
}

impl pallet_vesting::Config for Runtime {
Expand All @@ -839,6 +840,7 @@ impl pallet_vesting::Config for Runtime {
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
type MaxVestingSchedules = MaxVestingSchedules;
}

impl pallet_utility::Config for Runtime {
Expand Down Expand Up @@ -1592,4 +1594,18 @@ mod test_fees {
println!("can support {} nominators to yield a weight of {}", active, weight_with(active));
assert!(active > target_voters, "we need to reevaluate the weight of the election system");
}

#[test]
fn vesting_schedules_encoded_use_correct_space() {
use pallet_vesting::vesting_info::VestingInfo;
use frame_support::BoundedVec;
use parity_scale_codec::MaxEncodedLen;

let sched_len = VestingInfo::<Balance, BlockNumber>::max_encoded_len();
let vec_len = BoundedVec::<VestingInfo<Balance, BlockNumber>, MaxVestingSchedules>::max_encoded_len();

println!("Vesting schedules max encoded len: {} ({}).", vec_len, sched_len);
assert_eq!(sched_len, 36);
assert_eq!(vec_len, 1009);
}
emostov marked this conversation as resolved.
Show resolved Hide resolved
}
77 changes: 51 additions & 26 deletions runtime/polkadot/src/weights/pallet_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,71 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_vesting.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_vesting::WeightInfo for WeightInfo<T> {
fn vest_locked(l: u32, ) -> Weight {
(40_549_000 as Weight)
// Standard Error: 7_000
.saturating_add((162_000 as Weight).saturating_mul(l as Weight))
fn vest_locked(l: u32, s: u32, ) -> Weight {
(93_789_000 as Weight)
// Standard Error: 70_000
.saturating_add((41_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 182_000
.saturating_add((211_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vest_unlocked(l: u32, ) -> Weight {
(43_713_000 as Weight)
// Standard Error: 4_000
.saturating_add((129_000 as Weight).saturating_mul(l as Weight))
fn vest_unlocked(_l: u32, s: u32, ) -> Weight {
(90_737_000 as Weight)
// Standard Error: 0
.saturating_add((263_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))
}
fn vest_other_locked(l: u32, ) -> Weight {
(40_331_000 as Weight)
// Standard Error: 7_000
.saturating_add((154_000 as Weight).saturating_mul(l as Weight))
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
(85_211_000 as Weight)
// Standard Error: 17_000
.saturating_add((153_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((289_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn vest_other_unlocked(l: u32, ) -> Weight {
(43_179_000 as Weight)
// Standard Error: 4_000
.saturating_add((130_000 as Weight).saturating_mul(l as Weight))
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
(90_368_000 as Weight)
// Standard Error: 17_000
.saturating_add((31_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((132_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))
}
fn vested_transfer(l: u32, ) -> Weight {
(92_890_000 as Weight)
// Standard Error: 5_000
.saturating_add((156_000 as Weight).saturating_mul(l as Weight))
fn vested_transfer(l: u32, _s: u32, ) -> Weight {
(167_500_000 as Weight)
// Standard Error: 194_000
.saturating_add((255_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn force_vested_transfer(l: u32, ) -> Weight {
(92_001_000 as Weight)
// Standard Error: 5_000
.saturating_add((155_000 as Weight).saturating_mul(l as Weight))
fn force_vested_transfer(l: u32, _s: u32, ) -> Weight {
(174_000_000 as Weight)
// Standard Error: 70_000
.saturating_add((143_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(101_778_000 as Weight)
// Standard Error: 17_000
.saturating_add((194_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 48_000
.saturating_add((361_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))
}
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(104_111_000 as Weight)
// Standard Error: 88_000
.saturating_add((276_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 240_000
.saturating_add((194_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))
}
}

2 changes: 2 additions & 0 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ impl pallet_recovery::Config for Runtime {

parameter_types! {
pub const MinVestedTransfer: Balance = 100 * CENTS;
pub const MaxVestingSchedules: u32 = 28;
}

impl pallet_vesting::Config for Runtime {
Expand All @@ -640,6 +641,7 @@ impl pallet_vesting::Config for Runtime {
type BlockNumberToBalance = ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
type MaxVestingSchedules = MaxVestingSchedules;
}

impl pallet_sudo::Config for Runtime {
Expand Down
76 changes: 50 additions & 26 deletions runtime/westend/src/weights/pallet_vesting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,70 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_vesting.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_vesting::WeightInfo for WeightInfo<T> {
fn vest_locked(l: u32, ) -> Weight {
(40_663_000 as Weight)
// Standard Error: 20_000
.saturating_add((232_000 as Weight).saturating_mul(l as Weight))
fn vest_locked(l: u32, s: u32, ) -> Weight {
(93_789_000 as Weight)
// Standard Error: 70_000
.saturating_add((41_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 182_000
.saturating_add((211_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn vest_unlocked(l: u32, ) -> Weight {
(44_310_000 as Weight)
// Standard Error: 11_000
.saturating_add((172_000 as Weight).saturating_mul(l as Weight))
fn vest_unlocked(_l: u32, s: u32, ) -> Weight {
(90_737_000 as Weight)
// Standard Error: 0
.saturating_add((263_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))
}
fn vest_other_locked(l: u32, ) -> Weight {
(40_981_000 as Weight)
// Standard Error: 19_000
.saturating_add((218_000 as Weight).saturating_mul(l as Weight))
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
(85_211_000 as Weight)
// Standard Error: 17_000
.saturating_add((153_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((289_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn vest_other_unlocked(l: u32, ) -> Weight {
(43_731_000 as Weight)
// Standard Error: 16_000
.saturating_add((194_000 as Weight).saturating_mul(l as Weight))
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
(90_368_000 as Weight)
// Standard Error: 17_000
.saturating_add((31_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 45_000
.saturating_add((132_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))
}
fn vested_transfer(l: u32, ) -> Weight {
(96_952_000 as Weight)
// Standard Error: 15_000
.saturating_add((206_000 as Weight).saturating_mul(l as Weight))
fn vested_transfer(l: u32, _s: u32, ) -> Weight {
(167_500_000 as Weight)
// Standard Error: 194_000
.saturating_add((255_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn force_vested_transfer(l: u32, ) -> Weight {
(96_519_000 as Weight)
// Standard Error: 15_000
.saturating_add((204_000 as Weight).saturating_mul(l as Weight))
fn force_vested_transfer(l: u32, _s: u32, ) -> Weight {
(174_000_000 as Weight)
// Standard Error: 70_000
.saturating_add((143_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(101_778_000 as Weight)
// Standard Error: 17_000
.saturating_add((194_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 48_000
.saturating_add((361_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))
}
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
(104_111_000 as Weight)
// Standard Error: 88_000
.saturating_add((276_000 as Weight).saturating_mul(l as Weight))
// Standard Error: 240_000
.saturating_add((194_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))
}
}