Duniter quota pallet
Duniter identity system allows to allocate quota and refund transaction fees when not consumed.
General behavior
Quota system is plugged to transactions fees which is a rather critical aspect of substrate.
That's why in duniter-account
pallet OnChargeTransaction
implementation, the default behavior is preserved, and refunds are added to a queue handled in on_idle
.
Path for a refund
This is what happens on a transaction:
-
frame-executive
callsOnChargeTransaction
implementations -
duniter-account
OnChargeTransaction
implementation is called, and if an identity is linked to the account who pays the fees,request_refund
is called -
request_refund
implementation ofquota
pallet determines whether the fees are eligible for refund based on the identity and then callqueue_refund
-
queue_refund
adds a refund to theRefundQueue
which will be processed inon_idle
- during
on_idle
,quota
pallet processes the refund queue within the supplied weight limit withprocess_refund_queue
- for each refund in the
RefundQueue
,try_refund
is called - it first tries to use quotas to refund fees with
spend_quota
- if a certain amount of quotas has been spend, it actually performs the refund with
do_refund
, taking currency from theRefundAccount
to give it back to the account who paid the fee
The conditions for a refund to happen are:
- an identity is linked to the account who pays the fees
- some quotas are defined for the identity and have a non-null value after update
TODO
- sanity test checking that only member identities have quota