From b300da8446bcc4dfa7f13fcacf99400f6baf6237 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 26 Jun 2024 23:03:28 +0200 Subject: [PATCH 1/2] routing: assume TLV payloads everywhere This commit removes another check for TLV payload support of the destination node. We assume TLV payloads as the default everywhere else, so we just remove two checks that were previously forgotten. --- routing/pathfind.go | 26 ++++---------------------- routing/pathfind_test.go | 40 ---------------------------------------- 2 files changed, 4 insertions(+), 62 deletions(-) diff --git a/routing/pathfind.go b/routing/pathfind.go index 32302b941e..fbe4b58308 100644 --- a/routing/pathfind.go +++ b/routing/pathfind.go @@ -543,34 +543,16 @@ func findPath(g *graphParams, r *RestrictParams, cfg *PathFindingConfig, return nil, 0, errMissingDependentFeature } - // Now that we know the feature vector is well formed, we'll proceed in - // checking that it supports the features we need, given our - // restrictions on the final hop. - - // If the caller needs to send custom records, check that our - // destination feature vector supports TLV. - if len(r.DestCustomRecords) > 0 && - !features.HasFeature(lnwire.TLVOnionPayloadOptional) { - - return nil, 0, errNoTlvPayload - } - - // If the caller has a payment address to attach, check that our - // destination feature vector supports them. + // Now that we know the feature vector is well-formed, we'll proceed in + // checking that it supports the features we need. If the caller has a + // payment address to attach, check that our destination feature vector + // supports them. if r.PaymentAddr != nil && !features.HasFeature(lnwire.PaymentAddrOptional) { return nil, 0, errNoPaymentAddr } - // If the caller needs to send custom records, check that our - // destination feature vector supports TLV. - if r.Metadata != nil && - !features.HasFeature(lnwire.TLVOnionPayloadOptional) { - - return nil, 0, errNoTlvPayload - } - // Set up outgoing channel map for quicker access. var outgoingChanMap map[uint64]struct{} if len(r.OutgoingChannelIDs) > 0 { diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 51859adf6d..06005716f5 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -882,13 +882,6 @@ func runFindPathWithMetadata(t *testing.T, useCache bool) { _, err = ctx.findPath(target, paymentAmt) require.ErrorIs(t, errNoPathFound, err) - - // Assert that tlv payload support takes precedence over metadata - // issues. - ctx.restrictParams.DestFeatures = lnwire.EmptyFeatureVector() - - _, err = ctx.findPath(target, paymentAmt) - require.ErrorIs(t, errNoTlvPayload, err) } // runFindLowestFeePath tests that out of two routes with identical total @@ -1261,20 +1254,6 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) { restrictions := *noRestrictions restrictions.DestCustomRecords = record.CustomSet{70000: []byte{}} - _, err = find(&restrictions) - if err != errNoTlvPayload { - t.Fatalf("path shouldn't have been found: %v", err) - } - - // Set empty dest features so we don't try the fallback. We should still - // fail since the tlv feature isn't set. - restrictions.DestFeatures = lnwire.EmptyFeatureVector() - - _, err = find(&restrictions) - if err != errNoTlvPayload { - t.Fatalf("path shouldn't have been found: %v", err) - } - // Finally, set the tlv feature in the payload and assert we found the // same path as before. restrictions.DestFeatures = tlvFeatures @@ -1775,31 +1754,12 @@ func runDestTLVGraphFallback(t *testing.T, useCache bool) { // Add custom records w/o any dest features. restrictions.DestCustomRecords = record.CustomSet{70000: []byte{}} - // Path to luoji should fail because his node ann features are empty. - _, err = find(&restrictions, luoji) - if err != errNoTlvPayload { - t.Fatalf("path shouldn't have been found: %v", err) - } - // However, path to satoshi should succeed via the fallback because his // node ann features have the TLV bit. path, err := find(&restrictions, satoshi) require.NoError(t, err, "path should have been found") assertExpectedPath(t, ctx.testGraphInstance.aliasMap, path, "satoshi") - // Add empty destination features. This should cause both paths to fail, - // since this override anything in the graph. - restrictions.DestFeatures = lnwire.EmptyFeatureVector() - - _, err = find(&restrictions, luoji) - if err != errNoTlvPayload { - t.Fatalf("path shouldn't have been found: %v", err) - } - _, err = find(&restrictions, satoshi) - if err != errNoTlvPayload { - t.Fatalf("path shouldn't have been found: %v", err) - } - // Finally, set the TLV dest feature. We should succeed in finding a // path to luoji. restrictions.DestFeatures = tlvFeatures From 3ceb7d5887eedbeae81f57806542d56ed1a63b37 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Wed, 26 Jun 2024 14:28:21 -0700 Subject: [PATCH 2/2] docs: update release notes --- docs/release-notes/release-notes-0.18.2.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes/release-notes-0.18.2.md b/docs/release-notes/release-notes-0.18.2.md index 644ed5a992..78370fc25e 100644 --- a/docs/release-notes/release-notes-0.18.2.md +++ b/docs/release-notes/release-notes-0.18.2.md @@ -95,4 +95,5 @@ * Bufo * Elle Mouton * Matheus Degiovani +* Oliver Gugger * Slyghtning