Commit graph

4059 commits

Author SHA1 Message Date
Matt Corallo
af03788db0
Merge pull request #1656 from ViktorTigerstrom/2022-08-forward-htlcs-as-standalone-lock
Move `forward_htlcs` into standalone lock
2022-09-20 10:19:32 +00:00
Valentine Wallace
615b401f7b
Move router test utils into their own module
Useful for testing onion message pathfinding in upcoming PRs and any future
routing modules we add
2022-09-19 14:16:37 -04:00
Viktor Tigerström
fc12d43856 Add lock order docs to ChannelManager fields 2022-09-19 18:43:24 +02:00
Matt Corallo
d6988989f8
Merge pull request #1729 from TheBlueMatt/2022-09-lockablescore-bindings
Add a `MutexGuard` wrapper for the bindings-only `LockableScore`
2022-09-19 14:45:07 +00:00
Jeffrey Czyz
18ac915456
Merge pull request #1728 from TheBlueMatt/2022-09-slices-not-vecs
Swap `Vec<&RouteHop>` parameters for slices
2022-09-19 08:30:07 -05:00
Matt Corallo
85eb1fde56 Avoid returning a reference to a u64.
In c353c3ed7c an accessor method was
added which returns an `Option<&u64>`. While this allows Rust to
return an 8-byte object, returning a reference to something
pointer-sized is a somewhat strange API.

Instead, we opt for a straight `Option<u64>`, which is sadly
somewhat larger on the stack, but is simpler and already supported
in the bindings generation.
2022-09-19 09:23:26 +00:00
Matt Corallo
4910c7cffe Swap Vec<&RouteHop> parameters for slices
In c353c3ed7c, new scorer-updating
methods were added to the `Router` object, however they were
passed as a `Vec` of references. We use the list-of-references
pattern to make bindings simpler (by not requiring allocations per
entry), however there's no reason prefer to passing a `Vec` over
a slice, given the `Vec` doesn't hold ownership of the objects
anyway.
2022-09-19 09:23:26 +00:00
Matt Corallo
56b07e52aa Add a MutexGuard wrapper for the bindings-only LockableScore
In the bindings, we don't directly export any `std` types. Instead,
we provide trivial wrappers around them which expose only a
bindings-compatible API (and which is code in-crate, where the
bindings generator can see it).

We never quite finished this for `MultiThreadedLockableScore` - due
to some limitations in the bindings generator and the way the
scores are used in `lightning-invoice`, the scoring API ended up
being further concretized in patches for the bindings. Luckily the
scoring interface has been rewritten somewhat, and it so happens
that we can now generate bindings with the upstream code.

The final piece of the puzzle is done here, where we add a struct
which wraps `MutexGuard` so that we can expose the lock for
`MultiThreadedLockableScore`.
2022-09-19 09:21:56 +00:00
Viktor Tigerström
3379f8c492 Remove forward_htlc after channel_state lock order
The `forward_htlc` was prior to this commit only held at the same time
as the `channel_state` lock during the write process of the
`ChannelManager`. This commit removes the lock order dependency, by
taking the `channel_state`lock temporarily during the write process.
2022-09-18 23:13:56 +02:00
Viktor Tigerström
e8854a9ce2 Remove unnecessary aquiring of the channel_state lock 2022-09-18 23:13:56 +02:00
Viktor Tigerström
df12df354e Move forward_htlcs into standalone lock
As we are eventually removing the `channel_state` lock, this commit
moves the `forward_htlcs` map out of the `channel_state` lock, to ease
that process.
2022-09-18 23:13:56 +02:00
valentinewallace
dc28f9bb88
Merge pull request #1725 from TheBlueMatt/2022-09-no-bench-lockorder
Stop building with lockorder debugging in benchmarks
2022-09-16 17:12:49 -04:00
Jeffrey Czyz
ca76d0675b
Merge pull request #1694 from jurvis/jurvis/2022-08-move-scorer-from-router
Move `LockableScore` requirement away from `Router` trait
2022-09-16 14:01:38 -05:00
Jurvis Tan
c353c3ed7c
Move Scorer requirement away from Router trait
We do this to enable users to create routers that do not need a scorer.
This can be useful if they are running a node the delegates pathfinding.

* Move `Score` type parameterization from `InvoicePayer` and `Router` to
`DefaultRouter`
* Adds a new field, `scorer`, to `DefaultRouter`
* Move `AccountsForInFlightHtlcs` to `DefaultRouter`, which we
will use to wrap the new `scorer` field, so scoring only happens in
`DefaultRouter` explicitly.
* Add scoring related functions to `Router` trait that we used to call
directly from `InvoicePayer`.
* Instead of parameterizing `scorer` in `find_route`, we replace it with
inflight_map so `InvoicePayer` can pass on information about inflight
HTLCs to the router.
* Introduced a new tuple struct, InFlightHtlcs, that wraps functionality
for querying used liquidity.
2022-09-16 08:38:56 -07:00
Matt Corallo
070dd74602 Stop building with lockorder debugging in benchmarks
`cargo bench` sets `#[cfg(test)]` so our current checks for
enabling our lockorder debugging end up matching when we're trying
to build performance benchmarks.

This adds explicit checks to our debug_lockorder logic to filter
out `feature = "_bench_unstable"` builds.
2022-09-16 14:44:20 +00:00
Matt Corallo
313810ebdc Do not broadcast commitment txn on Permanent mon update failure
See doc updates for more info on the edge case this prevents, and
there isn't really a strong reason why we would need to broadcast
the latest state immediately. Specifically, in the case of HTLC
claims (the most important reason to ensure we have state on chain
if it cannot be persisted), we will still force-close if there are
HTLCs which need claiming and are going to expire.

Surprisingly, there were no tests which failed as a result of this
change, but a new one has been added.
2022-09-15 18:18:06 +00:00
Arik
8886d1dc76
Merge pull request #1708 from tnull/2022-09-rgs-unpub-modules
Improve RGS documentation
2022-09-15 09:55:39 -07:00
Elias Rohrer
ad8c955bd4
Add no-std support for RGS 2022-09-15 09:27:34 +02:00
Elias Rohrer
484c0e89f7
Rework RGS crate-level docs 2022-09-15 09:27:31 +02:00
Matt Corallo
48d21bad7b
Merge pull request #1707 from TheBlueMatt/2022-09-no-global-features
Move supported-feature-set logic into the supporting modules
2022-09-15 00:28:32 +00:00
Matt Corallo
9170804ca4 Assert that all defined features are in the known features set
Now that the features contexts track the full set of all known
features, rather than the set of supported features, all defined
features should be listed in the context definition macro.

This adds a compile-time assertion to check that all bits for known
features are set in the context known set.
2022-09-14 20:10:17 +00:00
Matt Corallo
b83e93c799 Stop tracking feature bits as known or required in features.rs
Now that the `*Features::known` constructor has been removed, there
is no reason to define feature bits as either optional required in
`features.rs` - that logic now belongs in the modules that are
responsible for the given features.

Instead, we only list all features in each context.
2022-09-14 20:10:17 +00:00
Matt Corallo
bec8bf10aa Remove the *Features::known constructor
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 (finally) remove the `known` constructor entirely,
modifying tests in the `features` module as required.
2022-09-14 20:10:17 +00:00
Matt Corallo
b93fe327d2 Remove all remaining references to *Features::known
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.

In anticipation of removing the `known` constructor, this commit
removes all remaining references to it outside of features.rs.
2022-09-14 20:09:36 +00:00
Matt Corallo
f6fa624da0 Stop relying on *Features::known in fuzzing 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 our fuzz tests.
2022-09-14 20:09:36 +00:00
Matt Corallo
d33f7268fb Stop relying on *Features::known in BP and persister 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
`lightning-background-processor` and `lightning-persister` crate
tests.
2022-09-14 20:09:36 +00:00
Matt Corallo
10b471d440 Stop relying on the *Features::known method in net-tokio
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
`lightning-net-tokio` crate.
2022-09-14 20:09:35 +00:00
Matt Corallo
4846570807 Stop relying on the *Features::known method in lightning-invoice
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
`lightning-invoice` crate.
2022-09-14 20:09:35 +00:00
Matt Corallo
32b5d843d9 Stop relying on *Features::known in channel{,manager}.rs
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 channel modules.
2022-09-14 20:09:35 +00:00
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