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

Investigate fungible trait Holds and Freezes overlap #1873

Merged

Conversation

mattheworris
Copy link
Collaborator

Goal

The goal of this PR is to investigate the overlap of hold and frozen in the frame system account, used by the balances pallet and the fungible trait (which replaced the Currency trait).

Closes #1819

Discussion

Investigation indicates that it is not currently possible to create a situation where frozen overlaps with hold [currently indicated by reserved in the frame system account] and that hold can be slashed.

  • Use the Democracy pallet to create a proposal that would result in some tokens being placed on hold. The tokens on hold would always be returned to the user at some point in the future, they are not able to be slashed, as near as I can tell.
  • Use the treasury pallet to create a spend proposal that would result in a minimum of 100 tokens being used as a bond and placed on hold. These tokens will be slashed if the proposal is rejected. We can simulate a rejection using sudo and see that the tokens are slashed.
  • Validators and their Nominators can have their stake slashed. This is done using hold.

However, experimentation with hold shows that conditions where hold and frozen overlap cause the transactions to fail.

Tests were added to make sure this behavior does not change in the future.

Changes

Two tests were added:

  1. Create a treasury spend proposal and then attempt to stake with an amount that would overlap the hold. This transaction fails.
  2. Create a stake and then attempt to create a treasury spend proposal that would require an amount of tokens that would overlap with the existing stake. This transaction fails.

How to Test

  • Confirm that the e2e tests pass.

Checklist

  • Chain spec updated
  • Custom RPC OR Runtime API added/changed? Updated js/api-augment.
  • Design doc(s) updated
  • Tests added
  • Benchmarks added
  • Weights updated

@mattheworris mattheworris requested a review from a team February 12, 2024 23:21
@mattheworris mattheworris self-assigned this Feb 12, 2024
@mattheworris mattheworris linked an issue Feb 12, 2024 that may be closed by this pull request
6 tasks
Copy link
Collaborator

@shannonwells shannonwells left a comment

Choose a reason for hiding this comment

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

Looks great, thanks. #themoreyouknow

@enddynayn
Copy link
Collaborator

enddynayn commented Feb 13, 2024

Experimentation with hold shows that conditions where hold and frozen overlap cause the transactions to fail.

Interestingly, the changes will allow to slash hold but yet we validate to prevent that. I am curious to learn what new feature makes this case useful.

Copy link
Collaborator

@enddynayn enddynayn left a comment

Choose a reason for hiding this comment

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

👍 Thanks!

Copy link
Collaborator

@wilwade wilwade left a comment

Choose a reason for hiding this comment

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

🚢

@mattheworris mattheworris merged commit 03bc60e into main Feb 14, 2024
27 checks passed
@mattheworris mattheworris deleted the 1819-investigate-fungible-trait-holds-and-freezes-overlap branch February 14, 2024 16:26
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.

Investigate fungible trait Holds and Freezes overlap.
4 participants