Fix #232
It seems that a chain using weights but no fees through a weight-to-fee and length-to-fee conversion is functional. The implemented solution is as follows:
When the current block's weight and length is less than a targeted weight and length, the conversion from weight to fee is mapped to 0, so no fee will be levied. When the current block's weight and length exceeds the target, the weight-to-fee conversion is mapped to the original values (see !227 (merged)).
To prevent any attacks, if the previous block's weight or length exceeds the targets, the chain will levy fees based on the current transaction weight multiplied by the FeeMultiplier
. For each consecutive block where the targets are surpassed, the multiplier will be incremented by one. Conversely, when the targets are not met, the multiplier will be decremented by one. The FeeMultiplier
will range from 1 (normal usage) to MaxMultiplier
(heavy usage, with n=MaxMultiplier
consecutive blocks surpassing the target).
Contrary to what is stated in the documentation, the FeeMultiplier
does not act directly on the fee but on the weight part, as fee = base_fee + length_fee + weight_fee * multiplier
.
This MR also fixes #236 (closed), originating from the discussion at https://forum.duniter.org/t/remboursement-des-frais-de-transaction-en-cas-de-bloc-non-plein/12249/17.