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

Allow early refund of slot deposit #1749

Closed
wants to merge 67 commits into from
Closed

Conversation

Ank4n
Copy link
Contributor

@Ank4n Ank4n commented Sep 29, 2023

closes #877
context: https://hackmd.io/4OLfULI6RtaPdE-L_hur4g

Changes since last approach (Updated on 19th Nov):

Instead of having a config value that determines how early refund can be applied before the slot expiry, now early refund can only be applied anytime during the last LP of the lease. Parachains should have at minimum MinLeasePeriodsForEarlyRefund LPs in their current lease to be able to refund early.

Summary

This change would allow a parachain to refund their slot deposit during their last lease period, given that they leased out minimum of MinLeasePeriodsForEarlyRefund in the last auction. For parachains who won the lease with a crowdloan, they could then refund crowdloan funds to contributors, and dissolve the crowdloan. This gives them opportunity to either start a new crowdloan or bid directly with their released funds.

If MinLeasePeriodsForEarlyRefund is set to 0, a slot deposit can never be refunded before it expires.

Changes

  • Config const MinLeasePeriodsForEarlyRefund: Determines how many minimum lease periods a leaser in their latest lease to be eligible for early refund. This value should always be greater than 0. If set to 0, early_lease_refund is disabled.
  • New signed extrinsic early_lease_refund: Only para or para manager can call this or can be executed via governance with Lease Admin origin track. It allows a parachain to unreserve their lease deposit during the last lease period of their full lease. This will unreserve the deposit of the slot but would not downgrade the parachain yet. Parachain would be downgraded as it happens today if at the start of the next lease period it does not have any new leases remaining or left alone if a new lease has become available and update the fund reserved to match the new requirement.
  • Storage double map LeaseInfo: Keeps track of how much funds is reserved as well as period count of the latest lease for a leaser.

early_lease_refund can be followed by the calls refund and dissolve on the crowdloan pallet for the para_id which will remove the crowdloan and allow the parachain to create a new crowdloan for the same para_id.

TODO

  • All existing tests pass in the scenario where early_lease_refund is not called. This ensures we do not impact any existing flows.
  • Unit + Integration test
  • Allow only Lease Admin or parachain manager to call early_lease_refund.
  • Migration of LeaseInfo.
  • Bench
  • Only leasers who have more than one lease can early refund slot deposit.
  • Intialise lease count of existing parachains to 4 (we need it to be greater than 2 to enable early_lease_refund).
  • Allow para manager or para origin to call early_lease_refund.

@Ank4n Ank4n added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Sep 29, 2023

// If this is less than what we were holding for this leaser's now-ended lease,
// then unreserve it.
if let Some(rebate) = ended_lease.1.checked_sub(&now_held) {
let current_hold = ended_lease.1;
// Fixme(ank4n): check reserved balance from state instead of deposit. We might
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fungibles would fix this but probably shouldn't migrate in this PR

@Ank4n Ank4n requested review from kianenigma and a team October 1, 2023 01:02
@Ank4n Ank4n requested review from a team and removed request for a team October 1, 2023 01:05
@gpestana gpestana self-requested a review November 20, 2023 17:02
polkadot/runtime/common/src/integration_tests.rs Outdated Show resolved Hide resolved
polkadot/runtime/common/src/slots/mod.rs Outdated Show resolved Hide resolved
polkadot/runtime/common/src/slots/mod.rs Show resolved Hide resolved
@Ank4n
Copy link
Contributor Author

Ank4n commented Mar 2, 2024

I guess its too late to be useful anymore? @SBalaguer

Closing this PR.

@Ank4n Ank4n closed this Mar 2, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Mar 26, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Mar 27, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 8, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 9, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
serban300 added a commit to serban300/polkadot-sdk that referenced this pull request Apr 10, 2024
bkchr pushed a commit that referenced this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parachain Slot Extension Story
7 participants