Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Gilts Pallet #8139

Merged
merged 34 commits into from
Feb 27, 2021
Merged

Gilts Pallet #8139

merged 34 commits into from
Feb 27, 2021

Conversation

gavofyork
Copy link
Member

@gavofyork gavofyork commented Feb 16, 2021

TODO:

  • Benchmarks

@gavofyork gavofyork added the A3-in_progress Pull request is in progress. No review needed at this stage. label Feb 16, 2021
@gavofyork gavofyork marked this pull request as draft February 16, 2021 17:23
@github-actions github-actions bot added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 16, 2021
@gavofyork gavofyork added A3-in_progress Pull request is in progress. No review needed at this stage. B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. and removed A0-please_review Pull request needs code review. labels Feb 17, 2021
@gavofyork gavofyork added A0-please_review Pull request needs code review. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Feb 20, 2021
@gavofyork gavofyork marked this pull request as ready for review February 20, 2021 19:05
Co-authored-by: Shawn Tabrizi <[email protected]>
@gavofyork
Copy link
Member Author

Looks good overall. Wouldn't this attract people to mint gilt rather than staking, and get the same inflation as the network, but no risk of slashing?

Yes. Obviously any chain introducing this should configure the economics appropriately.

@shawntabrizi
Copy link
Member

shawntabrizi commented Feb 26, 2021

Presuming this makes its way onto Kusama, what kind of "economic configuration" would make sense?

Also this pallet will do crazy things if it is introduced at genesis along side the claims pallet. 💸

@gavofyork
Copy link
Member Author

gavofyork commented Feb 26, 2021

Presuming this makes its way onto Kusama, what kind of "economic configuration" would make sense?

I expect ~12% for the target frozen under gilts, with otherwise the example parameters. But it probably makes sense to roll it out slowly and ramp it up depending on takeup.

Gilt::enlarge(200, 3);

// Double everyone's free balances.
Balances::make_free_balance_be(&2, 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

is this correct? 2 is not everyone else, nor is the 100 double its original balance.

Copy link
Member Author

@gavofyork gavofyork Feb 27, 2021

Choose a reason for hiding this comment

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

The comment refers to the following three lines. 2's free balance is 50 (50 was reserved and a gilt issued). 1's free balance is zero. So this does what it says - doubles their free (i.e. non-gilted) balances.

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

Looks pretty neat.

@gavofyork gavofyork merged commit 88ba0e6 into master Feb 27, 2021
@gavofyork gavofyork deleted the gav-gilts branch February 27, 2021 15:11
@xlc
Copy link
Contributor

xlc commented Feb 27, 2021

Looks good overall. Wouldn't this attract people to mint gilt rather than staking, and get the same inflation as the network, but no risk of slashing?

Staking should always have higher reward right (ignoring fee & slash)? Say 50% staking rate, 10% inflation rate and all goes to stakers, that's 20% reward rate not 10%. Gilt will only get 10%.

jam10o-new pushed a commit to jam10o-new/substrate that referenced this pull request Feb 28, 2021
* Initial draft

* Enlarge function drafted.

* Thaw draft

* Retract_bid draft

* Final bits of draft impl.

* Test mockup

* Tests

* Docs

* Add benchmark scaffold

* Integrate weights

* All benchmarks done

* Missing file

* Remove stale comments

* Fixes

* Fixes

* Allow for priority queuing.

* Another test and a fix

* Fixes

* Fixes

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_gilt --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/gilt/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* Grumble

* Update frame/gilt/src/tests.rs

Co-authored-by: Shawn Tabrizi <[email protected]>

* Update frame/gilt/src/tests.rs

Co-authored-by: Shawn Tabrizi <[email protected]>

* Grumble

* Update frame/gilt/src/tests.rs

Co-authored-by: Shawn Tabrizi <[email protected]>

* Update frame/gilt/src/lib.rs

Co-authored-by: Shawn Tabrizi <[email protected]>

* Update frame/gilt/src/lib.rs

Co-authored-by: Shawn Tabrizi <[email protected]>

* Fix unreserve ordering

* Grumble

* Fixes

Co-authored-by: Parity Benchmarking Bot <[email protected]>
Co-authored-by: Shawn Tabrizi <[email protected]>
@AlistairStewart
Copy link

I looked at the code and think this is ok mechanics wise. But we need to think about potential issues.

The first I want to comfirm is whether or not we need to change the staking reward logic to get our target inflation figure. The logic works out how many tokens to mint to get the target % inflation, e.g. 10%, of tokens to be minted in a year and then divides that between the stakers and treasury. It's important that the total token supply used for that calculation does not include gilt locked tokens, as if it did, we'd end up with over 10% inflation.

If we make the gilt locking limit 10% of the total supply, then I don't see it affecting the economics or staking security too much.

However if 90% of tokens are locked like this and only 5% are used for staking, then we have a potential security issue that 2.5%-10% of tokens could be unlocked and used to stake and attack Polkadot more cheaply than is currently possible.

We could limit that threat and have a higher fraction locked by making sure that not too many tokens could be unlocked at the same time. For that we'd want to rework the lazy unlock logic to force people to relock tokens. That can still be lazy; it's just that we'd limit inflation rewards to the lock duration rather than the total time since it was locked (though then the problem of including them in the total supply for staking again is an issue). Then we'd need complicated logic to allow locking only when not too many tokens would be unlocked near the end of the locking duration.

Obviously that's not a priority if we want to test the economics and demand for this with small fractions as the limit first. And it also would make this even more complicated.

@burdges
Copy link

burdges commented Mar 4, 2021

If I understand, gilt says "inflation of my tokens do not pay for validation." It's useful when stakers unstake so they can avoid loosing most of their returns while locked, which encourages unstaking and makes dots more liquid. I donno if stakers can or should unbond directly into parachain backing.

There is a problem however that gilts ignore slashing which makes gilts de facto a bet that slashing occurs, which sounds problematic politically if not for deeper reasons.

We should probably apply slashes to gilts in some form, perhaps pro-rated by inflation with lower bound on the pro-rating, so that Alistair's concerns about 90% gilts never occurs. I've not thought through the exact details however.

@jonasW3F
Copy link

jonasW3F commented Mar 8, 2021

I might not see the bigger picture and/or miss some crucial aspects of the idea but I have a few concerns:

  1. What is the motivation to create gilts in the first place? Other token-utilities such as staking (security), bonding (demand-creation) and holding (liquidity) provide clear benefits to the network. What is the benefit for the network of users locking their tokens in the gilt pallet? As far as I can see right now, it only drains capital from those above mentioned useful cases.

  2. In my understanding, inflation is mainly driven by NPoS and if gilts are suppose to somewhat compensate for inflation, it would need to have a similar rate of return as staking. That would make it super attractive, as users don’t have the risk of getting slashed. Even if we slash gilts based on some average validator slashes (as Jeff suggests), this remains quite attractive, because users are hedged against idiosyncratic risks of their nominations. As long as our nominators only end up with one active nomination, staking is a very risky endeavor and creates rightfully so a good rate of return. We should be careful to create alternatives which affect that risk/reward trade-off.

  3. What would be the economic implementation of it? Our current inflation model is composed of treasury and NPoS inflation while deducting slashes and fees. Would we add the inflation caused by gilts as another individual driver of inflation? If we want to keep the overall inflation constant, then we’d need to reduce either NPoS rewards or treasury rewards.

Aside from that and as a somewhat unrelated idea, I think providing some compensation for unbonding might be very good for the network. Right now, in Polkadot users forgo on almost a month of staking rewards if they unbond (in addition to be not liquid). This makes custodial services, which offer similar staking return but 0 unbonding time quite attractive. Giving some compensation for the unbonding time could increase the incentive to own your keys.

@emielsebastiaan
Copy link

@jonasW3F this exactly summarizes my concerns. Thank you.

@jonasW3F
Copy link

jonasW3F commented Mar 9, 2021

If gilts are considered to be beneficial from a tax perspective to reduce the number of payable events, there might be other ways to do so. For now, users could stake with third-party custodial services and sign an agreement to make sure that payouts are only once per some period, or, once we have parachains, such a system could certainly be implemented trustless.

@kianenigma
Copy link
Contributor

I don't think tax-friendliness is the goal here.

@chevdor
Copy link
Contributor

chevdor commented Mar 11, 2021

My understanding is that we currently have 2 options and gilt is adding a third one:

  1. bonded/stacked tokens: your tokens are working for the network, it is benefitial to the network, you are taking a risk (to be slashed), you get however rewarded if you/your validator behave properly. Those rewards generate the inflation we are talking about.
  2. inactive tokens: your tokens are neither bonded nor stacked. You take 0 risk (to be slashed via staking). Your tokens, by being held on the network still bring some benefit to the network.

What gilts are tying to solve is that the second option is still benefitial to the network and not hit full face by the inflation.

gilts would offer a third opt-in mechanism allowing holders to keep (at least a part of) their inactive tokens on the network, without taking any risk, and also without getting 100% hit by the inflation.

This thread already mentioned the issues if the gilt option becomes 'too sweet' and too close to the staking option (option 1).

IMO gilt could be a nice addition considering:

  • gilt should not be shadowing staking
  • as proposed, the % of the allowed stake under gilt should be capped and manageable using governance (which btw would allow disabling the feature entirely should we discover a major issue). This is a parameter with huge leverage as it defines how benefitial gilt would be and how much it "endangers" the current staking
  • gilt should be fairly accessible, independently from the holder's wealth

@shawntabrizi shawntabrizi added D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited and removed D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited labels Apr 15, 2021
@bernardoaraujor
Copy link
Contributor

bernardoaraujor commented Oct 13, 2022

At Parity's Delivery Services team, we are doing some Learning Sessions, where we do presentations on many FRAME's pallets with the goal of spreading knowledge. For this week, gilt was one of them, so we had to chew it down to details and a this point came out of that effort:

The pallet isn't necessarily 100% "risk-free", given that some meaningful deflationary event will cause the user to actually lose tokens, which would be actually worse than not having tokens in a gilt during that period. Whether such deflationary event is actually possible or not is a separate tokenomics issue, but we should at least be careful about saying 100% "risk-free" or "0 risk", or at least restrict such narrative to exclusively inflationary contexts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D1-audited 👍 PR contains changes to fund-managing logic that has been properly reviewed and externally audited
Projects
None yet
Development

Successfully merging this pull request may close these issues.