Fee calculation
Closed this issue · 0 comments
ERussel commented
Previous approach for fee calculation took sum of the amount values from the events balances.Deposit
and treasury.Deposit
. This approach is indirect and makes assumption that fee for transaction processing is distributed between block author and treasury. However there are corner cases: it can be multiple balances.Deposit
events and also it can be imbalance which also contributes to treasury.Deposit
.
New approach should you recently introduced balances.Withdraw
event but also should have fallback for previous approach to support old blocks. So the algorithm is the following:
- If extrinsic contains
balances.Withdraw
event with who parameters matching extrinsic sender then extract amount parameter as a fee, otherwise go to step 2. - Take last
balances.Deposit
andtreasury.Deposit
events and use their amounts sum as fee
To test check these extrinsics: