Commit graph

743 commits

Author SHA1 Message Date
Elias Rohrer
fde0d9e718
Add rustfmt::skip to the msg_target template 2024-06-07 20:37:08 +02:00
Jeffrey Czyz
5326171885
Refactor MessageRouter::create_blinded_paths
Using compact blinded paths isn't always necessary or desirable. For
instance, reply paths are communicated via onion messages where space
isn't a premium unlike in QR codes. Additionally, long-lived paths could
become invalid if the channel associated with the SCID is closed.
Refactor MessageRouter::create_blinded_paths into two methods: one for
compact blinded paths and one for normal blinded paths.
2024-06-05 17:52:30 -05:00
Elias Rohrer
15c709d747
Merge pull request #3089 from TheBlueMatt/2024-06-channel_state-module
Move the public channel state API into a new module
2024-06-04 16:28:39 +02:00
Matt Corallo
2d6d5cc86f Move the public path for channel_state types to their new path 2024-06-04 14:21:08 +00:00
Arik
993cd1e525
Merge pull request #2889 from Sharmalm/2840
Allow for user-specified error message during force close channel
2024-06-03 14:48:52 -07:00
Jiri Jakes
a8bd4c097f
Upgrade rust-bitcoin to 0.31 2024-05-30 18:35:29 +08:00
Jeffrey Czyz
e553a71b6f
Pass ForwardNode when creating BlindedPath
Instead of passing Vec<PublicKey> to MessageRouter::crate_blinded_path,
pass Vec<ForwardNode>. This way callers can include a short_channel_id
for a more compact BlindedPath encoding.
2024-05-28 16:35:55 -05:00
Jeffrey Czyz
d792afb08c
Support NextHop::ShortChannelId in BlindedPath
When sending an onion message to a blinded path, the short channel id
between hops isn't need in each hop's encrypted_payload since it is not
a payment. However, using the short channel id instead of the node id
gives a more compact representation. Update BlindedPath::new_for_message
to allow for this.
2024-05-28 16:35:41 -05:00
Jeffrey Czyz
38690bf50a
Merge pull request #2907 from shaavan/issue2882
Introduce ResponseInstructions for OnionMessage Handling
2024-05-08 17:32:41 -05:00
Matt Corallo
806b7f0e31
Merge pull request #3054 from TheBlueMatt/2024-04-fuzz-bolt11
Add fuzzing coverage for BOLT11 invoice deserialization
2024-05-08 13:24:31 -07:00
Matt Corallo
65ba75d500 Substantially increase coverage in BOLT11 deserialization fuzzer 2024-05-08 19:56:21 +00:00
Matt Corallo
d14ea82b5d Move existing BOLT11 fuzz test to the fuzz crate 2024-05-08 19:36:15 +00:00
shaavan
15d016ac52 Implement ResponseInstruction Usage in OnionMessage Handling
This commit integrates the newly introduced ResponseInstruction structs
and enums into the codebase for handling OnionMessage responses.
2024-05-08 17:57:57 +05:30
Matt Corallo
28d85af955 Fix the full_stack_target breakage test and doc feerate requests
When we added the additional deust exposure checks in
702196819e6445048b803574fcacef77d5ce8c9c we added several
additional feerate fetches which broke the `full_stack_target`
change-detection test.

This updates the hard-coded test to support the new feerate fetches
and also includes a comment on `FeeEstimator` to indicate that
users really need to be caching feerates as otherwise they'll slow
us down.
2024-05-07 16:51:38 +00:00
Gursharan Singh
c1125f00b3
Remove MonitorUpdateId from persist trait
MonitorUpdateId was an opaque abstraction for id's generated by
UpdateOrigin:Offchain and UpdateOrigin::ChainSync monitor updates.
It was mainly needed to map calls made to
ChainMonitor::channel_monitor_updated. We no longer track
UpdateOrigin::ChainSync MonitorUpdates and can directly use
ChannelMonitor::get_latest_update_id() for tracking
UpdateOrigin::Offchain monitor updates.
2024-04-26 20:28:55 -07:00
Lalitmohansharma1
d17e759d02 Allowing user-specified error message during force close channel
In this commit i added additional parameter `error_message` to
`force_close_sending_error`. This parameter will allow users to
configure error message and send to peers during the force closing
of channel.I have also updated the tests for this updated function.
2024-04-20 19:12:59 +05:30
Matt Corallo
195e666953
Merge pull request #2964 from jbesraa/prune-stale-chanmonitor
Add `archive_fully_resolved_monitors` to `ChainMonitor`
2024-04-18 14:39:43 -07:00
jbesraa
4b5504366b Add ChainMonitor::archive_fully_resolved_monitor_channels
Archives fully resolved channel monitors by adding them to a backup
  location and removing them from the primary storage & the monitor set.

  This is useful for pruning fully resolved monitors from the monitor
  set and primary storage so they are not reloaded on every new new
  block connection.

  We also add a new function, `archive_persisted_channel` to the
  `Persist` trait that writes the monitor to an archive storage and
  removes it from the primary storage.
2024-04-18 17:12:07 +00:00
Elias Rohrer
ec956516d1
Add ConfirmationTarget::OutputSpendingFee 2024-04-18 16:20:02 +02:00
Jeffrey Czyz
9f1ffab24c
Look up node id from scid in OnionMessenger
When forwarding onion messages, the next node may be represented by a
short channel id instead of a node id. Parameterize OnionMessenger with
a NodeIdLookUp trait to find which node is the next hop. Implement the
trait for ChannelManager for forwarding to channel counterparties.

Also use this trait when advancing a blinded path one hop when the
sender is the introduction node.
2024-04-15 10:58:30 -05:00
Jeffrey Czyz
7002180261
Generalize BlindedPath::introduction_node_id field
Allow using either a node id or a directed short channel id in blinded
paths. This allows for a more compact representation of blinded paths,
which is advantageous for reducing offer QR code size.

Follow-up commits will implement handling the directed short channel id
case in OnionMessenger as it requires resolving the introduction node in
MessageRouter.
2024-04-15 10:58:30 -05:00
benthecarman
712d97d3fe
Add DecodeError::DangerousValue for decoding invalid channel managers
This would help distinguish different types of errors when deserialzing
a channel manager. InvalidValue was used previously but this could be
because it is an old serialization format, whereas DangerousValue is a
lot more clear on why the deserialization failed.
2024-03-28 12:30:13 -05:00
valentinewallace
670b41ae4e
Merge pull request #2903 from jkczyz/2024-02-bindings-builders
Offers builders for C-bindings
2024-03-08 16:07:10 -05:00
Jeffrey Czyz
9277166a8b
Drop error type parameter from SignError
SignError allows implementors of SignFunction to return a custom error
type. Drop this as an unconstrained type causes problems with bindings
and isn't useful unless the caller can take some sort of action based on
different errors.
2024-03-08 10:39:23 -06:00
Jeffrey Czyz
407762446c
Support BOLT 12 signing in c_bindings
Replace the Fn trait bound on signing methods with a dedicated trait
since Fn is not supported in bindings. Implement the trait for Fn so
that closures can still be used in Rust.
2024-03-08 10:39:22 -06:00
Elias Rohrer
0c74cdc573
Introduce PeerManager::list_peers and peer_by_node_id
.. returning `PeerDetails` rather than tuples of peer-associated values.

Previously, we wouldn't offer any way to retrieve the features a
peer provided in their `Init` message.

Here, we allow to retrieve them via a new `PeerDetails` struct,
side-by-side with `SocketAddress`es and a bool indicating the direction
of the peer connection.
2024-02-21 10:12:16 +01:00
Matt Corallo
3096061bef Drop ahash dependency in favor of core's SipHasher
https://github.com/tkaitchuck/aHash/pull/196 bumped the MSRV of
`ahash` in a patch release, which makes it rather difficult for us
to have it as a dependency.

Further, it seems that `ahash` hasn't been particularly robust in
the past, notably
https://github.com/tkaitchuck/aHash/issues/163 and
https://github.com/tkaitchuck/aHash/issues/166.

Luckily, `core` provides `SipHasher` even on no-std (sadly its
SipHash-2-4 unlike the SipHash-1-3 used by the `DefaultHasher` in
`std`). Thus, we drop the `ahash` dependency entirely here and
simply wrap `SipHasher` for our `no-std` HashMaps.
2024-02-16 20:34:41 +00:00
Matt Corallo
d70124cec4
Merge pull request #2850 from TheBlueMatt/2024-01-fuzz-gossip 2024-02-09 00:49:33 +00:00
Matt Corallo
7aa06d25f2 [fuzz] Add fst coverage for ChannelManager::update_channel_config 2024-02-07 02:32:52 +00:00
Matt Corallo
e63fc65ce0 [fuzz] Add a second full_stack_target seed test for gossip 2024-02-07 02:32:52 +00:00
Matt Corallo
207fbb0296 [fuzz] De-dup hex in test_no_existing_test_breakage
This will make test_no_existing_test_breakage marginally easier to
update.
2024-02-07 02:32:52 +00:00
Matt Corallo
a4cacee4b1 [fuzz] Add additional method calls in full_stack_target
The whole point of full_stack_target is to just expose our entire
API to the fuzzer and see what happens. Sadly, we're really only
exposing a small subset of our API. This improves that by exposing
a handful of other assorted methods from ChannelManager and
PeerManager.
2024-02-07 02:32:52 +00:00
Matt Corallo
a17df4f8eb [fuzz] Use batch funding in full_stack_target
To potentially get more test coverage
2024-02-07 02:32:52 +00:00
Willem Van Lint
67e788eaa7 Include pending HTLCs in ChannelDetails
This exposes details around pending HTLCs in ChannelDetails.  The state
of the HTLC in the state machine is also included, so it can be
determined which protocol message the HTLC is waiting for to advance.
2024-02-05 17:35:54 -08:00
Matt Corallo
a3c4fe97df [fuzz] Fix misc warnings in full_stack_target 2024-02-05 23:54:06 +00:00
Matt Corallo
d1bb0cba07 [fuzz] Reduce size of payments_sent in full_stack_target
Slightly reducing the amount of data we read to do things.
2024-02-05 23:54:06 +00:00
Matt Corallo
e64342afab
Merge pull request #2810 from TheBlueMatt/2023-12-arbitrary-fuzz-config
Update `full_stack_target` to take an arbitrary config object
2024-02-05 23:53:06 +00:00
Matt Corallo
e594021052
Merge pull request #2847 from TheBlueMatt/2024-01-bindings-upstream
Misc Tweaks for bindings
2024-02-05 23:49:19 +00:00
Matt Corallo
7377cc99c7 [fuzz] Fix slice copy in peer_crypt_target
This has apparently been broken for quite some time...I guess
`peer_crypt_target` doesn't get much CPU anymore.
2024-02-02 18:05:09 +00:00
Matt Corallo
dedc8306f6 Bump hashbrown dependency to 0.13
While this isn't expected to materially improve performance, it
does get us ahash 0.8, which allows us to reduce fuzzing
randomness, making our fuzzers much happier.

Sadly, by default `ahash` no longer tries to autodetect a
randomness source, so we cannot simply rely on `hashbrown` to do
randomization for us, but rather have to also explicitly depend on
`ahash`.
2024-02-02 18:05:08 +00:00
Matt Corallo
f62a96ea93 Use arbitrary config object in full_stack_target fuzzer
As we've added more and more configuration parameters which change
our behavior, we're increasingly missing coverage in the general
`full_stack_target` fuzzer. Sadly, a reachable `unwrap` slipped in
uncaught that should have been stopped by the `full_stack_target`.

Here, we update the `full_stack_target` fuzzer to read a full
config object to substantially increase coverage.
2024-02-02 18:04:51 +00:00
Matt Corallo
5d5c8187b4 Store EntropySource in DefaultRouter instead of passing it
...as an arg to `Router`. Passing an `EntropySource` around all
the time is a bit strange as the `Router` may or may not actually
use it, and the `DefaultRouter` can just as easily store it.
2024-01-30 23:56:12 +00:00
Duncan Dean
cf2c27800a
Remove Outpoint::to_channel_id method
To avoid confusion and for accuracy going forward, we remove this method
as it is inconsistent with channel IDs generated during V2 channel
establishment. If one wants to create a V1, funding outpoint-based
channel ID, then `ChannelId::v1_from_funding_outpoint` should be used
instead.

A large portion of the library has always made the assumption that having
the funding outpoint will always allow us to generate the channel ID.
This will not be the case anymore and we need to pass the channel ID along
where appropriate. All channels that could have been persisted up to this
point could only have used V1 establishment, so if some structures don't
store a channel ID for them they can safely fall back to the funding
outpoint-based version.
2024-01-30 12:30:26 +02:00
valentinewallace
3eec5d3c17
Merge pull request #2820 from TheBlueMatt/2024-01-fuzz-ooo-monitor-updates
Test individual monitor update compl in chanmon_consistency fuzzer
2024-01-11 11:22:34 -05:00
Matt Corallo
ab66143cb6 Expose onion_message items directly rather than via re-exports
When we originally added the `onion_message` module, there weren't
a lot of public items in it, and it didn't make a lot of sense to
export the whole sub-module structure publicly. So, instead, we
exported the public items via re-exports directly in the
`onion_message` top-level module. However, as time went on, more
and more things entered the module, which left the top-level module
rather cluttered.

Worse, in 0.0.119, we exposed
`onion_message::messenger::SendSuccess` via the return type of
`send_message`, but forgot to re-export the enum itself, making
it impossible to actually use from external code.

Here we address both issues and simply replace the re-export with
the underlying sub-module structure.
2024-01-10 23:50:34 +00:00
Matt Corallo
757cf8fe1e Test individual monitor update compl in chanmon_consistency fuzzer
When users do async monitor updating, it may not be the case that
all pending monitors will complete updating at once. Thus, we
should fuzz monitor updates completing out of order, which we do
here.
2024-01-09 17:21:43 +00:00
Jeffrey Czyz
62f8669654
Add create_blinded_payment_paths to Router
The Router trait is used to find a Route for paying a node. Expand the
interface with a create_blinded_payment paths method for creating such
paths to a recipient node.

Provide an implementation for DefaultRouter that creates two-hop
blinded paths where the recipient's peers serve as the introduction
nodes.
2023-12-15 15:40:09 -06:00
Jeffrey Czyz
bedc2c64fc
Require any Router also implements MessageRouter
ChannelManager is parameterized by a Router in order to find routes when
sending and retrying payments. For the offers flow, it needs to be able
to construct blinded paths (e.g., in the offer and in reply paths).
Instead of adding yet another parameter to ChannelManager, require that
any Router also implements MessageRouter. Implement this for
DefaultRouter by delegating to a DefaultMessageRouter.
2023-12-15 14:52:07 -06:00
Jeffrey Czyz
97049daac2
Add create_blinded_paths to MessageRouter
The MessageRouter trait is used to find an OnionMessagePath to a
Destination (e.g., to a BlindedPath). Expand the interface with a
create_blinded_paths method for creating such paths to a recipient.
Provide a default implementation creating two-hop blinded paths where
the recipient's peers serve as introduction nodes.
2023-12-15 14:52:07 -06:00
valentinewallace
9856fb6710
Merge pull request #2688 from valentinewallace/2023-10-multihop-blinded-recv
Support receiving to multi-hop blinded paths
2023-12-13 10:31:02 -05:00