Commit Graph

274 Commits

Author SHA1 Message Date
Matt Corallo
49b375311b Bump crate versions to 0.0.123-beta/invoice 0.31-beta 2024-04-19 01:03:03 +00:00
Elias Rohrer
681106d23f
Add basic OutputSweeper test in BP
.. we simply check that the `OutputSweeper` generates a spending tx and
that the `TrackedSpendableOutput` is pruned once it reaches
`ANTI_REORG_DELAY`.
2024-04-18 16:20:03 +02:00
Jeffrey Czyz
d29e2ba949
Use AChannelManager in BackgroundProcessor
Replace instance of ChannelManager in BackgroundProcessor and in
Persister with AChannelManager. This reduces the number of type
parameters need in those types, which would need to be repeated in an
async version of Persister.
2024-03-23 17:02:28 -05:00
Jeffrey Czyz
5e56c5ed45
Fix indentation in doc example 2024-03-23 16:18:58 -05:00
Elias Rohrer
57911dcd41
Refactor BestBlock to expose inner fields rather than accessors
.. which is more idiomatic Rust, and easier to handle in (downstream)
bindings.
2024-03-07 11:02:23 +01:00
Matt Corallo
8157c01eab Never store more than one StdWaker per live Future
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 fix this by removing any `StdWaker`s stored for a given
`Future` when it is `drop`ped or prior to pushing a new `StdWaker`
onto the list when `poll`ed.

Sadly, the introduction of a `Drop` impl for `Future` means we
can't trivially destructure the struct any longer, causing a few
methods to need to take `Future`s by reference rather than
ownership and `clone` a few `Arc`s.

Fixes #2874
2024-02-15 21:52: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
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
Matt Corallo
7b31b303c6 Bump versions to LDK 0.0.121/invoice 0.29 2024-01-22 22:32:30 +00:00
Matt Corallo
37017ec39f Bump crate versions to 0.0.120/invoice 0.28 2024-01-17 21:34:29 +00:00
Elias Rohrer
e76ad1a245
Fix redundant import warning in BP's futures 2023-12-18 08:53:27 +01:00
Matt Corallo
c6e4debee9 Bump versions to 0.0.119/lightning-invoice 0.27 2023-12-15 23:53:40 +00:00
Matt Corallo
c92db69183
Merge pull request #2656 from TheBlueMatt/2023-09-scoring-decay-timer
Stop decaying liquidity information during scoring
2023-12-15 20:06:30 +00:00
Matt Corallo
21facd0d17 Make scorer decay + persistence more frequent
There's some edge cases in our scoring when the information really
should be decayed but hasn't yet been prior to an update. Rather
than try to fix them exactly, we instead decay the scorer a bit
more often, which largely solves them but also gives us a bit more
accurate bounds on our channels, allowing us to reuse channels at
a similar amount to what just failed immediately, but at a
substantial penalty.
2023-12-13 23:26:09 +00:00
Matt Corallo
b84842a904 Add a scoring decay method to the ScoreUpdate trait
Rather than relying on fetching the current time during
routefinding, here we introduce a new trait method to `ScoreUpdate`
to do so. This largely mirrors what we do with the `NetworkGraph`,
and allows us to take on much more expensive operations (floating
point exponentiation) in our decaying.
2023-12-13 23:26:09 +00:00
olegkubrakov
348db3baf7 Update tokio version to the latest to avoid tokio versions with security bugs.
This commit will set tokio version requirement to >=1.35.0, <2.0.0 to avoid versions with security issues (https://rustsec.org/packages/tokio.html).
2023-12-13 10:37:58 -08:00
Matt Corallo
6c366cf35f Pass the current time through ScoreUpDate methods
In the coming commits, we'll stop relying on fetching the time
during routefetching, preferring to decay score data in the
background instead.

The first step towards this - passing the current time through into
the scorer when updating.
2023-12-13 18:36:40 +00:00
Elias Rohrer
5112ac2f3f
Remove unused NodeId in BP tests 2023-12-11 19:58:46 +01:00
Elias Rohrer
ddf2509227
Bump MSRV to rustc 1.63.0 and edition to 2021
.. which is a reasonable common ground, also supported by Debian stable.
2023-12-08 14:03:45 +01:00
Matt Corallo
2d266794c2
Merge pull request #2723 from jkczyz/2023-11-direct-connect
Direct connect for `OnionMessage` sending
2023-12-08 01:39:13 +00:00
Jeffrey Czyz
e25af3eb01
Call OnionMessageHandler::timer_tick_occurred
lightning-background-processor processes events provided by the
PeerManager's OnionMessageHandler for when a connection is needed. If a
connection is not established in a reasonable amount of time, drop any
buffered onion messages by calling timer_tick_occurred.
2023-12-06 14:43:39 -06:00
Jeffrey Czyz
6ca81ff2bb
Process OnionMessageHandler events in background
OnionMessageHandler implementations now also implement EventsProvider.
Update lightning-background-processor to also process any events the
PeerManager's OnionMessageHandler provides.
2023-12-06 14:43:39 -06:00
Jeffrey Czyz
ce68f223e9
Re-order define_run_body macro parameters
Simply to avoid excessive wrapping when possible.
2023-12-06 14:43:39 -06:00
Jeffrey Czyz
36ecc8e729
Re-wrap define_run_body macro parameters
Some code hygiene before another parameter is added and rustfmt is
eventually used.
2023-12-06 14:43:39 -06:00
Jeffrey Czyz
ae9851794c
Remove unnecessary BackgroundProcessor type param 2023-12-06 14:43:38 -06:00
jbesraa
f0ecc3ec73
Use CandidateRouteHop as input for channel_penalty_msat
We remove `source`, `target` and `scid` from
  `channel_penalty_msat` inputs to consume them from
  `candidate` of type `CandidateRouteHop`
2023-12-05 21:07:48 +02:00
Matt Corallo
dfb02f1878 Marginally optimize test logging
973636bd2a introduced a new `HashMap`
in the `TestLogger` but then did lookups by iterating the entire
map. This fixes that, and also takes this opportunity to stop
allocating new `String`s for the module to store each log entry in
the `TestLogger`
2023-12-02 19:19:07 +00:00
Arik Sosman
27b9794bed
Rename SignerProvider's Signer to EcdsaSigner. 2023-11-27 16:27:20 -08:00
Wilmer Paulino
ec928d55b4
Bump rust-bitcoin to v0.30.2 2023-11-22 15:58:01 -08:00
Matthew Rheaume
bf395070dd Added temporary_channel_id to create_channel.
By default, LDK will generate the initial temporary channel ID for you.
However, in certain cases, it's desirable to have a temporary channel ID
specified by the caller in case of any pre-negotiation that needs to
happen between peers prior to the channel open message. For example, LND
has a `FundingShim` API that allows for advanced funding flows based on
the temporary channel ID of the channel.

This patch adds support for optionally specifying the temporary channel
ID of the channel through the `create_channel` API.
2023-11-03 17:44:50 -07:00
Matt Corallo
b664875c1b Bump crate versions to lightning 0.0.118, invoice 0.26 2023-10-23 23:41:11 +00:00
Matt Corallo
bbb8facbe6 Fix (and test) the c_bindings build flag
Rather than only building with the `c_bindings` flag in certain
crates, we go ahead and test all crates with the flag in CI here.
2023-10-21 14:30:21 +00:00
Matt Corallo
c74874604e Bump crate versions to 0.0.117/invoice 0.25 2023-10-03 23:00:48 +00:00
Matt Corallo
7aefa3131c
Merge pull request #2631 from TheBlueMatt/2023-09-pm-no-refs-reqd
Fix `Simple*PeerManager` to not require refs to the `UtxoLookup`
2023-10-03 17:12:19 +00:00
Matt Corallo
04841acb86
Merge pull request #2595 from TheBlueMatt/2023-09-117-bindings-part1
Various cleanups to make bindings generation simpler
2023-10-03 03:56:46 +00:00
Matt Corallo
26c1639ab6 Use Default::default() to construct () as score-updating param
In 6b0d94a302 we switched most tests
to `Default::default()` for scoring parameters passed to
route-fetching. Here we do the same for the scoring parameters when
passed to score-updating.
2023-10-01 00:05:01 +00:00
Matt Corallo
783e255d4f Switch Simple*ChannelManager locks around Score to RwLock
This switches the locks used around `ProbabilisticScorer` in
`Simple*ChannelManager` type aliases to `RwLock`.
2023-09-30 18:04:31 +00:00
Matt Corallo
6482635ba6 Fix Simple*PeerManager to not require refs to the UtxoLookup
`UtxoLookup` doesn't strictly need to be referenced from the
`PeerManager`, and in fact the new `GossipVerifier` in
`lightning-block-sync` requires itself to be owned by the
`PeerManager` (for circular type reasons).

This allows us to use `lightning-block-sync`'s `GossipVerifier`
with `SimpleArcPeerManager` in ldk-sample.
2023-09-30 17:57:54 +00:00
Matt Corallo
7036681728 Bump crate versions to 0.0.117-rc1/invoice 0.25-rc1 2023-09-29 23:39:18 +00:00
Matt Corallo
47e1148283 Update remaining references to primary/secondary namespaces
Update various variables, error strings, and the pending changelog
entry to refer to new namespace terminology.
2023-09-28 18:35:38 +00:00
Matt Corallo
1cb810358d Update storage constants to new PRIMARY/SECONDARY namespace terms 2023-09-28 18:35:38 +00:00
Matt Corallo
94140b91d8 Bump versions to 0.0.117-alpha2/invoice 0.25.0-alpha2 2023-09-26 20:21:08 +00:00
Matt Corallo
e01b51db67 Update crate version numbers to 0.0.117-alpha1/invoice 0.25-alpha1 2023-09-21 20:27:12 +00:00
Matt Corallo
36af1f06fa
Merge pull request #2534 from tnull/2023-08-upstream-preflight-probing
Upstream and fix preflight probing
2023-09-18 16:41:57 +00:00
Elias Rohrer
c6a1a12aca
Include maybe_announced field in RouteHop
When sending preflight probes, we want to exclude last hops that are
possibly announced. To this end, we here include a new field in
`RouteHop` that will be `true` when we either def. know the hop to be
announced, or, if there exist public channels between the hop's
counterparties that this hop might refer to (i.e., be an alias for).
2023-09-18 15:08:27 +02:00
Matt Corallo
7fa499c188 Separate ChannelManager needing persistence from having events
Currently, when a ChannelManager generates a notification for the
background processor, any pending events are handled and the
ChannelManager is always re-persisted.

Many channel related messages don't actually change the channel
state in a way that changes the persisted channel. For example,
an `update_add_htlc` or `update_fail_htlc` message simply adds the
change to a queue, changing the channel state when we receive a
`commitment_signed` message.

In these cases we shouldn't be re-persisting the ChannelManager as
it hasn't changed (persisted) state at all. In anticipation of
doing so in the next few commits, here we make the public API
handle the two concepts (somewhat) separately. The notification
still goes out via a single waker, however whether or not to
persist is now handled via a separate atomic bool.
2023-09-12 19:06:34 +00:00
Matt Corallo
9228f902e4 Rename ChannelManager update future methods for new API
In the next commit, we separate `ChannelManager`'s concept of
waking a listener to both be persisted and to allow the user to
handle events. Here we rename the future-fetching method in
anticipation of this split.
2023-09-10 23:05:51 +00:00
Elias Rohrer
cc1b505b30
Migrate to KVStore/FilesystemStore
Firstly, we switch our BP over to use `FilesystemStore`, which also gives us test
coverage and ensures the compatibility.

Then, we remove the superseded `KVStorePersister` trait and
the `FilesystemPersister` code.
2023-09-07 22:49:22 +02:00
jbesraa
3695b2aa13 Split LockableScore responsibilities between read & write operations
- Split Score from LockableScore to ScoreLookUp to handle read
      operations and ScoreUpdate to handle write operations
    - Change all struct that implemented Score to implement ScoreLookUp
      and/or ScoreUpdate
    - Change Mutex's to RwLocks to allow multiple data readers
    - Change LockableScore to Deref in ScorerAccountingForInFlightHtlcs
      as we only need to read
    - Add ScoreLookUp and ScoreUpdate docs
    - Remove reference(&'a) and Sized from Score in ScorerAccountingForInFlightHtlcs
      as Score implements Deref
    - Split MultiThreadedScoreLock into MultiThreadedScoreLockWrite and MultiThreadedScoreLockRead.
      After splitting LockableScore, we split MultiThreadedScoreLock following
      the same way, splitting a single score into two srtucts, one for read and
      other for write.
      MultiThreadedScoreLock is used in c_bindings.
2023-08-25 04:35:11 +03:00