-
Notifications
You must be signed in to change notification settings - Fork 411
Use the query start block for ReplyChannelRange response messages #961
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
Use the query start block for ReplyChannelRange response messages #961
Conversation
302322c
to
0e590cb
Compare
Codecov Report
@@ Coverage Diff @@
## main #961 +/- ##
==========================================
+ Coverage 90.56% 92.04% +1.48%
==========================================
Files 60 60
Lines 30423 38961 +8538
==========================================
+ Hits 27553 35863 +8310
- Misses 2870 3098 +228
Continue to review full report at Codecov.
|
Added a commit to tweak the comments to hopefully address all the feedback. |
Sadly it appears this is insufficient for c-lightning - it even checks that each message builds on the previous message (why, I don't fully understand, but...it does). |
Ended up rewriting this against the c-lightning 0.9.3 source - not only do they add requirements on the start height, but they enforce a strictly-increasing start height, which means if you get a query on an empty block boundary c-lightning will barf, even if your messages are otherwise great... |
ba42f76
to
310ef96
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.
Just nits and a question, LGTM
|
||
// Enforce exactly the sequencing requirements present on c-lightning v0.9.3 | ||
assert!(msg.first_blocknum == c_lightning_0_9_prev_end_blocknum || msg.first_blocknum == c_lightning_0_9_prev_end_blocknum.saturating_add(1)); | ||
assert!(msg.first_blocknum >= max_firstblocknum); |
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.
- Since we're checking for
>=
, wouldn't it bemin_firstblocknum
? - Is it fair to say that
max_firstblocknum
is checking that themsg
's first_blocknum is at least the first_blocknum of the previousmsg
?
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 the maximum-seen-firstblocknum, which each new message must be greater than.
Is it fair to say that max_firstblocknum is checking that the msg's first_blocknum is at least the first_blocknum of the previous msg?
Yes
Is it worth adding a workaround for a misbehaving peer? From what I gathered from ElementsProject/lightning@b2ee44b, c-lightning prior to 0.10 misinterpreted older versions of the spec, while c-lightning 0.10 correctly interprets the most recent version of the spec. |
Yea, I might argue no if the change were on-its-face-bad, but I don't really think it is - we're updating to send info that more accurately matches maybe the intent of the spec, I think, so I wouldn't say this patch is "bad" on its face, if a bit useless. I agree its kinda awkward to work around a bug in old versions of c-lightning, but I did encounter it connecting to the "Blockstream Store" node, which is one of the largest liquidity nodes on the network today. |
// Per spec, the last end_block needs to be >= the query's `end_blocknum`. | ||
// Thus, for the last reply, we calculate the difference between the query's | ||
// `end_blocknum` and the start of the reply. |
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.
Earlier you use first_blocknum + number_of_blocks
for end_blocknum
. Given end_blocknum
is not used in the spec, should we be consistent and expand it out here? Prior to the change, we were consistently using end_blocknum
throughout.
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 went for defining the "end block" and then using it as a non-` term.
- // Per spec, the last end_block needs to be >= the query's `end_blocknum`.
- // Thus, for the last reply, we calculate the difference between the query's
- // `end_blocknum` and the start of the reply.
+ // Per spec, the last end block (ie `first_blocknum + number_of_blocks`) needs to be
+ // >= the query's end block. Thus, for the last reply, we calculate the difference
+ // between the query's end block and the start of the reply.
//
C-Lightning versions prior to 0.10 (incorrectly) enforce that the reply_channel_range first_blocknum field is set to at least the value they sent in their query_channel_range message. Sending a 0 results in them responding with an Error message, closing open channels spuriously. Further, C-Lightning versions prior to 0.10 require that the reply_channel_range first_blocknum is either the same block implied as the last block of the previous reply_channel_range or one greater. This is not only a creative interpretation of the spec, but a perfectly reasonable implementation might still receive an Error message in the case of replies split by an empty block. This code is extracted and modified from a previous version of the original query_channel_range PR in commit 44ba52c. The original commit is by `bmancini55 <[email protected]>`.
59527b4
to
42f6a8f
Compare
Will take after CI unless someone complains. Total diff from Val's ACK:
|
C-Lightning versions prior to 0.10 (incorrectly) enforce that the
reply_channel_range first_blocknum field is set to at least the
value they sent in their query_channel_range message. Sending a 0
results in them responding with an Error message, closing open
channels spuriously.
This code is extracted from a previous version of the original
query_channel_range PR in commit
44ba52c. The original commit is by
bmancini55 <[email protected]>
.