pendulum-chain / pendulum

GNU General Public License v3.0
43 stars 14 forks source link

Use truly free balance (liquid) in chain extension #501

Closed gianfra-t closed 1 month ago

gianfra-t commented 1 month ago

Closes #483

Uses the reducible_balance fn from the Inspect trait. This is the truly liquid balance see here of orml_tokens and here for pallet_balances. Here frozen has a different meaning but the meaning of liquid is the same judging by how both use it in their transfer_all function.

There is no need to substract from reserved since these free and reserved are already mutually exclusive (see the reserve extrinsic).

Why not use MultiCurrency

Sadly, this trait does not implement the notion of a reducible balance nor of a frozen balance. It does implement this notion in ensure_can_withdraw but this won't actually tell us the amount, so the Inspect trait seems to be the only choice (that I could find). But this means we need to match between the native and token variants, which is not very ergonomic. Also, the return is encoded to avoid mismatches of Balance type.

ebma commented 1 month ago

@gianfra-t is this ready for review? You didn't add reviewers.

gianfra-t commented 1 month ago

Yes @ebma it is, but tests are failing (I was waiting for them). I will check if it is related.

gianfra-t commented 1 month ago

I will ran format afterwards since it will as always complicate the review of actual changes.

gianfra-t commented 1 month ago

I merged this even if the CI showed a failure, because locally when running the last clippy commands they all work. It may have been a one time thing.

TorstenStueber commented 1 month ago

Is the failing CI due to clippy? Isn't it the Test job that fails with the following error?

Oct 14 13:51:18.446 ERROR parachain_staking::pallet: 💥 keeping old session because of empty collator set!
gianfra-t commented 1 month ago

But that has been a very common log we see almost always we start the chain in tests. I doubt it will make the CI fail.

It almost seems like it didn't run the last 3 jobs.

gianfra-t commented 1 month ago

Ohhh I checked the logs of the CI again and I see:

System.IO.IOException: No space left on device : '/home/runner/runners/2.320.0/_diag/Worker_20241014-124125-utc.log

So that's it.