revault / research

4 stars 1 forks source link

Coin selection (Cancel) #6

Open darosior opened 3 years ago

darosior commented 3 years ago
darosior commented 3 years ago

If we go for a pool, the coin selection algorithm should probably be biased toward spending small UTXOs first. This way if the average value needed for a fee bump is increasing, we don't have to re-create new utxos out of the "deprecated" ones: they would be used before they are completely deprecated.

darosior commented 3 years ago

Given:

Fee bump coin selection algorithm

Without a dedicated consolidation mechanism

  1. Strip tx of all fee bumping inputs (spending some of the 8 coins) it could have
  2. Considering all the 8 now-available coins, select the set of the smallest coins such as appended to tx inputs they make its feerate go above f and its absolute fee above F.

FIXME: we could give this a bias. If the feerate is not crazy, do that, if it is, just take the most optimal ones, if it is mildly crazy do an in-between.

With a dedicated consolidation mechanism

If we have a process to swipe the low-value coins during low-fee periods, we can afford to go for the most optimal strategy. [0]

  1. Strip tx of all fee bumping inputs (spending some of the 8 coins) it could have
  2. Considering all the 8 now-available coins, select the set of the largest coins such as appended to tx inputs they make its feerate go above f and its absolute fee above F.

If the reserve isn't enough

In the unlikely case that we need to feebump (because the timelock is about to expire) and the block space price is higher than our reserve, we could use the unregistered coins as an emergency measure. What is the preferable solution?

No-brain rush

Just use up the unregistered coins if it can provide us with a high-enough feerate. This assumes that we won't have to immediately Cancel another vault for a higher value.

Strategic

Allocate unregistered coins to highest-value vaults under watch if we detect that our reserve isn't enough anymore. This gives some more leeway to these vaults should they need to be canceled, and we can still apply the above policy afterward since any left unregistered coin is an excess that can be used up by any vault. Obviously stop accepting new vaults and urge for a refill.


[0] Note that even if we don't, one could argue that they can still be re-purposed. But the assumption is that the average feerate will increase over time and therefore the low-value coins would be harder -if at all possible- to re-assign and eventually need to be sweeped.