Commit Graph

249 Commits

Author SHA1 Message Date
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
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
Gabor Szabo
1da6fc2ded http => https 2023-07-23 08:58:41 +03:00
Matt Corallo
983f2c1870 Bump crate versions to 0.0.116 release 2023-07-21 20:42:13 +00:00
Matt Corallo
ae33b093b8 Add lightning-background-processor no-std feature
While this is generally uneccessary as users set the `no-std` or
`std` features on the `lightning` crate directly, having this
allows `lightning-background-processor` to be built by itself
without extra dep lines. Specifically, the bindings are moving to
using the `-Z avoid-dev-deps` option, which now causes
`lightning-background-processor` to fail to build directly.
2023-07-21 20:33:13 +00:00
Matt Corallo
cc5fea84e6 Update version numbers to rc1, from alpha1 2023-07-17 20:07:30 +00:00
henghonglee
54bcb6eb02 Fix DefaultRouter type restrained to only MutexGuard
Type of DerefMut for DefaultRouter was specialized to only MutexGuard.
It should be generic around RefMut and MutexGuard. This commit fixes that
2023-07-04 22:30:07 +08:00
Jeffrey Czyz
129dd30c45
Define a default MessageRouter implementation
Otherwise, users need to define one when using "Simple" type aliases.
2023-06-30 10:29:37 -04:00
Matt Corallo
bd12067777
Merge pull request #2372 from wpaulino/channelmanager-new-highest-seen-timestamp
Require best block timestamp within ChannelManager::new
2023-06-29 04:15:46 +00:00
Wilmer Paulino
82e0df5e4d
Require best block timestamp within ChannelManager::new
This ensures freshly initialized nodes can proceed to create unexpired
invoices without a call to `best_block_updated`, since an invoice's
expiration delta is applied to `highest_seen_timestamp`.
2023-06-27 13:43:14 -07:00
Matt Corallo
23e9fc79fd Bump versions to LDK 116-alpha1 and invoice 24.0-alpha1 2023-06-23 19:43:26 +00:00
Jeffrey Czyz
a71000f35d
MessageRouter trait for OnionMessenger
Add a trait for finding routes for onion messages and parameterize
OnionMessenger with it. This allows OnionMessenger to reply to messages
that it handles via one of its handlers (e.g., OffersMessageHandler).
2023-06-13 13:07:47 -05:00
Duncan Dean
b52b936bdd
Send and handle networks field in Init messages
If the `networks` field is present in a received `Init` message, then
we need to make sure our genesis chain hash matches one of those, otherwise
we should disconnect the peer.

We now also always send our genesis chain hash in `Init` messages to
our peers.
2023-06-05 09:45:48 +02:00
Duncan Dean
e23102f565
Add networks TLV to Init's TLV stream
This was a fairly old introduction to the spec to allow nodes to indicate
to their peers what chains they are interested in (i.e. will open channels
and gossip for).

We don't do any of the handling of this message in this commit and leave
that to the very next commit, so the behaviour is effectively the same
(ignore networks preference).
2023-06-05 09:45:41 +02:00
Duncan Dean
142fdca66e
Fail RGS data processing early if there is a chain hash mismatch
No point in doing any extra processing if we don't even have a match
for the chain hash.
2023-05-29 16:15:42 +02:00
Matt Corallo
6aca7e1c4d
Merge pull request #2226 from alecchendev/2023-04-persist-network-graph-on-rgs
Update BP `NetworkGraph` and `Scorer` persist frequency
2023-05-20 22:55:43 +00:00
Alec Chen
2afbdf5d1c Persist scorer upon update based on event handling
Now that we persist the scorer upon events, we extend timer persistence
from 30 seconds to 1 hour, similar to network graph persistence.
2023-05-15 18:53:04 -05:00
Alec Chen
ad8ab4d722 Prune and persist RGS network graph after initial sync
Previously we would wait 60 seconds after startup, however for RGS we
prune/persist after its initial sync since 60 seconds is likely too
long.
2023-05-15 18:51:08 -05:00
Matt Corallo
5c89d01905
Merge pull request #2288 from wpaulino/rust-bitcoin-30-prereqs 2023-05-15 18:42:38 +00:00
henghonglee
21b0818be7 Score's FeeParams as passed-in params on Routefinding functions
This PR aims to create a "stateless" scorer. Instead of passing
in fee params at construction-time, we want to parametrize the
scorer with an associated "parameter" type, which is then
passed to the router function itself, and allows passing
different parameters per route-finding call.
2023-05-10 12:53:42 -07:00
Wilmer Paulino
17a74fcfc7
Use helper to create dummy blocks
`rust-bitcoin v0.30.0` introduces concrete variants for data members of
block `Header`s. To avoid having to update these across every use, we
introduce new helpers to create dummy blocks and headers, such that the
update process is a bit more straight-forward.
2023-05-10 11:39:49 -07:00
Arik Sosman
6cb9919f0c
Move keysinterface.rs to a directory-level module called sign. 2023-05-02 21:48:08 -07:00
Matt Corallo
14c6810e48 Expose a trait impl'd for all PeerManager for use as a bound
A while back, in tests, we added a `AChannelManager` trait, which
is implemented for all `ChannelManager`s, and can be used as a
bound when we need a `ChannelManager`, rather than having to
duplicate all the bounds of `ChannelManager` everywhere.

Here we do the same thing for `PeerManager`, but make it public and
use it to clean up `lightning-net-tokio` and
`lightning-background-processor`.

We should likely do the same for `AChannelManager`, but that's left
as a followup.
2023-05-02 22:17:25 +00:00
Matt Corallo
524981ddf4 Move the CustomMessageHandler into the MessageHandler struct
`PeerManager` takes a `MessageHandler` struct which contains all
the known message handlers for it to pass messages to. It then,
separately, takes a `CustomMessageHandler`. This makes no sense, we
should simply include the `CustomMessageHandler` in the
`MessageHandler` struct for consistency.
2023-04-30 04:03:55 +00:00
Duncan Dean
4abf3ba206
Use env::temp_dir() for BP tests
Currently `BackgroundProcessor` tests create persister directories in the
current working directory and rely on cleaning up in a `Drop` implementation.

Unfortunately, it seems that in the async tests that nodes are not
`drop()`ed for some reason and so the directories created by those
tests remain behind in the current working directory.

This commit at least ensures that these test directories are created in
a temporary location for the OS using `temp_dir()`. It doesn't aim to
solve the lack of cleanup in the async tests.

Partial fix for #2224 but I believe it's enough to resolve it as these
temp directories that do remain will be purged by the OS at some stage
and are overwritten by subsequent tests if there is a conflict.
2023-04-26 14:57:18 +02:00
Matt Corallo
fb424009e3 Bump crate versions to 0.0.115/invoice 0.23 2023-04-24 22:40:17 +00:00
Matt Corallo
ec3aa49495
Merge pull request #2004 from tnull/2023-02-add-async-bp-example
Add Tokio example to `process_events_async` docs
2023-04-24 22:38:40 +00:00