-
Notifications
You must be signed in to change notification settings - Fork 420
Correct the on-chain script checked in gossip verification #1666
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
Correct the on-chain script checked in gossip verification #1666
Conversation
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 like get_signed_channel_announcement() in the gossip tests makes the same assumption for the bitcoin keys and needs to be updated too.
Otherwise LGTM!
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.
Generally looks good mod the failing tests, i.e., the get_channel_script function (https://github.com/TheBlueMatt/rust-lightning/blob/2022-08-fix-script-check/lightning/src/routing/gossip.rs#L1945) also needs updating.
Also, could you maybe add a check to some test case to ensure we catch this (or similar) issue not only down the line in bindings generation, if there ever were to be a regression?
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 after outstanding feedback and CI
|
Pushed a fix, as for a check for this, I'm not entirely sure how to write one that is actually useful - sure I could write a test that checks the specific scripts which failed here, but that's not all that interesting, sadly we had several checks which ultimately should have caught this, but of course we replicated the same bug into the tests, which made them not all that helpful. |
Alright, then hopefully tests will just catch if there ever would be a regression. Seems the fix didn't do the trick entirely though. |
|
Seems we're still getting a test panic. With the amount of test panics that arose, I'm happy with the coverage 😆 |
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.
ACK 43814f3
Back to the nominal crate test failures for those two lol
The `bitcoin_key_1` and `bitcoin_key_2` fields in `channel_announcement` messages are sorted according to node_ids rather than the keys themselves, however the on-chain funding script is sorted according to the bitcoin keys themselves. Thus, with some probability, we end up checking that the on-chain script matches the wrong script and rejecting the channel announcement. The correct solution is to use our existing channel funding script generation function which ensure we always match what we generate. This was found in testing the Java bindings, where a test checks that retunring the generated funding script in `chain::Access` results in the constructed channel ending up in our network graph.
43814f3 to
6265da0
Compare
|
Squashed without further changes. |
The
bitcoin_key_1andbitcoin_key_2fields inchannel_announcementmessages are sorted according to node_idsrather than the keys themselves, however the on-chain funding
script is sorted according to the bitcoin keys themselves. Thus,
with some probability, we end up checking that the on-chain script
matches the wrong script and rejecting the channel announcement.
The correct solution is to use our existing channel funding script
generation function which ensure we always match what we generate.
This was found in testing the Java bindings, where a test checks
that retunring the generated funding script in
chain::Accessresults in the constructed channel ending up in our network graph.