paths: a local client's path response goes only to the requester

This commit is contained in:
DeFiDude committed 2026-11-18 13:04:58 -07:00
1 parent f0eedf453e
commit 7358306512
6 files changed
+39 -32

No files matched your search

+8 -9
View File
@@ -1194,21 +1194,20 @@ impl TransportActor {
}
let app_data_for_handlers = announce_app_data;
// The desiring interface is unused: the response rebroadcasts once
// everywhere through the announce table (Transport.py).
// Transport.py: a local client's answer to an external request goes
// once, as a path response, to the interface that asked.
if is_from_local_client
&& header.context == rns_wire::context::PacketContext::PathResponse
&& self
&& let Some(desiring) = self
.pending_local_path_requests
.remove(&header.destination_hash)
.is_some()
{
let now = now_f64();
let rebroadcast_raw = self.transport_announce_from_raw(
let response_raw = self.transport_announce_from_raw(
raw,
header.destination_hash,
header.hops,
rns_wire::context::PacketContext::None,
rns_wire::context::PacketContext::PathResponse,
);
self.announce_table.insert(
header.destination_hash,
@@ -1217,10 +1216,10 @@ impl TransportActor {
retransmit_timeout: now,
retries: PATHFINDER_R,
hops: header.hops,
packet_raw: rebroadcast_raw,
packet_raw: response_raw,
local_rebroadcasts: 0,
block_rebroadcast: false,
attached_interface: None,
block_rebroadcast: true,
attached_interface: Some(desiring),
source_interface: Some(interface_id),
packet_hash: announce_packet_hash,
dedup_interfaces: Vec::new(),
+5 -2
View File
@@ -12815,10 +12815,13 @@ mod tests {
actor.on_tick();
let response = external_rx
.try_recv()
.expect("the announce table rebroadcasts the local-client path response");
.expect("the announce table answers the requester");
let (header, _) = rns_wire::header::PacketHeader::unpack(&response).unwrap();
assert_eq!(header.destination_hash, dest);
assert_eq!(header.context, rns_wire::context::PacketContext::None);
assert_eq!(
header.context,
rns_wire::context::PacketContext::PathResponse
);
assert_eq!(
header.flags.header_type,
rns_wire::flags::HeaderType::Header2
@@ -1,6 +1,6 @@
//! A local client's path response to a pending external request against
//! upstream RNS 1.6.0. Expected values come from
//! `tests/fixtures/local_client_path_response/generate.py`.
//! upstream RNS 1.6.1, and the path state of a local client's announce.
//! Expected values come from `tests/fixtures/local_client_path_response/generate.py`.
use super::*;
use crate::InterfaceTransportSender;
@@ -27,7 +27,7 @@ fn golden() -> Value {
"../../../tests/fixtures/local_client_path_response/local_client_path_response.json"
))
.unwrap();
assert_eq!(v["provenance"]["rns_version"], "1.6.0");
assert_eq!(v["provenance"]["rns_version"], "1.6.1");
v
}
@@ -47,14 +47,15 @@ fn iface(name: &str, tx: mpsc::Sender<Bytes>) -> InterfaceEntry {
}
/// A local client's path response to a pending external request enters the
/// announce table and is rebroadcast once, context NONE, on every interface.
/// announce table and goes once, as a path response, to the requester only
/// (Transport.py 1.6.1, 70eb417d).
#[tokio::test]
async fn local_client_path_response_is_rebroadcast_once_everywhere() {
async fn local_client_path_response_goes_only_to_the_requester() {
let g = golden();
let lp = &g["local_pr"];
assert_eq!(lp["pending_cleared"], true);
assert_eq!(lp["announce_table_entry"]["block_rebroadcasts"], true);
assert!(lp["ext_a_sent_before_jobs"].as_array().unwrap().is_empty());
let none_ctx = g["consts"]["NONE"].as_u64().unwrap() as u8;
let raw = Bytes::from(hexv(&lp["announce_raw"]));
let dest: [u8; 16] = hexv(&lp["destination_hash"]).try_into().unwrap();
@@ -105,13 +106,16 @@ async fn local_client_path_response_is_rebroadcast_once_everywhere() {
}
}
assert_eq!(seen.len(), expected.len(), "{name}: {seen:?}");
assert_eq!(
seen[0],
(HeaderType::Header2, none_ctx, Some(transport_id)),
"{name}"
);
assert_eq!(expected[0]["context"].as_u64(), Some(u64::from(none_ctx)));
assert_ne!(seen[0].1, PacketContext::PathResponse.to_byte());
for (seen, expected) in seen.iter().zip(expected) {
assert_eq!(expected["header_type"], 1, "{name}");
let context = expected["context"].as_u64().unwrap() as u8;
assert_eq!(context, PacketContext::PathResponse.to_byte(), "{name}");
assert_eq!(
*seen,
(HeaderType::Header2, context, Some(transport_id)),
"{name}"
);
}
}
tx.send(TransportMessage::Shutdown).await.unwrap();
running.await.unwrap();
@@ -1,7 +1,8 @@
"""Shared bootstrap for the scripts in this directory. Runs upstream RNS 1.6.0 only.
"""Shared bootstrap for the scripts in this directory. Runs upstream RNS 1.6.1 only.
The upstream tree is RATSPEAK_UPSTREAM_RETICULUM_DIR if set, else upstream/Reticulum
in the workspace. Generators take an optional output directory (default: this directory).
in the workspace (set it to upstream/candidate/Reticulum until the pin lift). Generators take an
optional output directory (default: this directory).
"""
import os, subprocess, sys
HERE = os.path.dirname(os.path.abspath(__file__))
@@ -10,7 +11,7 @@ WORKSPACE = os.path.dirname(REPO)
RNS_DIR = os.environ.get("RATSPEAK_UPSTREAM_RETICULUM_DIR") or os.path.join(WORKSPACE, "upstream", "Reticulum")
sys.path.insert(0, RNS_DIR)
import RNS
assert RNS.__version__ == "1.6.0", RNS.__version__
assert RNS.__version__ == "1.6.1", RNS.__version__
assert os.path.realpath(RNS.__file__).startswith(os.path.realpath(RNS_DIR) + os.sep), RNS.__file__
RNS_REF = "upstream Reticulum " + RNS.__version__
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""A local client's path response to a pending external path request, recorded by driving
upstream RNS 1.6.0 Transport in-process (no daemon): the announce-table entry and what
jobs() sends on two external interfaces (Transport.py:2626-2648, :906-950).
upstream RNS 1.6.1 Transport in-process (no daemon): the announce-table entry and what
jobs() sends on two external interfaces (Transport.py:2747-2775, :965-1010).
Usage: generate.py [OUT_DIR]
"""
import json, os, tempfile
@@ -37,7 +37,7 @@ class Iface(_Base):
def process_outgoing(self, raw): self.sent.append(raw); self.txb += len(raw)
def __str__(self): return self.name
class SharedParent(Iface):
is_local_shared_instance = True
def __init__(self, name): super().__init__(name); self.is_local_shared_instance = True
class LocalClientIface(Iface):
def __init__(self, name): super().__init__(name); self.parent_interface = SharedParent("shared-parent")
@@ -1,5 +1,5 @@
{
"provenance": {"generator": "crates/rns-transport/tests/fixtures/local_client_path_response/generate.py", "rns_version": "1.6.0", "rns_commit": "cb1260891d1b6da8f6e9b21542c4f0cc0725cac4", "rns_path": "upstream Reticulum 1.6.0"},
"local_pr": {"announce_raw": "01009c190c86e279db5214ac5fa1d119c2710bac903c39aa02d203062e89e8bdee5001d294eaa15cd72f29f3c44c1851e3f15669d07a3463324e0ea35de5376b13fe0f27d80b5788c1c411967a3023fcea713ff34177a86279c1b8b65586fd551525006af37f54568117ee5933274f5f71deeb18a7de5bae274f347eb988f64e602b00afa229a390235d5f80aa0ee710d752538143c604d3b35567c7e2fa29ee644316cfb94207", "destination_hash": "9c190c86e279db5214ac5fa1d119c271", "pending_cleared": true, "announce_table_entry": {"retries": 1, "block_rebroadcasts": false, "attached_interface": null}, "after_jobs": {"ext-a": [{"raw": "5100e8f7fde90c979a85e17048e2f3e01f9a9c190c86e279db5214ac5fa1d119c27100ac903c39aa02d203062e89e8bdee5001d294eaa15cd72f29f3c44c1851e3f15669d07a3463324e0ea35de5376b13fe0f27d80b5788c1c411967a3023fcea713ff34177a86279c1b8b65586fd551525006af37f54568117ee5933274f5f71deeb18a7de5bae274f347eb988f64e602b00afa229a390235d5f80aa0ee710d752538143c604d3b35567c7e2fa29ee644316cfb94207", "header_type": 1, "context": 0, "packet_type": 1, "destination_hash": "9c190c86e279db5214ac5fa1d119c271", "transport_id": "e8f7fde90c979a85e17048e2f3e01f9a"}], "ext-b": [{"raw": "5100e8f7fde90c979a85e17048e2f3e01f9a9c190c86e279db5214ac5fa1d119c27100ac903c39aa02d203062e89e8bdee5001d294eaa15cd72f29f3c44c1851e3f15669d07a3463324e0ea35de5376b13fe0f27d80b5788c1c411967a3023fcea713ff34177a86279c1b8b65586fd551525006af37f54568117ee5933274f5f71deeb18a7de5bae274f347eb988f64e602b00afa229a390235d5f80aa0ee710d752538143c604d3b35567c7e2fa29ee644316cfb94207", "header_type": 1, "context": 0, "packet_type": 1, "destination_hash": "9c190c86e279db5214ac5fa1d119c271", "transport_id": "e8f7fde90c979a85e17048e2f3e01f9a"}]}, "transport_identity_hash": "e8f7fde90c979a85e17048e2f3e01f9a", "ext_a_sent_before_jobs": []},
"provenance": {"generator": "crates/rns-transport/tests/fixtures/local_client_path_response/generate.py", "rns_version": "1.6.1", "rns_commit": "cff4d03fdbd6bfb63b765280cd944756ac5cce8d", "rns_path": "upstream Reticulum 1.6.1"},
"local_pr": {"announce_raw": "0100d852593dd6100a72cf86c5579badbd7c0ba1dc5ab545d4ed16648032c8a559994602b27733ddc5ae4d82714faa8ac5706eab561f29e4910219ce596c194ba00bb8976c8c5431246ea0fd488bd7493103c3f34177a86279c1b8b65531ed17af00006afdfdae177970a660e48ef6d3f8f7a10fb4109ee97a45043385d903f9dca40a731f88a2e44bc9705b8ed8421281796d986410fee13350c92c77bc1339f2bf7c9e6a180fc1001f451f5424697e1b858006b31224800c", "destination_hash": "d852593dd6100a72cf86c5579badbd7c", "pending_cleared": true, "announce_table_entry": {"retries": 1, "block_rebroadcasts": true, "attached_interface": "ext-a"}, "after_jobs": {"ext-a": [{"raw": "5100657c69217c7e50cc8f69cbf51589f769d852593dd6100a72cf86c5579badbd7c0ba1dc5ab545d4ed16648032c8a559994602b27733ddc5ae4d82714faa8ac5706eab561f29e4910219ce596c194ba00bb8976c8c5431246ea0fd488bd7493103c3f34177a86279c1b8b65531ed17af00006afdfdae177970a660e48ef6d3f8f7a10fb4109ee97a45043385d903f9dca40a731f88a2e44bc9705b8ed8421281796d986410fee13350c92c77bc1339f2bf7c9e6a180fc1001f451f5424697e1b858006b31224800c", "header_type": 1, "context": 11, "packet_type": 1, "destination_hash": "d852593dd6100a72cf86c5579badbd7c", "transport_id": "657c69217c7e50cc8f69cbf51589f769"}], "ext-b": []}, "transport_identity_hash": "657c69217c7e50cc8f69cbf51589f769", "ext_a_sent_before_jobs": []},
"consts": {"PATH_RESPONSE": 11, "NONE": 0, "HEADER_2": 1, "PATHFINDER_R": 1}
}