Commit graph

3570 commits

Author SHA1 Message Date
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
Matt Corallo
82bbb807ad Refactor debug sync methods into helper functions 2022-03-09 06:23:39 +00: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
Matt Corallo
797a648b6c Merge branch '2022-02-fix-multi-hop-hint-panic' into 2022-02-0.0.105-sec 2022-03-01 02:23:07 +00:00
Matt Corallo
82b8d854e7
Merge pull request #1322 from TheBlueMatt/2022-02-0.0.105
Cut 0.0.105
2022-03-01 02:22:00 +00:00
Matt Corallo
ed8f36520d Ensure get_claimable_balances never panicks in tests
... by calling it both before and after every chain event in
testing and fuzzing.

This requires fixing some blockchain inconsistencies in
`do_test_onchain_htlc_reorg`, `do_retry_with_no_persist`, and
`do_test_dup_htlc_onchain_fails_on_reload` where we'd connect
conflicting transactions in the same chain.
2022-03-01 00:43:55 +00:00
Matt Corallo
b1653f0705 Fix HTLC tx balance calculation on local commitment transactions
When handling the broadcast of a local commitment transactions
(with associated CSV delays prior to spendability), we incorrectly
handled the CSV delays on HTLC transactions. This caused us to miss
spendable outputs for HTLCs which were awaiting a CSV delay.

Further, because of this, we could hit an assertion as
`get_claimable_balances` asserted that HTLCs were resolved after
the funding spend was resolved, which was not true if the HTLC did
not have a CSV delay attached (due to the above bug or due to it
being an HTLC claim by our counterparty).

This fixes both bugs, also converting some assertions to
`debug_assert`s to avoid future issues as balance mis-calculation
is not currently an indication of potential funds loss.

Thanks to Cash App for reporting this bug.
2022-03-01 00:43:55 +00:00
Matt Corallo
def0628332 Bump crate versions to 0.0.105/invoice 0.13 2022-03-01 00:43:24 +00:00
Matt Corallo
afc740056f Fill out CHANGELOG for 0.0.105 2022-03-01 00:43:24 +00:00
Matt Corallo
bd1b761655 Correct default value for A* heuristic for non-public nodes
This doesn't (appear) to change behavior, however if we have a
non-public node, we assign an A* heuristic of max-u32 fees, which
may result in us de-prioritizing the path in some rare cases around
multi-hop route hints which compete with public nodes.
2022-02-28 22:07:54 +00:00
Matt Corallo
19ebc8081a Fix panic when routing through multiple private last-hops
When we added support for routing through a multi-hop invoice hint
we failed to remove an assertion that we always are able to fill
in features for each hop except the last one. However, when a
multi-hop invoice hint is used, we will not have features for any
of the hinted hops, causing us to panic.
2022-02-28 22:07:54 +00:00
Arik Sosman
8219ae2439
Merge pull request #1327 from TheBlueMatt/2022-02-log-before-panic 2022-02-28 14:03:03 -08:00
Matt Corallo
5208f0c72a
Merge pull request #1303 from jkczyz/2022-02-docs-with-features
Generate docs with features for docs.rs
2022-02-28 21:00:05 +00:00
valentinewallace
219a4545be
Merge pull request #1335 from TheBlueMatt/2022-02-fix-honggfuzz-regression
Pin rustc in fuzzing to 1.58 due to honggfuzz-rs regression
2022-02-28 13:50:03 -05:00
Matt Corallo
99073c74dd
Merge pull request #1324 from valentinewallace/2022-02-phantom-followup
#1199 Followup
2022-02-28 18:16:21 +00:00
Matt Corallo
78174f349e
Merge pull request #1332 from TheBlueMatt/2022-02-persister-ignore-tmp
Ignore .tmp files when loading ChannelMonitors in persister
2022-02-26 01:30:29 +00:00
Matt Corallo
5da22534cd Pin rustc in fuzzing to 1.58 due to honggfuzz-rs regression 2022-02-25 22:09:30 +00:00
Valentine Wallace
694ef1ecb9
Fix bug where we encode flags field into all updates on htlc fail
Failing an HTLC with onion error channel_disabled requires encoding a 'flags' field into the failure
packet. However, we were encoding this 'flags' field for all failures packets that were failing on
update_add_htlc with an update (error 0x1000 UPDATE).

Discovered in the course of adding phantom payment failure tests, which also added testing for this bug
2022-02-24 22:33:35 -05:00
Valentine Wallace
26fe879896
Correctly wrap phantom onion errors
In any place where fail_htlc_backwards_internal was called for a phantom payment
failure, we weren't encoding the onion failure as if the phantom were the one
failing. Instead, we were encoding the failure as if it were coming from the
second-to-last hop. This caused our failures to not be parsed properly on the
payer's side.

Places we were encoding failures incorrectly include:
* on failure of a call to inbound_payment::verify
* on a user call to fail_htlc_backwards

Also drop some unnecessary panics when reading OnionHopData objects. This also
enables one of the phantom failure tests because we can construct OnionHopDatas
with invalid amounts.

Lastly, remove a bogus comment
2022-02-24 22:33:02 -05:00
Valentine Wallace
3faea33438
Fix phantom malformed onion error packet
Ensure we fail back phantom malformed payments with an update_fail_htlc s.t.
the error contains the sha256 of the onion, per LN protocol.
2022-02-24 22:33:02 -05:00