Commit graph

35 commits

Author SHA1 Message Date
Elias Rohrer
f93caaeada
Add config accessor to LSPS2ServiceHandler 2025-02-06 10:26:26 +01:00
Elias Rohrer
4615cd89d2
Add config accessor to LSPS2ClientHandler 2025-02-06 10:26:26 +01:00
Elias Rohrer
153643c41a
Add config accessor to LSPS1ServiceHandler 2025-02-06 10:26:26 +01:00
Elias Rohrer
5ec6819dfc
Add config accessor to LSPS1ClientHandler 2025-02-06 10:26:26 +01:00
Elias Rohrer
690fcb1545
Introduce LSPSDateTime wrapper
This wrapper is more ergonomic to use in the local context and will be
used as a serialization wrapper in following commits.
2025-02-03 09:24:48 +01:00
Elias Rohrer
8526b9fca3
Prefix general LSPS message types to avoid naming collisions 2025-02-03 09:23:55 +01:00
Elias Rohrer
cfc636c174
Prefix BLIP-52/LSPS2 message types to avoid naming collisions 2025-02-03 09:23:17 +01:00
Elias Rohrer
6b720fd88b
Prefix BLIP-51/LSPS1 message types to avoid naming collisions 2025-02-03 09:23:12 +01:00
Elias Rohrer
f9c477f80a
Prefix BLIP-50/LSPS0 message types to avoid naming collisions 2025-02-03 09:15:56 +01:00
Matt Corallo
095194ffcb
Mark static method string as 'static
since it is
2025-02-03 09:15:55 +01:00
Elias Rohrer
5e0c5f0821
Rename Event to LiquidityEvent
In order to avoid naming collisions with LDK's `Event` type, we rename
`lightning-liquidity`'s `Event` to `LiquidityEvent`. To minimize furhter
churn on the upcoming renaming changes, we also `impl From X for
LiquidityEvent` for the protocol-specific event variants, which also
allows us to reduce some boilerplate while enqueuing.
2025-02-03 09:15:55 +01:00
Elias Rohrer
962da67d8e
Fix lsps1_service builds
As we're not testing with `cfg(lsps1_service)`, the builds broke during
previous refactoring. This isn't bad as we're looking to completely
overhaul / rewrite LSPS1 service soon, but until then we fix this
pre-existing breakage to make sure following changes make sense.
2025-02-03 09:15:55 +01:00
Elias Rohrer
dfc71390b8
Introduce bLIP numbers in lightning-liquidity documentation
Recently, LSPS0, 1, and 2 were upstreamed as bLIP-50, 51, and 52,
respectively. Here, we

1. start linking to the bLIPs instead of the LSP spec repository, which
   is likely going to be deprecated.
2. start consistently citing the specs as `bLIP-5X / LSPSX` to avoid any
   confusions and to potentially initiate a process in which the LSP
   specs will be referred to by their bLIP number rather than their LSPS
   number (especially given that any upcoming specs by the LSP
   spec group will directly be drafted as bLIPs going forward).
2025-02-03 09:15:55 +01:00
Elias Rohrer
f19016f900
Drop (currently) unused BP dev-dependency from lightning-liquidity
.. we planned to use the BP for some more advanced integration tests, but we
haven't actually implemented them as of now. Here we drop the
unnecessary dev-dependency for now.
2025-01-28 16:45:09 +01:00
Matt Corallo
a8c03f455a
Bump crate versions to 0.1.0/invoice 0.33.0/dns-resolver 0.2
Sadly, dns-resolver got uploaded as 0.1.0 without a -beta1 tag (and
yanked), and thus we release it here as 0.2.0.
2025-01-28 16:45:09 +01:00
Elias Rohrer
e05b76af7b
liquidity: Allow setting process_events callback in c_bindings
To trigger message processing, we previously had the user set a callback
to `PeerManager::process_events` via an `Fn()` callback. This is however
not supported by `c_bindings`.

Here, we therefore introduce as `ProcessMesssagesCallback` trait that
can be used via `LiquidityManager::set_process_msgs_callback_fn`, which
is exposed in `c_bindings`.
2025-01-15 09:58:43 +01:00
Elias Rohrer
dd91418463
Add notes to docs/README to indicate beta status of service-side
As a few things are missing (most importantly persistence), we add notes
that the service-side integration is currently considered 'beta'.
2024-12-19 17:12:09 +01:00
Elias Rohrer
6e06262935
Update best_block field in Confirm::best_block_updated
Previously, we wouldn't set the field as we aren't yet making use of it.
Here, we start setting the field. To this end, we make `best_block` an
`RwLock<Option<BestBlock>>` rather than `Option<RwLock<BestBlock>>`.
2024-12-18 10:12:53 +01:00
Elias Rohrer
8825fc387b
Drop disconnecting peers from the list of ignored peers
When a peer misbehaves/sends bogus data we reply with an error message
and insert it to the ignored list.

Here, we avoid having this list grow unboundedly over time by removing
peers again once they disconnect, allowing them a second chance upon
reconnection.
2024-12-18 09:54:05 +01:00
Elias Rohrer
4cb4d66e1b
Address doc nits
We address some minor mistakes that made it into the docs before.
2024-12-17 11:06:15 +01:00
Elias Rohrer
f68c6c5be1
LSPS2: Limit the total number of peers
While LDK/`ChannelManager` should already introduce an upper-bound on
the number of peers, here we assert that our `PeerState` map can't
grow unboundedly. To this end, we simply return an `Internal error` and
abort when we would hit the limit of 100000 peers.
2024-12-16 16:19:27 +01:00
Elias Rohrer
7a8952110c
LSPS2: Include channels pending intial payment in the per-peer limit
We include any `OutboundJITChannel` that has not made it further than
`PendingInitialPayment` in the per-peer request limit, and will of
course prune it once it expires.
2024-12-16 16:19:27 +01:00
Elias Rohrer
440962e4fe
LSPS2: Prune empty PeerStates
In addition to pruning expired requests on peer disconnection we also
regularly prune for all peers on block connection, and also remove the
entire `PeerState` if it's empty after pruning (i.e., has no pending
requsts or in-flight channels left).
2024-12-16 16:19:27 +01:00
Elias Rohrer
776ede44cb
LSPS2: Also prune expired OutboundJITChannels pending initial payments
We're now also pruning any expired `OutboundJITChannels` if we haven't
seen any related HTLCs.
2024-12-16 16:19:26 +01:00
Elias Rohrer
b39c8b09ba
LSPS2: Prune expired buy requests on disconnection
.. we clean up any pending buy requests that hit their `valid_until`
time when the counterparty disconnects.
2024-12-16 16:19:24 +01:00
Elias Rohrer
6451a432cc
LSPS2: Clean pending get_info request state on disconnection
We clean up any `get_info` request state when peers disconnect.
2024-12-11 17:01:36 +01:00
Elias Rohrer
f75f124e02
LSPS2: Enforce a limit on total pending requests
To this end we introduce a new counter keeping track of overall requests
pending and reject inbound requests if they would put us over the
limit.
2024-12-11 17:01:36 +01:00
Elias Rohrer
1f13c80e92
LSPS2: DRY up pending request insertion/removal
.. which is a prefactor to also start checking the total number of
pending requests in the next commit.
2024-12-11 17:01:36 +01:00
Elias Rohrer
3f2e232814
LSPS2: Introduce MAX_PENDING_REQUESTS_PER_PEER service limit
We introduce a new `MAX_PENDING_REQUESTS_PER_PEER` limit for the
number of pending (get_info and buy) requests per peer.
2024-12-11 17:01:04 +01:00
Elias Rohrer
7e42b36e0f
Upper-bound the event queue size
We add a size limit on the event queue, after which we'll just start
dropping events to ensure we could never OOM.

Additionally, we document the requirement that users need to handle
generated events ASAP.
2024-12-11 17:01:04 +01:00
Elias Rohrer
9c9b4a8df7
Use lightning::sync via symlink in lightning-liquidity
.. to which end we also need to make some additions to `debug_sync` and
`nostd_sync`.
2024-12-11 17:01:04 +01:00
Elias Rohrer
3a8e1bffcc
Use LDK-internal Hash{Map,Set} types in lightning-liquidity 2024-12-11 17:01:03 +01:00
Elias Rohrer
d8ba98ba2e
Use split_off instead of collecting in get_pending_events() 2024-12-11 17:01:03 +01:00
Elias Rohrer
94c1e37a59
Avoid allocating during LSPSMethod serialization 2024-12-11 17:01:03 +01:00
Elias Rohrer
b8b807124f
Add lightning-liquidity crate to the workspace
We upstream the `lightning-liquidity` into the `rust-lightning`
workspace.

Files are copied over as per commit c80eb75f5a31bea5c2b73e41c50ca382ec0020f8.
2024-12-11 17:01:03 +01:00