Skip to content

Invoice features #876

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

Merged
merged 3 commits into from
Apr 26, 2021
Merged

Conversation

valentinewallace
Copy link
Contributor

Tested w/ sample

@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #876 (9e82f39) into main (0d75a63) will increase coverage by 0.51%.
The diff coverage is 85.88%.

❗ Current head 9e82f39 differs from pull request most recent head b24d02c. Consider uploading reports for the commit b24d02c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #876      +/-   ##
==========================================
+ Coverage   90.26%   90.77%   +0.51%     
==========================================
  Files          57       57              
  Lines       29226    30371    +1145     
==========================================
+ Hits        26380    27570    +1190     
+ Misses       2846     2801      -45     
Impacted Files Coverage Δ
lightning-invoice/src/lib.rs 83.33% <9.09%> (-1.03%) ⬇️
lightning-invoice/src/de.rs 80.93% <90.90%> (-0.42%) ⬇️
lightning/src/ln/features.rs 98.81% <98.36%> (-0.11%) ⬇️
lightning-invoice/src/ser.rs 91.94% <100.00%> (+8.17%) ⬆️
lightning/src/ln/functional_tests.rs 96.81% <0.00%> (+0.01%) ⬆️
lightning/src/ln/channel.rs 88.74% <0.00%> (+1.49%) ⬆️
lightning/src/ln/channelmanager.rs 87.98% <0.00%> (+4.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d75a63...b24d02c. Read the comment docs.

@valentinewallace valentinewallace marked this pull request as draft April 13, 2021 16:52
@@ -387,6 +391,17 @@ impl InitFeatures {
}
}

/// Calculates the base32 encoded size of a byte slice
fn bytes_size_to_base32_size(byte_size: usize) -> usize {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use the provided implementation for [u8] instead of copying this function https://docs.rs/bech32/0.8.0/bech32/trait.Base32Len.html#impl-Base32Len

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That didn't work sadly... Neither did the original copied&pasted function. I did something super inefficient 😬 still need to think through a better way

@valentinewallace valentinewallace force-pushed the invoice-features branch 5 times, most recently from 923fce5 to 001c996 Compare April 16, 2021 21:56
@valentinewallace valentinewallace marked this pull request as ready for review April 16, 2021 22:27
@@ -395,6 +399,68 @@ impl InvoiceFeatures {
}
}

impl ToBase32 for InvoiceFeatures {
fn write_base32<W: WriteBase32>(&self, writer: &mut W) -> Result<(), <W as WriteBase32>::Err> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add some tests for these conversions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is test_payment_secret_and_features_de_and_ser which uses those methods, and invoice fuzzing. Added more unit tests though.

@valentinewallace valentinewallace force-pushed the invoice-features branch 2 times, most recently from 1fb1cd6 to e1e5918 Compare April 21, 2021 16:19
Useful for constructing features objects from raw feature bytes.
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.

Looks good, trivial comments and one doc comment.

@@ -427,8 +493,8 @@ impl<T: sealed::Context> Features<T> {
Features::<C> { flags, mark: PhantomData, }
}

#[cfg(test)]
/// Create a Features given a set of flags, in LE.
/// Create a Features given a set of flags, in little-endian. This is in reverse bit order from
Copy link
Collaborator

Choose a reason for hiding this comment

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

byte order, not bit order. We don't reverse the bits :).

Copy link
Contributor Author

@valentinewallace valentinewallace Apr 25, 2021

Choose a reason for hiding this comment

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

Maybe dumb q, but the bits are literally in reverse order from what they were, right? Rephrased tho :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't believe so? The highest bit in the last position is ultimately the highest bit - not the lowest bit in the last position (which would be true if we swapped the bits as well).

Copy link

@ariard ariard left a comment

Choose a reason for hiding this comment

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

utACK 9e82f39

@TheBlueMatt
Copy link
Collaborator

Test locally, CI is just hella broken right now. See #895.

@TheBlueMatt TheBlueMatt merged commit cc18e8a into lightningdevkit:main Apr 26, 2021
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.

4 participants