From e16c8b4d39a5b21682020f3bccbf53edfe65a283 Mon Sep 17 00:00:00 2001 From: DeFiDude <59237470+DeFiDude@users.noreply.github.com> Date: Sun, 25 Oct 2026 07:06:33 -0600 Subject: [PATCH] transport: count a path request only once its tag passes the duplicate check --- CHANGELOG.md | 1 + crates/rns-transport/src/actor/mod.rs | 12 +++++++----- crates/rns-transport/src/actor/outbound.rs | 9 +++++---- .../src/actor/tests/interface_stats.rs | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc1a4d2..955752b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ - Interface discovery announces name this stack, `rsRNS`, and its version. `rnsd-rs` auto-connects only to Backbone interfaces announced by Python Reticulum 1.5.2 or later, or to any announced Backbone interface with `autoconnect_unverified_implementations`, and no longer stores or lists discovered TCP client interfaces, as in Python Reticulum. - Discovery announces a KISS-framed TCP client as a KISS interface and sends and reads unset radio parameters as nil, so Python and `rnsd-rs` read each other's KISS, Weave and RNode announces, as in Python Reticulum. - `rns_link::clock::ContinuousInstant` reads a monotonic clock that keeps counting while the system is suspended, for deadlines that must hold in real time across a sleep. +- An interface counts a path request in its stats only once its tag passes the duplicate check, as in Python Reticulum 1.5. ## 1.4.0 - 2026-10-12 diff --git a/crates/rns-transport/src/actor/mod.rs b/crates/rns-transport/src/actor/mod.rs index 5abd5d1..499b067 100644 --- a/crates/rns-transport/src/actor/mod.rs +++ b/crates/rns-transport/src/actor/mod.rs @@ -11001,8 +11001,10 @@ mod tests { assert_eq!(actor.discovery_pr_tags.len(), 3); } + /// Python 1.5 counts a path request only once its tag passes the + /// duplicate gate (Transport.py:1847-1858), where 1.4 counted every one. #[test] - fn duplicate_path_requests_still_count_toward_ingress_frequency() { + fn duplicate_path_requests_do_not_count_toward_ingress_frequency() { let (mut actor, _tx) = TransportActor::new(); actor.is_transport_enabled = true; @@ -11024,15 +11026,15 @@ mod tests { actor.handle_inbound_path_request(&payload, 1); assert!(boundary_rx.try_recv().is_err()); - assert!( + assert_eq!( actor .interfaces .get(&1) .unwrap() .ingress - .incoming_pr_frequency() - > 0.0, - "duplicate tagged PRs must still contribute to ingress PR stats" + .path_requests_received(), + 1, + "duplicate tagged PRs neither forward nor count" ); } diff --git a/crates/rns-transport/src/actor/outbound.rs b/crates/rns-transport/src/actor/outbound.rs index 0537182..8856317 100644 --- a/crates/rns-transport/src/actor/outbound.rs +++ b/crates/rns-transport/src/actor/outbound.rs @@ -606,10 +606,6 @@ impl TransportActor { self.protocol_violation(interface_id); } - if let Some(entry) = self.interfaces.get_mut(&interface_id) { - entry.ingress.received_path_request(); - } - let now = now_f64(); let mut unique_tag = Vec::with_capacity(32); unique_tag.extend_from_slice(&requested_dest); @@ -621,6 +617,11 @@ impl TransportActor { return; } self.discovery_pr_tags.insert(unique_tag, now); + // Python counts a path request once its tag passes this gate + // (Transport.py:1847-1858). + if let Some(entry) = self.interfaces.get_mut(&interface_id) { + entry.ingress.received_path_request(); + } if self.local_destinations.contains(&requested_dest) { debug!( diff --git a/crates/rns-transport/src/actor/tests/interface_stats.rs b/crates/rns-transport/src/actor/tests/interface_stats.rs index 86e121c..16d22e9 100644 --- a/crates/rns-transport/src/actor/tests/interface_stats.rs +++ b/crates/rns-transport/src/actor/tests/interface_stats.rs @@ -304,6 +304,25 @@ fn a_full_transmit_queue_counts_dropped_bytes() { assert_eq!(entry.tx_dropped_bytes, 50, "txdrb"); } +/// Python counts a path request once its destination and tag pass the +/// duplicate gate (Transport.py:1847-1858), so a repeat sent through another +/// requestor neither counts nor brings the ingress limit closer. +#[test] +fn a_repeated_path_request_tag_is_not_counted() { + let mut actor = hub(); + let _rx = attach(&mut actor, 1); + let request = |requestor: u8| { + let mut rest = vec![requestor; 16]; + rest.extend_from_slice(&[0xA1; 16]); + path_request([0x51; 16], &rest) + }; + + inbound(&mut actor, request(0xC1), 1); + inbound(&mut actor, request(0xC2), 1); + + assert_eq!(stats(&mut actor, 1).path_requests_received, 1, "prxc"); +} + #[test] fn an_accepted_client_names_its_listener() { let mut actor = hub();