Retiring Asgards are not selected for outbounds if few Active Asgards have received the asset type
This can be framed as 'in admiration of !2408 (merged) and !2534 (merged), and wanting to tighten them further'.
(Adjusted conditionals now in !2602 (closed).)
Another vault selection band-aid:
Early in Asgard migration (assuming deprecated Yggdrasils), consider if only one new Asgard has received a small amount of an Asset and no single Retiring Asgard has enough of the Asset to satisfy a swap in a single outbound.
By the requirement len(outputs) > len(outputsC)
,
my current impression is that even if remaining
is non-zero and remainingC
is zero,
the current code keeps the non-zero remaining
and refunds the swap with the error 'insufficient funds for outbound request'.
In the hypothetical example, the swapper might prefer to pay two outbound fees and have the swap complete rather than pay one outbound fee for the refund and one for the retry later.
Discussion is welcome.
Update: In blocks 8775871 and 8775786
(2022-12-22, two months and two weeks after this Issue's submission,
one month three weeks after !2624 (merged)'s submission)
a user (later asking in dismay in Discord (thread link) tried two times to do a swap to BUSD.
Both attempts were refunded (with similar reasons).
Using the first reason as an example:
"reason": "fail to add outbound tx: 2 errors occurred:\n\t* internal error\n\t* fail to prepare outbound tx: insufficient funds for outbound request: bnb1m96vgqz9hujppjmact32mklaw5ffduyhsfdp28 50954639176 remaining\n\n",
|
The (1e8) amount to swap was 911003879292, approximately equal to 101080259304,
According to the Asgard balances,
four ActiveVaults had BUSD balances and all five RetiringVaults had BUSD balances.
|
The four ActiveVaults: 49174971296 + 18930510132655 + 38186120510114 + 35232127176827
= 92397932790892.
Even with [the items in the outbound queue](https://thornode-v1.ninerealms.com/thorchain/queue/outbound?height=8775871 (208341967136 + 28541456568, no BUSD in the scheduled outbound queue) that should have been plenty.
|
There were seven Yggdrasils with small non-zero BUSD balances.
A single outbound fee is a minimum of 1 USD (by Mimir key MinimumL1OutboundFeeUSD), which was greater than the balances of five of the Yggdrasils:
59556580, 92090850, 67462081, 68439722, 33964550.
|
As such, I currently predict that the Yggdrasil outbounds selected by the current code would have two outputs and a non-zero remaining
, and so did not select any ActiveVaults or RetiringVaults with a zero remaining
and more than two outputs (since selecting only on security and not taking into account number of outbounds).
Further (this Issue now being more urgent), I am concerned regarding whether that this could recur even outside vault migrations as long as there are a small number of viable Yggdrasil balances).
(That said, outside vault migrations it is more likely that every ActiveVault (including the most secure one) would be able to satisfy an outbound.)
Further concern: In the above block there are exactly 2 outbound-viable Yggdrasil vaults for BUSD I believe, but if this number became 1 then would all current-code BUSD outbounds fail due to Asgards not being able to arrange fewer than 1 output?
**Update from one churn later:**
https://discord.com/channels/838986635756044328/1055516432206676069/1056617307113279630
B68B47976AB912059813A4EA9F0AE61B91FD3B4580C4F63A9164BFC57A8DDFDF
C6D6935EC0A534546747BE4EA86E835DF2B6B2341ACEC5CB84D55D4787833CE5
https://midgard.ninerealms.com/v2/debug/block/8819313
https://midgard.ninerealms.com/v2/debug/block/8819656
{
"attributes": {
"chain": "BNB",
"code": "108",
"coin": "110000000000 BNB.BUSD-BD1",
"from": "bnb1m96vgqz9hujppjmact32mklaw5ffduyhsfdp28",
"id": "C6D6935EC0A534546747BE4EA86E835DF2B6B2341ACEC5CB84D55D4787833CE5",
"memo": "=:ETH.TGT-325:0x978f267856f322b412d8489539200fb4b6353e1a:6687424568102",
"reason": "fail to add outbound tx: 2 errors occurred:\n\t* internal error\n\t* fail to prepare outbound tx: insufficient funds for outbound request: 0x978f267856f322b412d8489539200fb4b6353e1a 4722981344280 remaining\n\n; fail to refund (110000000000 BNB.BUSD-BD1): fail to prepare outbound tx: insufficient funds for outbound request: bnb1m96vgqz9hujppjmact32mklaw5ffduyhsfdp28 109940443420 remaining",
"to": "bnb1cdr086uky6kyu5ld02du5qnnfxg3ta356err22"
},
"type": "refund"
},
The same issue, but unable to construct an outbound for the refund either, thus the inbound swallowed by the vaults. Since having been observed, this should be resolvable with store migrations without involving the Treasury, but still needs fixing.