Skip to content

Fix serialization expected lengths and check them in test/fuzzing #854

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 2 commits into from
Apr 27, 2021

Conversation

TheBlueMatt
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Mar 22, 2021

Codecov Report

Merging #854 (ee0ffe5) into main (8a8c75a) will decrease coverage by 0.24%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #854      +/-   ##
==========================================
- Coverage   90.59%   90.35%   -0.25%     
==========================================
  Files          51       57       +6     
  Lines       27109    29353    +2244     
==========================================
+ Hits        24560    26522    +1962     
- Misses       2549     2831     +282     
Impacted Files Coverage Δ
lightning/src/util/config.rs 47.61% <ø> (ø)
lightning/src/ln/chan_utils.rs 97.34% <100.00%> (+<0.01%) ⬆️
lightning/src/ln/msgs.rs 88.76% <100.00%> (ø)
lightning/src/util/ser_macros.rs 96.73% <100.00%> (+0.15%) ⬆️
lightning/src/util/events.rs 18.26% <0.00%> (-5.63%) ⬇️
lightning-persister/src/lib.rs 94.06% <0.00%> (-1.55%) ⬇️
lightning/src/routing/router.rs 96.21% <0.00%> (-0.76%) ⬇️
lightning/src/util/test_utils.rs 83.23% <0.00%> (-0.42%) ⬇️
lightning/src/ln/functional_test_utils.rs 95.08% <0.00%> (-0.14%) ⬇️
lightning/src/ln/features.rs 98.81% <0.00%> (-0.11%) ⬇️
... and 19 more

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 8a8c75a...ee0ffe5. Read the comment docs.

Copy link
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

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

Nice improvement! 🥇 Minor feedback only here.

@@ -1611,7 +1611,7 @@ impl Readable for UnsignedNodeAnnouncement {
}
}

impl_writeable_len_match!(NodeAnnouncement, {
impl_writeable_len_match!(NodeAnnouncement, <=, {
Copy link
Contributor

Choose a reason for hiding this comment

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

Cool that macros can allow this type of thing!

@TheBlueMatt
Copy link
Collaborator Author

Used the constant instead and added a comment to clarify it:

$ git diff-tree -U1 a3163f1dc ee0ffe5df
diff --git a/lightning/src/ln/chan_utils.rs b/lightning/src/ln/chan_utils.rs
index 71cab6af0..da7ba15a1 100644
--- a/lightning/src/ln/chan_utils.rs
+++ b/lightning/src/ln/chan_utils.rs
@@ -41,2 +41,3 @@ use chain;
 
+// Maximum size of a serialized HTLCOutputInCommitment
 const HTLC_OUTPUT_IN_COMMITMENT_SIZE: usize = 1 + 8 + 4 + 32 + 5;
@@ -431,3 +432,3 @@ pub struct HTLCOutputInCommitment {
 impl_writeable_len_match!(HTLCOutputInCommitment, {
-		{ HTLCOutputInCommitment { transaction_output_index: None, .. }, 1 + 8 + 4 + 32 + 1},
+		{ HTLCOutputInCommitment { transaction_output_index: None, .. }, HTLC_OUTPUT_IN_COMMITMENT_SIZE - 4 },
 		{ _, HTLC_OUTPUT_IN_COMMITMENT_SIZE }

@TheBlueMatt TheBlueMatt merged commit affefb6 into lightningdevkit:main Apr 27, 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.

3 participants