From 1efce8aa467f038beb3de84221a6e4f44157e69d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 11 Nov 2026 09:05:58 -0800 Subject: [PATCH] fix(moq-net): the announce fuzz writer carries lite-07's Lite-06 Chain Co-Authored-By: Claude Opus 5.5 --- rs/moq-net/benches/announce.rs | 42 ++++++++---------- rs/moq-net/benches/path.rs | 18 +++++--- .../announce/lite07-update-lite06-chain | Bin 0 -> 18 bytes rs/moq-net/src/fuzz.rs | 16 ++----- 4 files changed, 36 insertions(+), 40 deletions(-) create mode 100644 rs/moq-net/fuzz/regressions/announce/lite07-update-lite06-chain diff --git a/rs/moq-net/benches/announce.rs b/rs/moq-net/benches/announce.rs index 38c97c65700..01da9a074ae 100644 --- a/rs/moq-net/benches/announce.rs +++ b/rs/moq-net/benches/announce.rs @@ -12,7 +12,8 @@ //! - unique: random single-segment paths and random two-hop chains, where no path //! is shared and every START pays the two zero base/keep bytes. //! -//! The hop chains travel only on lite-06; lite-07 names each claim's route instead. +//! The hop chains travel only on lite-06; lite-07 names each claim's route instead, so +//! its streams carry none. //! //! The byte counts print once before the timings. //! @@ -109,18 +110,19 @@ fn id(seed: u64) -> u64 { ((z ^ (z >> 31)) & ((1 << 62) - 1)).max(1) } +/// Start route `n`, with its hop chain only on lite-06: a lite-07 claim names its route +/// instead, and carries a chain only when it was learned over lite-06. +fn start(route: fn(u64) -> (Path, Vec), n: u64, compress: bool) -> Announced { + let (path, hops) = route(n); + Announced::Start(path, if compress { Vec::new() } else { hops }) +} + /// Announce `routes` routes, then replace `churn` of them, oldest first. -fn stream(routes: u64, churn: u64, route: impl Fn(u64) -> (Path, Vec)) -> Vec { - let mut announced: Vec<_> = (0..routes) - .map(|n| { - let (path, hops) = route(n); - Announced::Start(path, hops) - }) - .collect(); +fn stream(routes: u64, churn: u64, route: fn(u64) -> (Path, Vec), compress: bool) -> Vec { + let mut announced: Vec<_> = (0..routes).map(|n| start(route, n, compress)).collect(); for n in 0..churn { announced.push(Announced::End(n)); - let (path, hops) = route(routes + n); - announced.push(Announced::Start(path, hops)); + announced.push(start(route, routes + n, compress)); } announced } @@ -150,9 +152,8 @@ fn report() { eprintln!("announce stream bytes (lite-06 literal -> lite-07 compressed):"); for (name, route) in WORKLOADS { for (routes, churn) in SHAPES { - let announced = stream(routes, churn, route); - let literal = encode_announces(&announced, false).len(); - let compressed = encode_announces(&announced, true).len(); + let literal = encode_announces(&stream(routes, churn, route, false), false).len(); + let compressed = encode_announces(&stream(routes, churn, route, true), true).len(); let starts = routes + churn; eprintln!( " {name:>6} routes={routes:>5} churn={churn:>5}: {literal:>8} -> {compressed:>8} bytes, {:.1} -> {:.1} per START ({:+.0}%)", @@ -171,17 +172,12 @@ fn bench(c: &mut Criterion) { let mut group = c.benchmark_group(format!("announce_{name}")); for routes in LIVE { - // A ring twice the live set, so the route started never collides with one - // still live. - let ring: Vec<_> = (0..2 * routes) - .map(|n| { - let (path, hops) = route(n); - Announced::Start(path, hops) - }) - .collect(); group.throughput(Throughput::Elements(2)); for compress in [false, true] { + // A ring twice the live set, so the route started never collides with one + // still live. + let ring: Vec<_> = (0..2 * routes).map(|n| start(route, n, compress)).collect(); let version = if compress { "lite07" } else { "lite06" }; group.bench_function(BenchmarkId::new(format!("churn_{version}"), routes), |b| { let mut writer = AnnounceWriter::new(compress); @@ -201,9 +197,9 @@ fn bench(c: &mut Criterion) { } for (routes, churn) in SHAPES { - let announced = stream(routes, churn, route); - group.throughput(Throughput::Elements(announced.len() as u64)); for compress in [false, true] { + let announced = stream(routes, churn, route, compress); + group.throughput(Throughput::Elements(announced.len() as u64)); let version = if compress { "lite07" } else { "lite06" }; let encoded = encode_announces(&announced, compress); group.bench_with_input( diff --git a/rs/moq-net/benches/path.rs b/rs/moq-net/benches/path.rs index c18454b1c30..3515c80658d 100644 --- a/rs/moq-net/benches/path.rs +++ b/rs/moq-net/benches/path.rs @@ -102,12 +102,20 @@ fn decode() { ]; for (name, shape) in shapes { let paths: Vec = (0..1000).map(|i| moq_net::Path::try_from(shape(i)).unwrap()).collect(); - let stream: Vec = paths - .iter() - .enumerate() - .map(|(i, path)| Announced::Start(path.clone(), vec![0x1111 + i as u64, 0x2222])) - .collect(); for compress in [false, true] { + // Lite-07 names a claim's route in place of its hop chain. + let stream: Vec = paths + .iter() + .enumerate() + .map(|(i, path)| { + let hops = if compress { + vec![] + } else { + vec![0x1111 + i as u64, 0x2222] + }; + Announced::Start(path.clone(), hops) + }) + .collect(); let data = encode_announces(&stream, compress); let version = if compress { "lite07" } else { "lite06" }; allocs(&format!("decode/announce_{version}/{name}"), 50, 1000, || { diff --git a/rs/moq-net/fuzz/regressions/announce/lite07-update-lite06-chain b/rs/moq-net/fuzz/regressions/announce/lite07-update-lite06-chain new file mode 100644 index 0000000000000000000000000000000000000000..81dc4e40c2a096f3b8679f2304b5a4a0721c5f69 GIT binary patch literal 18 VcmZSJVqjoQ1R(|nCKe#O000Ue0Y(4- literal 0 HcmV?d00001 diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index bf2055d1c4d..d27aa124fd4 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -449,8 +449,8 @@ fn hop_chain(ids: impl IntoIterator) -> Hops { /// One announcement on an announce stream, resolved: what the application sees. /// -/// The hop chain travels only on lite-06: lite-07 names the claim's route instead, so -/// its writer drops the chain and its reader decodes an empty one. +/// The hop chain is lite-06's, and lite-07's trailing Lite-06 Chain: a lite-07 claim +/// names its route instead, and carries a chain only when it was learned over lite-06. #[derive(Clone, Debug, PartialEq, Eq)] pub enum Announced { /// ANNOUNCE_START: a route's suffix and wire hop ids, taking the next id. @@ -496,13 +496,13 @@ impl AnnounceWriter { instance: self.version.has_instance().then(|| "a".parse().unwrap()), epoch: 0, suffix, - hops: self.chain(hops), + hops: hop_chain(hops.iter().copied()), cost: Default::default(), } } Announced::Update(id, hops) => lite::AnnounceBroadcast::Update { id: *id, - hops: self.chain(hops), + hops: hop_chain(hops.iter().copied()), cost: Default::default(), }, Announced::End(id) => { @@ -513,14 +513,6 @@ impl AnnounceWriter { msg.encode(&mut Encoder::new(data, self.version.into()), self.version) .expect("could not encode an announcement"); } - - /// The hop chain as this version carries it: none on lite-07. - fn chain(&self, hops: &[u64]) -> Hops { - match self.version.has_routes() { - true => Hops::default(), - false => hop_chain(hops.iter().copied()), - } - } } /// Mark `track` as a copy received from a remote publisher, as a subscriber session does, for