Commit graph

3811 commits

Author SHA1 Message Date
Arik Sosman
a58ae4c97b
Introduce graph sync crate for fast-forwarding through gossip data downloaded from a server. 2022-05-25 01:21:33 -07:00
Mateusz Faltyn
70673734e6 Document lightning crate features 2022-05-24 16:21:29 -07:00
Matt Corallo
e4cc7db63e Rename HTLC input_idx fields to commitment_tx_output_idx
Several fields used in tracking on-chain HTLC outputs were
named `input_idx` despite referring to the output index in the
commitment transaction. Here they are all renamed
`commitment_tx_output_idx` for clarity.
2022-05-24 22:11:50 +00:00
Jeffrey Czyz
75ca50f5c0
Merge pull request #1490 from arik-so/rust_beta_doc_fix
Fix rust beta docs for lightning-invoice crate.
2022-05-23 00:16:04 -05:00
Arik Sosman
46e58ae025
Merge pull request #1492 from tnull/2022-05-fix-bolts-url
Docs: Update to 'new' spec repository URL.
2022-05-20 11:20:55 -07:00
Arik Sosman
0c6974b602
Merge pull request #1456 from jkczyz/2022-04-effective-capacity
Use `EffectiveCapacity` in `Score` trait
2022-05-20 10:56:10 -07:00
Arik Sosman
71d89d2c98
Fix rust beta docs lightning-invoice crate. 2022-05-20 08:31:56 -07:00
Elias Rohrer
ba7935d1f3 Use new spec repository URL. 2022-05-20 17:17:29 +02:00
Jeffrey Czyz
4715d90a06
Score without uncertainty for exact liquidity
For direct channels, the channel liquidity is known with certainty. Use
this knowledge in ProbabilisticScorer by either penalizing with the
per-hop penalty or u64::max_value depending on the amount.
2022-05-19 14:25:23 -05:00
Jeffrey Czyz
197cbc4d28
Pass effective capacity to scorer
Scorers could benefit from having the channel's EffectiveCapacity rather
than a u64 msat value. For instance, ProbabilisticScorer can give a more
accurate penalty when given the ExactLiquidity variant. Pass a struct
wrapping the effective capacity, the proposed amount, and any in-flight
HTLC value.
2022-05-19 14:25:22 -05:00
Jeffrey Czyz
435a325d02
Use correct penalty and CLTV delta in route hints
For route hints, the aggregate next hops path penalty and CLTV delta
should be computed after considering each hop rather than before.
Otherwise, these aggregate values will include values from the current
hop, too.
2022-05-19 14:25:22 -05:00
Jeffrey Czyz
a190aed88a
Use the correct amount when scoring route hints
When scoring route hints, the amount passed to the scorer should include
any fees needed for subsequent hops. This worked correctly for single-
hop hints since there are no further hops, but not for multi-hint hops
(except the final one).
2022-05-19 14:25:22 -05:00
Jeffrey Czyz
22ce7d89d7
Distinguish maximum HTLC from effective capacity
Using EffectiveCapacity in scoring gives more accurate success
probabilities when the maximum HTLC value is less than the channel
capacity. Change EffectiveCapacity to prefer the channel's capacity
over its maximum HTLC limit, but still use the latter for route finding.
2022-05-19 14:25:22 -05:00
Matt Corallo
bd1e20d49e Store an events::PaymentPurpose with each claimable payment
In fc77c57c3c we stopped using the
`FInalOnionHopData` in `OnionPayload::Invoice` directly and intend
to remove it eventually. However, in the next few commits we need
access to the payment secret when claimaing a payment, as we create
a new `PaymentPurpose` during the claim process for a new event.

In order to get access to a `PaymentPurpose` without having access
to the `FinalOnionHopData` we here change the storage of
`claimable_htlcs` to store a single `PaymentPurpose` explicitly
with each set of claimable HTLCs.
2022-05-19 18:16:53 +00:00
Matt Corallo
2a4259566e Enable removal of OnionPayload::Invoice::_legacy_hop_data later
In fc77c57c3c we stopped using the
`FinalOnionHopData` in `OnionPayload::Invoice` directly and renamed
it `_legacy_hop_data` with the intent of removing it in a few
versions. However, we continue to check that it was included in the
serialized data, meaning we would not be able to remove it without
breaking ability to serialize full `ChannelManager`s.

This fixes that by making the `_legacy_hop_data` an `Option` which
we will happily handle just fine if its `None`.
2022-05-19 18:16:53 +00:00
Jeffrey Czyz
0a318f4cf8
PathBuildingHop::value_contribution_msat in Debug 2022-05-19 12:47:45 -05:00
Matt Corallo
36817e0539
Merge pull request #1476 from tnull/2022-05-maximum-path-length
Consider maximum path length during path finding.
2022-05-18 19:22:42 +00:00
Elias Rohrer
87c9684c53 Consider maximum path length during path finding. 2022-05-18 19:20:00 +02:00
Matt Corallo
b083870554 Randomize the ConnectStyle during tests
We have a bunch of fancy infrastructure to ensure we can connect
blocks using all our different connection interfaces, but we only
bother to use it in a few select tests.

This expands our use of `ConnectStyle` to most of our tests by
simply randomizing the style in each test. This makes our tests
non-deterministic, but we print the connection style at start so
that it's easy to reproduce a failure deterministically.
2022-05-17 20:19:38 +00:00
Matt Corallo
c639920dca Make tests more robust against different connection styles
In the next commit we'll randomize the `ConnectStyle` used in each
test. However, some tests are slightly too prescriptive, which we
address here in a few places.
2022-05-17 20:19:38 +00:00
Matt Corallo
9ac483bc84 Add new block ConnectionStyles for transaction_unconfirmed
Previously `transaction_unconfirmed` was never called in tests!
2022-05-17 20:19:38 +00:00
valentinewallace
b20aea1cb0
Merge pull request #1472 from TheBlueMatt/2022-06-less-secp-ctx
Pull secp256k1 contexts from per-peer to per-PeerManager
2022-05-17 16:10:09 -04:00
Matt Corallo
998cdc0865
Merge pull request #1418 from bruteforcecat/timeout-outbound-paymnet-retires-instead-of-count-out
add timeout retry strategy to outbound payment
2022-05-17 17:32:46 +00:00
KaFai Choi
b7d6d0dc8e
add timeout retry strategy to outbound payment 2022-05-17 13:27:22 +07:00
Matt Corallo
342698fe5a
Merge pull request #1485 from ViktorTigerstrom/2022-05-add-force-close-param
Add missing `counterparty_node_id` in `force_close_channel` calls
2022-05-16 21:48:51 +00:00
Viktor Tigerström
d543ac04c4 Add missing counterparty_node_id in force_close_channel calls 2022-05-16 22:25:46 +02:00
Arik Sosman
a5629e5ca2
Merge pull request #1479 from ViktorTigerstrom/2022-05-pass-counterparty-id-to-functions
Pass `counterparty_node_id` to `ChannelManager` functions
2022-05-16 12:44:16 -07:00
valentinewallace
257a6f3e48
Merge pull request #1475 from atalw/2022-04-paymentforwarded-event
Expose `next_channel_id` in `PaymentForwarded` event
2022-05-16 14:21:39 -04:00
Matt Corallo
12e8e9f3db Store full blocks in the test blockchain tracker instead of headers 2022-05-16 02:16:20 +00:00
atalw
1ae1de97fd
Add next_channel_id in PaymentForwarded event
This update also includes a minor refactor. The return type of
`pending_monitor_events` has been changed to a `Vec` tuple with the
`OutPoint` type. This associates a `Vec` of `MonitorEvent`s with a
funding outpoint.

We've also renamed `source/sink_channel_id` to `prev/next_channel_id` in
the favour of clarity.
2022-05-15 09:41:18 +05:30
Matt Corallo
e5c988e00c
Merge pull request #1429 from TheBlueMatt/2022-04-drop-no-conn-possible 2022-05-14 19:35:47 +00:00
Viktor Tigerström
c1798443b0 Update OpenChannelRequest documentation
As the `counterparty_node_id` is now required to be passed back to the
`ChannelManager` to accept or reject an inbound channel request, the
documentation is updated to reflect that.
2022-05-14 20:33:05 +02:00
Viktor Tigerström
70fa465924 Pass counterparty_node_id to accept_inbound_channel 2022-05-14 20:32:44 +02:00
Viktor Tigerström
c581bab8be Pass counterparty_node_id to funding_transaction_generated 2022-05-14 20:32:44 +02:00
Viktor Tigerström
14e52cd7a6 Pass counterparty_node_id to force_close_channel 2022-05-14 20:32:44 +02:00
Viktor Tigerström
84a6e7bc51 Pass counterparty_node_id to close_channel functions 2022-05-14 20:32:44 +02:00
KaFai Choi
10f9795149
move Time trait from scoring mod to util::time and set it visibile within crate 2022-05-14 09:52:59 +07:00
Viktor Tigerström
7893ddc721 Add counterparty_node_id to FundingGenerationReady 2022-05-14 02:15:32 +02:00
Jeffrey Czyz
d166044f27
Merge pull request #1480 from tnull/2022-05-fix-test-warnings
Fix unused code warnings test.
2022-05-13 12:20:56 -05:00
Elias Rohrer
79f42d72e2 Fix unused code warnings. 2022-05-13 18:03:51 +02:00
Matt Corallo
e6aaf7c72d Pull secp256k1 contexts from per-peer to per-PeerManager
Instead of including a `Secp256k1` context per
`PeerChannelEncryptor`, which is relatively expensive memory-wise
and nontrivial CPU-wise to construct, we should keep one for all
peers and simply reuse it.

This is relatively trivial so we do so in this commit.

Since its trivial to do so, we also take this opportunity to
randomize the new PeerManager context.
2022-05-11 20:02:29 +00:00
Matt Corallo
b5a63070f5
Merge pull request #1023 from TheBlueMatt/2021-07-par-gossip-processing 2022-05-11 17:24:16 +00:00
Matt Corallo
3cae233491
Merge pull request #1477 from dunxen/2022-05-invoice-expiry-nits 2022-05-11 16:12:15 +00:00
Duncan Dean
ea016cd824
Address post-ACK formatting nits from #1474 2022-05-11 10:57:38 +02:00
Matt Corallo
46009a5f83 Add a few more simple tests of the PeerHandler
These increase coverage and caught previous lockorder inversions.
2022-05-10 23:40:20 +00:00
Matt Corallo
cc7f859c01 Add support for testing recvd messages in TestChannelMessageHandler 2022-05-10 23:40:20 +00:00
Matt Corallo
45c1411b16 Require PartialEq for wire::Message in cfg(test)
...and implement wire::Type for `()` for `feature = "_test_utils"`.
2022-05-10 23:40:20 +00:00
Matt Corallo
101bcd8da5 Drop a needless match in favor of an if let 2022-05-10 23:40:20 +00:00
Matt Corallo
b222be233b [net-tokio] Explicitly yield after processing messages from a peer
This reduces instances of disconnect peers after single timer
intervals somewhat, at least on Tokio 1.14.
2022-05-10 23:40:20 +00:00
Matt Corallo
96fc0f3453 Drop PeerHolder as it now only has one field 2022-05-10 23:40:20 +00:00