Commit graph

3611 commits

Author SHA1 Message Date
Jeffrey Czyz
574870e9f8
Move network_graph.rs to gossip.rs
The routing::network_graph module contains a few structs related to p2p
gossip. So renaming the module to 'gossip' seems more appropriate.
2022-06-02 15:15:30 -07:00
Jeffrey Czyz
ac35492877
Rename NetGraphMsgHandler to P2PGossipSync
NetGraphMsgHandler implements RoutingMessageHandler to handle gossip
messages defined in BOLT 7 and maintains a view of the network by
updating NetworkGraph. Rename it to P2PGossipSync, which better
describes its purpose, and to contrast with RapidGossipSync.
2022-06-02 15:15:30 -07:00
Jeffrey Czyz
3b3a4ba0a6
Rename ChannelClosed to ChannelFailure
A NetworkUpdate indicating ChannelClosed actually corresponds to a
channel failure as described in BOLT 4:

0x2000 (NODE): node failure (otherwise channel)

Rename the enum variant to ChannelFailure and rename NetworkGraph
methods close_channel_from_update and fail_node to channel_failed and
node_failed, respectively.
2022-06-02 15:15:29 -07:00
Jeffrey Czyz
dcffefae3d
Update missed references to get_route in docs 2022-06-02 13:15:15 -07:00
Jeffrey Czyz
8c5ca95d99
Fix build warnings 2022-06-02 13:15:05 -07:00
Jeffrey Czyz
9c5008334c
Merge pull request #1433 from arik-so/2022-04-rapid-sync-bg-processor
Allow indication to BackgroundProcessor that graph sync is pending
2022-06-02 14:10:00 -05:00
Arik Sosman
784addcaa9
Create separate timer for scorer persistence in background processor 2022-06-02 10:14:13 -07:00
Arik Sosman
312f765bd7
Indicate ongoing rapid sync to background processor.
Create a wrapper struct for rapid gossip sync that can be passed to
BackgroundProcessor's start method, allowing it to only start pruning
the network graph upon rapid gossip sync's completion.
2022-06-02 10:14:08 -07:00
Jeffrey Czyz
a3ad88ac69
Merge pull request #1512 from tnull/2022-05-remove-deprecated-scorer
Remove previously deprecated `Scorer`
2022-06-01 18:29:15 -05:00
Matt Corallo
4808afee03
Merge pull request #1509 from shamardy/main
Update regex to 1.5.6
2022-06-01 15:54:46 -07:00
Elias Rohrer
84c94a8fd9 Remove previously deprecated Scorer 2022-06-01 14:50:41 -07:00
Jeffrey Czyz
f84ce03cab
Merge pull request #1504 from TheBlueMatt/2022-05-pub-io
Re-export `core2::io` or `std::io` depending on feature flags
2022-06-01 15:57:18 -05:00
Jeffrey Czyz
324655477b
Merge pull request #1511 from justinmoon/repository
Add 'repository' to lightning-invoice's Cargo.toml
2022-06-01 15:52:20 -05:00
Justin Moon
7b8f6843f5 Add 'repository' to lightning-invoice's Cargo.toml 2022-06-01 13:17:16 -05:00
shamardy
a87b53ae9a Update regex to 1.5.6 2022-06-01 17:25:15 +02:00
Arik Sosman
0b7700830b
Merge pull request #1500 from arik-so/2022-05-network-graph-rapid-sync-timestamp
Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differential rapid syncing.
2022-05-31 11:57:18 -07:00
Matt Corallo
994fa07793
Merge pull request #1506 from tnull/2022-05-rename-funding-locked
Rename `FundingLocked` to `ChannelReady`.
2022-05-31 10:48:09 -07:00
Arik Sosman
c3bbfe5a17
Add optional last_rapid_gossip_sync_timestamp field to NetworkGraph to enable optimized differental rapid syncing. 2022-05-31 10:17:51 -07:00
Matt Corallo
b4a9b962dd Re-export core2::io or std::io depending on feature flags
This is useful in bindings as the `lightning::io` module is used in
the public interface, but also useful for users who want to refer
to the `io` as used in lightning irrespective of the feature flags.
2022-05-31 00:17:40 +00:00
Elias Rohrer
e98f68aee6 Rename FundingLocked to ChannelReady. 2022-05-30 17:07:09 -07:00
valentinewallace
a534a5e7af
Merge pull request #1434 from TheBlueMatt/2022-04-robust-payment-claims
Improve Robustness of Inbound MPP Claims Across Restart
2022-05-30 10:05:01 -07:00
Matt Corallo
531d6c8663 Change Event amt fields to amount_msat for clarity 2022-05-28 18:50:32 +00:00
Matt Corallo
8a5670245a Add internal docs for ChannelMonitor::payment_preimages 2022-05-28 00:02:49 +00:00
Matt Corallo
a12d37e063 Drop return value from fail_htlc_backwards, clarify docs
`ChannelManager::fail_htlc_backwards`' bool return value is quite
confusing - just because it returns false doesn't mean the payment
wasn't (already) failed. Worse, in some race cases around shutdown
where a payment was claimed before an unclean shutdown and then
retried on startup, `fail_htlc_backwards` could return true even
though (a duplicate copy of the same payment) was claimed, but the
claim event has not been seen by the user yet.

While its possible to use it correctly, its somewhat confusing to
have a return value at all, and definitely lends itself to misuse.

Instead, we should push users towards a model where they don't care
if `fail_htlc_backwards` succeeds - either they've locally marked
the payment as failed (prior to seeing any `PaymentReceived`
events) and will fail any attempts to pay it, or they have not and
the payment is still receivable until its timeout time is reached.

We can revisit this decision based on user feedback, but will need
to very carefully document the potential failure modes here if we
do.
2022-05-28 00:02:49 +00:00
Matt Corallo
11c2f12baa Do additional pre-flight checks before claiming a payment
As additional sanity checks, before claiming a payment, we check
that we have the full amount available in `claimable_htlcs` that
the payment should be for. Concretely, this prevents one
somewhat-absurd edge case where a user may receive an MPP payment,
wait many *blocks* before claiming it, allowing us to fail the
pending HTLCs and the sender to retry some subset of the payment
before we go to claim. More generally, this is just good
belt-and-suspenders against any edge cases we may have missed.
2022-05-28 00:02:49 +00:00
Matt Corallo
0e2542176b Provide a redundant Event::PaymentClaimed on restart if needed
If we crashed during a payment claim and then detected a partial
claim on restart, we should ensure the user is aware that the
payment has been claimed. We do so here by using the new
partial-claim detection logic to create a `PaymentClaimed` event.
2022-05-28 00:02:49 +00:00
Matt Corallo
0a2a40c4fd Add a PaymentClaimed event to indicate a payment was claimed
This replaces the return value of `claim_funds` with an event. It
does not yet change behavior in any material way.
2022-05-28 00:02:49 +00:00
Matt Corallo
ce7b0b4ca2
Merge pull request #1401 from TheBlueMatt/2022-02-0conf-round-two
Zero Conf Channels
2022-05-27 16:54:52 -07:00
Matt Corallo
ffaf9bc145 Add note about SCID collisions in PaymentPathFailed
This isn't specific to 0-conf but is useful for users to note as
the network moves towards more SCID aliases.
2022-05-27 22:40:07 +00:00
Matt Corallo
86ad2527bd Add test of 0conf channels getting the funding transaction reorg'd
In a previous version of the 0-conf code we did not correctly
handle 0-conf channels getting the funding transaction reorg'd out
(and the real SCID possibly changing on us).
2022-05-27 22:40:07 +00:00
Matt Corallo
7ed7a7d22e Correctly handle sending announcement sigs on public 0conf channels 2022-05-27 22:40:07 +00:00
Matt Corallo
8be97f0389 Add a new test for 0conf-with-monitor-update-failures
This tests a few cases of monitor failure updates that were broken
in earlier versions of the 0conf patchset.
2022-05-27 22:40:07 +00:00
Matt Corallo
26288e3014 Expose outbound SCID alias in ChannelDetails and use in routing
This supports routing outbound over 0-conf channels by utilizing
the outbound SCID alias that we assign to all channels to refer to
the selected channel when routing.
2022-05-27 22:40:07 +00:00
Matt Corallo
ff9e4572b6 Send funding_locked immediately for inbound channels with 0conf 2022-05-27 22:40:07 +00:00
Matt Corallo
9569bfe820 Add API and signaling to accept incoming channels at 0conf 2022-05-27 22:40:07 +00:00
Matt Corallo
35cd39da15 Lock outbound channels at 0conf if the peer indicates support for it
If our peer sets a minimum depth of 0, and we're set to trusting
ourselves to not double-spend our own funding transactions, send a
funding_locked message immediately after funding signed.

Note that some special care has to be taken around the
`channel_state` values - `ChannelFunded` no longer implies the
funding transaction is confirmed on-chain. Thus, for example, the
should-we-re-broadcast logic has to now accept `channel_state`
values greater than `ChannelFunded` as indicating we may still need
to re-broadcast our funding tranasction, unless `minimum_depth` is
greater than 0.

Further note that this starts writing `Channel` objects with a
`MIN_SERIALIZATION_VERSION` of 2. Thus, LDK versions prior to
0.0.99 (July 2021) will now refuse to read serialized
Channels/ChannelManagers.
2022-05-27 22:40:07 +00:00
Matt Corallo
168b3a51ae Define a crate-public constant for max fake SCID in blocks offset 2022-05-27 22:40:07 +00:00
Matt Corallo
585493a3e1 Handle cases where a channel is in use w/o an SCID in ChannelManager
In the next few commits we add support for 0conf channels, allowing
us to have an active channel with HTLC and other updates flying
prior to having an SCID available. This would break several
assumptions made in `ChannelManager`, which we address here by
looking at SCID aliases in addition to SCIDs.
2022-05-27 22:40:07 +00:00
valentinewallace
1fd6c6fb9f
Merge pull request #1481 from TheBlueMatt/2022-05-new-chain-tests
Test coverage for `transaction_unconfirmed`
2022-05-27 10:38:42 -07:00
Matt Corallo
3de59cef25
Merge pull request #1499 from tnull/2022-05-fix-unreachable-warning
Fix `rapid-gossip-sync` warning and version number
2022-05-26 21:51:46 -07:00
Matt Corallo
cc374eccb0
Merge pull request #1491 from tnull/2022-05-build-route-from-pubkeys
Build route from hop pubkey list.
2022-05-26 19:05:52 -07:00
Elias Rohrer
bdc2a47814 Fix rapid-gossip-sync warning and version number 2022-05-26 18:14:09 -07:00
Elias Rohrer
2010670ac1 Allow building of a route from given hops
Implements `build_route_from_hops`, which provides a simple way to build
a route from us (payer) to the target node (payee) via the given hops
(which should exclude the payer, but include the payee). This may be
useful, e.g., for probing the chosen path.
2022-05-26 17:29:33 -07:00
Matt Corallo
08ab6581f1
Merge pull request #1494 from TheBlueMatt/2022-05-mon-cleanups-renames
Correct variable names in `ChannelMonitor` and DRY tests
2022-05-26 11:11:08 -07:00
Matt Corallo
28c70ac506 Ensure all HTLCs for a claimed payment are claimed on startup
While the HTLC-claim process happens across all MPP parts under one
lock, this doesn't imply that they are claimed fully atomically on
disk. Ultimately, an application can crash after persisting one
`ChannelMonitorUpdate` out of multiple monitor updates needed for
the full claim.

Previously, this would leave us in a very bad state - because of
the all-channels-available check in `claim_funds` we'd refuse to
claim the payment again on restart (even though the
`PaymentReceived` event will be passed to the user again), and we'd
end up having partially claimed the payment!

The fix for the consistency part of this issue is pretty
straightforward - just check for this condition on startup and
complete the claim across all channels/`ChannelMonitor`s if we
detect it.

This still leaves us in a confused state from the perspective of
the user, however - we've actually claimed a payment but when they
call `claim_funds` we return `false` indicating it could not be
claimed.
2022-05-26 00:53:11 +00:00
Matt Corallo
d443b79743 Correct bogus references to revocation_point in ChannelMonitor
The `ChannelMonitor` had a field for the counterparty's
`cur_revocation_points`. Somewhat confusingly, this actually stored
the counterparty's *per-commitment* points, not the (derived)
revocation points.

Here we correct this by simply renaming the references as
appropriate. Note the update in `channel.rs` makes the variable
names align correctly.
2022-05-26 00:50:30 +00:00
Matt Corallo
78c3080537 Rename HTLC onchain_value_satoshis to htlc_value_satoshis
In `HTLCUpdate` and `OnchainEvent` tracking, we store the HTLC
value (rounded down to whole satoshis). This is somewhat
confusingly referred to as the `onchain_value_satoshis` even though
it refers to the commitment transaction output value, not the value
available on chain (which may have been reduced by an
HTLC-Timeout/HTLC-Success transaction).
2022-05-26 00:50:30 +00:00
Matt Corallo
a847809b5a DRY SpendableOutput tests in monitor_tests.rs 2022-05-26 00:50:30 +00:00
Jeffrey Czyz
aac39076d5
Merge pull request #1155 from arik-so/graph_sync_crate
Introduce graph sync crate
2022-05-25 16:40:00 -05:00
Jeffrey Czyz
440ea94a89
Merge pull request #1478 from mattfaltyn/issue1462
Document `lightning` crate features
2022-05-25 16:26:51 -05:00