-
Notifications
You must be signed in to change notification settings - Fork 584
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
Implement pallet-assets-freezer
#3951
Implement pallet-assets-freezer
#3951
Conversation
f2c9643
to
5fae57f
Compare
f59c9ea
to
29c0925
Compare
pallet-assets-freezer
pallet-assets-freezer
b0b6f59
to
c4681b6
Compare
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.
Pallet extension generally looking really good!
pallet-assets
also needs to be modified to allow attaching it, let me know if it's clear enough from Gav's PR how to could do that or if you need some pointers.
bdff229
to
56ac28b
Compare
/// The ID type for freezes. | ||
type FreezeIdentifier: Parameter + Member + MaxEncodedLen + Copy; | ||
|
||
/// The overarching freeze reason. | ||
#[pallet::no_default_bounds] | ||
type RuntimeFreezeReason: VariantCount; |
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.
can you tell please why two separate types?
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.
This follows the logic present in pallet-balances
:
type RuntimeFreezeReason: VariantCount; |
This is used to constraint the maximum amount of freezes to the count of variants in RuntimeFreezeReason
on the integrity test, but allowing the implementor of the pallet to use any other type as freeze identifier in case that's needed by the runtime dev.
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.
@muharem I was also curious and asked in Element but no one answered.
My best guess is it's to allow constraining the FreezeReasons allowed to be used in the pallet?
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.
Lets imagine FreezeIdentifier
is some non enum type, u32
for example. The overarching freeze reason in this case same - u32
. The varian count some const u32
number.
So I would imagine this as
trat Config {
/// The overarching freeze reason.
type RuntimeFreezeReason: Parameter + Member + MaxEncodedLen + Copy;
/// Ax number of freezes possible for a single asset account.
type MaxFreezes: Get<u32>;
}
where any type that implements VariantCount
, implements Get<u32>
by default via generic impl.
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.
there is actually an adapter VariantCountOf
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.
Good catch! In pallet-balances
, the struct VariantCountOf
is used to constraint the limit of Holds
, like this:
polkadot-sdk/substrate/frame/balances/src/lib.rs
Lines 476 to 485 in 0d71753
pub type Holds<T: Config<I>, I: 'static = ()> = StorageMap< | |
_, | |
Blake2_128Concat, | |
T::AccountId, | |
BoundedVec< | |
IdAmount<T::RuntimeHoldReason, T::Balance>, | |
VariantCountOf<T::RuntimeHoldReason>, | |
>, | |
ValueQuery, | |
>; |
This approach works in such a way there's no need to test for integrity, removes the need for a MaxHolds
, and the ambiguity between RuntimeFreezeReason
and FreezeIdentifier
. I can apply the same strategy for RuntimeFreezeReason
in pallet-assets-freezer
.
Open question: considering a freeze reason can be of type RuntimeFreezeReason
or any open-ended type that implements VariantCount
, should it really be named Runtime
in the type?
Note: I also suggest opening an issue to consider whether to standardize this approach to replace FreezeIdentifier
/MaxFreezes
in pallet-balances
in favour of using RuntimeFreezeReason
as the freezes Identifier there. Noticeably, for a potentially future implementation of fungibles::hold
in pallet-assets
either via a pallet extension, or via a direct implementation of those traits. would be good to apply the same approach.
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.
@muharem just removed FreezeIdentifier
in favour of RuntimeFreezeReason
as an unambiguous type for identifying freezes on the pallet. Left a comment above to explain the decision, and proposed some other questions and follow-up steps.
0e5e4c6
to
0f76c41
Compare
/tip medium |
@liamaharon A referendum for a medium (80 DOT) tip was successfully submitted for @pandres95 (12gMhxHw8QjEwLQvnqsmMVY1z5gFa54vND74aMUbhhwN6mJR on polkadot). |
The referendum has appeared on Polkassembly. |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/decoded-2024-sponsorship-for-active-community-members/7654/71 |
@pandres95 can you please resolve the conflicts and merge the master. we merge this after |
Done @muharem |
@pandres95 can you check failing |
@muharem fixed |
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-kusama-bridge/2971/56 |
a477bd0
Closes #3342
cc/ @liamaharon
TODO:
fungibles::freeze::Mutate
#3342).In case we define public calls to the pallet implementation:
polkadot address: 12gMhxHw8QjEwLQvnqsmMVY1z5gFa54vND74aMUbhhwN6mJR