Skip to content
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

[WIP] RFC-0097 Implementation to Decrease Unbonding Time #5715

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from

Conversation

rossbulat
Copy link

@rossbulat rossbulat commented Sep 14, 2024

This PR aims to implement RFC-0097, that introduces a flexible unbonding mechanism to decrease the time stakers have to wait to unbond by as much as 26 eras, resulting in 2 eras / 2 days on Polkadot in the best case scenario.

Commit Log

  • Introduce MinSlashableShare, UnbondPeriodUpperBound and UnbondPeriodLowerBound parameters as genesis storage items.
  • Record how much stake was used to back the lowest-backed 1/3 of validators, for the last UnbondingPeriodUpperBound eras. This LowestThirdTotalStake storage record can be updated when a new planned era is triggered, more specifically in the store_stakers_info function.
  • Implement a get_min_lowest_third_stake function that gets the lowest third stake entry over UnbondPeriodUpperBound eras.
  • Create pallet function get_quick_unbond_max_unstake(), that will essentially return MinSlashableShare * min_lowest_third_stake, where min_lowest_third_stake is determined by the above storage addition. Utilising this new storage item is of course less weight heavy than iterating through ErasStakersPaged.
  • Calculate unbonding_time_delta - this can use the following formula to determine a concrete unbond block number.
  • Combine new storage items into a struct.
  • Calculate back_of_unbonding_queue_block_number.
  • Calculate unbonding_block_number and reflect in unlock chunks.
  • Use correct back_of_unbonding_queue_block_number calculation.
  • Calculate unbond era and refactor to use eras instead of block numbers.
  • Make UnbondQueueParams OptionQuery, None by default, & configurable via set_staking_configs.
  • Ensure existing tests impacted by unbonding queue are amended.
  • Remove unbonding_period_upper_bound as duplicate of BondingDuration.
  • Add unit tests ensuring new functions returning expected results.
  • Amend bonding_duration interface so pallets like fast-unstake get the correct unbond duration.
  • Add Integration tests for unbonding scenarios (lowest, beyond max stake, etc).

@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: test-linux-stable 2/3
Logs: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7347472

Copy link
Contributor

@xlc xlc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a governance origin protected call to update the parameter.

substrate/frame/staking/src/migrations.rs Outdated Show resolved Hide resolved
substrate/frame/staking/src/lib.rs Outdated Show resolved Hide resolved

/// Parameters for the unbonding queue mechanism.
#[pallet::storage]
pub(crate) type UnbondingQueueParams<T: Config> = StorageValue<_, UnbondingQueue, ValueQuery>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub(crate) type UnbondingQueueParams<T: Config> = StorageValue<_, UnbondingQueue, ValueQuery>;
pub(crate) type UnbondingQueueParams<T: Config> = StorageValue<_, UnbondingQueue, OptionQuery>;

Maybe to not having a default and disable this feature when there is no parameter.
This requires a governance call to set the parameter to enable this feature, which I think should be the preferred way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended to OptionQuery and added an unbonding params entry to set_staking_configs.

@nirvanameow
Copy link

Wen are we having this released?

@kianenigma kianenigma added the T2-pallets This PR/Issue is related to a particular pallet. label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T2-pallets This PR/Issue is related to a particular pallet.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants