Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename most lightning-liquidity types for bindings compatibility #3583

Merged

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Feb 2, 2025

Based on #3510.
Supersedes #3574.

Here, we refactor the lightning-liquidity crate to ensure it's easier to work with in bindings generation, i.e., mainly ensure that types won't conflict with other LDK types. To this end, we rename Event to LiquidityEvent, and prefix all LSPS0/1/2 related types with LSPS0/1/2.

Note I didn't go for the BLIP50/51/52 naming as the LSPSX naming is pretty engrained in the specs currently (e.g., actual JSON API calls are namespaced by the lspsX prefixes), so if we'd ever want to change everything to be referred by bLIP numbers, the specs themselves should likely get cleaned up first (not sure if we'd ever be happy to do deal with the parts that break compat though).

I also tagged on a commit I had already lying around for upcoming persistence work which introduces a DateTime wrapper, as I assume that might be easier than chrono::DateTime to work with in bindings.

@tnull tnull requested a review from TheBlueMatt February 2, 2025 09:10
@tnull tnull force-pushed the 2025-01-rename-all-liquidity-types branch 2 times, most recently from 6dd41b7 to 9759af4 Compare February 2, 2025 09:17
Copy link

codecov bot commented Feb 2, 2025

Codecov Report

Attention: Patch coverage is 61.31687% with 94 lines in your changes missing coverage. Please review.

Project coverage is 88.54%. Comparing base (a91196b) to head (690fcb1).
Report is 17 commits behind head on main.

Files with missing lines Patch % Lines
lightning-liquidity/src/lsps1/client.rs 0.00% 48 Missing ⚠️
lightning-liquidity/src/lsps0/client.rs 18.75% 13 Missing ⚠️
lightning-liquidity/src/lsps2/service.rs 65.62% 11 Missing ⚠️
lightning-liquidity/src/events.rs 68.18% 7 Missing ⚠️
lightning-liquidity/src/lsps0/ser.rs 78.57% 5 Missing and 1 partial ⚠️
lightning-liquidity/src/lsps2/client.rs 84.00% 4 Missing ⚠️
lightning-liquidity/src/manager.rs 42.85% 4 Missing ⚠️
lightning-liquidity/src/lsps0/msgs.rs 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3583      +/-   ##
==========================================
- Coverage   88.55%   88.54%   -0.02%     
==========================================
  Files         149      149              
  Lines      114944   114973      +29     
  Branches   114944   114973      +29     
==========================================
+ Hits       101794   101799       +5     
- Misses      10663    10682      +19     
- Partials     2487     2492       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tnull tnull force-pushed the 2025-01-rename-all-liquidity-types branch 2 times, most recently from 9db2575 to 2643ee0 Compare February 2, 2025 09:38
tnull and others added 9 commits February 3, 2025 09:15
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).
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.
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.
This wrapper is more ergonomic to use in the local context and will be
used as a serialization wrapper in following commits.
@tnull tnull force-pushed the 2025-01-rename-all-liquidity-types branch from 2643ee0 to 690fcb1 Compare February 3, 2025 08:25
@tnull
Copy link
Contributor Author

tnull commented Feb 4, 2025

I have no idea how this is possible, but it seems this didn't have any conflicts with #3510.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I thought you'd wanted to name by the new BLIP terminology rather than LSPS? Otherwise feel free to land, its just really simple type renames and shuffling.

#[serde(transparent)]
pub struct LSPSDateTime(chrono::DateTime<chrono::Utc>);

impl LSPSDateTime {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks for doing this.

@tnull
Copy link
Contributor Author

tnull commented Feb 4, 2025

LGTM. I thought you'd wanted to name by the new BLIP terminology rather than LSPS? Otherwise feel free to land, its just really simple type renames and shuffling.

Yeah, see the PR description: unfortunately I think it doesn't make sense to completely switch to bLIP terminology just yet if the specs themselves are still using LSPS everywhere. And of course the actual protocol methods are prefixed by lspsX, not sure if we'd ever want to go through the hassle of migrating away from that. I might at some point open another set of PRs towards cleaning up the spec first, we'll see.

@tnull tnull merged commit 2c3f11d into lightningdevkit:main Feb 4, 2025
24 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants