Skip to content

[V124-specific] Deduct all pending txout item amounts when selecting outbound vaults

Multipartite requested to merge Multi/deduct-all-pending-txouts into develop

[V124-specific]


Intended to close #1494 (closed)
'More txouts can be assigned to a vault than it has the balance to pay'.

Specifically, doing this by reverting part of !2408 (merged)
'Optimise outbound vaults selection logic'.

Please note that while SortBySecurity takes txout items into account when sorting a slice of vaults, it does not change the balances of the vaults in the slice it returns.


Further thoughts:

Vaults do need to have both outbound-queue and scheduled-outbound-queue items deducted,
in order to represent only those funds which are available for new txout items.

That said, if/since SortBySecurity only takes into account outbound-queue txout items and not scheduled-outbound-queue txout items, then use of SortBySecurity in manager_txout_current.go requires either ignoring the scheduled-outbound-queue items when using it or counting the outbound-queue txout items twice.

Once approach would be to replace SortBySecurity with a new version-indicating SortBySecurityV function which also accounts for scheduled-outbound-queue txout items.
Please tell me if this is preferred.

For the moment, treating SortBySecurity as the function currently intended to be indicative of vault security
(though why ignore scheduled-outbound-queue txout items if so?),
my current approach is to do the SortBySecurity sorting before the deductVaultPendingOutbounds deductions.

Further further thoughts:
On reflection, perhaps the reasoning is that outbound-queue items have already started being signed for and so can't reliably be stolen, whereas scheduled-outbound-queue items are vulnerable to being stolen because there's no signing competing for them (until their scheduled outbound height).
(If this is indeed the reasoning used, I believe it is consistent with doing the security-based sort before deducting (both types of) txout items.)

Edited by Multipartite

Merge request reports