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

[report] Crowdloans Contributors State Report #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muharem
Copy link
Owner

@muharem muharem commented Nov 4, 2024

Polkadot currently has multiple open and active leases for parachain slots funded by crowdloans (in Kusama, all leases have ended). The crowdloans were open to all stakeholders, with a minimum contribution requirement of 5 DOT. Contributions for the winning bid that secured the slot lease are locked until the lease expires (note 1).

Upon reviewing the current state, we observe that each active crowdloan has hundreds of contributors, with contributions starting from 5 DOT. Some associated leases will end in 6 months, others in a year, and the latest in 18 months. This likely means that, to transition to the Asset Hub (AH), we would need to transfer the crowdloan data, along with associated balances and locked funds, to AH.

Note 1.
Contributions can be withdrawn before the lease ends if the leases funded by a specific crowdloan (the one including the contribution) have already started (fund.first_period) and the crowdloan has enough free balance. However, our report and test show that there isn’t enough free balance to refund to all contributors in all crowdloans. With the upcoming lease expirations, there won’t be any additional free balance in the crowdloan accounts, as each lease of every crowdloan requires the same amount of locked funds.
https://github.com/paritytech/polkadot-sdk/blob/5f782a4c5836f9bd8f279e8dd8d3a0d03a88a64f/polkadot/runtime/common/src/crowdloan/mod.rs#L724

Possible Solution

There are two pallets responsible for lease and crowdloan management: slots and crowdloan. The slots pallet is used by the system to manage leases and must remain on the Relay Chain (RC). It also tracks the total balances held for each lease and releases them when the lease ends. The crowdloan pallet manages contributions and withdrawals once a lease concludes. Although crowdloan is loosely coupled with slots, it checks certain lease details, such as the lease status.

To transition to AH, we would migrate the state of these two pallets, including balances, to AH and configure them there. On the RC, we could retain only part of the slots state (without balances) and would not need the crowdloan pallet. When a lease ends, RC would send an XCM message to the slots pallet on AH to signal the lease conclusion. At that point, contributors would be able to withdraw their tokens via the crowdloan pallet on AH.

State Inspection Results

Raw Data: One Record per Contributor

polkadot_crowdloan_contributors.csv

Test Output

You can obtain this data by running the test from this PR with the snapshot uploaded with try-runtime cli

index: 71 
para_id: Id(3344) 
funds raised: 75256 DOT 
lease interval: 14 - 21 
month left: 9 
contributions: 62
small contributions: 31
small contributions sum: 157 DOT 
med contributions: 13
med contributions sum: 192 DOT 
upmed contributions: 6
upmed contributions sum: 176 DOT 
min contribution: 5 
lease deposit: 71591 DOT 
fund account balance: 3665 DOT 

index: 88 
para_id: Id(3367) 
funds raised: 273468 DOT 
lease interval: 16 - 23 
month left: 15 
contributions: 543
small contributions: 104
small contributions sum: 593 DOT 
med contributions: 146
med contributions sum: 1910 DOT 
upmed contributions: 96
upmed contributions sum: 3597 DOT 
min contribution: 5 
lease deposit: 163408 DOT 
fund account balance: 110059 DOT 

index: 64 
para_id: Id(3369) 
funds raised: 133995 DOT 
lease interval: 12 - 19 
month left: 4 
contributions: 540
small contributions: 162
small contributions sum: 918 DOT 
med contributions: 153
med contributions sum: 2037 DOT 
upmed contributions: 105
upmed contributions sum: 3832 DOT 
min contribution: 5 
lease deposit: 116081 DOT 
fund account balance: 17913 DOT 

index: 91 
para_id: Id(2008) 
funds raised: 222 DOT 
lease interval: 17 - 24 
month left: 18 
contributions: 9
small contributions: 3
small contributions sum: 15 DOT 
med contributions: 4
med contributions sum: 50 DOT 
upmed contributions: 1
upmed contributions sum: 32 DOT 
min contribution: 5 
lease deposit: 185 DOT 
fund account balance: 37 DOT 

index: 75 
para_id: Id(2025) 
funds raised: 50836 DOT 
lease interval: 15 - 22 
month left: 12 
contributions: 427
small contributions: 124
small contributions sum: 681 DOT 
med contributions: 112
med contributions sum: 1507 DOT 
upmed contributions: 86
upmed contributions sum: 3080 DOT 
min contribution: 5 
lease deposit: 46422 DOT 
fund account balance: 4414 DOT 

index: 76 
para_id: Id(2002) 
funds raised: 66150 DOT 
lease interval: 15 - 22 
month left: 12 
contributions: 97
small contributions: 36
small contributions sum: 192 DOT 
med contributions: 32
med contributions sum: 426 DOT 
upmed contributions: 14
upmed contributions sum: 532 DOT 
min contribution: 5 
lease deposit: 65979 DOT 
fund account balance: 171 DOT 

index: 70 
para_id: Id(3345) 
funds raised: 299999 DOT 
lease interval: 14 - 21 
month left: 9 
contributions: 114
small contributions: 5
small contributions sum: 25 DOT 
med contributions: 8
med contributions sum: 114 DOT 
upmed contributions: 16
upmed contributions sum: 633 DOT 
min contribution: 5 
lease deposit: 299999 DOT 
fund account balance: 2 DOT 

index: 68 
para_id: Id(3340) 
funds raised: 153447 DOT 
lease interval: 14 - 21 
month left: 9 
contributions: 585
small contributions: 139
small contributions sum: 755 DOT 
med contributions: 158
med contributions sum: 2140 DOT 
upmed contributions: 94
upmed contributions sum: 3498 DOT 
min contribution: 5 
lease deposit: 150489 DOT 
fund account balance: 2960 DOT 

index: 66 
para_id: Id(3338) 
funds raised: 207140 DOT 
lease interval: 13 - 20 
month left: 7 
contributions: 749
small contributions: 206
small contributions sum: 1143 DOT 
med contributions: 206
med contributions sum: 2847 DOT 
upmed contributions: 121
upmed contributions sum: 4355 DOT 
min contribution: 5 
lease deposit: 207140 DOT 
fund account balance: 1 DOT 

index: 82 
para_id: Id(3356) 
funds raised: 34735 DOT 
lease interval: 16 - 23 
month left: 15 
contributions: 180
small contributions: 57
small contributions sum: 299 DOT 
med contributions: 55
med contributions sum: 738 DOT 
upmed contributions: 32
upmed contributions sum: 1167 DOT 
min contribution: 5 
lease deposit: 0 DOT 
fund account balance: 523 DOT 

index: 87 
para_id: Id(3366) 
funds raised: 124084 DOT 
lease interval: 16 - 23 
month left: 15 
contributions: 351
small contributions: 83
small contributions sum: 480 DOT 
med contributions: 88
med contributions sum: 1177 DOT 
upmed contributions: 70
upmed contributions sum: 2742 DOT 
min contribution: 5 
lease deposit: 119065 DOT 
fund account balance: 5019 DOT 

index: 78 
para_id: Id(2012) 
funds raised: 215668 DOT 
lease interval: 15 - 22 
month left: 12 
contributions: 233
small contributions: 58
small contributions sum: 315 DOT 
med contributions: 62
med contributions sum: 912 DOT 
upmed contributions: 45
upmed contributions sum: 1689 DOT 
min contribution: 5 
lease deposit: 208905 DOT 
fund account balance: 6763 DOT 

index: 85 
para_id: Id(2043) 
funds raised: 249998 DOT 
lease interval: 16 - 23 
month left: 15 
contributions: 289
small contributions: 34
small contributions sum: 192 DOT 
med contributions: 50
med contributions sum: 695 DOT 
upmed contributions: 42
upmed contributions sum: 1552 DOT 
min contribution: 5 
lease deposit: 249998 DOT 
fund account balance: 0 DOT 

index: 77 
para_id: Id(3354) 
funds raised: 111334 DOT 
lease interval: 15 - 22 
month left: 12 
contributions: 317
small contributions: 92
small contributions sum: 498 DOT 
med contributions: 84
med contributions sum: 1151 DOT 
upmed contributions: 52
upmed contributions sum: 2040 DOT 
min contribution: 5 
lease deposit: 109386 DOT 
fund account balance: 1948 DOT 

latest ends (# months): 18

@Ank4n
Copy link

Ank4n commented Nov 4, 2024

To transition to AH, we would migrate the state of these two pallets, including balances, to AH and configure them there. On the RC, we could retain only part of the slots state (without balances) and would not need the crowdloan pallet. When a lease ends, RC would send an XCM message to the slots pallet on AH to signal the lease conclusion. At that point, contributors would be able to withdraw their tokens via the crowdloan pallet on AH.

Since slot auctions are not used anymore, we can keep the existing lease slots without needing the slot deposit to exist for the rest of the period. To keep things simple, we can refund all crowdloan funds to the contributors and apply a lock on it that expires at the expiration of lease. I think vesting pallet can manage this if am not wrong.

To summarise:

  • Modify slots to ensure it can continue lease renewals for the existing ones even if there is no held deposit (this might already be the case). No new lease creation should be possible.
  • Write a migration to pallet_vesting::force_vested_transfer funds from crowdloan pot to the contributors with VestingInfo { locked: user_contribution, per_block: user_contribution, starting_block: lease_expiry_block}.
  • Clean up/dissolve the crowdloan state.

These balances would then be migrated as part of pallet_vesting, avoiding any need for additional pallet or custom logic beyond the changes above.

@seadanda
Copy link

seadanda commented Nov 4, 2024

Ankan beat me to it, I think we spoke about this in one of the calls recently - I agree that it's not worth keeping the pallet around on Asset Hub as long as we can faithfully represent the side effects of it (locked funds). Should look into that to make sure we can do it the right way with vesting as is, otherwise we can add to it.
The lease details are already on the coretime chain separately so the rest of the state (except the balances) can be dropped

@muharem
Copy link
Owner Author

muharem commented Nov 5, 2024

@Ank4n @seadanda
It simplifies the implementation, I like it. But two things to consider.
It changes the behaviour, right now these funds are not available for the contributors (not for holds and not for locks). We need to make sure such change is acceptable.
Additionally we need to make sure we are not breaking anything for parachains. They usually have some program to incentivize contributors, it might depend on this chain data.

@Ank4n
Copy link

Ank4n commented Nov 5, 2024

It changes the behaviour, right now these funds are not available for the contributors (not for holds and not for locks). We need to make sure such change is acceptable.

Fair point. The good side effect I believe is that it would allow crowdloan contributors to be able to participate in voting, which is anyways a behaviour we wanted to have.

The bad side effect: It would also allow staking which we don't want. Vesting as it is, won't prevent that since it uses locks.

So two options:

  • Check with w3f/fellowship if it is acceptable for these funds to be used for staking. This might be okay since there is no new crowdloan that can happen anymore, but would also mean these contributors gets some extra benefits than previous cl contributors.
  • Or, implement a special kind of vesting that uses holds.

Additionally we need to make sure we are not breaking anything for parachains. They usually have some program to incentivize contributors, it might depend on this chain data.

May be staking reward + voting would be good offset against this. :)

In general though I agree the final behaviour with this approach might not be 1-1, but may be acceptable.

@muharem
Copy link
Owner Author

muharem commented Nov 5, 2024

@Ank4n most probably the were reserved to prevent from contributing into multiple crowdloans the same funds. That make sense.

@muharem
Copy link
Owner Author

muharem commented Nov 5, 2024

@joepetrowski do you know who would be the best person to confirm that we can let the crowdloan contributors to stake and vote with those assets?

@Ank4n @seadanda
Another question I have, why some of the contributors do not withdraw their contributions, many of them already can. This might be because they do not know they can or there is some contract with parachain (hold your contribution till the end of the last lease and you get 10 coins, tho there is no incentive for a parachain to make you wait till the last lease ends).

@joepetrowski
Copy link
Collaborator

Good points, yeah it's unintended that these funds could be used in staking, but governance availability is really nice plus I can see how it simplifies things. I don't think allowing them to stake is such a bad side effect. Maybe @jonasW3F @kianenigma or @shawntabrizi have an opinion here?

@Ank4n
Copy link

Ank4n commented Nov 5, 2024

Another question I have, why some of the contributors do not withdraw their contributions, many of them already can. This might be because they do not know they can or there is some contract with parachain (hold your contribution till the end of the last lease and you get 10 coins, tho there is no incentive for a parachain to make you wait till the last lease ends).

You mean crowdloans are ended but not completely refunded? Pretty sure because they just don't know. Generally parachain teams do this for them: i.e. permissionlessly refund all the contributors.

@jonasW3F
Copy link

jonasW3F commented Nov 6, 2024

Good points, yeah it's unintended that these funds could be used in staking, but governance availability is really nice plus I can see how it simplifies things. I don't think allowing them to stake is such a bad side effect. Maybe @jonasW3F @kianenigma or @shawntabrizi have an opinion here?

With crowdloan contributions comprising only 0.24% of the currently staked tokens, this issue is less about economic impact and more about the cost of upholding principles. Allowing these funds to be staked would fundamentally (and in hindsight) alter the terms that people agreed to. Many individuals might have been more inclined to participate if they had known they would bear only a fraction of the anticipated costs, especially for crowdloans that are only a few months old.

There is no clear answer here and depends on the philosophical perspective you take. I think we all agree that the optimal solution would be to keep the original contract and disallow funds to stake. But including considerations about costs could have us go for something more practical. Time to equip my amateur philosophy hat!

From the deontological perspective, we could argue that a shortcut would change the terms everyone agreed on retrospectively, somewhat violating the social contract people accepted when contributing (or not contributing) in the crowdloans. This could have an impact on the trust participants place in these mechanisms that rely on commitment and long-term planning. Individuals that participated in the crowdloans would have their pledge rewards, now obtain the ability to earn staking rewards. The rewards they get would be taken away from the stakers currently in the system.

From a practical and utilitarian perspective, however, one could argue that the resources saved from not pursuing a complex solution here could be better spent improving the protocol, potentially benefiting all users more than this situation disadvantages them.

I think going for a quick and easy solution that only vests the tokens could be fine given the previous argument and the fact that it seems rather complex and convoluted to try to fix this properly. Additionally, this will only be a proposal, which still needs to be ratified by OpenGov. Given the fact that these funds still cannot vote, we could see it as a vote by the people most disadvantaged by this deciding whether they are willing to accept the new terms.

@muharem
Copy link
Owner Author

muharem commented Nov 7, 2024

I agree with @jonasW3F, I would also rather not change the contract. It also gives a higher confidence that we are doing things right and we wont have some unexpected issues.

I would suggest to move forward with my initial proposal (if no other proposals). I think we can even simplify it and drop XCM communication. We should know in advance the RC block numbers when every lease will end.

@seadanda
Copy link

seadanda commented Nov 7, 2024

Sounds good. I agree with this on a high level.
I still think that if we can faithfully reproduce the side effects of the pallet then we don't need to bring the pallet over as-is. Even if we don't use vesting (if it's too much to tweak it to allow balances to be held in this way) we could still create a new pallet which holds the funds and releases them at the correct point in time. I'm not sure if your initial proposal is aiming to just add the pallets and disallow extrinsics or something like that @muharem, do you have a concrete idea in mind for how the state will be represented on AH?

@muharem
Copy link
Owner Author

muharem commented Nov 11, 2024

I think it will be simpler to almost replicate it, with some part being disabled. The funds are hold by fundraising account, not by individual contributors, and individual contributors are storred in child tree, not the usual API we use. Plus some multi condition logic when an individual contributor can withdraw. But whoever will implement it can decide. Someone needs to try to pick the simplest path.

@muharem
Copy link
Owner Author

muharem commented Nov 12, 2024

We wont need any XCM communication. The crowdloan pallet will be fully migrate to AH (it does not hold any balances, only keeps info about contributors, their account ids and contribution amounts). Every contribution transferred to the fundraising account (keyless). The slots pallet holds reserves for every lease on a specific to that lease allocation account (fundraising account in case of crowdloans). We release the funds from fundraising accounts and transfer to the AH to the same account id. For simplicity we keep them liquid (no concern since accounts are keyless). We provide an implementation of the Auctioneer trait for the crowdloan instance on AH, the pallet uses it to get the current lease period and decide if the contributions can be withdrawn. The end of a lease is calculated from the RC block number and LeasePeriod constant. That's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants