polkadot-sdk icon indicating copy to clipboard operation
polkadot-sdk copied to clipboard

[WIP] RFC-0097 Implementation to Decrease Unbonding Time

Open rossbulat opened this issue 1 year ago • 1 comments

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

  • [x] Introduce MinSlashableShare, UnbondPeriodUpperBound and UnbondPeriodLowerBound parameters as genesis storage items.
  • [x] Define new migration to set initial parameter values in storage.
  • [x] 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.
  • [x] Implement a get_min_lowest_third_stake function that gets the lowest third stake entry over UnbondPeriodUpperBound eras.
  • [x] 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.
  • [x] Calculate unbonding_time_delta - this can use the following formula to determine a concrete unbond block number.
  • [x] Combine new storage items into a struct.
  • [x] Calculate back_of_unbonding_queue_block_number.
  • [x] Calculate unbonding_block_number and reflect in unlock chunks.
  • [x] Use correct back_of_unbonding_queue_block_number calculation.
  • [x] Calculate unbond era and refactor to use eras instead of block numbers.
  • [ ] Add unit tests ensuring new functions returning expected results.
  • [ ] Add Integration tests for unbonding scenarios (lowest, beyond max stake, etc).
  • [ ] Ensure existing tests impacted by unbonding queue are amended.

More to come...

Post Implementation Checklist

  • [ ] Add migration to runtimes.

rossbulat avatar Sep 14 '24 04:09 rossbulat

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

paritytech-cicd-pr avatar Sep 14 '24 06:09 paritytech-cicd-pr

Wen are we having this released?

nirvanameow avatar Nov 02 '24 22:11 nirvanameow

How can one apply to work on this?

came across this on X

runcomet avatar Jan 14 '25 23:01 runcomet

@runcomet so you could start forking this pr and implementing the missing things.

bkchr avatar Jan 15 '25 09:01 bkchr

@runcomet do you have element?

bkchr avatar Jan 23 '25 14:01 bkchr

@bkchr @runcomet:matrix.org

searched for the fellowship channel, don't think it's public.

runcomet avatar Jan 25 '25 04:01 runcomet

@bkchr Better to commit to this branch or open a new PR?

runcomet avatar Jan 30 '25 04:01 runcomet

@bkchr Better to commit to this branch or open a new PR?

I'd recommend forking this branch & then merging updates into it, to keep one source of truth for the implementation.

rossbulat avatar Jan 30 '25 04:01 rossbulat

set aside in favor of @runcomet

kianenigma avatar Jan 30 '25 11:01 kianenigma