-
Notifications
You must be signed in to change notification settings - Fork 367
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
Upgrade bech32 dependency #3244
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3244 +/- ##
==========================================
+ Coverage 89.80% 89.81% +0.01%
==========================================
Files 126 126
Lines 102953 102981 +28
Branches 102953 102981 +28
==========================================
+ Hits 92457 92497 +40
+ Misses 7770 7767 -3
+ Partials 2726 2717 -9 ☔ View full report in Codecov by Sentry. |
13db894
to
b7bf4dd
Compare
New round, ready for review @arik-so @TheBlueMatt ( @apoelstra ) |
Hmm, this version mostly just converts what we were doing, which was pretty inefficient/allocation-heavy, and keeps doing the same. Can we explore @apoelstra's approach at https://github.com/apoelstra/rust-lightning/tree/2024-08--new-bech32 first? That avoids a ton of our allocations (or, it will once we have GATs and can drop the Box traits, but even with those its probably a bit better), which would be really nice. |
This needs a rebase now that the |
679c109
to
a4e6d75
Compare
I propose to include the dependency update first, and switch to iterative conversion in a separate step. The proposed changes break several tests, I fixed some, but not all yet. Iterative transformations are especially beneficial if they can be combined, but this is not the case (the iterative conversion trait is private). The main benefit of iterative transformation is less memory footprint, but with intermediary collect/reverse operations this is not always the case. |
It's private but it's used to serialize an entire lightning invoice. If you want to compose that further, without allocations, you can use the |
That sounds reasonable to me, given that this PR, in isolation, wouldn't be penalizing performance compared to what we already have. |
I will continue to straighten out the iterative solution (WIP branch: https://github.com/optout21/rust-lightning/tree/bech32-iterser ) |
4b466a8
to
968a46c
Compare
Replaced by #3270 |
Reopening of #3181 . Fixes #3176 .
Changes summary:
bech32
dependency to0.11.0
(from0.9
)lightning/types
,lightning-invoice
andlightning
bech32::u5
can be replaced bybech32::Fe32
, mostly as a drop-in replacement.u5::try_from_u8
is nowFe32::try_from
bech32::Error
is mostly replaced bybech32::primitives::decode::CheckedHrpstringError
bech32
, they have been taken over tolighning-invoice
crate. The implementations (for Bolt11InvoiceFeatures and Payment*) have been moved tolightning-invoice
crate (as the trait is defined there)Here are some minor issues identified
Fe32
does not haveOrd
, so it had to be explicitly implemented forRawTaggedField
Fe32
does not haveDefault
, for which some workaround was needed. This will be added in nextbech32 0.12
release (see Add Ord trait to Fe32 (derived) rust-bitcoin/rust-bech32#186)bech32
error types are not always optimalbech32
crate)TODO:
fuzz
target