-
Notifications
You must be signed in to change notification settings - Fork 690
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
Refactor pallet recovery to fungibles #1807
Conversation
#[cfg(feature = "runtime-benchmarks")] | ||
type Currency: Mutate<Self::AccountId> | ||
+ MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>; |
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.
We need to set_balance
in benchmarking, so Mutate
is needed
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.
It is possible to set custom where bounds for benchmarks, like this.
So it should be possible to add a <T as Config>::Currency: Mutate
there.
bot bench $ pallet dev pallet_recovery |
@juangirini Positional arguments are not supported anymore. I guess you meant |
bot bench substrate-pallet --pallet=pallet_recovery |
@juangirini https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3893936 was started for your command Comment |
@juangirini Command |
Hey, I was already working on moving |
I did update #226 before starting this, not sure how that got lost in between. I have just updated it again, sorry to hear that you already spent time on it. |
bot bench substrate-pallet --pallet=pallet_recovery |
@juangirini https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/3932248 was started for your command Comment |
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.
You're missing a migration for those runtimes that use this pallet
@@ -187,7 +192,7 @@ type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup | |||
pub struct ActiveRecovery<BlockNumber, Balance, Friends> { | |||
/// The block number when the recovery process started. | |||
created: BlockNumber, | |||
/// The amount held in reserve of the `depositor`, | |||
/// The amount held the `depositor`, |
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.
/// The amount held the `depositor`, | |
/// The amount held by the `depositor`, |
…=dev --target_dir=substrate --pallet=pallet_recovery
@juangirini Command |
I guess we can't really migrate until we have the MBM PR (#1781) ready. And lazy migrations don't seem to be a great solution as with it |
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.
Looks good 👍
#[cfg(feature = "runtime-benchmarks")] | ||
type Currency: Mutate<Self::AccountId> | ||
+ MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason>; |
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.
It is possible to set custom where bounds for benchmarks, like this.
So it should be possible to add a <T as Config>::Currency: Mutate
there.
// Acts like a slashing mechanism for those who try to maliciously recover accounts. | ||
let res = T::Currency::repatriate_reserved( | ||
let res = T::Currency::transfer_on_hold( |
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.
I am thinking about how to do a lazy migration here. Maybe you can require the Currency
config trait to be Currency + MutateHold
so that it requires currency and fungibles.
Then in this function you can first try to use the new transfer_on_hold
function, but if that does not work then fallback to the old repatriate_reserved
. Do you think this could work?
Otherwise the MBMs are still in review and will need audit, so its a bit out.
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.
I am not a big fan of lazy migrations here, cause that will generate some "garbage" code that will live there forever. It seems more like a patch to me than a real solution. It's been a while already since we wanted the traits to be migrated that I would rather wait for the MBM to be ready and apply a proper solution
The CI pipeline was cancelled due to failure one of the required jobs. |
Stale |
Partial for #226
The Currency (and
ReservableCurrency
) traits are deprecated after this paritytech/substrate#12951 in favour of the fungible traits.A few things have changed:
ReservableCurrency::reserve
becomesfungible::MutateHold::hold
;ReservableCurrency::unreserve
becomesfungible::MutateHold::release
andReservableCurrency::repatriate_reserved
becomesfungible::MutateHold::transfer_on_hold
.Holds are roughly analogous 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 Recovery context we only have
HoldReason::RecoveryProcessDeposit
andHoldReason::ConfigurationDeposit
Upgrade notes
The
pallet_recovery::Config
trait now requires new typeRuntimeHoldReason
:Also,
construct_runtime
needspallet_recovery::HoldReason
:TODO