-
Notifications
You must be signed in to change notification settings - Fork 368
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
Encode & test channel_update
message type in failure messages.
#1465
Encode & test channel_update
message type in failure messages.
#1465
Conversation
First steps towards encoding are done, which however feel somewhat hacky. Optimally, there should be a neater solution to Currently two tests are still failing and the new one(s) are still work in progress. |
Yea, I don't think it makes sense to go rewrite the serialization stuff, this is fine. That said, lets get the constant from |
d22611a
to
85d0698
Compare
Codecov Report
@@ Coverage Diff @@
## main #1465 +/- ##
==========================================
- Coverage 90.92% 90.91% -0.01%
==========================================
Files 75 75
Lines 41842 41869 +27
Branches 41842 41869 +27
==========================================
+ Hits 38043 38066 +23
- Misses 3799 3803 +4
Continue to review full report at Codecov.
|
Rebased and added test to confirm we still can handle failure messages including channel updates without the type prefix. |
85d0698
to
11768fb
Compare
Squashed. |
7940903
to
94c8ad8
Compare
94c8ad8
to
6d8be70
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.
I need to review the tests, and I will do it in a couple of hours, but I have considered to how to remove the prefix
@@ -2249,7 +2250,7 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana | |||
break None; | |||
} | |||
{ | |||
let mut res = VecWriter(Vec::with_capacity(chan_update.serialized_length() + 8 + 2)); | |||
let mut res = VecWriter(Vec::with_capacity(chan_update.serialized_length() + 2 + 8 + 2)); |
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 would like to have a very tiny comment that documents what this sum will do!
This make it harder to read for people that switch implementation during the day
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 would like to have a very tiny comment that documents what this sum will do!
I'm not sure that a comment would provide much more information that is not self-explanatory? Maybe chan_update.serialized_length() + mem::size_of<u16>() + mem::size_of<u64> + mem::size_of<u16>()
would be more expressive, but would also render the line unnecessarily long? Also, this only reserves a certain amount of vector capacity, nothing would really break if the calculation would be off by a byte or two.
This make it harder to read for people that switch implementation during the day
Mh, how does this relate to other implementations?
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.
Mh? I mean a comment to explain the meaning of the number // to the serialization length we sum up: 2 (flag) + 8 (whatever) + 2(whatever)
BTW, it is not relevent!
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.
Looks good! Tried to hunt for other places we encode channel updates in errors but they seem to be covered, and the testing hits the two cases.
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
Following the clarification of the spec (lightning/bolts#979) and the ability to decode type-prefixed channel updates attached to failure messages (#1455), this PR implements also the encoding of said channel updates.
It also aims to increase test coverage, in particular to check whether we still allow decoding of channel updates without the type prefix be be backwards-compatible.
Based off #1455.
Closes #1450.