Skip to content

[V122-specific] Restore the cancelled-out 1e8 in CalcTxOutHeight

Multipartite requested to merge Multi/commonOne-TxOutDelayRate-reduction into develop

[V122-specific]

At time of writing, this is the branch referred to in #1535 (closed)
'Queued TxOutItems' value has a neligible effect on TxOutDelayRate, contrary to the commented intention'.

In the line
txOutDelayRate -= int64(sumValue.Uint64()) / minTxOutVolumeThreshold
TxOutDelayRate and MinTxOutVolumeThreshold and sumValue are all in terms of 1e8 RUNE, but the 1e8 cancels out in the reduction.

For TxOutDelayRate 100 RUNE and MinTxOutVolumeThreshold 1000 RUNE,
even if sumValue were 500 million RUNE (the total supply of RUNE),
TxOutDelayRate would only be reduced to 99.995 RUNE.

With
txOutDelayRate -= (int64(sumValue.Uint64()) / minTxOutVolumeThreshold) * common.One
this seeks to restore the cancelled 1e8 term.

The reason for not using
txOutDelayRate -= common.One * int64(sumValue.Uint64()) / minTxOutVolumeThreshold
is that testing this resulted in an int64 overflow, such that the deducted amount was negative,
instead increasing TxOutDelayRate and thus reducing the number of delay blocks.

Suggestions for alternative/safer code approaches are welcome.

Edited by Multipartite

Merge request reports