-
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
base: master
Are you sure you want to change the base?
Changes from 101 commits
c8ac431
b40c592
fca892e
a0d58ea
c350589
848c8ba
4bdb6aa
14ef617
92d6b68
7e7b49c
be0a586
0c9d92c
97676f0
e59ad8f
2b05b98
1066355
2191a81
c819eb8
aa3d40c
f973e3d
1866f07
0f7d125
7cdf802
4d21ca1
88449ef
3d05285
92770bf
11372b8
195fd67
c660d41
0866132
d67975c
4766e3b
827af56
4f3cbeb
0733988
1312eeb
4aa9fb6
ad5b1d1
5fa2f51
5c6a263
4d312e6
b79a90d
69e32e2
d9b4e71
e0ba2fa
57a5747
9dda79a
03b5965
32a3e35
e2fbceb
7c31a09
9568a4b
8c5c44c
330eed6
0e95a96
b2eafa8
c76b691
eea716f
27bb7e9
22c23d3
1c59638
e42c8a3
34e1abd
f496c42
e8c5104
ba1b1a7
3c3e8ee
e3d1813
41f0885
16ceaf5
0298cfe
45739ba
a0b7e6b
686a956
3dea491
b220761
cd4ff76
8413a9e
8553273
3e57c94
926aecd
f45f8a4
6229768
637884c
8c532bf
77386c3
0483d2f
3542c3a
87e0466
08338a9
45903a8
50d209e
d2c99ca
940d131
75d6a9c
6c39d58
36e2114
e860939
522ef70
8bd21b4
550d394
2fd16f4
1cbe511
8e74321
bdb80eb
20af53e
d0597b0
a8217ba
ba083d8
0f1ae18
5ef323f
8cb1c10
c230572
69ce1c1
005bef5
408feba
f6cb997
7546c99
f2972c4
96d4226
468c0c1
7720b6e
2079d89
4456c23
ebe47f5
6d77785
4522c4f
509cae6
6c98c6b
36015ce
f46842e
468edb6
6a30cb4
14ce7ba
9ae727a
19a5d2e
e69da63
f66eaa1
File filter
Filter by extension
Conversations
Jump to
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| 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. | ||
| - `TotalUnbondInEra`: 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: major | ||
| - name: pallet-staking-async | ||
| bump: major | ||
| - name: sp-staking | ||
| bump: patch |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1089,7 +1089,7 @@ parameter_types! { | |
| impl pallet_migrations::Config for Runtime { | ||
| type RuntimeEvent = RuntimeEvent; | ||
| #[cfg(not(feature = "runtime-benchmarks"))] | ||
| type Migrations = (); | ||
| type Migrations = (pallet_staking_async::migrations::v18::LazyMigrationV17ToV18<Runtime>,); | ||
|
||
| // Benchmarks need mocked migrations to guarantee that they succeed. | ||
| #[cfg(feature = "runtime-benchmarks")] | ||
| type Migrations = pallet_migrations::mock_helpers::MockedMigrations; | ||
|
|
@@ -1794,6 +1794,10 @@ impl_runtime_apis! { | |
| fn pending_rewards(era: sp_staking::EraIndex, account: AccountId) -> bool { | ||
| Staking::api_pending_rewards(era, account) | ||
| } | ||
|
|
||
| fn unbonding_duration(account: AccountId) -> Vec<(sp_staking::EraIndex, Balance)> { | ||
| Staking::unbonding_duration(account) | ||
| } | ||
| } | ||
|
|
||
| #[cfg(feature = "runtime-benchmarks")] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thet are needed? this pallet has not benchmark code.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of completeness. Anyhow, removed in 7720b6e.