Commit Graph
100 Commits
Author SHA1 Message Date
Carla Kirk-Cohen b31bab3529 docs: add release notes 2023-12-18 12:08:05 -05:00
Carla Kirk-Cohen 4071db77b5 routing: add handling for blinded errors from final node
We do not expect blinding errors from the final node:
1. If the introduction is the recipient, they should use regular errors.
2. Otherwise, nodes have no business sending this error when they are
   not part of a blinded route.
2023-12-18 12:07:56 -05:00
Carla Kirk-Cohen 7ce3a152a1 routing/refactor: add failNode helper to final outcome processing
Note: this refactor updates the inequality used from >= 2 to > 1 to
align with the rest of this file so that we express this concept
consistently throughout the code.
2023-12-18 12:07:47 -05:00
Carla Kirk-Cohen b82478a7e7 routing: add result interpretation for intermediate invalid blinding
This commit adds handling for route blinding errors that are reported
by the introduction node in a multi-hop blinded route. As the
introduction node is always responsible for handling blinded errors,
it is not penalized - only the final hop is penalized to discourage the
blinded route without filling up mission control with ephemeral
results.

If this error code is reported by a node that is not an introduction
node, we penalize the node because it is returning an error code that
it should not be using.
2023-12-18 12:07:46 -05:00
Carla Kirk-Cohen f91589bef9 routing: handle introduction node failure to convert error
This commit adds handling for errors that originate after the
introduction node when making payment to a blinded route. This
indicates that the introduction node is not obeying the spec, so
it is punished for the violation.
2023-12-18 12:07:36 -05:00
Carla Kirk-Cohen 31d4242b6d docs: add release notes for 0.18 2023-12-18 11:27:57 -05:00
Carla Kirk-Cohen af4fdcc1fd htlcswitch/test: allow missing field errors in payload decode 2023-12-18 11:27:56 -05:00
Carla Kirk-Cohen 69d5496e7c multi: update payload validation to account for blinded routes 2023-12-18 11:27:55 -05:00
Carla Kirk-Cohen 343a6ed831 hltcswitch/hop: add next hop to intermediate hop with custom records
Fix our existing test to have a valid intermediate hop that will pass
stricter validation. Previously, we did not specify a next channel for
an intermediate hop (which violates bolt4).
2023-12-18 11:27:53 -05:00
Carla Kirk-Cohen 7db072e020 routing: add additional validation to hop payload creation 2023-12-18 11:27:52 -05:00
Carla Kirk-Cohen 585f28c5f5 multi: explicitly signal final hop in pack hop payload
Previously, we'd use the value of nextChanID to infer whether a payload
was for the final hop in a route. This commit updates our packing logic
to explicitly signal to account for blinded routes, which allow zero
value nextChanID in intermediate hops. This is a preparatory commit
that allows us to more thoroughly validate payloads.
2023-12-18 11:27:52 -05:00
Carla Kirk-Cohen b5afd905d1 htlcswitch/hop: explicitly signal final hop from sphinx packet
Previously, we were using nextChanID to determine whether a hop
payload is for the final recipient. This is no longer suitable in a
route-blinding world where intermediate hops are allowed to have zero
nextChanID TLVs (as this information is provided to forwarding nodes
in their encrypted data). This commit updates payload reading to use
the signal provided by sphinx that we are on the last packet, rather
than implying it from the contents of a hop.
2023-12-18 11:27:51 -05:00
Carla Kirk-Cohen 2f8587341a htlcswitch/test: do not set amount and cltv for blinded test cases 2023-12-18 11:27:50 -05:00
Carla Kirk-Cohen a75bc13230 routing/test: set outgoing timelock on non-legacy test cases
Provide valid hop payloads for tests cases that use TLV onion format.
2023-12-18 11:27:49 -05:00
Carla Kirk-Cohen fa78d21975 htlcswitch/test: add sphinx action to decoding test
Update test to include the sphinx action to more closely represent
reality. This will be required when we add more validation to the
presence of a nextChanID field. A MoreHops action is chose because
we're testing the case with a payload that contains forwarding info.
2023-12-18 11:27:48 -05:00
Carla Kirk-Cohen b0870ea2ed htlcswitch/test: add encrypted data to blinded intermediate hop
Blinding points will always be accompanied by encrypted data, so
update the test to more accurately represent reality.
2023-12-12 10:01:26 -05:00
Carla Kirk-Cohen 1bb48178d7 routing/test: add channel id for final hop in clear route
Add the missing channel field to the final hop in our clear text
route test case. Note that this is the channel of the hop. With the
addition of stricter validation, we'll need this so that the
penultimate hop has a non-zero next channel ID.
2023-12-12 10:01:25 -05:00
Carla Kirk-Cohen d017fe01e3 lnrpc: surface invalid onion blinding on rpc 2023-12-12 09:44:42 -05:00
Carla Kirk-Cohen fd8381bf2a lnwire: add invalid onion blinding error code 2023-12-12 09:44:05 -05:00
Carla Kirk-Cohen a8a86b290c peer/test: setup clean peer for each TestHandleNewPendingChannel case
Running test cases in parallel with shared state means that they
can intermingle if they're run at the same time and set up incorrect
values when we assert on the number of channels we have. Moving the
peer setup into the parallel test run fixes this because no single
test case can interfere with the other.
2023-11-14 15:45:19 -05:00
Carla Kirk-Cohen b994b6f9e0 docs: add release notes 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 32ea77b96b lncli: add blinded route cli flags to query routes
Note: This commit can be dropped before merge, it's mostly added
to make the PR easier to manually test against other
implementations that have bolt 12 invoices implemented already!
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen b42a621438 lntest: add coverage for single hop blinded route query routes 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen eb31ff553b lntest/itest: add coverage for querying routes to blinded paths 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 0e179fae1e routing: remove 0-value warning log in pathfinding
Blinded routes can now have "hints" that have zero value edges, so we
remove this log to avoid spamming logs.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen cae22dc862 lnrpc: add blinded payment to QueryRoutes request 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 63b4ac8057 lnrpc/refactor: move query routes request parsing into method 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen c2aebe2aa9 lnrpc: surface blinded payment fields in hops 2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 014683ee66 routing: include route blinding fields in blinded portion of path
This commit updates route construction to backfill the fields
required for payment to blinded paths and set amount to forward
and expiry fields to zero for intermediate hops (as is instructed
in the route blinding specification).

We could attempt to do this in the first pass, but that loop
relies on fields like amount to forward and expiry to calculate
each hop backwards, so we keep it simple (stupid) and post
processes the blinded portion, since it's computationally cheap
and more readable.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen c9609b8214 multi: add blinded route to route requests expressed as hints
Add the option to include a blinded route in a route request (exclusive
to including hop hints, because it's incongruous to include both), and
express the route as a chain of hop hints.

Using a chain of hints over a single hint to represent the whole path
allows us to re-use our route construction to fill in a lot of the
path on our behalf.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 48e36d93d4 multi/refactor: add RouteRequest to hold FindRoute parameters
This commit introduces a single struct to hold all of the parameters
that are passed to FindRoute. This cleans up an already overloaded
function signature and prepares us for handling requests with blinded
routes where we need to perform some additional processing on our
para (such as extracting the target node from the blinded path).
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 11a007dc16 routing: account for blinded routes in fee calculation
When we introduce blinded routes, some of our hops are expected
to have zero amounts to forward in their hop payload. This commit
updates our hop fee logic to attribute the full blinded route's
fees to the introduction node. We can't actually know where/how
these fees are distributed, so we collect them all at the
introduction node.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 940b491051 routing: only pack amount and cltv if populated
With the addition of blinded routes, we now need to account for the
possibility that intermediate nodes payloads will not have an amount
and expiry set because that information is provided by the recipient
encrypted data blob. This commit updates our payload packing to only
optionally include those fields.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen fee0e05708 multi: add blinded path TLVs to onion payload / hops
This commit adds the encrypted_data, blinding_point and total_amt_msat
tlvs to the known set of even tlvs for the onion payload. These TLVs
are added in two places (the onion payload and hop struct) because
lnd uses the same set of TLV types for both structs (and they
inherently represent the same thing).

Note: in some places, unit tests intentionally mimic the style
of older tests, so as to be more consistently readable.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 539a275faa routing: add representation of blinded payments
This commit adds a representation of blinded payments, which include a
blinded path and aggregate routing parameters to be used in payment to
the path.
2023-10-06 16:38:33 -07:00
Carla Kirk-Cohen 4645fdfb0a invoice/test: make all tests parallel
When we have tests using global variables and a mix of parallel and
non-parallel tests, odd races can appear when we run them.
2023-07-24 10:54:03 -04:00
Carla Kirk-Cohen 94e434d2f1 invoices/test: move payment address required global into test using it 2023-07-24 10:54:02 -04:00
Carla Kirk-Cohen d080d07a22 invoices/test: remove duplicate test invoice amount global
We have testInvoiceAmt and testInvoiceAmount with the same value.
2023-07-24 10:54:01 -04:00
Carla Kirk-Cohen 40f695743a invoice/test: move payment address optional into test using it
No need for a global when this is only used once.
2023-07-24 10:54:00 -04:00
Carla Kirk-Cohen ceff879f37 invoices/test: replace global testInvoice with constructor
For our relatively "static" test invoice, add a simple constructor
using the globals defined, rather than having a global invoice which
risks being mutated.
2023-07-24 10:53:58 -04:00
Carla Kirk-Cohen 17f529bfad invoices/test: rename newInvoice to reflect return value better
Test utils currently have two different test invoices - a minimalist
one that is used in a variety of test cases, and a customizable one
that is used specifically for tests concerning invoice expiry. The
latter is renamed and moved closer to the calling code to more clearly
indicate its use.
2023-07-17 09:39:40 -04:00
Carla Kirk-Cohen 590d898ba0 invoices/test: fix data race in TestMppPaymentWithOverpayment
Details of race:
- A global testInvoice is used in various invoice related tests.
- All tests are running with t.Parallel.
- TestMppPaymentWithOverpayment passes a reference to the testInvoice
  to AddInvoice which writes the AddIndex.
- TestMultipleSetHeightExpiry reads the testInvoice to make a copy.
2023-07-13 10:39:35 -04:00
Carla Kirk-Cohen 8a9dd105fc docs: add release notes 2023-06-02 11:01:45 -04:00
Carla Kirk-Cohen 7b1a288320 channeldb: store extra HTLC data in variable onion blob slot
Take advantage of the variable byte encoding for a known length field
to extend HLTCs with additional data.
2023-06-02 11:01:44 -04:00
Carla Kirk-Cohen 2fc8e9d617 multi: update channel db HTLC OnionBlob to array
We know that onion blobs in lightning are _exactly_ 1366 bytes in
lightning, but they are currently expressed as a byte slice in
channeldb's HTLC struct. Blobs are currently serialized as var bytes,
so we can take advantage of this known length and variable length
to add additional data to the inline serialization of our HTLCs, which
are otherwise not easily extensible (without creating a new bucket).
2023-06-02 11:01:43 -04:00
Carla Kirk-Cohen 820920a749 docs: add release notes 2023-05-04 10:42:44 -04:00
Carla Kirk-Cohen ad6ccb415f lncli: fix typo in updatenodeannouncement 2023-05-04 10:42:37 -04:00
Carla Kirk-Cohen 019da315a8 itest: add coverage for custom features 2023-05-04 10:42:17 -04:00
Carla Kirk-Cohen fe7cad2695 features: disallow unsetting of config-set features 2023-05-04 10:35:49 -04:00
Carla Kirk-Cohen 4e36e2fd2b multi: add custom feature bits to config options 2023-05-04 10:35:48 -04:00
Carla Kirk-Cohen 4e98f4da5e feature/refactor: unexport set raw 2023-05-04 10:35:47 -04:00
Carla Kirk-Cohen e41c65785f multi: update node announcement features in feature manager first
Move merge of our features into the feature manager, rather than
updating our node announcement then retrospectively setting the
feature manger's set to the new vector. This allows us to use the
feature vector as our single source of truth for announcements.
2023-05-04 10:35:46 -04:00
Carla Kirk-Cohen 019127c4f4 multi: add restriction on maximum feature bit in invoices
Base 32 encoded bolt 11 invoices only allow 10 bits to express the
length of the feature vector in a tagged field, so there is a much
lower limit on the values invoice custom features can hold.

Other places in the protocol are theoretically limited by the maximum
message size, but since we express a feature bit as u16 we don't need
to be concerned about this.

The decision is made to track maximum per-set in the feature manager,
which is conceptually aware of sets and then validate in lnwire/features
against some arbitrary maximum value provided to the caller to keep
the base features package unaware of sets.
2023-05-04 10:35:45 -04:00
Carla Kirk-Cohen 5a139fd297 feature: add update function for safe feature update
Disallow update of any features that are defined by LND (since
just updating the feature, but not the functionality will result in
strange behavior). All known feature bits should be toggled using
protocol config options.
2023-05-04 10:35:44 -04:00
Carla Kirk-Cohen 1a9d743e18 lnwire: add feature vector update validation helpers 2023-05-04 10:35:43 -04:00
Carla Kirk-Cohen 3f9f0ea5d1 multi/refactor: separate methods for get and set node announcement
In preparation for a more complex function signature for set node
announcement, separate get and set so that readonly callers don't need
to handle the extra arguments.
2023-05-04 10:35:42 -04:00
Carla Kirk-Cohen c6263c2fe6 multi/refactor: move node ann modification outside of sign method
In preparation for moving feature bit modification inside of the
feature manager, separate node modification from signing.
2023-05-04 10:35:41 -04:00
Carla Kirk-Cohen 03a61617f8 release-notes: add UpdateNodeAnnouncement changes 2023-02-16 14:42:20 -05:00
Carla Kirk-Cohen 3cc8e81121 lncli/bugfix: use int64slice for update node announcement features
As is, we'll never get any add/remove features because the flag is
set as an int 64 slice but accessed as an int slice (which has no
value, and the cli doesn't fail if the flag doesn't exist).
2023-02-14 15:53:56 -05:00
Carla Kirk-Cohen 19f013b5c4 release-notes: add send custom message override functionality 2023-01-05 12:06:25 -05:00
Carla Kirk-Cohen 1b1bc642bc lntest/itest: add custom messaging itest including new override feature 2023-01-05 12:06:24 -05:00
Carla Kirk-Cohen 1cb08e42ef lnrpc: update custom message API to explain ability to override 2023-01-05 12:05:06 -05:00
Carla Kirk-Cohen c2ce8635e7 multi: add custom message overrides to protocol config options 2023-01-05 12:05:05 -05:00
Carla Kirk-Cohen 93dcbd7ea3 lnwire: allow overriding of protocol messages outside of custom range
Add the ability to specify messages < CustomRangeStart that will still
be treated like custom messages by lnd (rather than unknown ones). This
allows code external to lnd to handle protocol messages that are *not
yet known to lnd*.
2023-01-05 12:05:04 -05:00
Carla Kirk-Cohen 610f5d2140 lnwire: make custom type start a constant 2023-01-05 12:05:03 -05:00
Carla Kirk-Cohen 4df0759ad5 docs: add 0.16 release notes and add warning logging PR 2022-05-16 15:19:19 -04:00
Carla Kirk-Cohen 99828b8ebb multi: add ability to read warning messages and log on link level
Warning messages are intended to add "softer" failure modes for peers,
so to start with we simply log the warnings sent to us. While we "may"
disconnect from the peer according to the spec, we start with the least
extreme option (which is also not a change in behavior because
previously we'd just log that we received an unknown odd message).
2022-05-16 13:51:31 -04:00
Carla Kirk-Cohen f5ef4992e0 lnwire: add warning message wrapping existing Error message structure
This commit adds Warning messages to lnwire, as introduced in bolts/950.
It does not include reading/writing of warning messages, which will be
covered in followup commits.
2022-05-16 13:51:29 -04:00
carla 46e048af31 docs: add pr to release notes 2022-02-07 09:07:10 +02:00
carla 0092c731e5 lnrpc: limit hop hint selection in both passes by amount + count
Previously, we'd always add up to the maximum number of hop hints
(and beyond!) when selecting hop hints in our first pass. This
change updates hop hint selection to always stick to our hop hint
limit, and to the "hop hint factor" that we scale our invoices by.

This change will result in selecting fewer channels in our first
pass if their total inbound capacity reaches our hop hint factor.
This prevents us from revealing as many private channels as
before, but has the downside of providing fewer options for
payers.
2022-02-07 09:04:30 +02:00
carla 5836d58a99 lnrpc: add unit test covering too many hop hints 2022-02-07 09:03:10 +02:00
carla 4ac6f82b5e itest: fix lack of hop hint coverage in hold invoice test
Update our test to assert that we have hop hints present when we
expect them, and fix the "alice is a private node" issue that was
previously preventing us from adding hop hints. Asserting that we
have hop hints present in this itest ensures that we'll fail our
itests if a change to SelectHopHints results in our no longer
having hints in this secnario.
2022-02-07 09:03:09 +02:00
carla 0f8d314ee7 github: simplify PR template and add more sections [skip ci] 2022-01-28 09:50:02 +02:00
carla c15d010ba2 docs: add release notes 2022-01-27 15:10:04 +02:00
carla 714a1fb05c invoicerpc: move hop hint to constant and add tests to select hop hint 2022-01-27 15:09:21 +02:00
carla 80bf4bf014 invoicerpc: return hop hints from select hop hint rather than functions
Update SelectHopHints to return a set of hop hints that can be
converted to route hints / functional options by the caller. This
change allows external code to call SelectHopHints to get a set of
route hints and use them as it likes, rather than limiting the
return value to functional options for invoice creation.
2022-01-27 15:09:20 +02:00
carla 00a47740c8 invoicesrpc: pass in specialized config for select hop hints 2022-01-27 15:09:19 +02:00
carla 56e83de9ef invoicesrpc: add HopHintInfo decoupling hop hint from channel internals 2022-01-27 15:09:18 +02:00
carla 5e8f86a9b6 lntest/test: ensure nodes connected before disconnecting [skip ci] 2022-01-25 14:42:11 +02:00
carla 7241653561 docs: add release notes 2022-01-20 14:31:47 +02:00
carla 0ae38457de server: disable chain health check if we're running without backend
There is no chain backend to check, so this check will always fail.
This commit disables it when we're running without a backend.
2022-01-20 14:21:36 +02:00
carla 721ef7d367 release-notes: add amount sensitive bandwidth hints 2021-10-19 09:52:19 +02:00
carla 990dda4b18 multi: thread bandwidth check amount down to MayAddOutgoingHtlc
Pass htlc amount down to the channel so that we don't need to rely
on minHtlc (and pad it when the channel sets a 0 min htlc). Update
test to just check some sane values since we're no longer relying
on minHtlc amount at all.
2021-10-19 09:50:51 +02:00
carla 45de686d35 multi: move bandwidth hints behind interface 2021-10-19 09:50:49 +02:00
carla 6aa37066b2 server: send 0 bandwidth hints for links that can't add htlc 2021-06-22 15:39:33 +02:00
carla 5d717cb039 multi: surface may add outgoing hltc 2021-06-22 13:56:08 +02:00
carla e3a4d6e989 lnwallet: refactor add htlc sanity checks to separate methods 2021-06-22 13:56:07 +02:00
carla 8491d0da43 multi: enable monitoring build by default
The monitoring server still needs to be enabled using prometheus.enable,
so including this in the default build does not add an additional http
server unless the user opts in.
2021-06-18 09:15:51 +02:00
carla 64333c0303 channeldb: cache htlc attempt session key 2021-05-19 09:08:18 +02:00
carla 8071ebb16a channeldb: read raw htlc attempt session key 2021-05-19 09:03:52 +02:00
carla eb068bf666 multi: unexport session key and add constructor for htlc attempt info 2021-05-19 09:03:46 +02:00
carla 74373f26b9 invoices/test: add height expiry watcher tests with registry 2021-05-11 08:47:17 +02:00
carla 8066ff7047 itest/test: assert expired hold invoice updated correctly 2021-05-11 08:45:32 +02:00
carla b7d1ed0cbb itest/test: test hold invoice cancel before force close 2021-05-11 08:45:31 +02:00
carla 85e56dbfb7 invoices/test: add test for hodl invoices 2021-05-11 08:45:30 +02:00
carla 34de5922ed multi: add height-based invoice expiry
This commit adds height-based invoice expiry for hodl invoices
that have active htlcs. This allows us to cancel our intentionally
held htlcs before channels are force closed. We only add this for
hodl invoices because we expect regular invoices to automatically
be resolved.

We still keep hodl invoices in the time-based expiry queue,
because we want to expire open invoices that reach their timeout
before any htlcs are added. Since htlcs are added after the
invoice is created, we add new htlcs as they arrive in the
invoice registry. In this commit, we allow adding of duplicate
entries for an invoice to be added to the expiry queue as each
htlc arrives to keep implementation simple. Our cancellation
logic can already handle the case where an entry is already
canceled, so this is ok.
2021-05-11 08:45:29 +02:00
carla b43ddfdb11 routing: label payment lifecycle loop 2021-04-23 08:51:07 +02:00
carla a63640c488 routing: account for payment terminal errors
If we have processed a terminal state while we're pathfinding
for another shard, the payment loop should not error out on
ErrPaymentTerminal. Instead, it would wait for our shards to
complete then cleanly exit.
2021-04-23 08:46:22 +02:00
carla 58d95be4dd multi: change RegisterAttempt error checking order
Move our more generic terminal check forward so that we only
need to handle a single class of expected errors. This change
is mirrored in our mock, and our reproducing tests are updated
to assert that this move catches both classes of errors we get.
2021-04-23 08:39:45 +02:00
carla 12136a97a9 routing/test: add test for stuck payment with in-flight htlcs
Add an additional stuck-payment case, where our payment gets
a terminal error while it has other htlcs in-flight, and a
shard fails with ErrTerminalPayment. This payment also falls in
our class of expected errors, but is not currently handled. The
mock is updated accordingly, using the same ordering as in our
real RegisterAttempt implementation.
2021-04-23 08:39:45 +02:00