From 81d79077d07c4e3ce88d75c8b51f31a780e61625 Mon Sep 17 00:00:00 2001 From: Daniel Norman Date: Tue, 13 Oct 2026 18:03:12 +0200 Subject: [PATCH] protocol: Do not panic on trivially empty duration Any connected peer can send a `Subscribe` with `since` after `until`. The service passes the range to `Store::filtered`, which asserts `from <= to`. The panic stops the service thread. Remove the assertion. The query already returns no rows when `from > to`, so the peer gets no history. --- crates/radicle-node/src/tests.rs | 21 +++++++++++++++++++ .../src/service/gossip/store.rs | 7 ------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/crates/radicle-node/src/tests.rs b/crates/radicle-node/src/tests.rs index c97c4d2b7..cb200b34f 100644 --- a/crates/radicle-node/src/tests.rs +++ b/crates/radicle-node/src/tests.rs @@ -601,6 +601,27 @@ fn announcement_rebroadcast_timestamp_filtered() { assert_eq!(relayed, second); } +#[test] +fn announcement_rebroadcast_inverted_range() { + let mut amy = Peer::amy(); + let bob = Peer::bob(); + let cid = Peer::cid(); + + amy.connect_to(&bob); + amy.connect_from(&cid); + amy.outbox().for_each(drop); + + amy.receive( + *cid.nid(), + Message::Subscribe(Subscribe { + filter: Filter::default(), + since: Timestamp::MAX, + until: Timestamp::MIN, + }), + ); + assert_eq!(amy.relayed(*cid.nid()).count(), 0); +} + #[test] fn announcement_relay() { let mut amy = Peer::amy(); diff --git a/crates/radicle-protocol/src/service/gossip/store.rs b/crates/radicle-protocol/src/service/gossip/store.rs index b5b005166..9dc98efd4 100644 --- a/crates/radicle-protocol/src/service/gossip/store.rs +++ b/crates/radicle-protocol/src/service/gossip/store.rs @@ -54,11 +54,6 @@ pub trait Store { /// Get all the latest gossip messages of all nodes, filtered by inventory filter and /// announcement timestamps. - /// - /// # Panics - /// - /// Panics if `from` > `to`. - /// fn filtered<'a>( &'a self, filter: &'a Filter, @@ -188,8 +183,6 @@ impl Store for Database { WHERE timestamp >= ?1 and timestamp < ?2 ORDER BY timestamp, node, type", )?; - assert!(*from <= *to); - stmt.bind((1, &from))?; stmt.bind((2, &to))?;