mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
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.
This commit is contained in:
parent
58ebb042ff
commit
8ea9adbd35
6 changed files with 33 additions and 4 deletions
|
|
@ -128,6 +128,9 @@ func (r Reason) String() string {
|
|||
case ReasonLoopInUnreachable:
|
||||
return "loop in unreachable"
|
||||
|
||||
case ReasonCustomChannelData:
|
||||
return "custom channel data"
|
||||
|
||||
case ReasonStaticLoopInNoCandidate:
|
||||
return "no static loop-in candidate"
|
||||
|
||||
|
|
|
|||
|
|
@ -2442,6 +2442,9 @@ func rpcAutoloopReason(reason liquidity.Reason) (looprpc.AutoReason, error) {
|
|||
return looprpc.AutoReason_AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE,
|
||||
nil
|
||||
|
||||
case liquidity.ReasonCustomChannelData:
|
||||
return looprpc.AutoReason_AUTO_REASON_CUSTOM_CHANNEL_DATA, nil
|
||||
|
||||
default:
|
||||
return 0, fmt.Errorf("unknown autoloop reason: %v", reason)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,16 @@ func TestRPCAutoloopReasonStaticLoopInNoCandidate(t *testing.T) {
|
|||
)
|
||||
}
|
||||
|
||||
// TestRPCAutoloopReasonCustomChannelData verifies that custom-channel
|
||||
// disqualifications are exposed over rpc instead of failing the whole dry run.
|
||||
func TestRPCAutoloopReasonCustomChannelData(t *testing.T) {
|
||||
reason, err := rpcAutoloopReason(liquidity.ReasonCustomChannelData)
|
||||
require.NoError(t, err)
|
||||
require.Equal(
|
||||
t, looprpc.AutoReason_AUTO_REASON_CUSTOM_CHANNEL_DATA, reason,
|
||||
)
|
||||
}
|
||||
|
||||
// TestSwapClientServerStopDaemon ensures that calling StopDaemon triggers the
|
||||
// daemon shutdown.
|
||||
func TestSwapClientServerStopDaemon(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -427,6 +427,9 @@ const (
|
|||
// No static loop-in candidate indicates that static loop-in autoloop was
|
||||
// selected, but no full-deposit static candidate fit the rule.
|
||||
AutoReason_AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE AutoReason = 14
|
||||
// Custom channel data indicates that the target channel carries custom
|
||||
// channel data and is excluded from the standard autoloop planner.
|
||||
AutoReason_AUTO_REASON_CUSTOM_CHANNEL_DATA AutoReason = 15
|
||||
)
|
||||
|
||||
// Enum value maps for AutoReason.
|
||||
|
|
@ -447,6 +450,7 @@ var (
|
|||
12: "AUTO_REASON_BUDGET_INSUFFICIENT",
|
||||
13: "AUTO_REASON_FEE_INSUFFICIENT",
|
||||
14: "AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE",
|
||||
15: "AUTO_REASON_CUSTOM_CHANNEL_DATA",
|
||||
}
|
||||
AutoReason_value = map[string]int32{
|
||||
"AUTO_REASON_UNKNOWN": 0,
|
||||
|
|
@ -464,6 +468,7 @@ var (
|
|||
"AUTO_REASON_BUDGET_INSUFFICIENT": 12,
|
||||
"AUTO_REASON_FEE_INSUFFICIENT": 13,
|
||||
"AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE": 14,
|
||||
"AUTO_REASON_CUSTOM_CHANNEL_DATA": 15,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
@ -7059,7 +7064,7 @@ const file_client_proto_rawDesc = "" +
|
|||
"\x1dLOOP_IN_SOURCE_STATIC_ADDRESS\x10\x01*/\n" +
|
||||
"\x11LiquidityRuleType\x12\v\n" +
|
||||
"\aUNKNOWN\x10\x00\x12\r\n" +
|
||||
"\tTHRESHOLD\x10\x01*\xd3\x03\n" +
|
||||
"\tTHRESHOLD\x10\x01*\xf8\x03\n" +
|
||||
"\n" +
|
||||
"AutoReason\x12\x17\n" +
|
||||
"\x13AUTO_REASON_UNKNOWN\x10\x00\x12\"\n" +
|
||||
|
|
@ -7077,7 +7082,8 @@ const file_client_proto_rawDesc = "" +
|
|||
"\x18AUTO_REASON_LIQUIDITY_OK\x10\v\x12#\n" +
|
||||
"\x1fAUTO_REASON_BUDGET_INSUFFICIENT\x10\f\x12 \n" +
|
||||
"\x1cAUTO_REASON_FEE_INSUFFICIENT\x10\r\x12+\n" +
|
||||
"'AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE\x10\x0e*\x88\x02\n" +
|
||||
"'AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE\x10\x0e\x12#\n" +
|
||||
"\x1fAUTO_REASON_CUSTOM_CHANNEL_DATA\x10\x0f*\x88\x02\n" +
|
||||
"\fDepositState\x12\x11\n" +
|
||||
"\rUNKNOWN_STATE\x10\x00\x12\r\n" +
|
||||
"\tDEPOSITED\x10\x01\x12\x0f\n" +
|
||||
|
|
|
|||
|
|
@ -1549,6 +1549,12 @@ enum AutoReason {
|
|||
selected, but no full-deposit static candidate fit the rule.
|
||||
*/
|
||||
AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE = 14;
|
||||
|
||||
/*
|
||||
Custom channel data indicates that the target channel carries custom
|
||||
channel data and is excluded from the standard autoloop planner.
|
||||
*/
|
||||
AUTO_REASON_CUSTOM_CHANNEL_DATA = 15;
|
||||
}
|
||||
|
||||
message Disqualified {
|
||||
|
|
|
|||
|
|
@ -1544,10 +1544,11 @@
|
|||
"AUTO_REASON_LIQUIDITY_OK",
|
||||
"AUTO_REASON_BUDGET_INSUFFICIENT",
|
||||
"AUTO_REASON_FEE_INSUFFICIENT",
|
||||
"AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE"
|
||||
"AUTO_REASON_STATIC_LOOP_IN_NO_CANDIDATE",
|
||||
"AUTO_REASON_CUSTOM_CHANNEL_DATA"
|
||||
],
|
||||
"default": "AUTO_REASON_UNKNOWN",
|
||||
"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."
|
||||
"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."
|
||||
},
|
||||
"looprpcClientReservation": {
|
||||
"type": "object",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue