CalcTxOutHeight's GetTxOutValue ignores MaxGas value
For UTXO outbounds especially, THORChain sends out the full MaxGas and any not used for the miner gas cost goes to the recipient.
Even for non-UTXO outbounds, the MaxGas represents the maximum value THORChain's signed transaction allows to be taken by the miner.
CalcTxOutHeight
calls GetTxOutValue
:
https://gitlab.com/thorchain/thornode/-/blob/v1.127.0/x/thorchain/manager_txout_current.go#L827-828
for height := ctx.BlockHeight() + 1; height <= ctx.BlockHeight()+txOutDelayMax; height++ {
value, clout, err := tos.keeper.GetTxOutValue(ctx, height)
(though not for past-scheduled outbounds, as when the pending outbound queue has lots of items; why not?)
, but GetTxOutValue
only reflects the outbound value of the TxOutItem's Coin and not its MaxGas.
https://gitlab.com/thorchain/thornode/-/blob/v1.127.0/x/thorchain/keeper/v1/keeper_txout.go#L78-88
for _, item := range txout.TxArray {
if item.Coin.Asset.IsRune() {
runeValue = runeValue.Add(item.Coin.Amount)
} else {
var pool Pool
pool, err = k.GetPool(ctx, item.Coin.Asset)
if err != nil {
_ = dbError(ctx, fmt.Sprintf("unable to get pool : %s", item.Coin.Asset), err)
continue
}
runeValue = runeValue.Add(pool.AssetValueInRune(item.Coin.Amount))
I currently propose that GetTxOutValue
be versioned (using k.GetVersion()
)
and a range used for a Coin-slice includes both the Coin and each Coin in the MaxGas.
Specifically: !3410 (merged)
'GetTxOutValue
: Sum the value of MaxGas Coins too'.