Commit graph

4180 commits

Author SHA1 Message Date
Matt Corallo
c1d8cb9710 Stop relying on *Features::known in functional test utils
As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the
functional_test_utils module.
2022-09-14 20:09:35 +00:00
Matt Corallo
3b3713fdde Stop relying on the *Features::known method in functional tests
This diff is commit, like the last, stops relying on the `known`
feature set constructor, doing so entirely with import changes and
sed rules.
2022-09-14 20:09:35 +00:00
Matt Corallo
1a3273792b Stop relying on the *Features::known method in routing tests
As we move towards specify supported/required feature bits in the
module(s) where they are supported, the global `known` feature set
constructors no longer make sense.

Here we stop relying on the `known` method in the `routing` module,
which was only used in tests.
2022-09-14 20:09:35 +00:00
Matt Corallo
6b1f867eaa List supported/required feature bits explicitly in ChannelManager
Historically, LDK has considered the "set of known/supported
feature bits" to be an LDK-level thing. Increasingly this doesn't
make sense - different message handlers may provide or require
different feature sets.

In a previous PR, we began the process of transitioning with
feature bits sent to peers being sourced from the attached message
handler.

This commit makes further progress by moving the concept of which
feature bits are supported by our ChannelManager into
channelmanager.rs itself, via the new `provided_*_features`
methods, rather than in features.rs via the `known_channel_features`
and `known` methods.
2022-09-14 20:08:54 +00:00
valentinewallace
58f76f2800
Merge pull request #1721 from acid-bit/fix_typo
Fix typo in comment in Cargo.toml
2022-09-14 12:28:39 -04:00
Matt Corallo
6ae6d362bb
Merge pull request #1720 from TheBlueMatt/2022-09-fix-fuzz-warnings
Fix compile-time warnings in fuzzing
2022-09-14 14:35:49 +00:00
acid-bit
65d3bc27d9 Fix typo in comment in Cargo.toml 2022-09-14 11:49:20 +01:00
Matt Corallo
f1d70be864 Fix warnings in fuzz which should have been fixed in f725c5a90a 2022-09-14 00:50:29 +00:00
Matt Corallo
464391c245 Fix compile warning in fuzzing introduced in cd0d19c005 2022-09-14 00:49:21 +00:00
Matt Corallo
71f4749e1c
Merge pull request #1685 from wpaulino/anchors-prep 2022-09-13 21:09:25 +00:00
valentinewallace
d2a9ae0b8e
Merge pull request #1717 from TheBlueMatt/2022-09-req-features-in-handlers
Move checking of specific require peer feature bits to handlers
2022-09-13 16:17:57 -04:00
Matt Corallo
a922830ebb
Merge pull request #1706 from jkczyz/2022-09-filtered-blocks
Support filtered blocks in `lightning-block-sync`
2022-09-13 19:50:34 +00:00
Wilmer Paulino
f3a5a72346
Update anchors test vectors to zero HTLC transaction fee variant
Each test featuring HTLCs had a minimum and maximum feerate case. This
is no longer necessary for the zero HTLC transaction anchors variant as
the commitment feerate does not impact whether HTLCs can be trimmed or
not, only the dust limit does.
2022-09-13 10:58:39 -07:00
Wilmer Paulino
af2ff9b5b9
Account for zero fee HTLC transaction within dust limit calculation
With the zero fee HTLC transaction anchors variant, HTLCs can no longer
be trimmed due to their amount being too low to have a mempool valid
HTLC transaction. Now they can only be trimmed based on the dust limit
of each party within the channel.
2022-09-13 10:58:36 -07:00
Wilmer Paulino
cd0d19c005
Update HTLC script detection to check for anchor output variants 2022-09-13 10:58:32 -07:00
Wilmer Paulino
a447965b80
Use zero fee HTLC transactions for anchor channels
This is based on the assumption that we only support the zero HTLC
transaction fee variant of anchor channels.
2022-09-13 10:58:29 -07:00
Wilmer Paulino
5aae0ab721
Exclude HTLC transactions from broadcast on anchor channels
HTLC transactions from anchor channels are constrained by a CSV of 1
block, so broadcasting them along with the unconfirmed commitment
tranasction will result in them being immediately rejected as premature.
2022-09-13 10:58:24 -07:00
Wilmer Paulino
62236c70d8
Avoid commitment broadcast upon detected funding spend
There's no need to broadcast our local commitment transaction if we've
already seen a confirmed one as it'll be immediately rejected as a
duplicate/conflict.

This will also help prevent dispatching spurious events for bumping
commitment and HTLC transactions through anchor outputs (once
implemented in future work) and the dispatch for said events follows the
same flow as our usual commitment broadcast.
2022-09-13 10:58:20 -07:00
Wilmer Paulino
2f4a1f7f79
Use proper sighash flag for remote HTLCs with anchor outputs 2022-09-13 10:58:14 -07:00
Jeffrey Czyz
c1938e8c9f
Support filtered blocks in lightning-block-sync
Expand the BlockSource trait to allow filtered blocks now that
chain::Listen supports them (d629a7edb7).
This makes it possible to use BIP 157/158 compact block filters with
lightning-block-sync.
2022-09-13 12:47:31 -05:00
valentinewallace
a82fb62856
Merge pull request #1703 from TheBlueMatt/2022-09-badonion-first-check
Correctly handle BADONION onion errors
2022-09-13 13:47:23 -04:00
Matt Corallo
f725c5a90a Add now-missing unwraps on test calls to peer_connected. 2022-09-13 16:59:30 +00:00
Matt Corallo
bbb590b551 Move checking of specific require peer feature bits to handlers
As we remove the concept of a global "known/supported" feature set
in LDK, we should also remove the concept of a global "required"
feature set. This does so by moving the checks for specific
required features into handlers.

Specifically, it allows the handler `peer_connected` method to
return an `Err` if the peer should be disconnected. Only one such
required feature bit is currently set - `static_remote_key`, which
is required in `ChannelManager`.
2022-09-13 16:59:30 +00:00
Matt Corallo
29484d8e2c Swap some peer_connected features to known from empty in test
In the next commit we'll enforce counterparty `InitFeatures`
matching our required set in `ChannelManager`, implying they must
be set for many tests where they previously did not need to be (as
they were enforced in `PeerManager`, which is not used in
functional tests).
2022-09-13 16:59:30 +00:00
Matt Corallo
91db4ba2f8 Add a note that peer_disconnected impls must be idempotent
It appears our code is already correct here, but its also nice to
add a quick safety check in `channel.rs` which ensures we will
remain idempotent.
2022-09-13 16:59:30 +00:00
Duncan Dean
e6a3c23d10 Add test for malformed update error with NODE bit set
Some tweaks by Matt Corallo <git@bluematt.me>
2022-09-13 02:21:42 +00:00
Matt Corallo
5e07c60f9e Correctly handle BADONION onion errors
Currently we entirely ignore the BADONION bit when deciding how to
handle HTLC failures. This opens us up to an attack where a
malicious node always fails HTLCs backwards via
`update_fail_malformed_htlc` with an error code of
`BADONION|NODE|PERM|X`. In this case, we may decide to interpret
this as a permanent node failure for the node encrypting the onion,
i.e. the counterparty of the node who sent the
`update_fail_malformed_htlc` message and ultimately failed the
HTLC.

Thus, any node we route through could cause us to fully remove its
counterparty from our network graph. Luckily we do not do any
persistent tracking of removed nodes, and thus will re-add the
removed node once it is re-announced or on restart, however we are
likely to add such persistent tracking (at least in-memory) in the
future.
2022-09-13 02:21:35 +00:00
Matt Corallo
4ae65e8f4f
Merge pull request #1712 from TheBlueMatt/2022-09-111
Cut 0.0.111
2022-09-13 00:27:54 +00:00
Matt Corallo
f5473d5051 Bump versions to lightning* 0.0.111 and lightning-invoice 0.19 2022-09-12 22:34:27 +00:00
Matt Corallo
27e3464b66 Update release notes for 0.0.111 2022-09-12 22:33:37 +00:00
Matt Corallo
990e346798
Merge pull request #1714 from TheBlueMatt/2022-09-111-bindings-discovered-cleanups
Small Cleanups Discovered during Bindings for 0.0.111
2022-09-12 20:51:51 +00:00
Matt Corallo
3f3335ac48
Merge pull request #1715 from TheBlueMatt/2022-09-fix-msg-send
Fix encryption of broadcasted gossip messages
2022-09-12 20:01:32 +00:00
Matt Corallo
b78359af9e Update Simple*PeerManager type aliases to support Onion Messages
Note that `SimpleArcPeerHandler` is also updated to not wrap
`IgnoringMessageHandler` in an `Arc`, as `IgnoringMessageHandler`
is already zero-sized.
2022-09-12 18:33:55 +00:00
Elias Rohrer
0190fec003
Export error type instead of entire modules
Previously the `error` and `processing` modules have been `pub`, leading
to them being included in the docs, altough (almost) empty.

Instead, we now `pub use` the `GraphSyncError` directly, cleaning up the
docs.
2022-09-12 20:25:54 +02:00
Matt Corallo
dbd0ab8cf8
Merge pull request #1716 from TheBlueMatt/2022-09-log-unreadable-type
Include the message type when we send unreadable gossip msg errors
2022-09-12 18:10:47 +00:00
Matt Corallo
45ec1db2e0 Encrypt+MAC most P2P messages in-place
For non-gossip-broadcast messages, our current flow is to first
serialize the message into a `Vec`, and then allocate a new `Vec`
into which we write the encrypted+MAC'd message and header.

This is somewhat wasteful, and its rather simple to instead
allocate only one buffer and encrypt the message in-place.
2022-09-12 18:06:52 +00:00
Matt Corallo
8ec92f5b6b Fix encryption of broadcasted gossip messages
In 47e818f198, forwarding broadcasted
gossip messages was split into a separate per-peer message buffer.
However, both it and the original regular-message queue are
encrypted immediately when the messages are enqueued. Because the
lightning P2P encryption algorithm is order-dependent, this causes
messages to fail their MAC checks as the messages from the two
queues may not be sent to peers in the order in which they were
encrypted.

The fix is to simply queue broadcast gossip messages unencrypted,
encrypting them when we add them to the regular outbound buffer.
2022-09-12 18:06:52 +00:00
Matt Corallo
be7107f212 Drop unused type parameter on BlindedRoute::new
I'm not sure why rustc didn't complain about the unused parameter
or why we're allowed to get away without explicitly bounding the
`Sign` in the `KeysInterface`, but the current code requires all
`BlindedPath` construction to explicitly turbofish an unused type.
2022-09-12 16:26:58 +00:00
Matt Corallo
88ec5da4b3 Add relevant (C-not exported) tags on OnionMessenger aliases
The "helpful" type aliases don't make sense for C bindings as all
generics are concretized anyway.
2022-09-12 16:26:58 +00:00
Matt Corallo
95eb2b52be Inline generic bounds rather than using the where clause
The bindings generator is pretty naive in its generic resolution
and doesn't like `where` clauses for bounds that are simple traits.
This should eventually change, but for now its simplest to just
inline the relevant generic bounds.
2022-09-12 16:26:58 +00:00
Matt Corallo
0f3536f87a Do not use blanket impls when building for c_bindings
The C bindings generator isn't capable of figuring out if a blanket
impl applies in a given context, and instead opts to always write
out any relevant impl's for a trait. Thus, blanket impls should be
disabled when building with `#[cfg(c_bindings)]`.
2022-09-12 16:26:58 +00:00
Matt Corallo
8b3516208a Rename {Signed,}RawInvoice::hash to avoid naming collisions
Now that `{Signed,}RawInvoice` implement the std `Hash` trait,
having a method called `hash` is ambiguous.

Instead, we rename the `hash` methods `signed_hash` to make it
clear that the hash is the one used for the purpose of signing the
invoice.
2022-09-12 16:26:58 +00:00
Matt Corallo
c4466bdb95 Include the message type when we send unreadable gossip msg errors 2022-09-12 15:35:56 +00:00
Matt Corallo
15a5966fa2
Merge pull request #1710 from TheBlueMatt/2022-09-compile-warn
Fix several compile warnings added in some of my recent commits
2022-09-11 14:54:05 +00:00
Matt Corallo
0cc3572719 Fix several compile warnings when testing in no-std mode 2022-09-10 00:18:32 +00:00
Matt Corallo
610511ced6 Fix (really dumb) warning rustc introduced in latest beta 2022-09-09 21:49:05 +00:00
Matt Corallo
f14ea3dd18 Fix several compile warnings added in some of my recent commits 2022-09-09 21:49:05 +00:00
Matt Corallo
877a5fc9c0
Merge pull request #1688 from valentinewallace/2022-08-flip-om-feature-bit
Onion messages: flip feature bit 🎉
2022-09-09 21:48:33 +00:00
Matt Corallo
ad24b8c891
Merge pull request #1713 from TheBlueMatt/2022-09-bad-doc-versions
Correct `get_claimable_balance` version info
2022-09-09 21:13:36 +00:00
Matt Corallo
e94e403dda
Merge pull request #1711 from TheBlueMatt/2022-08-0conf-panic
Fix spurious panic on receipt of a block while awaiting funding
2022-09-09 20:24:07 +00:00