Add dest_coords to SessionAck for return-path routing

SessionAck previously only carried the responder's coordinates
(src_coords). When the return path diverged from the forward path
(e.g., after tree reconvergence), transit nodes on the return path
lacked the initiator's coordinates and couldn't route the SessionAck
back, causing handshake timeouts.

Add dest_coords (initiator's coordinates) to the SessionAck wire
format, mirroring SessionSetup's design. Transit nodes now cache both
endpoints' coordinates when forwarding a SessionAck, making the return
path self-sufficient regardless of path asymmetry.

Root cause confirmed by churn-20 sim log analysis: the n04-n14
handshake failure was caused by n15 (return-path transit) lacking
n04's coordinates, not by stale tree routes through a downed node.
This commit is contained in:
Johnathan Corgan
2026-02-21 14:18:48 +00:00
parent cfb087a95d
commit 19efe06622
8 changed files with 50 additions and 21 deletions
+7 -4
View File
@@ -159,8 +159,9 @@ async fn test_coord_cache_warming_session_ack() {
let root_addr = make_node_addr(0xF0);
let src_coords = TreeCoordinate::from_addrs(vec![src_addr, root_addr]).unwrap();
let dest_coords = TreeCoordinate::from_addrs(vec![dest_addr, root_addr]).unwrap();
let ack = SessionAck::new(src_coords.clone());
let ack = SessionAck::new(src_coords.clone(), dest_coords.clone());
let ack_payload = ack.encode();
let dg = SessionDatagram::new(src_addr, dest_addr, ack_payload);
@@ -172,16 +173,18 @@ async fn test_coord_cache_warming_session_ack() {
.as_millis() as u64;
assert!(node.coord_cache().get(&src_addr, now_ms).is_none());
assert!(node.coord_cache().get(&dest_addr, now_ms).is_none());
node.handle_session_datagram(&from, &encoded[1..]).await;
// SessionAck only caches src_coords (the acknowledger's coords)
// SessionAck caches both src_coords and dest_coords
let cached_src = node.coord_cache().get(&src_addr, now_ms);
assert!(cached_src.is_some(), "src_addr coords not cached from SessionAck");
assert_eq!(cached_src.unwrap().root_id(), &root_addr);
// dest_addr should NOT be cached (SessionAck doesn't carry dest coords)
assert!(node.coord_cache().get(&dest_addr, now_ms).is_none());
let cached_dest = node.coord_cache().get(&dest_addr, now_ms);
assert!(cached_dest.is_some(), "dest_addr coords not cached from SessionAck");
assert_eq!(cached_dest.unwrap().root_id(), &root_addr);
}
#[tokio::test]
+3 -2
View File
@@ -424,8 +424,9 @@ async fn test_session_ack_for_unknown_session() {
let node1_addr = *nodes[1].node.node_addr();
// Fabricate a SessionAck and deliver directly
let coords = nodes[1].node.tree_state().my_coords().clone();
let ack = SessionAck::new(coords).with_handshake(vec![0u8; 33]);
let src_coords = nodes[1].node.tree_state().my_coords().clone();
let dest_coords = nodes[0].node.tree_state().my_coords().clone();
let ack = SessionAck::new(src_coords, dest_coords).with_handshake(vec![0u8; 33]);
let datagram = SessionDatagram::new(node1_addr, node0_addr, ack.encode());
// Send through link layer