Enforce that node_ids are sorted in channel_announcements#4611
Enforce that node_ids are sorted in channel_announcements#4611TheBlueMatt wants to merge 1 commit into
Conversation
|
👋 Thanks for assigning @tankyleo as a reviewer! |
|
No new issues found. Review SummaryI thoroughly reviewed the entire PR diff, all modified files, and the surrounding code paths (validation flow, signature verification, UTXO checking, all three channel announcement test helpers, both The core change ( Previously flagged (from prior review, not repeated)
No new issues found |
|
Drafting until claude fixes tests. |
798f08f to
271ac91
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4611 +/- ##
==========================================
+ Coverage 86.12% 86.66% +0.54%
==========================================
Files 157 159 +2
Lines 108922 110612 +1690
Branches 108922 110612 +1690
==========================================
+ Hits 93812 95865 +2053
+ Misses 12495 12221 -274
+ Partials 2615 2526 -89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tankyleo
left a comment
There was a problem hiding this comment.
LGTM, just one nit from claude above
271ac91 to
86897b0
Compare
|
Updated the other test utility: $ git diff-tree -U1 271ac9149 86897b079
diff --git a/lightning/src/routing/gossip.rs b/lightning/src/routing/gossip.rs
index f45cb0ae50..3dda719414 100644
--- a/lightning/src/routing/gossip.rs
+++ b/lightning/src/routing/gossip.rs
@@ -2840,4 +2840,11 @@ pub(crate) mod tests {
) -> ChannelAnnouncement {
- let node_id_1 = PublicKey::from_secret_key(&secp_ctx, node_1_key);
- let node_id_2 = PublicKey::from_secret_key(&secp_ctx, node_2_key);
+ let mut node_id_1 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_1_key));
+ let mut node_id_2 = NodeId::from_pubkey(&PublicKey::from_secret_key(&secp_ctx, node_2_key));
+ let mut signer_1 = node_1_key;
+ let mut signer_2 = node_2_key;
+ if node_id_1 > node_id_2 {
+ core::mem::swap(&mut node_id_1, &mut node_id_2);
+ core::mem::swap(&mut signer_1, &mut signer_2);
+ }
+
let node_1_btckey = &SecretKey::from_slice(&[40; 32]).unwrap();
@@ -2849,4 +2856,4 @@ pub(crate) mod tests {
short_channel_id: 0,
- node_id_1: NodeId::from_pubkey(&node_id_1),
- node_id_2: NodeId::from_pubkey(&node_id_2),
+ node_id_1,
+ node_id_2,
bitcoin_key_1: NodeId::from_pubkey(&PublicKey::from_secret_key(
@@ -2864,4 +2871,4 @@ pub(crate) mod tests {
ChannelAnnouncement {
- node_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_key),
- node_signature_2: secp_ctx.sign_ecdsa(&msghash, node_2_key),
+ node_signature_1: secp_ctx.sign_ecdsa(&msghash, signer_1),
+ node_signature_2: secp_ctx.sign_ecdsa(&msghash, signer_2),
bitcoin_signature_1: secp_ctx.sign_ecdsa(&msghash, node_1_btckey), |
We already enforced that nodes can't have a chanel with themselves, but the spec was updated to require strict ordering at lightning/bolts#1333 so we enforce this as well. Test fixes by claude.
86897b0 to
ac7e4e8
Compare
|
Oops, also had claude fix the |
We already enforced that nodes can't have a chanel with themselves, but the spec was updated to require strict ordering at lightning/bolts#1333 so we enforce this as well.