Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

reserve operation should ensure repatriate_reserved works. #12701

@gavofyork

Description

@gavofyork

Any pallet implementing ReservableCurrency or fungible::MutateHold should ensure that the reserve/hold operation can be followed by a slash or repatriation of the reserved amount without bringing the state becoming invalid. I.e. something like this should always succeed:

Balances::make_free_balance_be(1, 1000);
if Balances::reserve(1, 1000).is_ok() {
	System::inc_consumers(1);
	assert_ok!(Balances::slash_reserved(1, 1000);
	assert_eq!(System::consumers(1), 1);
	assert_eq!(System::providers(1), 1);
}

Right now, this will fail as the balance is both reserved/slashed and used for a provider ref.

The solution is to ensure that any reserved amounts are not considered toward the ED (only the free, unlocked balance); if a transfer, reserve or lock operation were to take the unlocked free balance below the ED then it should fail.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions