Skip to content

Commit 96d04ae

Browse files
committed
Ignore Duplicate Gossip Error while updating networkGraph from RGS #1746
1 parent 559ed20 commit 96d04ae

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

lightning-rapid-gossip-sync/src/processing.rs

+49-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,11 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
194194
synthetic_update.htlc_maximum_msat = htlc_maximum_msat;
195195
}
196196

197-
network_graph.update_channel_unsigned(&synthetic_update)?;
197+
match network_graph.update_channel_unsigned(&synthetic_update) {
198+
Ok(_) => {},
199+
Err(LightningError { action: ErrorAction::IgnoreDuplicateGossip, .. }) => {},
200+
Err(e) => return Err(e.into()),
201+
}
198202
}
199203

200204
self.network_graph.set_last_rapid_gossip_sync_timestamp(latest_seen_timestamp);
@@ -435,6 +439,50 @@ mod tests {
435439
assert!(after.contains("783241506229452801"));
436440
}
437441

442+
#[test]
443+
fn update_succeeds_when_duplicate_gossip_update_from_server() {
444+
let initialization_input = vec![
445+
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
446+
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 227, 98, 218,
447+
0, 0, 0, 4, 2, 22, 7, 207, 206, 25, 164, 197, 231, 230, 231, 56, 102, 61, 250, 251,
448+
187, 172, 38, 46, 79, 247, 108, 44, 155, 48, 219, 238, 252, 53, 192, 6, 67, 2, 36, 125,
449+
157, 176, 223, 175, 234, 116, 94, 248, 201, 225, 97, 235, 50, 47, 115, 172, 63, 136,
450+
88, 216, 115, 11, 111, 217, 114, 84, 116, 124, 231, 107, 2, 158, 1, 242, 121, 152, 106,
451+
204, 131, 186, 35, 93, 70, 216, 10, 237, 224, 183, 89, 95, 65, 3, 83, 185, 58, 138,
452+
181, 64, 187, 103, 127, 68, 50, 2, 201, 19, 17, 138, 136, 149, 185, 226, 156, 137, 175,
453+
110, 32, 237, 0, 217, 90, 31, 100, 228, 149, 46, 219, 175, 168, 77, 4, 143, 38, 128,
454+
76, 97, 0, 0, 0, 2, 0, 0, 255, 8, 153, 192, 0, 2, 27, 0, 0, 0, 1, 0, 0, 255, 2, 68,
455+
226, 0, 6, 11, 0, 1, 2, 3, 0, 0, 0, 4, 0, 40, 0, 0, 0, 0, 0, 0, 3, 232, 0, 0, 3, 232,
456+
0, 0, 0, 1, 0, 0, 0, 0, 58, 85, 116, 216, 255, 8, 153, 192, 0, 2, 27, 0, 0, 56, 0, 0,
457+
0, 0, 0, 0, 0, 1, 0, 0, 0, 100, 0, 0, 2, 224, 0, 25, 0, 0, 0, 1, 0, 0, 0, 125, 255, 2,
458+
68, 226, 0, 6, 11, 0, 1, 4, 0, 0, 0, 0, 29, 129, 25, 192, 0, 5, 0, 0, 0, 0, 29, 129,
459+
25, 192,
460+
];
461+
462+
let block_hash = genesis_block(Network::Bitcoin).block_hash();
463+
let logger = TestLogger::new();
464+
let network_graph = NetworkGraph::new(block_hash, &logger);
465+
466+
assert_eq!(network_graph.read_only().channels().len(), 0);
467+
468+
let rapid_sync = RapidGossipSync::new(&network_graph);
469+
let initialization_result = rapid_sync.update_network_graph(&initialization_input[..]);
470+
assert!(initialization_result.is_ok());
471+
472+
let single_direction_incremental_update_input = vec![
473+
76, 68, 75, 1, 111, 226, 140, 10, 182, 241, 179, 114, 193, 166, 162, 70, 174, 99, 247,
474+
79, 147, 30, 131, 101, 225, 90, 8, 156, 104, 214, 25, 0, 0, 0, 0, 0, 97, 229, 183, 167,
475+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
476+
0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 8, 153, 192, 0, 2, 27, 0, 0, 136, 0, 0, 0, 221, 255, 2,
477+
68, 226, 0, 6, 11, 0, 1, 128,
478+
];
479+
let update_result_1 = rapid_sync.update_network_graph(&single_direction_incremental_update_input[..]);
480+
// Apply duplicate update
481+
let update_result_2 = rapid_sync.update_network_graph(&single_direction_incremental_update_input[..]);
482+
assert!(update_result_1.is_ok());
483+
assert!(update_result_2.is_ok());
484+
}
485+
438486
#[test]
439487
fn full_update_succeeds() {
440488
let valid_input = vec![

0 commit comments

Comments
 (0)