Commit graph

4395 commits

Author SHA1 Message Date
Matt Corallo
5f404b9d0a Give Futures for a FutureState an idx and track StdWaker idxn
When an `std::future::Future` is `poll()`ed, we're only supposed to
use the latest `Waker` provided. However, we currently push an
`StdWaker` onto our callback list every time `poll` is called,
waking every `Waker` but also using more and more memory until the
`Future` itself is woken.

Here we take a step towards fixing this by giving each `Future` a
unique index and storing which `Future` an `StdWaker` came from in
the callback list. This sets us up to deduplicate `StdWaker`s by
`Future`s in the next commit.
2024-02-15 21:52:06 +00:00
Matt Corallo
2c987209f9 Split lists of Waker and directly-registered Future callbacks
In the next commit we'll fix a memory leak due to keeping too many
`std::task::Waker` callbacks in `FutureState` from redundant `poll`
calls, but first we need to split handling of `StdWaker`-based
future wake callbacks from normal ones, which we do here.
2024-02-15 21:52:06 +00:00
Matt Corallo
f98a652f11
Merge pull request #2816 from wpaulino/retryable-holder-sigs
Allow holder commitment and HTLC signature requests to fail
2024-02-13 21:22:55 +00:00
Elias Rohrer
0995de7fa8
Merge pull request #2892 from TheBlueMatt/2024-02-destination-eq
Add further standard derives to various onion message structs
2024-02-13 09:21:04 +01:00
Matt Corallo
6f02025246 Add further standard derives to various onion message structs 2024-02-12 23:54:14 +00:00
Elias Rohrer
0c2a715c01
Merge pull request #2888 from TheBlueMatt/2024-02-destination-eq
Implement `Debug`/`PartialEq`/`Eq` for `Destination`
2024-02-12 13:29:15 +01:00
Matt Corallo
71c0d56415 Implement Debug/PartialEq/Eq for Destination 2024-02-10 02:27:59 +00:00
Matt Corallo
ee34bcf2d6 Replace spaces with tabs in msgs.rs 2024-02-08 23:05:08 +00:00
Matt Corallo
5faca20934 Fix silent merge conflict introduced in d3ddf15357 2024-02-08 23:05:08 +00:00
Matt Corallo
c93b59e13d
Merge pull request #2871 from dunxen/2024-02-msgcommonfields
Combine common fields for OpenChannel and AcceptChannel V1 & V2
2024-02-08 21:50:27 +00:00
Wilmer Paulino
e38dccaef4
Allow holder commitment and HTLC signature requests to fail
As part of the ongoing async signer work, our holder signatures must
also be capable of being obtained asynchronously. We expose a new
`ChannelMonitor::signer_unblocked` method to retry pending onchain
claims by re-signing and rebroadcasting transactions. Unfortunately, we
cannot retry said claims without them being registered first, so if
we're not able to obtain the signature synchronously, we must return the
transaction as unsigned and ensure it is not broadcast.
2024-02-07 15:44:23 -08:00
Wilmer Paulino
043ab75bb4
Introduce FeerateStrategy enum for onchain claims
This refactors the existing `force_feerate_bump` flag into an enum as we
plan to introduce a new flag/enum variant in a future commit.
2024-02-07 15:42:28 -08:00
Wilmer Paulino
71b4bd0811
Rework get_latest_holder_commitment_txn to broadcast for users
This method is meant to be used as a last resort when a user is forced
to broadcast the current state, even if it is stale, in an attempt to
claim their funds in the channel. Previously, we'd return the commitment
and HTLC transactions such that they broadcast them themselves. Doing so
required a different code path, one which was not tested, to obtain
these transactions than our usual path when force closing. It's not
worth maintaining both, and it's much simpler for us to broadcast
instead.
2024-02-07 15:42:26 -08:00
Valentine Wallace
fff1aa7cb0
Add min_final_cltv_delta to aggregated CLTV delta.
The spec was previously missing this requirement.
2024-02-07 12:02:26 -05:00
Valentine Wallace
fa44185ba8
Parameterize BlindedPath::new_for_payment by min final CLTV delta.
Currently we are not including this value in the aggregated CLTV delta, which
is wrong.
2024-02-07 12:02:24 -05:00
Matt Corallo
a9d73c2889
Merge pull request #2873 from tnull/2024-02-expose-channel-details-in-bte
Expose `channel_id` / `counterparty_node_id` in `BumpTransaction` event
2024-02-07 00:57:01 +00:00
Elias Rohrer
5b5c87464a
Expose channel_id / counterparty_node_id in BumpTransaction event
A client node might choose not to handle `Event::BumptTransaction`
events and leave bumping / Anchor output spending to a trusted
counterparty.

However, `Event::BumptTransaction` currently doesn't offer any clear
indication what channel and/or counterparty it is referring to. In order
to allow filtering these events, we here expose the `channel_id` and
`counterparty_node_id` fields.
2024-02-06 21:02:33 +01:00
Matt Corallo
d1c2e143fe Note when new HTLC state can be None 2024-02-06 18:53:56 +00:00
Matt Corallo
8296515871 Fix comment spelling 2024-02-06 18:53:04 +00:00
Matt Corallo
4a7ba675d4
Merge pull request #2442 from wvanlint/list_pending_htlcs
Include pending HTLC's in ChannelDetails
2024-02-06 18:45:36 +00:00
Elias Rohrer
a0917e50e8
Merge pull request #2876 from TheBlueMatt/2024-02-2863-doc-nits
Minor doc nits on the new coop close reason variants
2024-02-06 11:44:32 +01: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
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
bad2efb73c Minor doc nits on the new coop close reason variants 2024-02-05 23:47:36 +00:00
Matt Corallo
8d9d099bf8
Merge pull request #2725 from shaavan/issue2096
Ensure successful message propagation in case of disconnection mid-handshake
2024-02-05 23:44:36 +00:00
Matt Corallo
f70c113fd8
Merge pull request #2863 from benthecarman/breakup-coop-close
Breakup CooperativeClosure into Local/Remote initiated
2024-02-05 23:43:26 +00:00
Elias Rohrer
2e61d92044
Expose channel_type in Event::ChannelPending
It is useful to immediately know what kind of channel is being opened,
and not having to wait until `ChannelReady`.
2024-02-05 14:32:33 +01:00
benthecarman
efcb5d9d0f
Rename old CooperativeClosure to LegacyCooperativeClosure 2024-02-04 16:33:28 +00:00
benthecarman
58f7942e11
Breakup CooperativeClosure into Local/Remote initiated 2024-02-04 16:33:27 +00:00
Matt Corallo
c9e4410a05 Fix test variable typos 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
efbaa41fae Stop relying on Hash{Set,Map}::from_iter directly
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for `FromIterator`
constructors instead of calling the tables directly to make the
version bump changeset smaller.
2024-02-02 18:04:51 +00:00
Matt Corallo
3e0d55bd2b Use utility methods to construct HashMaps and HashSets
In the next commit we'll bump the `hashbrown` version, which no
longer randomizes its hasher by default. Thus, we'll need to call
a different constructor in no-std builds from std builds.

Here we do a quick prefactor to use wrappers for constructors
instead of calling the tables directly to make the version bump
changeset smaller.
2024-02-02 18:04:51 +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
248e2f5be5 Disable fuzzing-reachable debug assertions in ChannelMonitors 2024-02-02 18:04:51 +00:00
Matt Corallo
c7258426cd Disable fuzzing-reachable debug assertion
Because of txid conflicts, a txid can match both a local and remote
commitment transaction when fuzzing. Thus, we disable this
assertion when fuzzing.
2024-02-02 18:04:51 +00:00
Jeffrey Czyz
7c9463668a
Merge pull request #2868 from orbitalturtle/export-send-onion-path
export send_onion_message_using_path for testing
2024-02-02 11:18:24 -06:00
Matt Corallo
4d993c06b4
Merge pull request #2870 from benthecarman/pub-source-target
Make DirectedChannelInfo `source` and `target` public
2024-02-02 17:08:52 +00:00
Duncan Dean
0a7a5f9538
Combine common fields of AcceptChannel & AcceptChannelV2 into struct 2024-02-02 18:32:16 +02:00
benthecarman
a931decbbb
Make DirectedChannelInfo source and target public
We use these params for our HubPreferentialScorer and without these
utility functions then we have to manually do this and calculate which
is the source and which is the target node.
2024-02-02 14:14:51 +00:00
Duncan Dean
d3ddf15357
Combine common fields of OpenChannel & OpenChannelV2 into struct 2024-02-02 14:39:42 +02:00
Orbital
06f9dd7e83
export send_onion_message_using_path for testing 2024-02-01 20:22:53 -06:00
valentinewallace
3751398518
Merge pull request #2858 from tnull/2024-01-expose-skimmed-fee-msat
Expose withheld amount for underpaying HTLCs in `PaymentForwarded`
2024-02-01 09:42:22 -05:00
Elias Rohrer
96445880f6
Expose skimmed_fee_msat in PaymentForwarded
We generally allow routing nodes to forward less than the expected HTLC
amount, if the receiver knowingly accepts this and claims the
underpaying HTLC (see `ChannelConfig::accept_underpaying_htlcs`). This
use case is in particular useful for the LSPS2/JIT channel setting where
the intial underpaying HTLC pays for the channel open.

While we previously exposed the withheld amount as
`PaymentClaimable::counterparty_skimmed_fee_msat` on the receiver side,
we did not individually provide it on the forwarding node's side.
Here, we therefore expose this additionally withheld amount via
`PaymentForwarded::skimmed_fee_msat`.
2024-02-01 09:21:15 +01:00
shaavan
a6a6b48102 Add tests to check the introduced behaviour
- The first test make sure that the OutboundV1Channel is not
immediately removed when peers disconnect, but is removed after N timer
ticks.
- The second test makes sure that the SendOpenChannel is rebroadcasted
for the OutboundV1Channel if peer reconnects within time.
2024-01-31 18:00:03 +05:30
shaavan
ddf75afd16 Do not remove Outbound Channel immediately when peer disconnects
- Do not remove channel immediately when peer_disconnect, instead
  removed it after some time if peer doesn't reconnect soon (handled in
previous commit).
- Do not mark per ok_to_remove if we have some OutboundV1Channels too.
- Rebroadcast SendOpenChannel for outboundV1Channel when peer
  reconnects.
- Update the relevant tests to account for the behavior change.
- Repurpose the test_disconnect_in_funding_batch to test that all
  channels in the batch close when one them closes.
2024-01-31 17:59:50 +05:30
Elias Rohrer
8e472669a1
Rename PaymentForwarded::fee_earned_msat to total_fee_earned_msat 2024-01-31 13:22:20 +01:00
Valentine Wallace
2616f02016
Track min HTLC overpay separately from skimmed fees in test utils 2024-01-31 13:22:19 +01:00
Valentine Wallace
42490efa2c
Struct-ify claim_along_route args.
Lays groundwork to make claim_payment* test utils easier to adapt without
changing a million callsites.
2024-01-31 13:22:19 +01:00