-
Notifications
You must be signed in to change notification settings - Fork 411
Drop address ordering enforcement in NodeAnnouncement deser #797
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
Drop address ordering enforcement in NodeAnnouncement deser #797
Conversation
Agreed. I had to comment these exact lines out to get the |
Codecov Report
@@ Coverage Diff @@
## main #797 +/- ##
==========================================
- Coverage 90.84% 90.79% -0.05%
==========================================
Files 44 44
Lines 24073 24064 -9
==========================================
- Hits 21868 21848 -20
- Misses 2205 2216 +11
Continue to review full report at Codecov.
|
It seems many other nodes never bothered to enforce these requirements, so there's little reason that we should either. cc lightning/bolts#842
b3676c6
to
8dd08bd
Compare
It was further pointed out upstream that we really shouldn't be following the old-spec-recommendation to not relay if a message has any excess data, but instead allow some, so I pushed a commit to do so as well. |
1b33a3e
to
d682718
Compare
d682718
to
d873e72
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.
Ok(msg.contents.excess_data.is_empty() && msg.contents.excess_address_data.is_empty()) | ||
Ok(msg.contents.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY && | ||
msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY && | ||
msg.contents.excess_data.len() + msg.contents.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY) |
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.
Any reason for the above two checks when the additive branch exists?
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 probably not possible to hit just because of the deserialization limits, but I like to make sure code is obviously overflow-safe :)
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.
Good to know, thanks!
let should_relay = | ||
msg.excess_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY && | ||
msg.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY && | ||
msg.excess_data.len() + msg.excess_address_data.len() <= MAX_EXCESS_BYTES_FOR_RELAY; |
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.
Same q as above
Note that the spec PR got some pushback (the ordering requirement, in the future, as we add more address types, is important to allow us to read all known versions before we hit unknown ones, though it doesnt really impact us today). I'd still prefer to just merge this and we can revisit when the spec PR gets some more responses as we need to do something and I don't really want to create a whole getter/setter API for this when other implementations dont enforce this on the read side. |
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 🌴
In lightningdevkit#797, we stopped enforcing that read/sent node_announcements had their addresses sorted. While this is fine in practice, we should still make a best-effort to sort them to comply with the spec's forward-compatibility requirements, which we do here in the ChannelManager.
In lightningdevkit#797, we stopped enforcing that read/sent node_announcements had their addresses sorted. While this is fine in practice, we should still make a best-effort to sort them to comply with the spec's forward-compatibility requirements, which we do here in the ChannelManager.
It seems many other nodes never bothered to enforce these
requirements, so there's little reason that we should either.
cc lightning/bolts#842
Its honstly long-since time we drop this check. As noted upstream we should maybe add a check to not relay node announcements which have more than 10 addresses, but this on its own doesn't change the malicious-DDoS attack surface.