Commit graph

18 commits

Author SHA1 Message Date
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