-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implementation of RFC-0097: Unbonding Queue for pallet-staking-async #8298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
moliholy
wants to merge
139
commits into
paritytech:master
Choose a base branch
from
blockdeep:RFC-0097-port
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
139 commits
Select commit
Hold shift + click to select a range
c8ac431
Implement RFC-0097
b40c592
Merge remote-tracking branch 'origin/master' into RFC-0097-port
fca892e
Improve test with pagination
a0d58ea
Merge remote-tracking branch 'origin/master' into RFC-0097-port
c350589
Add checks in ahm-tests
848c8ba
Merge remote-tracking branch 'origin/master' into RFC-0097-port
4bdb6aa
Fix clippy issues
14ef617
Add prdoc
92d6b68
Merge remote-tracking branch 'origin/master' into RFC-0097-port
7e7b49c
Merge remote-tracking branch 'origin/master' into RFC-0097-port
be0a586
Merge remote-tracking branch 'origin/master' into RFC-0097-port
0c9d92c
Merge remote-tracking branch 'origin/master' into RFC-0097-port
97676f0
Add extra test
e59ad8f
Use pico-eras to measure time
2b05b98
Handle the rebonding scenario
1066355
Only round up if needed
2191a81
Merge remote-tracking branch 'origin/master' into RFC-0097-port
c819eb8
Search for unbonding slots throughout the whole unbonding queue
aa3d40c
Improve code structure and test
f973e3d
Merge remote-tracking branch 'origin/master' into RFC-0097-port
1866f07
Move back_of_unbonding_queue as a separate storage item
0f7d125
Remove max_bonding_duration function
7cdf802
Create view functions
4d21ca1
Improve test "calculate_lowest_total_stake_works"
88449ef
Add extra function to ExtBuilder
3d05285
Simplify unbonding queue config in mock
92770bf
Merge remote-tracking branch 'origin/master' into RFC-0097-port
11372b8
Fix benchmarks
195fd67
Polish ahm-test dependencies
c660d41
Fix compilation issues
0866132
Merge remote-tracking branch 'origin/master' into RFC-0097-port
d67975c
Update prdoc bumps
4766e3b
Merge remote-tracking branch 'origin/master' into RFC-0097-port
827af56
Merge remote-tracking branch 'origin/master' into RFC-0097-port
4f3cbeb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
0733988
Merge remote-tracking branch 'origin/master' into RFC-0097-port
1312eeb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
4aa9fb6
Merge remote-tracking branch 'origin/master' into RFC-0097-port
ad5b1d1
Fix documentation
5fa2f51
Merge remote-tracking branch 'origin/master' into RFC-0097-port
5c6a263
Merge remote-tracking branch 'origin/master' into RFC-0097-port
4d312e6
Reimplement the logic
b79a90d
Fix all tests
69e32e2
Merge remote-tracking branch 'origin/master' into RFC-0097-port
d9b4e71
Merge remote-tracking branch 'origin/master' into RFC-0097-port
e0ba2fa
Add test to withdraw funds
57a5747
Add more tests for withdrawal
9dda79a
Add extra test to calculate the unbonding duration
03b5965
Update documentation
32a3e35
Update runtime api
e2fbceb
Implement new runtime api
7c31a09
Rename view function
9568a4b
Merge remote-tracking branch 'origin/master' into RFC-0097-port
8c5c44c
Fix prdoc
330eed6
Merge remote-tracking branch 'origin/master' into RFC-0097-port
0e95a96
Increase minimum bond duration to 2 eras
b2eafa8
Add extra checks when unbonding
c76b691
Add extra checks for new storage items
eea716f
Merge remote-tracking branch 'origin/master' into RFC-0097-port
27bb7e9
Merge remote-tracking branch 'origin/master' into RFC-0097-port
22c23d3
Add test to delay expected withdrawal by unbonding a huge amount
1c59638
Improve tests
e42c8a3
Merge remote-tracking branch 'origin/master' into RFC-0097-port
34e1abd
Add multi-block migration
f496c42
Merge remote-tracking branch 'origin/master' into RFC-0097-port
e8c5104
Add benchmarks and weights
ba1b1a7
Merge remote-tracking branch 'origin/master' into RFC-0097-port
3c3e8ee
Add pre and post checks to the migration
e3d1813
Merge remote-tracking branch 'origin/master' into RFC-0097-port
41f0885
Fix era in tests
16ceaf5
Merge remote-tracking branch 'origin/master' into RFC-0097-port
0298cfe
Fix default-features
45739ba
fmt
a0b7e6b
Fix clippy issues again
686a956
Merge remote-tracking branch 'origin/master' into RFC-0097-port
3dea491
Merge remote-tracking branch 'origin/master' into RFC-0097-port
b220761
Update prdoc
cd4ff76
Merge remote-tracking branch 'origin/master' into RFC-0097-port
8413a9e
Address feedback
8553273
Merge remote-tracking branch 'origin/master' into RFC-0097-port
3e57c94
Link ErasLowestRatioTotalStake and Eras
926aecd
Format
f45f8a4
Merge remote-tracking branch 'origin/master' into RFC-0097-port
6229768
Add mbm to runtime
637884c
Fix compilation error in benchmarks
8c532bf
Reset preset to development
77386c3
Merge remote-tracking branch 'origin/master' into RFC-0097-port
0483d2f
Merge remote-tracking branch 'origin/master' into RFC-0097-port
3542c3a
Merge remote-tracking branch 'origin/master' into RFC-0097-port
87e0466
Merge remote-tracking branch 'origin/master' into RFC-0097-port
08338a9
Merge remote-tracking branch 'origin/master' into RFC-0097-port
45903a8
Merge remote-tracking branch 'origin/master' into RFC-0097-port
50d209e
Merge remote-tracking branch 'origin/master' into RFC-0097-port
d2c99ca
Merge remote-tracking branch 'origin/master' into RFC-0097-port
940d131
Merge remote-tracking branch 'origin/master' into RFC-0097-port
75d6a9c
Update prdoc
6c39d58
Merge remote-tracking branch 'origin/master' into RFC-0097-port
36e2114
fmt
e860939
Merge remote-tracking branch 'origin/master' into RFC-0097-port
522ef70
Merge remote-tracking branch 'origin/master' into RFC-0097-port
8bd21b4
Merge remote-tracking branch 'origin/master' into RFC-0097-port
550d394
Merge remote-tracking branch 'origin/master' into RFC-0097-port
2fd16f4
Remove migration from dev chain
1cbe511
Add the migration to westend AH
8e74321
Remove no longer needed benchmark setup
bdb80eb
Merge remote-tracking branch 'origin/master' into RFC-0097-port
20af53e
Improve benchmarks
d0597b0
Improve documentation
a8217ba
Improve unbonding queue curating logic
ba083d8
Improve unbonding logic
0f1ae18
Allow multiple chunks to be released in the same era
5ef323f
Update prdoc
8cb1c10
Merge remote-tracking branch 'origin/master' into RFC-0097-port
c230572
Merge remote-tracking branch 'origin/master' into RFC-0097-port
69ce1c1
Include weight implementation
005bef5
Merge remote-tracking branch 'origin/master' into RFC-0097-port
408feba
Merge remote-tracking branch 'origin/master' into RFC-0097-port
f6cb997
Merge remote-tracking branch 'origin/master' into RFC-0097-port
7546c99
Merge remote-tracking branch 'origin/master' into RFC-0097-port
f2972c4
Rename TotalUnbondInEra -> ErasTotalUnbond
96d4226
Use Rotator::planned_era()
468c0c1
Use ValueQuery for ErasTotalUnbond
7720b6e
Remove runtime-benchmark dependencies from pallet-ahm-test
2079d89
Rename variable for clarity
4456c23
Merge remote-tracking branch 'origin/master' into RFC-0097-port
ebe47f5
Remove unintended change
6d77785
Merge remote-tracking branch 'origin/master' into RFC-0097-port
4522c4f
Rename BondingDuration -> MaxUnbondingDuration
509cae6
Add extra check when setting the lower unbonding time
6c98c6b
Improve comment
36015ce
Fix typo
f46842e
Add runtime api to query estimated unbonding duration
468edb6
Use MaxUnbondingDuration for migration benchmarks
6a30cb4
Use existing error variant
14ce7ba
Use more idiomatic Rust
9ae727a
Merge remote-tracking branch 'origin/master' into RFC-0097-port
19a5d2e
Fix compilation issuFix compilation issue
e69da63
Calculate correctly the earliest withdrawal era
f66eaa1
Merge remote-tracking branch 'origin/master' into RFC-0097-port
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| title: 'Implementation of RFC-0097: Unbonding Queue for pallet-staking-async' | ||
| doc: | ||
| - audience: [Runtime Dev, Runtime User] | ||
| description: | | ||
| # Description | ||
| This PR implements [RFC-0097](https://polkadot-fellows.github.io/RFCs/approved/0097-unbonding_queue.html) and its | ||
| [modification](https://hackmd.io/@vKfUEAWlRR2Ogaq8nYYknw/SyfioMGWgl), which introduces a variable unbonding time | ||
| mechanism to improve the security-liquidity trade-off in the staking system. | ||
|
|
||
| The unbonding queue allows for faster unbonding of staked tokens while maintaining network security by keeping a | ||
| minimum slashable share of stake locked for the full unbonding period. | ||
|
|
||
| ### Modified extrinsics: | ||
| - `unbond`: Enhanced to work with the unbonding queue mechanism, calculating variable unbonding times based on stake distribution. | ||
| - `withdraw_unbonded`: Modified to handle withdrawals from the unbonding queue with different unlock periods. | ||
| - `rebond`: Updated to work with the queue-based unbonding system. | ||
|
|
||
| ### Storage items: | ||
| - `ElectableStashes`: Added the stake backing up a given electable stash account. | ||
| - `UnbondingQueueParams`: New storage item containing configuration parameters: | ||
| - `min_slashable_share`: The minimum share of stake of the lowest backed validators that must remain slashable at any point in time. | ||
| - `lowest_ratio`: The proportion of the lowest-backed validator set. | ||
| - `unbond_period_lower_bound`: Minimum unbonding time in eras. | ||
| - `ErasLowestRatioTotalStake`: Tracks the lowest stake proportion among validators in each era. | ||
| - `ErasTotalUnbond`: Tracks the stake that started unbonding in a given era. | ||
| - `Ledger`: Added `previous_unbonded_stake` to track the accumulated stake to be unbonded at the time a given unlock chunk was created. | ||
|
|
||
| ### View functions: | ||
| - `unbonding_duration`: Used to obtain the list of funds that will be released at a given era. | ||
|
|
||
| ## Key features: | ||
| 1. Variable unbonding time: Unbonding time varies based on the amount of stake in the system. | ||
| 2. Security maintenance: Ensures a sufficient percentage of stake remains slashable at all times. | ||
| 3. Unbonding queue management: Implements an efficient queue system for managing unbonding requests. | ||
|
|
||
| ### Migration v18: | ||
| Includes multi-block migration `LazyMigrationV17ToV18` that: | ||
| - Updates `StakingLedger` structure to include the new `previous_unbonded_stake` field in `UnlockChunk`. | ||
| - Migrates `ElectableStashes` from set-based to map-based storage (AccountId -> Balance mapping). | ||
| - Performs era adjustment for existing unlock chunks by subtracting the bonding duration. | ||
| - Uses stepped migration pattern to handle large datasets efficiently across multiple blocks. | ||
| - Includes comprehensive pre/post-upgrade checks for data integrity. | ||
|
|
||
| crates: | ||
| - name: pallet-staking-async-parachain-runtime | ||
| bump: minor | ||
| - name: pallet-staking-async-runtime-api | ||
| bump: minor | ||
| - name: pallet-staking-async | ||
| bump: major | ||
| - name: sp-staking | ||
| bump: patch | ||
| - name: asset-hub-westend-runtime | ||
| bump: major |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.