Commit graph

3337 commits

Author SHA1 Message Date
Elias Rohrer
ff7ec0c645 Minor refactor for sort / add, and some nits.
- `sort_by_key` to `sort_unstable_by_key`
- `checked_add() .. max_value()` to `saturating_add()`
- Some typos and nits
2022-03-24 09:12:44 -06:00
Elias Rohrer
b11dcf9ba8 Randomize candidate paths during route selection. 2022-03-24 09:12:26 -06:00
Matt Corallo
5ed2985cae
Merge pull request #1361 from luizParreira/rust-lightning/issues/1280
Create normal/phantom invoice with description hash
2022-03-18 20:29:23 +00:00
Luiz Parreira
7714393cf0
Create normal/phantom invoice with description hash 2022-03-18 15:08:00 -03:00
Matt Corallo
2af3413b35
Merge pull request #1363 from TheBlueMatt/2022-03-tx-conf-ordering-lock-delay
Generate a funding_locked on relevant transactions_confirmed calls
2022-03-18 17:20:53 +00:00
Matt Corallo
c244c781f6
Merge pull request #1358 from TheBlueMatt/2022-03-max-cltv
Make `max_total_cltv_expiry_delta` include the final CLTV
2022-03-17 05:13:56 +00:00
Matt Corallo
bb4413cc65 Make max_total_cltv_expiry_delta include the final CLTV
This fixes an integer underflow found by the `router` fuzz target
in CI.
2022-03-16 22:10:46 +00:00
Matt Corallo
fef8acf70c Make routing benchmark robust against path changes
If the scoring in the routing benchmark causes us to take a
different path from the original scan, we may end up deciding that
the only path to a node has a too-high total CLTV delta, causing us
to panic in the benchmarking phase.

Here we simply check for that possibility and remove paths that
fail post-scoring.
2022-03-16 22:10:46 +00:00
Matt Corallo
699ac8390a
Merge pull request #1325 from ViktorTigerstrom/2022-02-filter-route-hints
Filter route hints when creating invoices
2022-03-16 17:32:40 +00:00
Viktor Tigerström
ff792e05bb Add phantom invoice route hints filtering tests 2022-03-16 11:24:12 +01:00
Viktor Tigerström
43cc81c893 Filter route hints for phantom invoices
Filter the route hints in `create_phantom_invoice` based on the
following criteria:

* Only one channel for every counterparty node per phantom
payment-receiving node in the invoice
* Always select the channel with the highest inbound capacity
* For each payment-receiving node, filter out channels with a lower
inbound capacity than the invoice amount, if any channel exists with
enough capacity to cover the invoice amount
* If any public channels exists for a payment-receiving node, push a
single RouteHintHop with the phantom route and let the sender find the
path to the payment-receiving node through the public channels.
2022-03-16 11:24:12 +01:00
Viktor Tigerström
eae5086b8d Add tests for create invoice route hints filtering 2022-03-16 11:24:12 +01:00
Viktor Tigerström
fe49fbd7b8 Filter route hints for create invoice
Filter the route hints in `create_invoice_from_channelmanager` based on
the following criteria:

* Only one channel per counterparty node
* Always select the channel with the highest inbound capacity
* Filter out channels with a lower inbound capacity than the invoice
amount, if any channel exists with enough capacity to cover the invoice
amount
* If any public channel exists, the invoice route_hints should be empty,
and the sender will need to find the path to the payment-receiving node
by looking at the public channels instead
2022-03-16 11:24:12 +01:00
Matt Corallo
ea769427fe Generate a funding_locked on relevant transactions_confirmed calls
Previously, if we were offline when a funding transaction was
locked in, and then we came back online, calling
`best_block_updated` once followed by `transactions_confirmed`,
we'd not generate a funding_locked until the next
`best_block_updated`.

We address this by re-calling `best_block_updated` in
`transactions_confirmed`, similar to how `ChannelMonitor` works.
2022-03-15 23:59:35 +00:00
Jeffrey Czyz
ca163c3fae
Merge pull request #1331 from TheBlueMatt/2022-02-no-copy-invoice-fields
Use &mut self in invoice updaters, not take-self-return-Self
2022-03-11 14:26:02 -06:00
Matt Corallo
b1cd5a7434
Merge pull request #1311 from TheBlueMatt/2022-02-0conf-part-1
Support for SCID Aliases
2022-03-10 00:47:23 +00:00
valentinewallace
756bcbc667
Merge pull request #1341 from jkczyz/2022-03-expiry-time-panic
Correct docs about invoice_expiry_delta_secs panic
2022-03-09 18:19:22 -05:00
Jeffrey Czyz
e6024ab788
Merge pull request #1349 from TheBlueMatt/2022-03-listen-send-sync
Require `chain::Listen` impls in block sync be `Send + Sync`
2022-03-09 16:41:40 -06:00
Matt Corallo
2bba1d4251
Merge pull request #1348 from TheBlueMatt/2022-03-timer-tick-count
Reduce the number of timer ticks a peer is allowed to take
2022-03-09 21:28:05 +00:00
Matt Corallo
eafe7d2e24
Merge pull request #1355 from lightningdevkit/dependabot/cargo/lightning/regex-0.2.11
Update regex requirement from 0.1.80 to 0.2.11 in /lightning
2022-03-09 21:27:50 +00:00
Jeffrey Czyz
f1a6469a0a
Correct docs about invoice_expiry_delta_secs panic 2022-03-09 14:39:31 -06:00
Matt Corallo
e4486fe9f4 Support receiving multiple funding_locked messages
As a part of adding SCID aliases to channels, we now have to accept
otherwise-redundant funding_locked messages which serve only to
update the SCID alias. Previously, we'd failt he channel as such
an update used to be bogus.
2022-03-09 19:14:39 +00:00
Matt Corallo
84fa127661 Provide our peers with SCID aliases and forward payments with them
This creates an SCID alias for all of our outbound channels, which
we send to our counterparties as a part of the `funding_locked`
message and then recognize in any HTLC forwarding instructions.

Note that we generate an SCID alias for all channels, including
already open ones, even though we currently have no way of
communicating to our peers the SCID alias for already-open
channels.
2022-03-09 19:14:39 +00:00
Matt Corallo
10be993f94 Handle short_to_id state updates on channel closure via macros
This avoids needing to update channel closure code in many places
as we add multiple SCIDs for each channel and have to track them.
2022-03-09 19:14:38 +00:00
Matt Corallo
b2629afd88 Track SCID aliases from our counterparty and use them in invoices
New `funding_locked` messages can include SCID aliases which our
counterparty will recognize as "ours" for the purposes of relaying
transactions to us. This avoids telling the world about our
on-chain transactions every time we want to receive a payment, and
will allow for receiving payments before the funding transaction
appears on-chain.

Here we store the new SCID aliases and use them in invoices instead
of he "standard" SCIDs.
2022-03-09 19:14:38 +00:00
Matt Corallo
f54ebf78f6 Add support for deserializing the new SCID alias in funding_locked 2022-03-09 19:14:38 +00:00
Matt Corallo
a274261c59 Clean up the handle_monitor_err!() macro argument forms somewhat
`handle_monitor_err!()` has a number of different forms depending
on which messages and actions were outstanding when the monitor
updating first failed. Instead of matching by argument count, its
much more readable to put an explicit string in the arguments to
make it easy to scan for the called form.
2022-03-09 19:14:38 +00:00
Jeffrey Czyz
a50e9549b4
Merge pull request #1286 from tnull/add_random_cltv_offsets
Add random 'shadow route' CLTV delta offsets to improve privacy
2022-03-09 13:08:57 -06:00
Matt Corallo
84a08dbf8a Make lightning-block-sync's init module slightly more generic
Users who want to use lightning-block-sync's init module would
be reasonable in wanting to use it in a multithreaded environment,
however because it takes a list of listeners as dyn chain::Listen
without any Send or Sync bound they fail in doing so.

Here we make the type bounds on `chain::Listen` generic across
`chain::Listen + ?Sized`, which the existing bound of `&dyn
chain::Listen` satisfies. Thus, this is strictly less restrictive
and allows for the use of `&dyn chain::Listen + Send + Sync`.
2022-03-09 18:20:43 +00:00
dependabot[bot]
ca96bb7fb6
Update regex requirement from 0.1.80 to 0.2.11 in /lightning
Updates the requirements on [regex](https://github.com/rust-lang/regex) to permit the latest version.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/0.1.80...0.2.11)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-09 17:38:53 +00:00
Elias Rohrer
e92b5a7ebd Add a random per-path CLTV offset for privacy. 2022-03-09 11:13:47 -06:00
Jeffrey Czyz
1a734492d9
Merge pull request #1347 from jkczyz/2022-03-log-approximation
Use log approximation in ProbabilisticScorer
2022-03-09 10:19:25 -06:00
Jeffrey Czyz
f041a64fca
Check for no-std compatibility across dependencies
To ensure no-std is honored across dependencies, add a crate depending
on lightning crates supporting no-std. This should ensure any
regressions are caught. Otherwise, cargo doesn't seem to catch some
incompatibilities (e.g., f64::log10 unavailable in core) and seemingly
across other dependencies as describe here:

https://blog.dbrgn.ch/2019/12/24/testing-for-no-std-compatibility/
2022-03-08 23:23:26 -06:00
Jeffrey Czyz
d70292d6c8
Fix compilation warnings with --features=no-std 2022-03-08 23:23:25 -06:00
Jeffrey Czyz
7f83c559b4
Use log approximation in ProbabilisticScorer
Since f64::log10 exists in std but not core, unconditionally use log
approximation so --feature=no-std will compile.
2022-03-08 23:22:38 -06:00
Matt Corallo
09f8abad93 Move private channel and short-conf tests to new module 2022-03-08 19:16:17 +00:00
Matt Corallo
3fe76e61a3 Add a new functional test utility to open an unannounced channel 2022-03-08 19:16:17 +00:00
Matt Corallo
a9c4e70213 Give ChannelManagers channel_udpates for pub chans in test
This makes tests slightly more realistic by delivering
`channel_update`s to `ChannelManager`s, ensuring we have
forwarding data stored locally for all channels, including public
ones.
2022-03-08 19:16:17 +00:00
Matt Corallo
252280d6bf Reduce the number of timer ticks a peer is allowed to take
In 2d3a210897, we increased the
default ping timer in `lightning-background-processor` to ten
seconds from five. However, we didn't change the timer count at
which we disconnect peers if they're not responding, which we
likely should have done. We do so here, as well as update the
documentation for `PeerManager::timer_tick_occurred` to suggest
always ticking the timer every ten seconds instead of five.
2022-03-07 19:07:14 +00:00
Matt Corallo
0e0aabea07
Merge pull request #1317 from TheBlueMatt/2022-02-fix-bunk-test
Fix what `bolt2_open_channel_sending_node_checks_part1` tests
2022-03-05 20:54:57 +00:00
Matt Corallo
6e776d9fb9 Clean up TestKeysInterface random bytes override interface
Its very confusing to have multiple fields that do the same thing,
one of which isn't even used for its stated purpose anymore after
the previous few commits.
2022-03-04 21:54:32 +00:00
Matt Corallo
010c34f351 Fix what bolt2_open_channel_sending_node_checks_part1 tests
There are currently two issues with
`bolt2_open_channel_sending_node_checks_part1` which counteract
each other and hide that the test isn't testing what it should be.

First of all, the final `create_channel` call actually fails
because we try to open a channel with ourselves, instead of
panicing as the test is supposed to check for.

However, when we fix the create_channel call to panic, when we
drop `nodes[1]` after `create_channel` panics, we fail the
no-pending-messages test as it as an expeted `accept_channel` in
its outbound buffer. This causes a double-panic.

Previously, these two offset each other - instead of panicing in
`create_channel` we'd panic in the Node drop checks.

This fixes both by fetching the `accept_channel` before we go into
the panic'ing `create_channel` call (who's arguments were
		corrected).
2022-03-04 21:54:21 +00:00
valentinewallace
b89f8815c3
Merge pull request #1343 from lightningdevkit/dependabot/github_actions/actions/checkout-3
Bump actions/checkout from 2 to 3
2022-03-03 14:35:01 -05:00
valentinewallace
40a4f86114
Merge pull request #1346 from TheBlueMatt/2022-03-clones
Add Clone to a few structs which contain only a few fields
2022-03-03 14:34:07 -05:00
Matt Corallo
60f7977ea8 Add Clone to a few structs which contain only a few fields
Specifically, `PhantomRouteHints`, `FixedPenaltyScorer`, and
`ScoringParamters`.
2022-03-03 18:10:59 +00:00
Matt Corallo
5e86bbf970
Merge pull request #1310 from TheBlueMatt/2022-02-bump-msrv
Bump MSRV to 1.41.1.
2022-03-02 19:09:14 +00:00
dependabot[bot]
670aebe07a
Bump actions/checkout from 2 to 3
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-02 17:35:18 +00:00
Matt Corallo
6259e7a674
Merge pull request #1339 from TheBlueMatt/2022-02-0.0.105-sec
0.0.105 Security Fixes
2022-03-01 04:13:19 +00:00
Matt Corallo
d798ac15c0 Update CHANGELOG with security info for 0.0.105 2022-03-01 02:23:20 +00:00
Matt Corallo
f9983de485 Merge branch '2022-02-bal-panic' into 2022-02-0.0.105-sec 2022-03-01 02:23:14 +00:00