-
Notifications
You must be signed in to change notification settings - Fork 371
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
Swap the dep order between lightning
and lightning-invoice
#3234
Swap the dep order between lightning
and lightning-invoice
#3234
Conversation
08671c8
to
7d52254
Compare
Note that the first commit can/should be dropped after #3020, but I needed it to get things to compile at all until then. |
ut/concept ACK 7d52254 Thanks! |
7d52254
to
7716d79
Compare
Oops, forgot to rustfmt, pushed that. |
7716d79
to
f7ff707
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3234 +/- ##
==========================================
- Coverage 89.75% 89.75% -0.01%
==========================================
Files 122 123 +1
Lines 101903 101887 -16
Branches 101903 101887 -16
==========================================
- Hits 91465 91445 -20
+ Misses 7753 7751 -2
- Partials 2685 2691 +6 ☔ View full report in Codecov by Sentry. |
f7ff707
to
66748fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsurprisingly, strong concept ACK from my side for this.
lightning/src/ln/mod.rs
Outdated
pub mod invoice_utils; | ||
pub mod bolt11_payment; | ||
|
||
pub use lightning_types::{PaymentHash, PaymentPreimage, PaymentSecret}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, re-exporting under lightning::ln
and lightning::ln::types
is a bit confusing. Can't we just switch to either use a re-export at the top-level (i.e., lightning::types
or similar) or using lightning_types::{..}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, though we have a lot of code that references these as lightning::ln::...
that I'm not sure what to do about, and it seems like something to fix in a followup rather than here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, doing it in a follow-up (possibly still landing for the same release?) would be fine I think
FWIW, not sure which first commit you're referring to. Seems you might have already dropped it? |
[package.metadata.docs.rs] | ||
rustdoc-args = ["--cfg", "docsrs"] | ||
|
||
[features] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When building lightning-types
by itself, I found that the std/no-std features are missing:
[features] | |
[features] | |
default = ["std"] | |
no-std = ["bitcoin/no-std"] | |
std = ["bitcoin/std", "bech32/std"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be resolved when we upgrade to rust-bitcoin 32 in the same release.
LGTM! This change straightens the |
I did.
Yea, for now. We can add other stuff that may be useful for crates that want some additional types but don't want to depend on all of |
8d53b79
to
2350921
Compare
/// The difference in CLTV values between this node and the next node. | ||
pub cltv_expiry_delta: u16, | ||
/// The minimum value, in msat, which must be relayed to the next hop. | ||
pub htlc_minimum_msat: Option<u64>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, to keep this new crate as generic Lightning as possible, we could eventually consider a way to drop/move these fields which are somewhat proprietary to LDK/leak LDK internals as they don't exist in the actual BOLT11 r
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, I dunno, I don't mind it. These aren't really BOLT 11 fields but rather a generic concept of what a route hint hop should be.
Feel free to squash fixups. |
2350921
to
fff0ef3
Compare
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This is the first step towards fixing that - moving the common types we need into a new `lightning-types` crate which both can depend on. Since we're using a new crate and can't depend on the existing `lightning` hex utility to implement `Display`, we also take this opportunity to switch to the new `Display` impl macro in `hex_conservative`.
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This takes one more step, moving the routing types `lightning-invoice` uses into `lightning-types`.
It turns out all the places we use `Features::is_subset` we could as well be using `Features::requires_unknown_bits_from`. Further, in the next commit `Features` will move to a different crate so any methods which the `lightning` crate uses will need to be public. As the `is_subset` API is prety confusing (it doesn't consider optional/required bits, only whether the bits themselves are strictly a subset) it'd be nice to not have to expose it, which is enabled here.
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This takes one more step, moving the `Features` types from `lightning` to `lightning-types`.
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This takes one more step, moving the `UntrustedString` and `PrintableString` types to `lightning-types`.
In a coming commit, the `lightning-invoice::utils` module will move to the `lightning` crate, causing its tests to be included in the global lockorder tests done in that crate. This should be fine, except that the `lightning-invoice::utils` module currently holds the `added_monitors` lock too long causing lockorder violations. Instead, this commit replaces the legacy monitors-added test with the `check_added_monitors` test utility.
`lightning-invoice` currently has a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. This takes tees us up for the final step, adding a `lightning-types` dependency to `lightning-invoice` and using it for imports rather than the `lightning` crate.
`lightning-invoice` previously had a dependency on the entire `lightning` crate just because it wants to use some of the useful types from it. This is obviously backwards and leads to some awkwardness like the BOLT 11 invoice signing API in the `lightning` crate taking a `[u5]` rather than a `Bolt11Invoice`. Here we finally rectify this issue, swapping the dependency order and making `lightning` depend on `lightning-invoice` rather than the other way around. This moves various utilities which were in `lightning-invoice` but relied on `lightning` payment types to make payments to where they belong (the `lightning` crate), but doesn't bother with integrating them well in their new home.
Now that the `lightning` crate depends on the `lightning-invoice` crate, there's no reason to have the `sign_invoice` method take raw base32 field elements as we can now give it a real `RawBolt11Invoice`, which we do here. This simplifies the interface and avoids a serialization-deserialization roundtrip when signing invoices in a validating signer. FIxes lightningdevkit#3227
In the next commit we'll `rustfmt` newly-added files, but before we do so we clean up some code so that the resulting files won't be quite as absurd. We also exclude the new `invoice_utils.rs` file, as it needs quite substantial cleanups.
The past handful of commits were mostly moving code around, so to aid reviewers violated our `rustfmt` rules. Here we rectify that by `rustfmt`'ing the newly-added files.
fff0ef3
to
ae59d1d
Compare
Rebased to address trivial conflict and squashed without other changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
While this is mostly moving code, I think this needs a second or third set of eyes given the ~ +1800/-1600 change set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -0,0 +1,24 @@ | |||
[package] | |||
name = "lightning-types" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the PR description I was expecting a name like lightning-common
, but types
is fine too I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*-common
seems a bit vague as it might imply actual "core" lightning functionality. I've seen the suffix be used a bit loosely to not only refer to types. *-types
seems more appropriate IMO :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its also not really intended to be used by downstream crates, so I'm not sure it matters that much :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quite a chonky one, but thanks for leaving the formatting until the final commit. I've confirmed it's mostly moves.
LGMT.
@@ -93,7 +93,7 @@ pub(crate) fn verify_channel_type_features(channel_type_features: &Option<Channe | |||
supported_feature_set |= additional_permitted_features; | |||
} | |||
|
|||
if !features.is_subset(&supported_feature_set) { | |||
if features.requires_unknown_bits_from(&supported_feature_set) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way clearer.
Fixes #3227