-
Notifications
You must be signed in to change notification settings - Fork 683
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
[Assets] Implement pallet-assets-holder
#4530
Open
pandres95
wants to merge
78
commits into
paritytech:master
Choose a base branch
from
pandres95:pallet-assets-holder
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
a0f5015
change(pallet-assets): define HeldBalance
pandres95 6d2aa57
change(pallet-assets): implement `Holder` to calculate reducible bala…
pandres95 029e887
change: add Holder type to missing pallet_assets Config implementations
pandres95 bf376a5
change(pallet-assets): call died hook for Holder whenever necessary
pandres95 fe951fa
Merge branch 'master' into pallet-assets-holder
pandres95 89ea43a
fix(pallet-asset-conversion-ops): missing Holder in mock config
pandres95 2ab3535
change(pallet-assets): adjust reducible/can_decrease to be in line wi…
pandres95 9d326b8
Merge branch 'master' into pallet-assets-holder
pandres95 c76b654
change(pallet-assets): introduce tests to check for holds and freezes…
pandres95 c5690e1
Merge branch 'master' into pallet-assets-holder
pandres95 a4bb10c
change(pallet-assets-freezer): adjust mock and tests to changes in `p…
pandres95 32fa5c1
feat(pallet-assets-holder): pallet implementation
pandres95 fe0a5e5
Merge branch 'master' into pallet-assets-holder
pandres95 b93337e
fix: fmt / cargo fmt
pandres95 4e0ced7
chore: umbrella
pandres95 c5b103a
chore: pr doc
pandres95 9cdb256
Merge branch 'master' into pallet-assets-holder
pandres95 f36b540
fix(staging-xcm-builder): missing references to `Holder`
pandres95 5829558
change(pallet-assets): set `Holder` and `Freezer` to have default val…
pandres95 17ce1d9
change(pallet-assets-holder): apply @gui1117's suggestion of tightly …
pandres95 f2a9e96
change(pallet-assets): account for `held_balance` when calculating `t…
pandres95 fc41634
change(pallet-assets-holder): test preservation of `total_balance`.
pandres95 9e9edfb
change(pallet-assets-holder): resolve `VARIANT_COUNT` to match number…
pandres95 e7155eb
change(pallet-assets-holder): remove assertion in test that fails aft…
pandres95 4268b76
change(pallet-assets-holder): implement changes suggested by @gui1117
pandres95 818e590
change(pallet-assets-holder): apply change from HeldBalance to Balanc…
pandres95 06db701
minor(pallet-assets-holder): small adjustments
pandres95 be7576e
Merge branch 'master' into pallet-assets-holder
pandres95 0a0487e
Merge branch 'pallet-assets-holder' of https://github.com/pandres95/p…
pandres95 7dff111
fix(pallet-revive-mock-network): include Holder on pallet_assets conf…
pandres95 5d04950
change(prdoc): update prdoc with all impacted crates
pandres95 44e8f62
change(pallet-assets-holder): add additional assertions to `try_state…
pandres95 bb1a98d
minor(pallet-assets-holder): rename _held_ references in comments wit…
pandres95 aab6498
Merge branch 'master' into pallet-assets-holder
pandres95 3688f89
change(pallet-assets-holder): address changes requested by @muharem
pandres95 900dbaa
change(pallet-assets-holder): impls -> impl_fungibles
pandres95 b689e2e
fix(pallet-assets-holder): missing `CheckedAdd` import
pandres95 2f14b32
change(pallet-assets-holder): make `died` burn balance on hold (if any).
pandres95 548eee1
Merge branch 'master' into pallet-assets-holder
pandres95 5d7d874
change(pallet-assets-holder): fast exit for `set_balance_on_hold`.
pandres95 427a29b
fix(penpal-runtime): missing `Holder` in `PoolAssets` config
pandres95 7c28175
Merge branch 'master' into pallet-assets-holder
pandres95 9ccc35c
fix(pallet-assets-holder): lint
pandres95 c65a4c2
change(pallet-assets-holder): revert `died` to make it an infallible …
pandres95 174b3d5
Merge branch 'master' into pallet-assets-holder
pandres95 f1c0983
change(pallet-assets): remark the change of parameters in the `freeze…
pandres95 ae2f67a
Merge branch 'master' into pallet-assets-holder
pandres95 92769f1
change(pallet-assets): implement contains_holds / contains_freezes
pandres95 a02904d
Merge branch 'master' into pallet-assets-holder
pandres95 b559bda
Merge branch 'master' into pallet-assets-holder
pandres95 0e848ac
fix(pallet-assets-freezer): missing import
pandres95 3bd7241
change(pallet-assets): disallow `refund`/`refund_other` for an accoun…
pandres95 4e25e73
Merge branch 'master' into pallet-assets-holder
pandres95 3233d48
fix(umbrella): revert unintended misformatting of Cargo.toml
pandres95 a80e6e3
fix(Cargo): revert unintended regression in Cargo lockfile
pandres95 668c148
fix(pallet-assets): missing documentation changes
pandres95 4f27725
fix(pallet-assets): missing borrowing
pandres95 9d2256d
Merge branch 'master' into pallet-assets-holder
pandres95 dec2a4c
change: resolve issues raised by ci checks
pandres95 25d9bb0
change(pallet-assets): make `dead_account` return either `DeadConsequ…
pandres95 de4702e
Merge branch 'master' into pallet-assets-holder
pandres95 c81ad85
change(Cargo): update lockfile
pandres95 bd72de1
fix(pallet-pass): missing clone for asset id
pandres95 4bab6f1
make ci happy
pandres95 f1e5b9b
Merge branch 'master' into pallet-assets-holder
pandres95 8d46fa3
change(pallet-assets): tests to assert calling on `dead_account` fail…
pandres95 8b9b6db
Merge branch 'master' into pallet-assets-holder
pandres95 ba8c452
Merge branch 'master' into pallet-assets-holder
pandres95 7d84bee
change(pallet-assets-holder): make CI happy
pandres95 608b688
change(prdoc): apply suggestions and clarify changes in balance model
pandres95 f12acd2
Merge branch 'master' into pallet-assets-holder
pandres95 6ce2b83
Merge branch 'master' into pallet-assets-holder
pandres95 189d8d4
change(pallet-assets-freezer): handle `assert_debug`s when calling `d…
pandres95 6130c60
fix(pallet-assets): on `can_decrease`, return `WouldDie` if there's b…
pandres95 f7d0a41
change(pallet-assets): assert `died` hooks for both `Freezer` AND `Ho…
pandres95 6bebe7e
change(pallet-assets): document the `balance` field of `AssetAccount`…
pandres95 3e797b1
change(pallet-assets): assert deposit
pandres95 595b838
fix(pallet-assets): typo (thanks to @gui1117 for the suggestion)
pandres95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
title: "Implement `pallet-assets-holder`" | ||
|
||
doc: | ||
- audience: Runtime Dev | ||
description: | | ||
This change creates the `pallet-assets-holder` pallet, as well as changes `pallet-assets` | ||
to support querying held balances via a new trait: `BalanceOnHold`. | ||
|
||
## Changes in Balance Model | ||
|
||
The change also adjusts the balance model implementation for fungible sets. This aligns the | ||
calculation of the _spendable_ balance (that can be reduced either via withdrawals, like | ||
paying for fees, or transfer to other accounts) to behave like it works with native tokens. | ||
|
||
As a consequence, when this change is introduced, adding freezes (a.k.a. locks) or balances | ||
on hold (a.k.a. reserves) to an asset account will constraint the amount of balance for such | ||
account that can be withdrawn or transferred, and will affect the ability for these accounts | ||
to be destroyed. | ||
|
||
See [sdk docs](https://paritytech.github.io/polkadot-sdk/master/frame_support/traits/tokens/fungible/index.html#visualising-balance-components-together-) | ||
to understand how to calculate the spendable balance of an asset account on the client side. | ||
|
||
## Implementation of `InspectHold` and `MutateHold` | ||
|
||
The `pallet-assets-holder` implements `hold` traits for `pallet-assets`, by extending this | ||
pallet and implementing the `BalanceOnHold` trait so the held balance can be queried by | ||
`pallet-assets` to calculate the reducible (a.k.a. spendable) balance. | ||
|
||
These changes imply adding a configuration type in `pallet-assets` for `Holder` | ||
|
||
## Default implementation of `Holder` | ||
|
||
Use `()` as the default value, when no holding capabilities are wanted in the runtime | ||
implementation. | ||
|
||
## Enable `pallet-assets-holder` | ||
|
||
Define an instance of `pallet-assets-holder` (we'll call it `AssetsHolder`) and use | ||
`AssetsHolder` as the type for `Holder`, when intend to use holding capabilities are | ||
wanted in the runtime implementation. | ||
|
||
crates: | ||
- name: asset-hub-rococo-runtime | ||
bump: minor | ||
- name: asset-hub-westend-runtime | ||
bump: minor | ||
- name: pallet-asset-tx-payment | ||
bump: patch | ||
- name: pallet-asset-conversion-ops | ||
bump: patch | ||
- name: pallet-asset-conversion-tx-payment | ||
bump: patch | ||
- name: pallet-assets | ||
bump: major | ||
- name: pallet-assets-holder | ||
bump: major | ||
- name: pallet-assets-freezer | ||
bump: patch | ||
- name: pallet-contracts-mock-network | ||
bump: patch | ||
- name: pallet-nft-fractionalization | ||
bump: patch | ||
- name: pallet-revive-mock-network | ||
bump: patch | ||
- name: pallet-xcm | ||
bump: patch | ||
- name: penpal-runtime | ||
bump: patch | ||
- name: rococo-parachain-runtime | ||
bump: patch | ||
- name: polkadot-sdk | ||
bump: minor | ||
- name: staging-xcm-builder | ||
bump: patch | ||
- name: xcm-runtime-apis | ||
bump: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe having a comparison with the previous model would help for people having live chains to not be scared by this change.
The change for live chains with assets with freeze is that now the ED is included in the frozen amount, as a result the new frozen amount will be the previous frozen amount - ED.