Skip to content

Commit 16b9281

Browse files
committed
f only skip double-validation if peers remain the same
1 parent d5cdf7a commit 16b9281

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lightning/src/routing/gossip.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,10 +1440,21 @@ impl<L: Deref> NetworkGraph<L> where L::Target: Logger {
14401440
if chan.capacity_sats.is_some() {
14411441
// If we'd previously looked up the channel on-chain and checked the script
14421442
// against what appears on-chain, ignore the duplicate announcement.
1443-
return Err(LightningError {
1444-
err: "Already have chain-validated channel".to_owned(),
1445-
action: ErrorAction::IgnoreDuplicateGossip
1446-
});
1443+
//
1444+
// Because a reorg could replace one channel with another at the same SCID, if
1445+
// the channel appears to be different, we re-validate. This doesn't expose us
1446+
// to any more DoS risk than not, as a peer can always flood us with
1447+
// randomly-generated SCID values anyway.
1448+
//
1449+
// We use the Node IDs rather than the bitcoin_keys to check for "equivalence"
1450+
// as we didn't (necessarily) store the bitcoin keys, and we only really care
1451+
// if the peers on the channel changed anyway.
1452+
if NodeId::from_pubkey(&msg.node_id_1) == chan.node_one && NodeId::from_pubkey(&msg.node_id_2) == chan.node_two {
1453+
return Err(LightningError {
1454+
err: "Already have chain-validated channel".to_owned(),
1455+
action: ErrorAction::IgnoreDuplicateGossip
1456+
});
1457+
}
14471458
} else if chain_access.is_none() {
14481459
// Similarly, if we can't check the chain right now anyway, ignore the
14491460
// duplicate announcement without bothering to take the channels write lock.

0 commit comments

Comments
 (0)