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

pallet-vesting: Support multiple, merge-able vesting schedules #9202

Merged
167 commits merged into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
167 commits
Select commit Hold shift + click to select a range
fd523c8
Support multiple, mergable vesting schedules
emostov Jun 25, 2021
73eb139
Update node runtime
emostov Jun 25, 2021
100bca1
Remove some TODO design questions and put them as commennts
emostov Jun 25, 2021
29898c4
Update frame/vesting/src/benchmarking.rs
emostov Jun 25, 2021
5a41c95
Syntax and comment clean up
emostov Jun 27, 2021
c891107
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jun 27, 2021
65eb0da
Create filter enum for removing schedules
emostov Jun 27, 2021
4c95ba2
Dry vesting calls with do_vest
emostov Jun 27, 2021
fe24ab1
Improve old benchmarks to account for max schedules
emostov Jun 28, 2021
ce92a01
Update WeightInfo trait and make dummy fns
emostov Jun 28, 2021
0f8fef8
Add merge_schedule weights
emostov Jun 28, 2021
08d5475
Explicitly test multiple vesting scheudles
emostov Jun 28, 2021
ce18c07
Make new vesting tests more more clear
emostov Jun 29, 2021
5e673b8
Apply suggestions from code review
emostov Jun 29, 2021
1c1a56d
Update remove_vesting_schedule to error with no index
emostov Jun 29, 2021
4ea964c
Try reduce spacing diff
emostov Jun 29, 2021
48d0ec4
Apply suggestions from code review
emostov Jun 29, 2021
1af7527
Use get on vesting for bounds check; check origin first
emostov Jun 29, 2021
fa3994d
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jun 29, 2021
b87b3c0
No filter tuple; various simplifications
emostov Jun 29, 2021
a429640
unwrap or default when getting user schedules
emostov Jun 29, 2021
bc35a10
spaces be gone
emostov Jun 29, 2021
ce49bc8
ReadMe fixes
emostov Jun 29, 2021
b0a7fed
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jun 29, 2021
0a23437
Update frame/vesting/src/lib.rs
emostov Jun 29, 2021
9225929
address some comments for docs
emostov Jun 29, 2021
5b50b07
Try merge origin master
emostov Jun 29, 2021
7fe0561
merge sched docs
emostov Jun 29, 2021
6c864c7
Apply suggestions from code review
emostov Jun 29, 2021
620535d
log error when trying to push to vesting vec
emostov Jun 29, 2021
383ddb6
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jun 29, 2021
afe25d2
use let Some, not is_some
emostov Jun 29, 2021
8abf51d
remove_vesting_schedule u32, not optin
emostov Jun 30, 2021
23b35d4
new not try_new, create validate builder; VestingInfo
emostov Jun 30, 2021
cb5121d
Merge prep: break out tests and mock
emostov Jun 30, 2021
1fa0abb
Try merge origin master (w/ move of tests and mock)
emostov Jun 30, 2021
52ae49f
Add files forgot to include in merge
emostov Jun 30, 2021
14510de
revert some accidental changes to merged files
emostov Jun 30, 2021
0d28e03
Revert remaining accidental file changes
emostov Jun 30, 2021
26ae627
More revert of accidental file change
emostov Jun 30, 2021
fed0878
Try to reduce diff on tests
emostov Jun 30, 2021
e60275d
namespace Vesting; check key when key should not exist;
emostov Jun 30, 2021
089f5da
ending_block throws error on per_block of 0
emostov Jun 30, 2021
3a3d227
Try improve merge vesting info comment
emostov Jun 30, 2021
0b27654
Update frame/vesting/src/lib.rs
emostov Jun 30, 2021
899859e
add validate + correct; handle duration > blocknumber
emostov Jun 30, 2021
9924ddd
Move vesting_info module to its own file
emostov Jun 30, 2021
4aaa158
Seperate Vesting/locks updates from writing
emostov Jul 1, 2021
14cfd86
Add can_add_vesting schedule
emostov Jul 1, 2021
482f1a5
Adjust min vested transfer to be greater than all ED
emostov Jul 4, 2021
f1a760e
Initial integrity test impl
emostov Jul 4, 2021
7929278
merge_finished_and_yet_to_be_started_schedules
emostov Jul 4, 2021
6b564d8
Make sure to assert storage items are cleaned up
emostov Jul 4, 2021
279386a
Migration initial impl (not tested)
emostov Jul 4, 2021
08da674
Correct try-runtime hooks
emostov Jul 4, 2021
66c8fd2
Apply suggestions from code review
emostov Jul 4, 2021
aa88b65
header
emostov Jul 4, 2021
62c3649
WIP: improve benchmarks
emostov Jul 4, 2021
3f8c303
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jul 4, 2021
652d3ee
Benchmarking working
emostov Jul 4, 2021
ec87a9a
benchmarking: step over max schedules
emostov Jul 4, 2021
5e76128
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 4, 2021
1b0eacb
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Jul 4, 2021
40fb449
Simplify APIs by accepting vec; convert to bounded on write
emostov Jul 4, 2021
879a65d
Test: build_genesis_has_storage_version_v1
emostov Jul 5, 2021
0b243e0
Test more error cases
emostov Jul 5, 2021
1b6d3ec
Hack to get polkadot weights to work; should revert later
emostov Jul 5, 2021
a5299c7
Improve benchmarking; works on polkadot
emostov Jul 5, 2021
d885218
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 5, 2021
d9c5488
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Jul 5, 2021
bd00ccc
WIP override storage
emostov Jul 5, 2021
bdeda40
Set storage not working example
emostov Jul 5, 2021
a42c8f6
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jul 5, 2021
9c699e4
Remove unused tests
emostov Jul 5, 2021
e5af45f
Merge remote-tracking branch 'origin' into zeke-multi-vest-2
emostov Jul 5, 2021
f5aee3b
VestingInfo: make public, derive MaxEndcodedLen
emostov Jul 6, 2021
e67c6c5
Rename ending_block to ending_block_as_balance
emostov Jul 6, 2021
defb875
Superificial improvements
emostov Jul 6, 2021
03e4399
Check for end block infinite, not just duration
emostov Jul 6, 2021
848a4ad
More superficial update
emostov Jul 6, 2021
b202ff8
Update tests
emostov Jul 6, 2021
38dfbcd
Test vest with multi schedule
emostov Jul 6, 2021
a9fca6d
Don't use half max balance in benchmarks
emostov Jul 6, 2021
96af8dd
Use debug_assert when locked is unexpected 0
emostov Jul 6, 2021
4d410f7
Implement exec_action
emostov Jul 6, 2021
c750bd8
Simplify per_block calc in vesting_info
emostov Jul 6, 2021
24214ac
VestingInfo.validate in add_vesting_schedule & can_add_vesting_schedule
emostov Jul 6, 2021
48dd1b5
Simplify post migrate check
emostov Jul 6, 2021
c3cae6b
Remove merge event
emostov Jul 6, 2021
05bf0c5
Minor benchmarking updates
emostov Jul 6, 2021
e4493d7
Remove VestingInfo.correct
emostov Jul 6, 2021
ee6a75d
per_block accesor max with 1
emostov Jul 6, 2021
ba7bc83
Improve comment
emostov Jul 6, 2021
bd8fed2
Remoe debug
emostov Jul 6, 2021
ca727c6
Fix add schedule comment
emostov Jul 6, 2021
366b93b
Apply suggestions from code review
emostov Jul 6, 2021
01ecef5
no ref for should_remove param
emostov Jul 6, 2021
ace04cb
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jul 6, 2021
09ef3e8
Remove unused vestingaction derive
emostov Jul 6, 2021
ce37a9e
Asserts to show balance unlock in merge benchmark
emostov Jul 6, 2021
272d663
Remove unused imports
emostov Jul 6, 2021
42a3fe1
Merge remote-tracking branch 'origin' into zeke-multi-vest-2
emostov Jul 6, 2021
0b227c3
trivial
emostov Jul 6, 2021
0630003
Fix benchmark asserts to handle non-multiple of 20 locked
emostov Jul 7, 2021
03bbd59
Add generate_storage_info
emostov Jul 7, 2021
22a1cae
migration :facepalm
emostov Jul 7, 2021
ff8c217
Remove per_block 0 logic
emostov Jul 7, 2021
ee82bf5
Update frame/vesting/src/lib.rs
emostov Jul 7, 2021
5c02c57
Do not check for ending later than greatest block
emostov Jul 7, 2021
eae2fb0
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jul 7, 2021
af400f3
Apply suggestions from code review
emostov Jul 7, 2021
6f2a618
Benchmarks: simplify vesting schedule creation
emostov Jul 7, 2021
e049325
Merge branch 'zeke-multi-vest-2' of https://github.com/paritytech/sub…
emostov Jul 7, 2021
b2109ff
Add log back for migration
emostov Jul 7, 2021
cb57017
Add note in ext docs explaining that all schedules will vest
emostov Jul 8, 2021
1c0b8db
Make integrity test work
emostov Jul 8, 2021
dcdcda5
Improve integrity test
emostov Jul 8, 2021
2ea52d2
Remove unnescary type param from VestingInfo::new
emostov Jul 8, 2021
6d13d90
Remove unnescary resut for ending_block_as_balance
emostov Jul 8, 2021
213a867
Remove T param from ending_block_as_balance
emostov Jul 8, 2021
fc094da
Reduce visibility of raw_per_block
emostov Jul 8, 2021
9f1a90c
Remove unused type param for validate
emostov Jul 8, 2021
28dab15
update old comment
emostov Jul 8, 2021
da79899
Make log a dep; log warn in migrate
emostov Jul 8, 2021
7a05c71
VestingInfo.validate returns Err(()), no T type param
emostov Jul 8, 2021
45726f7
Try improve report_schedule_updates
emostov Jul 9, 2021
81a29af
is_valid, not validate
emostov Jul 9, 2021
66bddb1
revert node runtime reorg;
emostov Jul 9, 2021
83de83c
change schedule validity check to just warning
emostov Jul 9, 2021
869103d
Simplify merge_vesting_info return type
emostov Jul 13, 2021
ab4cb46
Apply suggestions from code review
emostov Jul 13, 2021
b040038
Apply suggestions from code review
emostov Jul 13, 2021
adb28b0
Add warning for migration
emostov Jul 13, 2021
f3caa67
Fix indentation
emostov Jul 13, 2021
ee1b434
Delete duplicate warnings
emostov Jul 13, 2021
83425fd
Reduce diff in node runtime
emostov Jul 13, 2021
6db9f58
Fix benchmark build
emostov Jul 14, 2021
985623e
Merge branch 'master' into zeke-multi-vest-2
emostov Jul 14, 2021
5e4f653
Upgrade cargo.toml to use 4.0.0-dev
emostov Jul 14, 2021
6e76ec0
Cleanup
emostov Jul 14, 2021
c524815
MaxVestingSchedulesGetter initial impl
emostov Jul 20, 2021
830e04b
MinVestedTransfer getter inintial impl
emostov Jul 20, 2021
2946f75
Test MaxVestingSchedules & MinVestedTransfer getters; use getters in …
emostov Jul 20, 2021
94e50c5
Merge branch 'master' of https://github.com/paritytech/substrate into…
Jul 20, 2021
d5e6ac2
Merge branch 'master' into zeke-multi-vest-2
emostov Jul 21, 2021
82e8061
Run cargo fmt
emostov Jul 21, 2021
a4b8061
Revert MinVestedTransfer & MaxVestingSchedules getters; Add integrity…
emostov Jul 21, 2021
1af1708
Make MAX_VESTING_SCHEDULES a const
emostov Jul 22, 2021
db8c215
Merge remote-tracking branch 'origin' into zeke-multi-vest-2
emostov Jul 22, 2021
884c150
fmt
emostov Jul 22, 2021
2f6ba5e
WIP: benchmark improvements
emostov Jul 22, 2021
a94f0c9
Finish benchmark update
emostov Jul 22, 2021
dca7132
Add test for transfer to account with less than ed
emostov Jul 22, 2021
fd12e17
Rm min_new_account_transfer; move sp-io to dev-dep
emostov Jul 23, 2021
c471f9f
Reduce cargo.toml diff
emostov Jul 23, 2021
ed9878f
Explain MAX_VESTING_SCHEDULES choice
emostov Jul 23, 2021
0c8c07e
Try merge origin master
emostov Aug 9, 2021
7b82502
Fix after merge
emostov Aug 9, 2021
ca99a29
Try fix CI complaints
emostov Aug 9, 2021
bb3b591
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Aug 9, 2021
bb4138d
Merge branch 'master' of https://github.com/paritytech/substrate into…
Aug 10, 2021
23e15d9
cargo run --quiet --release --features=runtime-benchmarks --manifest-…
Aug 10, 2021
d5e5da7
Master.into()
kianenigma Aug 16, 2021
0a11ab1
fmt
kianenigma Aug 16, 2021
140af31
Merge remote-tracking branch 'origin' into zeke-multi-vest-2
emostov Aug 19, 2021
81c064c
trigger
emostov Aug 19, 2021
1b3c0c5
fmt
emostov Aug 19, 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 bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,7 @@ impl pallet_society::Config for Runtime {

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

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

impl pallet_mmr::Config for Runtime {
Expand Down
5 changes: 4 additions & 1 deletion frame/support/src/traits/tokens/currency/lockable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ pub trait VestingSchedule<AccountId> {

/// Remove a vesting schedule for a given account.
///
/// Parameter `schedule_index` is only applicable for implementations that
/// support multiple schedules.
///
/// NOTE: This doesn't alter the free balance of the account.
fn remove_vesting_schedule(who: &AccountId);
fn remove_vesting_schedule(who: &AccountId, schedule_index: Option<u32>) -> DispatchResult;
emostov marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 4 additions & 1 deletion frame/vesting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ equivalent to the amount remaining to be vested. This is done through a dispatch
either `vest` (in typical case where the sender is calling on their own behalf) or `vest_other`
in case the sender is calling on another account's behalf.

A user can have multiple vesting schedules, which are capped by an upper bound. With an upper bound
>= 2, users can merge 2 schedules.
emostov marked this conversation as resolved.
Show resolved Hide resolved
## Interface

This module implements the `VestingSchedule` trait.
Expand All @@ -24,8 +26,9 @@ This module implements the `VestingSchedule` trait.
- `vest` - Update the lock, reducing it in line with the amount "vested" so far.
- `vest_other` - Update the lock of another account, reducing it in line with the amount
"vested" so far.
- `merge_schedules` - Merge two vesting schedules together, creating a new vesting schedule that
over the "worst case" duration.

[`Call`]: ./enum.Call.html
[`Config`]: ./trait.Config.html

License: Apache-2.0
Loading