-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Contracts: migrate to fungible traits #14020
Contracts: migrate to fungible traits #14020
Conversation
Needs a migration. So we wait with merging until #14045 is merged so we can include the migration in this PR. |
log::info!( | ||
target: LOG_TARGET, | ||
"Total held amount for storage deposit: {:?}", | ||
total_held | ||
); |
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.
wouldn't comparing the total held vs reserved amount be enough here ?
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.
Unfortunately not, as there could be several reasons the code owner could have balance reserved, not just for uploaded code deposit. Therefore the "old" reserved balance should be >= than the "new" held balance under the HoldReason::CodeUploadDepositReserve
, and that's a loose comparison to make.
@@ -4256,12 +4225,15 @@ fn set_code_extrinsic() { | |||
#[test] | |||
fn slash_cannot_kill_account() { |
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.
do we need this test at all as slashing can not kill account by design now that we moved to fungible?
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.
In general I would agree, but the fact that this extra test is there does not hurt, and it adds an extra shield that can potentially prevent a situation in which we are not thinking of at the moment. (It might sound stupid, but maybe a situation where the Currency type used in the test does not honour the actual definition of the trait implementation)
bot merge |
1 similar comment
bot merge |
* Init `PeerStore` in `build_collator_network` * kick CI * Update Cargo.lock for substrate * Companion for substrate 14373 * Companion for paritytech/substrate#14020 * update lockfile for {"substrate", "polkadot"} --------- Co-authored-by: Davide Galassi <davxy@datawok.net> Co-authored-by: parity-processbot <>
Fix #13643
Cumulus companion: paritytech/cumulus#2841
The
Currency
(andReservableCurrency
) traits are deprecated after this PR in favour of thefungible
traits.A few things have changed:
ReservableCurrency::reserve
becomesfungible::hold::Mutate::hold
; andReservableCurrency::unreserve
becomesfungible::hold::Mutate::release
Holds are roughly analagous to reserves, but are now explicitly designed to be infallibly slashed. They do not contribute to the ED but do require a provider reference, removing any possibility of account reference counting from being problematic for a slash. They are also always named, ensuring different holds do not accidentally slash each other's balances.
Also they require an identifier which is configurable and is expected to be an enum aggregated across all pallet instances of the runtime.
In the Pallet Contracts context we only have one identifier only
HoldReason::CodeUploadDepositReserve
Due to the changes from
reserve/unreserve
tohold/release
some events have been changed:pallet_balances::Event::Reserved
is not fired anymore in the context of Contracts, insteadpallet_contracts::Event::CodeStored
contains adeposit_held
field.pallet_balances::Event::Unreserved
is not fired anymore in the context of Contracts, insteadpallet_contracts::Event::CodeRemoved
contains adeposit_held
field.Please note that these events belong to
pallet_contracts
as thefungible
traits don't emit any events onhold
andrelease
.The
ExistenceRequirement
enum is not used anymore, it is replaced byPreservation
. They don't map exactly therefore a few adaptations have been made.Currency::transfer()
does not perform the sanity it used to anymore, so those are now addressed before callingCurrency::transfer()
Upgrade notes
The
pallet_contracts::Config
trait now requires new typeRuntimeHoldReason
:Also,
construct_runtime
needspallet_contracts::HoldReason
:Migrations generic
OldCurrency
Some migrations require a generic
OldCurrency
that implements the traits that the previousT::Currency
implemented. Most commonly we could just usepallet_balances::Pallet<T>
.Deposit account
After this PR we should no longer need the deposit accounts, as the new "held" balance does not contribute to the
ED
.This PR does not alters the deposit accounts and its functionality. There is this other PR #14589 that takes care of that.