From cb951f5f30cfb4f0f84dd8f4e6633413c9ec643c Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Tue, 14 Oct 2025 13:17:03 -0400 Subject: [PATCH] ln-simln-jamming: only look up node 69 if running slowjam Without this, running attacks that don't contain node 69 can't run. --- ln-simln-jamming/src/main.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/ln-simln-jamming/src/main.rs b/ln-simln-jamming/src/main.rs index 74486b19..4a3029bf 100644 --- a/ln-simln-jamming/src/main.rs +++ b/ln-simln-jamming/src/main.rs @@ -266,22 +266,34 @@ async fn main() -> Result<(), BoxError> { .await?; let simulation = Arc::new(simulation); + // Collect all attacker nodes from the network + let attacker_pubkeys_map: HashMap = network + .attackers() + .iter() + .map(|(alias, pk)| (*pk, alias.clone())) + .collect(); + // Ugly hack specific to SlowJam attack to include this node in the list of nodes passed to run_attack. // This node is used as an "honest" node to send a test payment through our target channel to // check that it is actually jammed. - let honest_sender_pubkey = find_pubkey_by_alias("69", sim_network)?; + let honest_sender_pubkey = if cli.attack_type == AttackType::SlowJam { + Some(find_pubkey_by_alias("69", sim_network)?) + } else { + None + }; + let attacker_nodes: HashMap>>> = sim_nodes .into_iter() .filter_map(|(pk, node)| { - if cli.attack_type == AttackType::SlowJam && pk == honest_sender_pubkey { - Some(("69".to_string(), node)) - } else { - network - .attackers() - .iter() - .find(|attacker| attacker.1 == pk) - .map(|a| (a.0.clone(), node)) + if let Some(honest_pk) = honest_sender_pubkey { + if honest_pk == pk { + return Some(("69".to_string(), node)); + } } + + attacker_pubkeys_map + .get(&pk) + .map(|alias| (alias.clone(), node)) }) .collect();