Skip to content

Commit 522b437

Browse files
committed
looprpc: map custom channel reason
Static autoloop testing surfaced a SuggestSwaps failure when the planner disqualified a custom asset channel. Add the missing AutoReason enum value and handle ReasonCustomChannelData.
1 parent f377f0b commit 522b437

6 files changed

Lines changed: 33 additions & 4 deletions

File tree

liquidity/reasons.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ func (r Reason) String() string {
128128
case ReasonLoopInUnreachable:
129129
return "loop in unreachable"
130130

131+
case ReasonCustomChannelData:
132+
return "custom channel data"
133+
131134
case ReasonStaticLoopInNoCandidate:
132135
return "no static loop-in candidate"
133136

loopd/swapclient_server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,9 @@ func rpcAutoloopReason(reason liquidity.Reason) (looprpc.AutoReason, error) {
24422442
return looprpc.AutoReason_AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE,
24432443
nil
24442444

2445+
case liquidity.ReasonCustomChannelData:
2446+
return looprpc.AutoReason_AUTO_REASON_CUSTOM_CHANNEL_DATA, nil
2447+
24452448
default:
24462449
return 0, fmt.Errorf("unknown autoloop reason: %v", reason)
24472450
}

loopd/swapclient_server_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,16 @@ func TestRPCAutoloopReasonStaticLoopInNoCandidate(t *testing.T) {
294294
)
295295
}
296296

297+
// TestRPCAutoloopReasonCustomChannelData verifies that custom-channel
298+
// disqualifications are exposed over rpc instead of failing the whole dry run.
299+
func TestRPCAutoloopReasonCustomChannelData(t *testing.T) {
300+
reason, err := rpcAutoloopReason(liquidity.ReasonCustomChannelData)
301+
require.NoError(t, err)
302+
require.Equal(
303+
t, looprpc.AutoReason_AUTO_REASON_CUSTOM_CHANNEL_DATA, reason,
304+
)
305+
}
306+
297307
// TestSwapClientServerStopDaemon ensures that calling StopDaemon triggers the
298308
// daemon shutdown.
299309
func TestSwapClientServerStopDaemon(t *testing.T) {

looprpc/client.pb.go

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

looprpc/client.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,6 +1549,12 @@ enum AutoReason {
15491549
selected, but no full-deposit static candidate fit the rule.
15501550
*/
15511551
AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE = 14;
1552+
1553+
/*
1554+
Custom channel data indicates that the target channel carries custom
1555+
channel data and is excluded from the standard autoloop planner.
1556+
*/
1557+
AUTO_REASON_CUSTOM_CHANNEL_DATA = 15;
15521558
}
15531559

15541560
message Disqualified {

looprpc/client.swagger.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,10 +1544,11 @@
15441544
"AUTO_REASON_LIQUIDITY_OK",
15451545
"AUTO_REASON_BUDGET_INSUFFICIENT",
15461546
"AUTO_REASON_FEE_INSUFFICIENT",
1547-
"AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE"
1547+
"AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE",
1548+
"AUTO_REASON_CUSTOM_CHANNEL_DATA"
15481549
],
15491550
"default": "AUTO_REASON_UNKNOWN",
1550-
"description": " - AUTO_REASON_BUDGET_NOT_STARTED: Budget not started indicates that we do not recommend any swaps because\nthe start time for our budget has not arrived yet.\n - AUTO_REASON_SWEEP_FEES: Sweep fees indicates that the estimated fees to sweep swaps are too high\nright now.\n - AUTO_REASON_BUDGET_ELAPSED: Budget elapsed indicates that the autoloop budget for the period has been\nelapsed.\n - AUTO_REASON_IN_FLIGHT: In flight indicates that the limit on in-flight automatically dispatched\nswaps has already been reached.\n - AUTO_REASON_SWAP_FEE: Swap fee indicates that the server fee for a specific swap is too high.\n - AUTO_REASON_MINER_FEE: Miner fee indicates that the miner fee for a specific swap is to high.\n - AUTO_REASON_PREPAY: Prepay indicates that the prepay fee for a specific swap is too high.\n - AUTO_REASON_FAILURE_BACKOFF: Failure backoff indicates that a swap has recently failed for this target,\nand the backoff period has not yet passed.\n - AUTO_REASON_LOOP_OUT: Loop out indicates that a loop out swap is currently utilizing the channel,\nso it is not eligible.\n - AUTO_REASON_LOOP_IN: Loop In indicates that a loop in swap is currently in flight for the peer,\nso it is not eligible.\n - AUTO_REASON_LIQUIDITY_OK: Liquidity ok indicates that a target meets the liquidity balance expressed\nin its rule, so no swap is needed.\n - AUTO_REASON_BUDGET_INSUFFICIENT: Budget insufficient indicates that we cannot perform a swap because we do\nnot have enough pending budget available. This differs from budget elapsed,\nbecause we still have some budget available, but we have allocated it to\nother swaps.\n - AUTO_REASON_FEE_INSUFFICIENT: Fee insufficient indicates that the fee estimate for a swap is higher than\nthe portion of total swap amount that we allow fees to consume.\n - AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE: No static loop-in candidate indicates that static loop-in autoloop was\nselected, but no full-deposit static candidate fit the rule."
1551+
"description": " - AUTO_REASON_BUDGET_NOT_STARTED: Budget not started indicates that we do not recommend any swaps because\nthe start time for our budget has not arrived yet.\n - AUTO_REASON_SWEEP_FEES: Sweep fees indicates that the estimated fees to sweep swaps are too high\nright now.\n - AUTO_REASON_BUDGET_ELAPSED: Budget elapsed indicates that the autoloop budget for the period has been\nelapsed.\n - AUTO_REASON_IN_FLIGHT: In flight indicates that the limit on in-flight automatically dispatched\nswaps has already been reached.\n - AUTO_REASON_SWAP_FEE: Swap fee indicates that the server fee for a specific swap is too high.\n - AUTO_REASON_MINER_FEE: Miner fee indicates that the miner fee for a specific swap is to high.\n - AUTO_REASON_PREPAY: Prepay indicates that the prepay fee for a specific swap is too high.\n - AUTO_REASON_FAILURE_BACKOFF: Failure backoff indicates that a swap has recently failed for this target,\nand the backoff period has not yet passed.\n - AUTO_REASON_LOOP_OUT: Loop out indicates that a loop out swap is currently utilizing the channel,\nso it is not eligible.\n - AUTO_REASON_LOOP_IN: Loop In indicates that a loop in swap is currently in flight for the peer,\nso it is not eligible.\n - AUTO_REASON_LIQUIDITY_OK: Liquidity ok indicates that a target meets the liquidity balance expressed\nin its rule, so no swap is needed.\n - AUTO_REASON_BUDGET_INSUFFICIENT: Budget insufficient indicates that we cannot perform a swap because we do\nnot have enough pending budget available. This differs from budget elapsed,\nbecause we still have some budget available, but we have allocated it to\nother swaps.\n - AUTO_REASON_FEE_INSUFFICIENT: Fee insufficient indicates that the fee estimate for a swap is higher than\nthe portion of total swap amount that we allow fees to consume.\n - AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE: No static loop-in candidate indicates that static loop-in autoloop was\nselected, but no full-deposit static candidate fit the rule.\n - AUTO_REASON_CUSTOM_CHANNEL_DATA: Custom channel data indicates that the target channel carries custom\nchannel data and is excluded from the standard autoloop planner."
15511552
},
15521553
"looprpcClientReservation": {
15531554
"type": "object",

0 commit comments

Comments
 (0)