Skip to content

Commit d5096cd

Browse files
committed
liquidity: relax restriction which requires no unrestricted swaps
In practice, this restriction has proven to be too strict. Autoloop will now only hold off on a swap for a channel if a manual swap is specifically using that channel.
1 parent 7ba1821 commit d5096cd

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

docs/autoloop.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,4 @@ in manually dispatched swaps - for loop out, this would mean the channel is
224224
specified in the outgoing channel swap, and for loop in the channel's peer is
225225
specified as the last hop for an ongoing swap. This check is put in place to
226226
prevent the autolooper from interfering with swaps you have created yourself.
227-
If there is an ongoing swap that does not have a restriction placed on it (no
228-
outgoing channel set, or last hop), then the autolooper will take no action
229-
until it has resolved, because it does not know how that swap will affect
230-
liquidity balances.
231227

liquidity/liquidity.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -930,8 +930,6 @@ func (m *Manager) checkExistingAutoLoops(ctx context.Context,
930930

931931
// getEligibleChannels takes lists of our existing loop out and in swaps, and
932932
// gets a list of channels that are not currently being utilized for a swap.
933-
// If an unrestricted swap is ongoing, we return an empty set of channels
934-
// because we don't know which channels balances it will affect.
935933
func (m *Manager) getEligibleChannels(ctx context.Context,
936934
loopOut []*loopdb.LoopOut, loopIn []*loopdb.LoopIn) (
937935
[]lndclient.ChannelInfo, error) {
@@ -988,13 +986,6 @@ func (m *Manager) getEligibleChannels(ctx context.Context,
988986
continue
989987
}
990988

991-
if len(chanSet) == 0 {
992-
log.Debugf("Ongoing unrestricted loop out: "+
993-
"%v, no suggestions at present", out.Hash)
994-
995-
return nil, nil
996-
}
997-
998989
for _, id := range chanSet {
999990
chanID := lnwire.NewShortChanIDFromInt(id)
1000991
existingOut[chanID] = true
@@ -1007,11 +998,9 @@ func (m *Manager) getEligibleChannels(ctx context.Context,
1007998
continue
1008999
}
10091000

1001+
// Skip over swaps that may come through any peer.
10101002
if in.Contract.LastHop == nil {
1011-
log.Debugf("Ongoing unrestricted loop in: "+
1012-
"%v, no suggestions at present", in.Hash)
1013-
1014-
return nil, nil
1003+
continue
10151004
}
10161005

10171006
existingIn[*in.Contract.LastHop] = true

liquidity/liquidity_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ func TestRestrictedSuggestions(t *testing.T) {
299299
{
300300
name: "unrestricted loop out",
301301
channels: []lndclient.ChannelInfo{
302-
channel1, channel2,
302+
channel1,
303303
},
304304
loopOut: []*loopdb.LoopOut{
305305
{
@@ -308,12 +308,14 @@ func TestRestrictedSuggestions(t *testing.T) {
308308
},
309309
},
310310
},
311-
expected: nil,
311+
expected: []loop.OutRequest{
312+
chan1Rec,
313+
},
312314
},
313315
{
314316
name: "unrestricted loop in",
315317
channels: []lndclient.ChannelInfo{
316-
channel1, channel2,
318+
channel1,
317319
},
318320
loopIn: []*loopdb.LoopIn{
319321
{
@@ -322,7 +324,9 @@ func TestRestrictedSuggestions(t *testing.T) {
322324
},
323325
},
324326
},
325-
expected: nil,
327+
expected: []loop.OutRequest{
328+
chan1Rec,
329+
},
326330
},
327331
{
328332
name: "restricted loop out",

release_notes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ This file tracks release notes for the loop client.
2424
baked one with the exact permissions needed for Loop. If the now deprecated
2525
flag/option `--lnd.macaroondir` is used, it will fall back to use only the
2626
`admin.macaroon` from that directory.
27+
* The rules used for autoloop have been relaxed to allow autoloop to dispatch
28+
swaps even if there are manually initiated swaps that are not limited to a
29+
single channel in progress. This change was made to allow autoloop to coexist
30+
with manual swaps.
2731

2832
#### Breaking Changes
2933
* The `AutoOut`, `AutoOutBudgetSat` and `AutoOutBudgetStartSec` fields in the

0 commit comments

Comments
 (0)