From b9e4b76ea52b9658b7717375e57a318b31ee48b4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 07:01:00 -0700 Subject: [PATCH 1/9] chore(quest): claim quest/m1/ietf-epoch-cut.md Quest-Claim: a5c32d05d9bb8b26 From ef868a0fc798a69df54ca60657534dfa938c695d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 07:13:32 -0700 Subject: [PATCH 2/9] feat(net)!: remove epochs from moq-transport Co-Authored-By: GPT-6.1 Sol --- doc/bin/cli.md | 3 +- doc/bin/relay/cluster.md | 7 +- doc/bin/relay/config.md | 2 - doc/concept/moq-lite.md | 12 +- doc/concept/standard.md | 7 +- doc/concept/stats.md | 5 +- doc/setup/redundancy.md | 4 +- doc/setup/upgrade.md | 5 +- js/net/api/index.api.md | 1 - js/net/src/connection/extensions.test.ts | 15 - js/net/src/connection/extensions.ts | 4 - js/net/src/connection/handshake.ts | 10 +- js/net/src/ietf/aliases.test.ts | 8 - js/net/src/ietf/aliases.ts | 7 +- js/net/src/ietf/cluster.test.ts | 2 +- js/net/src/ietf/connection.ts | 10 - js/net/src/ietf/epoch.test.ts | 198 -------- js/net/src/ietf/epoch.ts | 28 -- js/net/src/ietf/fetch.ts | 14 - js/net/src/ietf/index.ts | 1 - js/net/src/ietf/parameters.ts | 44 +- js/net/src/ietf/publish_namespace.ts | 24 +- js/net/src/ietf/publisher.test.ts | 215 +-------- js/net/src/ietf/publisher.ts | 83 +--- js/net/src/ietf/setup_options.test.ts | 1 - js/net/src/ietf/setup_options.ts | 2 - js/net/src/ietf/subscribe.ts | 12 - js/net/src/ietf/subscribe_namespace.ts | 7 +- js/net/src/ietf/subscriber.test.ts | 207 +------- js/net/src/ietf/subscriber.ts | 77 +-- js/net/src/ietf/track.ts | 11 +- rs/moq-net/src/fuzz.rs | 3 - rs/moq-net/src/ietf/epoch.rs | 97 ---- rs/moq-net/src/ietf/fetch.rs | 26 +- rs/moq-net/src/ietf/mod.rs | 3 - rs/moq-net/src/ietf/parameters.rs | 2 - rs/moq-net/src/ietf/peer.rs | 41 +- rs/moq-net/src/ietf/publish_namespace.rs | 18 +- rs/moq-net/src/ietf/publisher.rs | 447 ++---------------- rs/moq-net/src/ietf/publisher/tracks.rs | 4 +- rs/moq-net/src/ietf/session.rs | 20 +- rs/moq-net/src/ietf/subscribe.rs | 19 - rs/moq-net/src/ietf/subscribe_namespace.rs | 97 +--- rs/moq-net/src/ietf/subscriber.rs | 288 +---------- rs/moq-net/src/ietf/subscriber/tracks.rs | 4 - rs/moq-net/src/ietf/track.rs | 8 - rs/moq-net/src/setup.rs | 6 +- rs/moq-net/src/test_interop.rs | 2 - .../tests/integration/catalog_acquisition.rs | 7 +- rs/moq-net/tests/integration/extensions.rs | 71 --- rs/moq-net/tests/integration/multi_cdn.rs | 35 +- rs/moq-net/tests/integration/replacement.rs | 14 +- rs/moq-net/tests/integration/route_change.rs | 7 +- test/interop/clients/js-native/control.ts | 2 +- test/interop/clients/js-native/goaway.ts | 17 +- test/interop/clients/js-native/server.ts | 2 +- test/interop/clients/js/media.ts | 6 +- test/interop/clients/rust/goaway-client.rs | 10 +- test/interop/clients/rust/goaway.rs | 6 +- 59 files changed, 201 insertions(+), 2087 deletions(-) delete mode 100644 js/net/src/ietf/epoch.test.ts delete mode 100644 js/net/src/ietf/epoch.ts delete mode 100644 rs/moq-net/src/ietf/epoch.rs diff --git a/doc/bin/cli.md b/doc/bin/cli.md index b1d716afe07..3a4f9fd7938 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -387,8 +387,7 @@ rtsp` one per RTSP session, and `import ts --program all` one per program. A restarted process takes the name at once: viewers see the broadcast restart, and their next subscribe reaches the new run instead of waiting for its group numbers to catch up. Epochs cross a connection only on moq-lite 07, which is -opt-in, and on moq-transport, and order by the host's clock -there, so a host whose clock runs behind the old run's waits for it to close. +opt-in, and order by the host's clock there, so a host whose clock runs behind the old run's waits for it to close. Other versions carry no epoch, so a restart from another session is the newest route at an equal cost, or a better one. diff --git a/doc/bin/relay/cluster.md b/doc/bin/relay/cluster.md index 80a9fdcd264..02e1d69d22e 100644 --- a/doc/bin/relay/cluster.md +++ b/doc/bin/relay/cluster.md @@ -38,10 +38,9 @@ publishes under a new epoch, which replaces the old broadcast instead of resuming it; the RTMP, SRT, and WHIP ingests mint one per connection. Epochs order by creation time, so a reconnect to a different gateway assumes the two gateways' clocks roughly agree. Seamless failover needs a publisher that -announces an epoch and, on every link the route crosses, moq-lite 07 or -moq-transport with the [epoch extension](/draft/moq-epoch). A route -without an epoch, including every route on moq-lite 06 and older or a -moq-transport link without the extension, keeps its subscriptions until it goes or a track fails +announces an epoch and, on every link the route crosses, moq-lite 07. A route +without an epoch, including every route on moq-lite 06 and older or +moq-transport, keeps its subscriptions until it goes or a track fails upstream, and any other route winning it is announced as a restart. Viewers re-request on a restart, and a relay drops its copy of the old instance, including every path beneath a prefix claim when one of them moves to another diff --git a/doc/bin/relay/config.md b/doc/bin/relay/config.md index da3e71ef842..7552b28f7a9 100644 --- a/doc/bin/relay/config.md +++ b/doc/bin/relay/config.md @@ -42,7 +42,6 @@ allow.uid = [1001] # The relay always offers ietf, for moq-lite-07 relay links. auth = false # Decline MoQ Auth. solicit = false # Decline MoQ Solicit, so peers may announce unasked. -epoch = false # Decline MoQ Epoch, so routes over moq-transport carry no epoch. ``` `timeout` bounds the whole handshake, transport through MoQ SETUP and auth @@ -317,7 +316,6 @@ goaway.redirect = "same-host" # How far to trust a draining peer's redire goaway.handover = "10s" # Cap on how long the drained upstream keeps serving. extensions.auth = false # Decline MoQ Auth on outbound moq-transport sessions. extensions.solicit = false # Decline MoQ Solicit. -extensions.epoch = false # Decline MoQ Epoch. All default to on, as in [listen.extensions]. ``` A draining upstream may name a replacement URI. `same-host` follows it only diff --git a/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index ccdd5ed442c..a8a3a15d9b6 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -136,13 +136,8 @@ authorization and hidden names work exactly as without one. name instead of stalling viewers on the old sequence. A relay drops its copy of the old instance, so a new subscriber never sees its cached groups. -The epoch and the restart message travel on moq-lite 07, which is opt-in. -moq-transport carries the epoch when both sides offer the [epoch -extension](/draft/moq-epoch), on by default. A restart onto another epoch is -advertised before the old one is withdrawn, so the path is never absent, and one -that gains or loses an epoch is an end then a start. Older moq-lite versions -and a side that declines the extension carry no -epoch. Without an epoch, any other route winning is a restart, even a reconnect +The epoch and the restart message travel only on moq-lite 07, which is opt-in. +moq-transport and older moq-lite versions carry no epoch. Without an epoch, any other route winning is a restart, even a reconnect over the same path, since nothing says it serves the same bytes. A peer that ignores the end and start may keep cached objects of the old run under the same names, so an end and a start is not a cache flush. @@ -163,8 +158,7 @@ compared. A subscription uses the preferred link that has a route and moves to t next when that route goes; a publisher pushes the same broadcast to every CDN. The move resumes without a seam only between routes with the same epoch, which -needs moq-lite 07, or moq-transport with the epoch extension, -on both links. A CDN link that carries no epoch makes moving onto it, or back +needs moq-lite 07 on both links. A CDN link that carries no epoch makes moving onto it, or back off it, a restart, and the player requests the path again. Both links must also speak the same protocol and draft: a copy's track info records the moq-transport draft it crossed, and a copy whose track info differs is refused, diff --git a/doc/concept/standard.md b/doc/concept/standard.md index 670612e71b6..4c3819b1b71 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -47,14 +47,15 @@ ignores unknown parameters: [cluster](/draft/moq-cluster) routing hop lists, [auth](/draft/moq-auth) to tell each peer what it may publish and subscribe to, [active-count](/draft/moq-active-count) to count the `NAMESPACE` messages before a `SUBSCRIBE_NAMESPACE` is synced, -[epoch](/draft/moq-epoch) to carry [publisher epochs](/concept/moq-lite#publisher-epochs) -without changing a path, and +and [probe](/draft/moq-probe) for bandwidth estimation. Rust sessions request PROBE only while an owned `recv_bandwidth()` consumer is held. Read estimates through its `peek()` or `changed()` methods; session statistics do not request PROBE. -Both libraries offer solicit, auth, and epoch unless a side's +Both libraries offer solicit and auth unless a side's `extensions` setting declines one, which connects it as a peer that does not speak that extension. The pooled JavaScript `Connection` has no such setting yet. +moq-transport carries no [publisher epochs](/concept/moq-lite#publisher-epochs); +the [epoch draft](/draft/moq-epoch) remains an unimplemented proposal. [ietf](/draft/moq-ietf) goes the other way: it extends moq-lite-07 to carry this object state between relays. moq-lite-07 is still a work in progress (`moq-lite-07-wip`), negotiated only when both sides enable it, so a peer that diff --git a/doc/concept/stats.md b/doc/concept/stats.md index bd1c35b8373..84e292433f7 100644 --- a/doc/concept/stats.md +++ b/doc/concept/stats.md @@ -173,9 +173,8 @@ The broadcast stays announced for the producer's life. Each announcement carries a fresh [publisher epoch](/concept/moq-lite#publisher-epochs) on its route, so a restarted node is a new broadcast at the same path: it replaces the old one, and no relay serves it groups cached under the old epoch. A reader -treats each epoch as its own set of counters. The epoch rides moq-lite 07 -announcements, and moq-transport with the -[epoch extension](/draft/moq-epoch); over anything else a reader sees the same +treats each epoch as its own set of counters. The epoch rides only moq-lite 07 +announcements; over moq-transport and older moq-lite versions a reader sees the same change as an end and a start at the path. An aggregating reader pins each node's subscription to its epoch, and when one publisher is reached through both kinds of link (with and without an epoch), it diff --git a/doc/setup/redundancy.md b/doc/setup/redundancy.md index f4e1840480e..4f6495e37f3 100644 --- a/doc/setup/redundancy.md +++ b/doc/setup/redundancy.md @@ -29,9 +29,7 @@ promise. both. Give both publishers permission to announce the same full path. 2. Publish the same broadcast name under the same auth path. Each publisher keeps its own epoch; `moq` creates one automatically. -3. Use epoch-capable connections on every hop: moq-lite 07, which is opt-in, - or moq-transport with the [epoch extension](/draft/moq-epoch) - enabled. Keep the publisher hosts' clocks synchronized, since epochs order +3. Use moq-lite 07, which is opt-in, on every hop to carry epochs. Keep the publisher hosts' clocks synchronized, since epochs order by their UUIDv7 creation time. For example, two HLS importers can publish `event.hang` through different diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index a8f81385c52..0803c70701a 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -68,9 +68,8 @@ These land with the next breaking release. publishers together. - **Announce restarts.** moq-lite 07 adds `ANNOUNCE_RESTART` (0x3): another publisher instance now serves the prefix. lite-06's `ANNOUNCE_RESTART` is - named `ANNOUNCE_UPDATE`, as it always meant. moq-transport with the epoch - extension advertise another epoch before withdrawing the old - one. Elsewhere, a restart is still an end then a start. + named `ANNOUNCE_UPDATE`, as it always meant. moq-transport carries no epoch; + a restart is still an end then a start. - **Publisher epochs ride the route** (#4942). moq-lite 07 carries the epoch after the path in `ANNOUNCE_START`, `TRACK`, `SUBSCRIBE`, and `FETCH`. Routes without an epoch no longer resume across routes, so default lite-06 diff --git a/js/net/api/index.api.md b/js/net/api/index.api.md index d4986d25a6f..f9b9d65a984 100644 --- a/js/net/api/index.api.md +++ b/js/net/api/index.api.md @@ -165,7 +165,6 @@ export namespace Connection { } export interface Extensions { auth?: boolean; - epoch?: boolean; solicit?: boolean; } export interface Goaway { diff --git a/js/net/src/connection/extensions.test.ts b/js/net/src/connection/extensions.test.ts index 24ac0d1c476..8679a511e16 100644 --- a/js/net/src/connection/extensions.test.ts +++ b/js/net/src/connection/extensions.test.ts @@ -49,21 +49,6 @@ test("a declined extension stays out of SETUP", async () => { expect(none.dialed.solicit).toBe(true); }); -test("MoQ Epoch is negotiated only when both sides offer it", async () => { - const all = await handshake({}, {}); - expect(all.dialed.epoch).toBe(true); - expect(all.accepted.epoch).toBe(true); - - for (const [client, server] of [ - [{ epoch: false }, {}], - [{}, { epoch: false }], - ]) { - const declined = await handshake(client, server); - expect(declined.dialed.epoch).toBe(false); - expect(declined.accepted.epoch).toBe(false); - } -}); - test("an AUTH to a side that declined it closes the session", async () => { // Control: offered by both, the connection credential is granted. const offering = await acceptWith({}); diff --git a/js/net/src/connection/extensions.ts b/js/net/src/connection/extensions.ts index 142887d0d26..f144ac09b47 100644 --- a/js/net/src/connection/extensions.ts +++ b/js/net/src/connection/extensions.ts @@ -10,8 +10,6 @@ export interface Extensions { auth?: boolean; /** The MoQ Solicit extension: the peer answers our SUBSCRIBE_NAMESPACE rather than announcing unasked. */ solicit?: boolean; - /** The MoQ Epoch extension: announcements and requests carry the publisher's epoch, as moq-lite does (draft-18+). */ - epoch?: boolean; } /** Every extension resolved to whether it is offered. */ @@ -22,7 +20,6 @@ export function offered(extensions?: Extensions): Offered { return { auth: extensions?.auth ?? true, solicit: extensions?.solicit ?? true, - epoch: extensions?.epoch ?? true, }; } @@ -30,5 +27,4 @@ export function offered(extensions?: Extensions): Offered { export function intoSetup(params: Ietf.SetupOptions, extensions: Offered) { if (extensions.solicit) Ietf.solicitIntoSetup(params); if (extensions.auth) Ietf.Auth.intoSetup(params); - if (extensions.epoch) Ietf.Epoch.intoSetup(params); } diff --git a/js/net/src/connection/handshake.ts b/js/net/src/connection/handshake.ts index e7b9171a303..e7c2332542a 100644 --- a/js/net/src/connection/handshake.ts +++ b/js/net/src/connection/handshake.ts @@ -19,9 +19,9 @@ export const DEFAULT_TIMEOUT = Milli(30_000); * Returns the control stream, the uni streams that arrived before it (see * {@link receiveSetup}), plus what the peer's SETUP declared: whether it requires * solicitation, which decides whether we announce namespaces unprompted (see the MoQ Solicit - * extension), its Hop ID (see the MoQ Cluster extension), and whether MoQ Auth and MoQ Epoch - * are negotiated, plus the implementation it advertised. We declare our Hop ID on every - * session, and Solicit, Auth, and Epoch unless `extensions` declines them: we send SUBSCRIBE_NAMESPACE for each prefix we want, so an unsolicited advertisement + * extension), its Hop ID (see the MoQ Cluster extension), and whether MoQ Auth + * is negotiated, plus the implementation it advertised. We declare our Hop ID on every + * session, and Solicit and Auth unless `extensions` declines them: we send SUBSCRIBE_NAMESPACE for each prefix we want, so an unsolicited advertisement * can tell us nothing we won't have asked for, and a peer that knows our Hop ID can withhold * the advertisements that already flowed through us. */ @@ -39,7 +39,6 @@ export async function exchangeSetup( activeCount: boolean; cluster: Ietf.Cluster.Hops; auth: boolean; - epoch: boolean; peerImplementation: string | undefined; }> { const params = new Ietf.SetupOptions(); @@ -82,7 +81,6 @@ export async function exchangeSetup( cluster: { self, peer: received.cluster }, // Negotiated only when both sides offer it. auth: received.auth && extensions.auth, - epoch: received.epoch && extensions.epoch, peerImplementation: received.implementation, }; } @@ -114,7 +112,6 @@ async function receiveSetup( activeCount: boolean; cluster: Hop | undefined; auth: boolean; - epoch: boolean; implementation: string | undefined; }> { const uniReader = transport.incomingUnidirectionalStreams.getReader() as ReadableStreamDefaultReader< @@ -171,7 +168,6 @@ async function receiveSetup( activeCount: Ietf.activeCountFromSetup(setup.parameters), cluster: Ietf.Cluster.fromSetup(setup.parameters), auth: Ietf.Auth.fromSetup(setup.parameters) === true, - epoch: Ietf.Epoch.fromSetup(setup.parameters), implementation: Ietf.implementationFromSetup(setup.parameters), }; } diff --git a/js/net/src/ietf/aliases.test.ts b/js/net/src/ietf/aliases.test.ts index 55f221a4637..ec0eebad6a5 100644 --- a/js/net/src/ietf/aliases.test.ts +++ b/js/net/src/ietf/aliases.test.ts @@ -49,14 +49,6 @@ test("sharing an alias across subscriptions to one track is not fatal", () => { expect(() => aliases.set(7n, {}, { broadcast: "cam", name: "video" })).toThrow(SharedTrackAlias); }); -// Another publisher instance is other content under the same name (MoQ Epoch). -test("one alias for two epochs of a track is a collision", () => { - const aliases = new TrackAliases(); - aliases.set(7n, {}, { broadcast: "cam", name: "video", epoch: "a" }); - - expect(() => aliases.set(7n, {}, { broadcast: "cam", name: "video", epoch: "b" })).toThrow(DuplicateTrackAlias); -}); - // Metadata keyed by an alias (the track's timescale) must only be torn down by whoever // still owns the binding, so retirement reports ownership rather than returning void. test("retire reports whether the caller still owned the alias", () => { diff --git a/js/net/src/ietf/aliases.ts b/js/net/src/ietf/aliases.ts index 2301771d8ee..4f87c2a51dd 100644 --- a/js/net/src/ietf/aliases.ts +++ b/js/net/src/ietf/aliases.ts @@ -22,14 +22,13 @@ type Resolver = PromiseWithResolvers["resolve"]; * * Kept as two components rather than one joined string: a track name may contain the same * separator a broadcast path uses, so `a` + `b/c` and `a/b` + `c` would otherwise compare - * equal and turn a genuine collision into apparent sharing. The publisher instance a - * subscription names (MoQ Epoch) is part of it: another instance is other content. + * equal and turn a genuine collision into apparent sharing. * @internal */ -export type TrackIdentity = { broadcast: string; name: string; epoch?: string }; +export type TrackIdentity = { broadcast: string; name: string }; function sameTrack(a: TrackIdentity, b: TrackIdentity): boolean { - return a.broadcast === b.broadcast && a.name === b.name && a.epoch === b.epoch; + return a.broadcast === b.broadcast && a.name === b.name; } /** diff --git a/js/net/src/ietf/cluster.test.ts b/js/net/src/ietf/cluster.test.ts index 355f7bfb99a..82159734ac9 100644 --- a/js/net/src/ietf/cluster.test.ts +++ b/js/net/src/ietf/cluster.test.ts @@ -16,7 +16,7 @@ import { type IetfVersion, Version } from "./version.ts"; const VERSION = Version.DRAFT_18; /** A session that negotiated MoQ Cluster alone. */ -const CLUSTER = { cluster: true, epoch: false }; +const CLUSTER = { cluster: true }; function origin(id: bigint): Hop { return HopSchema.parse(id); diff --git a/js/net/src/ietf/connection.ts b/js/net/src/ietf/connection.ts index 98bf82d7a4b..6abcc90d6fc 100644 --- a/js/net/src/ietf/connection.ts +++ b/js/net/src/ietf/connection.ts @@ -92,9 +92,6 @@ export class Connection implements Established { // The Hop IDs this session declared; see {@link Cluster}. #cluster?: Cluster.Hops; - // Whether both SETUPs offered MoQ Epoch, so advertisements and requests may carry EPOCH. - #epoch: boolean; - // The peer's GOAWAY, read off its SETUP stream. #goaway = new Once(); @@ -130,7 +127,6 @@ export class Connection implements Established { cluster, auth = false, handle, - epoch = false, early = [], extensions, peerImplementation, @@ -163,8 +159,6 @@ export class Connection implements Established { auth?: boolean; /** The auth handle to build the session on, or undefined for one of its own. */ handle?: Auth.Handle; - /** Whether MoQ Epoch is negotiated: offered by both SETUPs. */ - epoch?: boolean; /** Uni streams that arrived before the peer's SETUP, type unread. */ early?: Reader[]; /** What our own SETUP offered; every extension when omitted. */ @@ -214,7 +208,6 @@ export class Connection implements Established { hidden, activeCount, cluster, - epoch, grant: this.#auth.scope, auth: this.#auth, ready: this.#auth.setupAnswered(), @@ -222,13 +215,11 @@ export class Connection implements Established { this.#solicit = solicit; this.#declaredSolicit = extensions?.solicit ?? true; this.#cluster = cluster; - this.#epoch = epoch; this.#subscriber = new Subscriber({ maxAge, session: this.#session, quic, cluster, - epoch, hidden, activeCount, goaway: this.#goaway, @@ -391,7 +382,6 @@ export class Connection implements Established { case BigInt(PublishNamespace.id): { const decoded = PublishNamespace.decode(stream.reader, this.#session.version, { cluster: Cluster.negotiated(this.#cluster), - epoch: this.#epoch, }); const msg = await this.#request(stream, "publish_namespace", decoded); if (!msg) break; diff --git a/js/net/src/ietf/epoch.test.ts b/js/net/src/ietf/epoch.test.ts deleted file mode 100644 index 82e2523ed44..00000000000 --- a/js/net/src/ietf/epoch.test.ts +++ /dev/null @@ -1,198 +0,0 @@ -import { expect, test } from "bun:test"; -import * as Epoch from "../epoch.ts"; -import { ProtocolViolation } from "../error.ts"; -import { HopSchema } from "../hop.ts"; -import * as Path from "../path.ts"; -import { Reader, Writer } from "../stream.ts"; -import type * as Cluster from "./cluster.ts"; -import * as EpochExt from "./epoch.ts"; -import { Fetch } from "./fetch.ts"; -import * as Message from "./message.ts"; -import { Parameters } from "./parameters.ts"; -import { type AdvertParams, PublishNamespace } from "./publish_namespace.ts"; -import { SetupOptions } from "./setup_options.ts"; -import { Subscribe } from "./subscribe.ts"; -import { SubscribeNamespaceEntry } from "./subscribe_namespace.ts"; -import { TrackStatusRequest } from "./track.ts"; -import { type IetfVersion, Version } from "./version.ts"; - -const VERSION = Version.DRAFT_18; -const EPOCH_PARAM = 0x40b69n; -const EPOCH = Epoch.mint(); - -const ALL = [Version.DRAFT_18, Version.DRAFT_22] as const; - -async function encode( - message: { encode(w: Writer, v: IetfVersion): Promise }, - version: IetfVersion = VERSION, -): Promise { - const chunks: Uint8Array[] = []; - const writer = new Writer( - new WritableStream({ - write(chunk) { - chunks.push(new Uint8Array(chunk)); - }, - }), - version, - ); - await message.encode(writer, version); - writer.close(); - await writer.closed; - - const out = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.byteLength, 0)); - let offset = 0; - for (const chunk of chunks) { - out.set(chunk, offset); - offset += chunk.byteLength; - } - return out; -} - -function reader(bytes: Uint8Array, version: IetfVersion = VERSION): Reader { - return new Reader(undefined, bytes, version); -} - -/** A parameter block carrying `value` under the EPOCH key, valid or not. */ -function epochParam(value: Uint8Array): Parameters { - const params = new Parameters(); - params.bytes.set(EPOCH_PARAM, value); - return params; -} - -test("Epoch: SETUP declares it", async () => { - for (const version of ALL) { - const params = new SetupOptions(); - expect(EpochExt.fromSetup(params)).toBe(false); - EpochExt.intoSetup(params); - const decoded = await SetupOptions.decode(reader(await encode(params, version), version)); - expect(EpochExt.fromSetup(decoded)).toBe(true); - } -}); - -test("Epoch: the parameter is the UUID's 16 bytes, length-prefixed", async () => { - const params = new Parameters(); - params.epoch = EPOCH; - expect(Array.from(await encode(params))).toEqual([ - 0x01, // parameter count - 0xc4, - 0x0b, - 0x69, // EPOCH (0x40b69), delta encoded from 0 - 0x10, // value length - ...Epoch.toBytes(EPOCH), - ]); - - const decoded = await Parameters.decode(reader(await encode(params)), VERSION, "subscribe"); - expect(decoded.epoch).toBe(EPOCH); -}); - -test("Epoch: anything but a UUIDv7's 16 bytes is a protocol violation", async () => { - const v4 = Epoch.toBytes(EPOCH); - v4[6] = (v4[6] & 0x0f) | 0x40; - - for (const value of [new Uint8Array(), Epoch.toBytes(EPOCH).slice(0, 15), v4]) { - const encoded = await encode(epochParam(value)); - await expect(Parameters.decode(reader(encoded), VERSION, "subscribe")).rejects.toThrow(ProtocolViolation); - } -}); - -test("Epoch: a REQUEST_UPDATE never carries one", async () => { - const encoded = await encode(epochParam(Epoch.toBytes(EPOCH))); - for (const message of ["request-update", "subscribe-update"] as const) { - await expect(Parameters.decode(reader(encoded), VERSION, message)).rejects.toThrow(ProtocolViolation); - } -}); - -test("Epoch: SUBSCRIBE and TRACK_STATUS carry it", async () => { - const trackNamespace = Path.from("alice"); - for (const version of ALL) { - const expected = EPOCH; - - const subscribe = new Subscribe({ - requestId: 0n, - trackNamespace, - trackName: "video", - subscriberPriority: 0, - epoch: EPOCH, - }); - expect((await Subscribe.decode(reader(await encode(subscribe, version), version), version)).epoch).toBe( - expected, - ); - - const status = new TrackStatusRequest({ requestId: 0n, trackNamespace, trackName: "video", epoch: EPOCH }); - expect((await TrackStatusRequest.decode(reader(await encode(status, version), version), version)).epoch).toBe( - expected, - ); - } -}); - -test("Epoch: a joining FETCH that names one is malformed", async () => { - const joining = (params: Parameters) => ({ - encode: (w: Writer, version: IetfVersion) => - Message.encode(w, async (mw) => { - await mw.u62(0n); // request id - await mw.u53(0x2); // relative joining - await mw.u62(0n); // joining request id - await mw.u62(0n); // group offset - await params.encode(mw, version); - }), - }); - - // Control: the same FETCH without it decodes. - expect((await Fetch.decode(reader(await encode(joining(new Parameters()))), VERSION)).epoch).toBeUndefined(); - - const named = new Parameters(); - named.epoch = EPOCH; - await expect(Fetch.decode(reader(await encode(joining(named))), VERSION)).rejects.toThrow( - "EPOCH is not allowed on a joining FETCH", - ); -}); - -test("Epoch: PUBLISH_NAMESPACE carries it only once negotiated", async () => { - const encoded = await encode( - new PublishNamespace({ requestId: 1n, trackNamespace: Path.from("alice"), params: { epoch: EPOCH } }), - ); - - const decoded = await PublishNamespace.decode(reader(encoded), VERSION, { cluster: false, epoch: true }); - expect(decoded.params).toEqual({ cluster: undefined, epoch: EPOCH }); - - // A session that did not negotiate it was never sent one. - await expect(PublishNamespace.decode(reader(encoded), VERSION)).rejects.toThrow(ProtocolViolation); - - // An advertisement may lack one: the route had no epoch to carry. - const bare = await encode(new PublishNamespace({ requestId: 1n, trackNamespace: Path.from("alice") })); - expect( - (await PublishNamespace.decode(reader(bare), VERSION, { cluster: false, epoch: true })).params.epoch, - ).toBeUndefined(); -}); - -test.each([ - ["neither", false, false], - ["cluster only", true, false], - ["epoch only", false, true], - ["both", true, true], -] as const)("Epoch: NAMESPACE framing with %s negotiated", async (_name, cluster, epoch) => { - const negotiated = { cluster, epoch }; - const advert: Cluster.Advert = { hops: [HopSchema.parse(7n)], cost: 0n }; - const params: AdvertParams = { cluster: cluster ? advert : undefined, epoch: epoch ? EPOCH : undefined }; - const extended = cluster || epoch; - - const entry = new SubscribeNamespaceEntry({ suffix: Path.from("alice"), params: extended ? params : undefined }); - const encoded = await encode(entry); - const decoded = await SubscribeNamespaceEntry.decode(reader(encoded), VERSION, negotiated); - expect(decoded.suffix).toBe(Path.from("alice")); - expect(decoded.params).toEqual(extended ? params : undefined); - - // The block is present iff either extension is, so the base form is strictly shorter. - const base = await encode(new SubscribeNamespaceEntry({ suffix: Path.from("alice") })); - expect(base.length < encoded.length).toBe(extended); -}); - -test("Epoch: a NAMESPACE carrying one without MoQ Epoch is a protocol violation", async () => { - const advert: Cluster.Advert = { hops: [HopSchema.parse(7n)], cost: 0n }; - const encoded = await encode( - new SubscribeNamespaceEntry({ suffix: Path.from("alice"), params: { cluster: advert, epoch: EPOCH } }), - ); - await expect( - SubscribeNamespaceEntry.decode(reader(encoded), VERSION, { cluster: true, epoch: false }), - ).rejects.toThrow(ProtocolViolation); -}); diff --git a/js/net/src/ietf/epoch.ts b/js/net/src/ietf/epoch.ts deleted file mode 100644 index 022dc3f0793..00000000000 --- a/js/net/src/ietf/epoch.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { SetupOption, type SetupOptions } from "./setup_options.ts"; - -/** - * The MoQ Epoch extension (draft-lcurley-moq-epoch-00). - * - * moq-transport names content by namespace alone, so a publisher that restarts at the same - * namespace looks like the same broadcast to every relay. This extension carries the - * publisher instance, the epoch moq-lite 07 puts on its routes and requests, as an EPOCH - * parameter: on each advertisement (PUBLISH_NAMESPACE and NAMESPACE), and on each request - * that resolves one (SUBSCRIBE, FETCH, and TRACK_STATUS). A namespace and an EPOCH name one - * broadcast; a request carrying one is refused rather than served by another instance. - * - * Negotiated on draft-18+ only, where SETUP is a Key-Value-Pair block, and only when both - * endpoints declare the option. - * - * @module - * @internal - */ - -/** Whether the peer declared the option. @internal */ -export function fromSetup(params: SetupOptions): boolean { - return params.getVarint(SetupOption.Epoch) !== undefined; -} - -/** Declare that we understand the EPOCH parameter. @internal */ -export function intoSetup(params: SetupOptions) { - params.setVarint(SetupOption.Epoch, 1n); -} diff --git a/js/net/src/ietf/fetch.ts b/js/net/src/ietf/fetch.ts index fe88878009d..9a074f28fd8 100644 --- a/js/net/src/ietf/fetch.ts +++ b/js/net/src/ietf/fetch.ts @@ -1,5 +1,4 @@ import type { Milli } from "@moq/clock"; -import type * as Epoch from "../epoch.ts"; import type * as Path from "../path.ts"; import { type Reader, Writer } from "../stream.ts"; import type { Order } from "../track.ts"; @@ -102,9 +101,6 @@ export class Fetch { /** Whether the requester wants Track Properties in FETCH_OK (INCLUDE_PROPERTIES, draft-22). */ propertiesWanted: boolean; - /** The publisher instance the requester expects (EPOCH, MoQ Epoch), never on a joining fetch. */ - epoch?: Epoch.Valid; - constructor({ requestId, type, @@ -113,7 +109,6 @@ export class Fetch { rangeFilters = false, fillTimeout, propertiesWanted = true, - epoch, }: { requestId: bigint; type: FetchType; @@ -122,7 +117,6 @@ export class Fetch { rangeFilters?: boolean; fillTimeout?: Milli; propertiesWanted?: boolean; - epoch?: Epoch.Valid; }) { this.requestId = requestId; this.type = type; @@ -131,7 +125,6 @@ export class Fetch { this.rangeFilters = rangeFilters; this.fillTimeout = fillTimeout; this.propertiesWanted = propertiesWanted; - this.epoch = epoch; } async #encode(w: Writer, version: IetfVersion): Promise { @@ -141,7 +134,6 @@ export class Fetch { params.subscriberPriority = this.subscriberPriority; if (this.groupOrder !== undefined) params.groupOrder = this.groupOrder === "ascending" ? GroupOrder.Ascending : GroupOrder.Descending; - params.epoch = this.epoch; params.fillTimeout = this.fillTimeout; const type = this.type; @@ -224,11 +216,6 @@ export class Fetch { if (params.trackPropertyFilter) { throw new Error("TRACK_PROPERTY_FILTER is not allowed on FETCH"); } - // A joining FETCH is served by its subscription's instance, so naming one is malformed. - const epoch = params.epoch; - if (epoch !== undefined && (type.kind === "relativeJoining" || type.kind === "absoluteJoining")) { - throw new Error("EPOCH is not allowed on a joining FETCH"); - } // An absent LOCATION_FILTER fetches the whole track. if (type.kind === "filtered") type.filter = params.subscriptionFilter ?? { kind: "unfiltered" }; @@ -243,7 +230,6 @@ export class Fetch { fillTimeout: params.fillTimeout, // Defaults to 1, so an absent parameter means the requester wants them. propertiesWanted: params.includeProperties ?? true, - epoch, }); } } diff --git a/js/net/src/ietf/index.ts b/js/net/src/ietf/index.ts index 2d4208134ff..975d8ccf413 100644 --- a/js/net/src/ietf/index.ts +++ b/js/net/src/ietf/index.ts @@ -3,7 +3,6 @@ export * from "./active_count.ts"; export * as Auth from "./auth_setup.ts"; export * as Cluster from "./cluster.ts"; -export * as Epoch from "./epoch.ts"; export * from "./hidden.ts"; export * from "./max_age.ts"; export * from "./setup.ts"; diff --git a/js/net/src/ietf/parameters.ts b/js/net/src/ietf/parameters.ts index 1e08070f457..41a54318081 100644 --- a/js/net/src/ietf/parameters.ts +++ b/js/net/src/ietf/parameters.ts @@ -1,6 +1,5 @@ import { Milli } from "@moq/clock"; -import * as Epoch from "../epoch.ts"; -import { ProtocolViolation, reason } from "../error.ts"; +import { ProtocolViolation } from "../error.ts"; import type * as Path from "../path.ts"; import type { Reader, Writer } from "../stream.ts"; import * as Filter from "./filter.ts"; @@ -44,8 +43,6 @@ const MSG_PARAM_FILL_PARAMETERS = 0x23n; const MSG_PARAM_HOP_PATH = 0x40b57n; /// ACTIVE_COUNT, from the MoQ Active Count extension. const MSG_PARAM_ACTIVE_COUNT = 0x40b66n; -/// EPOCH, from the MoQ Epoch extension: a UUIDv7's 16 bytes. See `epoch.ts`. -const MSG_PARAM_EPOCH = 0x40b69n; /** Which control message the parameter block belongs to. Omitted keeps the unfiltered decode. */ type ControlMessage = @@ -82,7 +79,6 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool const fill = id === MSG_PARAM_FILL_PARAMETERS && from22; const include = id === MSG_PARAM_INCLUDE_PROPERTIES && from22; const newGroup = id === MSG_PARAM_NEW_GROUP_REQUEST; - const epoch = id === MSG_PARAM_EPOCH; switch (message) { case "subscribe-tracks": @@ -123,8 +119,7 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool fill || range || newGroup || - include || - epoch + include ); case "subscribe-ok": return expires || largest; @@ -160,24 +155,15 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool (order && from22) ); case "publish-namespace": - return auth || id === MSG_PARAM_HOP_PATH || id === MSG_PARAM_ROUTE_COST || epoch; + return auth || id === MSG_PARAM_HOP_PATH || id === MSG_PARAM_ROUTE_COST; case "fetch": - return ( - auth || - id === MSG_PARAM_FILL_TIMEOUT || - priority || - (filter && from22) || - order || - range || - include || - epoch - ); + return auth || id === MSG_PARAM_FILL_TIMEOUT || priority || (filter && from22) || order || range || include; case "fetch-ok": return false; case "request-ok": return expires || largest || id === MSG_PARAM_ACTIVE_COUNT; case "namespace": - return id === MSG_PARAM_HOP_PATH || id === MSG_PARAM_ROUTE_COST || epoch; + return id === MSG_PARAM_HOP_PATH || id === MSG_PARAM_ROUTE_COST; } } @@ -227,7 +213,6 @@ function getMessageParamKind(id: bigint): MessageParamKind { case MSG_PARAM_AUTHORIZATION_TOKEN: case MSG_PARAM_FILL_PARAMETERS: case MSG_PARAM_HOP_PATH: - case MSG_PARAM_EPOCH: return "bytes"; default: if (MSG_PARAM_REPEATABLE.includes(id)) return "bytes"; @@ -448,17 +433,6 @@ export class Parameters { this.vars.set(MSG_PARAM_ROUTE_COST, v); } - /** EPOCH (MoQ Epoch): the publisher instance an advertisement or request names. */ - get epoch(): Epoch.Valid | undefined { - const value = this.bytes.get(MSG_PARAM_EPOCH); - return value === undefined ? undefined : Epoch.fromBytes(value); - } - - set epoch(v: Epoch.Valid | undefined) { - if (v === undefined) this.bytes.delete(MSG_PARAM_EPOCH); - else this.bytes.set(MSG_PARAM_EPOCH, Epoch.toBytes(v)); - } - /** Encode the block. */ async encode(w: Writer, version: IetfVersion) { const filter = this.#filter; @@ -604,14 +578,6 @@ export class Parameters { case "bytes": { const size = await r.u53(); const value = await r.read(size); - // Anything but a UUIDv7's 16 bytes is malformed, so refuse it here rather than on first read. - if (id === MSG_PARAM_EPOCH) { - try { - Epoch.fromBytes(value); - } catch (err) { - throw new ProtocolViolation(`malformed EPOCH: ${reason(err)}`, { cause: err }); - } - } params.bytes.set(id, value); break; } diff --git a/js/net/src/ietf/publish_namespace.ts b/js/net/src/ietf/publish_namespace.ts index 8702598e82b..bdd5df85a18 100644 --- a/js/net/src/ietf/publish_namespace.ts +++ b/js/net/src/ietf/publish_namespace.ts @@ -1,4 +1,3 @@ -import type * as Epoch from "../epoch.ts"; import { ProtocolViolation, reason, SessionError, StreamError } from "../error.ts"; import type * as Path from "../path.ts"; import type { Reader, Writer } from "../stream.ts"; @@ -16,31 +15,26 @@ import type { IetfVersion } from "./version.ts"; export interface Negotiated { /** MoQ Cluster: every advertisement carries HOP_PATH, and may carry ROUTE_COST. */ cluster: boolean; - /** MoQ Epoch: an advertisement may carry EPOCH. */ - epoch: boolean; } -/** A session that negotiated neither advertisement extension. */ -export const NEGOTIATED_NONE: Negotiated = { cluster: false, epoch: false }; +/** A session without the advertisement extension. */ +export const NEGOTIATED_NONE: Negotiated = { cluster: false }; /** Whether NAMESPACE takes the extended form, with a Parameters field. */ export function extended(negotiated: Negotiated): boolean { - return negotiated.cluster || negotiated.epoch; + return negotiated.cluster; } /** The extension parameters one advertisement carries. */ export interface AdvertParams { /** The MoQ Cluster parameters (see {@link Cluster}), set exactly on a session that negotiated it. */ cluster?: Cluster.Advert; - /** The MoQ Epoch parameter: the publisher instance the route serves, if it names one. */ - epoch?: Epoch.Valid; } /** Write an advertisement's extension parameters into a fresh block. */ export function advertIntoParams(advert: AdvertParams): Parameters { const params = new Parameters(); if (advert.cluster) Cluster.intoParams(advert.cluster, params); - params.epoch = advert.epoch; return params; } @@ -48,9 +42,8 @@ export function advertIntoParams(advert: AdvertParams): Parameters { * Read an advertisement's Parameters field, checked against the list of the message that * carries it (PUBLISH_NAMESPACE also allows a token), expecting what the session negotiated. * - * Every way this fails is one to close the session over: a block that does not parse, a - * negotiated cluster session that omits HOP_PATH, or an EPOCH on a session that did not - * negotiate MoQ Epoch. A request token's own refusal keeps its type. + * A malformed block or a negotiated cluster session omitting HOP_PATH closes the + * session. A request token's own refusal keeps its type. */ export async function decodeAdvert( r: Reader, @@ -67,10 +60,7 @@ export async function decodeAdvert( throw new ProtocolViolation(reason(err), { cause: err }); } - const epoch = params.epoch; - // An unknown parameter to a session that never offered the extension. - if (epoch !== undefined && !negotiated.epoch) throw new ProtocolViolation("EPOCH without MoQ Epoch"); - return { cluster: negotiated.cluster ? Cluster.fromParams(params) : undefined, epoch }; + return { cluster: negotiated.cluster ? Cluster.fromParams(params) : undefined }; } export class PublishNamespace { @@ -191,8 +181,6 @@ export class PublishNamespaceUpdate { static async #decode(r: Reader, version: IetfVersion): Promise { const requestId = await r.u62(); const params = await Parameters.decode(r, version, "publish-namespace"); - // An epoch is fixed for the life of an advertisement, so no update carries one. - if (params.epoch !== undefined) throw new ProtocolViolation("EPOCH on a PUBLISH_NAMESPACE update"); return new PublishNamespaceUpdate({ requestId, update: Cluster.updateFromParams(params) }); } } diff --git a/js/net/src/ietf/publisher.test.ts b/js/net/src/ietf/publisher.test.ts index 631b0e12262..e17863b0d49 100644 --- a/js/net/src/ietf/publisher.test.ts +++ b/js/net/src/ietf/publisher.test.ts @@ -43,7 +43,7 @@ function publish(origin: OriginProducer, path: Path.Valid) { const VERSION = Version.DRAFT_18; /** A session that negotiated MoQ Cluster alone. */ -const CLUSTER = { cluster: true, epoch: false }; +const CLUSTER = { cluster: true }; /** How long to wait for a stream before calling it absent, which is how a regression reports. */ const STREAM_WAIT = 1000; @@ -163,7 +163,6 @@ function publisher( grant, activeCount, auth, - epoch, }: { requiresSolicitation?: boolean; session?: Session; @@ -171,7 +170,6 @@ function publisher( grant?: Signal; activeCount?: boolean; auth?: Tokens; - epoch?: boolean; } = {}, ): { pub: Publisher; origin: OriginProducer } { const origin = new OriginProducer(); @@ -186,7 +184,6 @@ function publisher( grant, activeCount, auth, - epoch, }), origin, }; @@ -1435,214 +1432,6 @@ test("an advertisement carries our hop id once the peer declared one", async () } }); -/** A session that negotiated MoQ Epoch alone. */ -const EPOCH = { cluster: false, epoch: true }; - -/** - * An advertisement names the publisher instance once the peer declared MoQ Epoch. A peer - * that did not has not read the parameter, so sending it would be a protocol violation. - */ -test("an advertisement carries its epoch only once negotiated", async () => { - for (const negotiated of [true, false]) { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const { pub, origin } = publisher(pair.server, { epoch: negotiated }); - const epoch = Epoch.mint(); - origin.createBroadcast(Path.from("mine")).announce({ epoch }); - void pub.runPublishNamespaces(); - - const stream = await nextStream(pair.client); - if (!stream) throw new Error("no PUBLISH_NAMESPACE for the broadcast"); - expect(await stream.reader.u53()).toBe(PublishNamespace.id); - const msg = await PublishNamespace.decode(stream.reader, VERSION, EPOCH); - expect(msg.params.epoch).toBe(negotiated ? epoch : undefined); - await acceptPublishNamespace(stream); - - origin.close(); - } -}); - -/** - * A new instance at a path is other content, but the namespace never goes absent: the new - * epoch is advertised first, and the old one withdrawn only once the peer accepted it, - * since the two streams are unordered. A peer without MoQ Epoch cannot tell the two apart, - * so it still sees the old one withdrawn first. - */ -test.each([true, false])( - "an epoch change advertises the new epoch before withdrawing the old (negotiated: %p)", - async (negotiated) => { - using clock = manual(); - const pair = createMockTransportPair(ALPN.DRAFT_18); - const { pub, origin } = publisher(pair.server, { epoch: negotiated }); - const streams = accepted(pair.client); - try { - const broadcast = origin.createBroadcast(Path.from("mine")); - const first = Epoch.mint(); - broadcast.announce({ epoch: first }); - void pub.runPublishNamespaces(); - - const old = await take(clock, streams); - expect(await old.reader.u53()).toBe(PublishNamespace.id); - expect((await PublishNamespace.decode(old.reader, VERSION, EPOCH)).params.epoch).toBe( - negotiated ? first : undefined, - ); - await acceptPublishNamespace(old); - - const second = Epoch.mint(); - broadcast.announce({ ...broadcast.route, epoch: second }); - const withdrawn = watch(old.reader.done()); - - const next = await take(clock, streams); - expect(await next.reader.u53()).toBe(PublishNamespace.id); - expect((await PublishNamespace.decode(next.reader, VERSION, EPOCH)).params.epoch).toBe( - negotiated ? second : undefined, - ); - await clock.advance(Nano.zero); - expect(withdrawn.state).toBe(negotiated ? "pending" : "rejected"); - - await acceptPublishNamespace(next); - expect(await old.reader.done().catch(error)).toMatchObject({ code: StreamCode.Cancel }); - } finally { - origin.close(); - } - }, -); - -/** On a SUBSCRIBE_NAMESPACE stream, another epoch is one NAMESPACE and no NAMESPACE_DONE. */ -test("a solicited namespace takes another epoch as one NAMESPACE and no NAMESPACE_DONE", async () => { - using clock = manual(); - const pair = createMockTransportPair(ALPN.DRAFT_18); - const { pub, origin } = publisher(pair.server, { requiresSolicitation: true, epoch: true }); - try { - const broadcast = origin.createBroadcast(Path.from("mine")); - const first = Epoch.mint(); - broadcast.announce({ epoch: first }); - - const subscription = await Stream.open(pair.client, { version: VERSION }); - const stream = await Stream.accept(pair.server, VERSION); - if (!stream) throw new Error("the subscription stream was never accepted"); - void pub.runSubscribeNamespace(new SubscribeNamespace({ requestId: 0n, namespace: Path.empty() }), stream); - const entry = async () => { - expect(await subscription.reader.u53()).toBe(SubscribeNamespaceEntry.id); - return await SubscribeNamespaceEntry.decode(subscription.reader, VERSION, EPOCH); - }; - - expect(await subscription.reader.u53()).toBe(RequestOk.id); - await RequestOk.decode(subscription.reader, VERSION); - expect(await entry()).toMatchObject({ suffix: Path.from("mine"), params: { epoch: first } }); - - const second = Epoch.mint(); - broadcast.announce({ ...broadcast.route, epoch: second }); - expect(await entry()).toMatchObject({ suffix: Path.from("mine"), params: { epoch: second } }); - - const more = watch(subscription.reader.u53()); - await clock.advance(Nano.zero); - expect(more.state).toBe("pending"); - subscription.close(); - } finally { - origin.close(); - } -}); - -/** A request that names an instance is served by that one alone, or refused as gone. */ -test("a request pinned to another epoch is refused DOES_NOT_EXIST", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const session = new NativeSession(pair.server, VERSION, true); - const { pub, origin } = publisher(pair.server, { session, epoch: true }); - const epoch = Epoch.mint(); - const broadcastPublication = origin.createBroadcast(Path.from("room")); - const broadcast = broadcastPublication.broadcast; - broadcastPublication.announce({ epoch }); - broadcast.createTrack("video"); - origin.createBroadcast(Path.from("epochless")).announce(); - - const status = async (namespace: string, pinned: Epoch.Valid | undefined) => { - const { stream, wire } = requestStream(VERSION); - const request = new TrackStatusRequest({ - requestId: 7n, - trackNamespace: Path.from(namespace), - trackName: "video", - epoch: pinned, - }); - await pub.runTrackStatusRequest(request, stream); - return wire(); - }; - - // Control: the named instance, or none at all, is served. - expect(await (await status("room", epoch)).u53()).toBe(TrackStatusOk.id); - expect(await (await status("room", undefined)).u53()).toBe(TrackStatusOk.id); - - const missing = toRequestCode("does_not_exist", "track_status", VERSION); - expect(await refusalCode(await status("room", Epoch.mint()), VERSION)).toBe(missing); - expect(await refusalCode(await status("epochless", epoch), VERSION)).toBe(missing); - - // An instance never comes back, so asking to wait for a gone one changes nothing. - for (const rendezvous of [false, true]) { - for (const [namespace, pinned] of [ - ["room", Epoch.mint()], - ["epochless", epoch], - ] as const) { - const subscribe = requestStream(VERSION); - await pub.runSubscribe( - new Subscribe({ - requestId: 7n, - trackNamespace: Path.from(namespace), - trackName: "video", - subscriberPriority: 0, - rendezvous, - epoch: pinned, - }), - subscribe.stream, - ); - const r = subscribe.wire(); - expect(await r.u53()).toBe(RequestError.id); - expect((await RequestError.decode(r, VERSION)).errorCode).toBe( - toRequestCode("does_not_exist", "subscribe", VERSION), - ); - } - } - - origin.close(); -}); - -/** Only a session that negotiated MoQ Epoch may name an instance. */ -test("EPOCH on a request without MoQ Epoch is a protocol violation", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const { pub, origin } = publisher(pair.server); - const epoch = Epoch.mint(); - const trackNamespace = Path.from("room"); - - await expect( - pub.runSubscribe( - new Subscribe({ requestId: 7n, trackNamespace, trackName: "video", subscriberPriority: 0, epoch }), - requestStream(VERSION).stream, - ), - ).rejects.toThrow(ProtocolViolation); - await expect( - pub.runTrackStatusRequest( - new TrackStatusRequest({ requestId: 7n, trackNamespace, trackName: "video", epoch }), - requestStream(VERSION).stream, - ), - ).rejects.toThrow(ProtocolViolation); - await expect( - pub.runFetch( - new Fetch({ - requestId: 7n, - type: { - kind: "standalone", - trackNamespace, - trackName: "video", - start: { group: 0n, object: 0n }, - end: { group: 0n, object: 0n }, - }, - epoch, - }), - requestStream(VERSION).stream, - ), - ).rejects.toThrow(ProtocolViolation); - - origin.close(); -}); - /** Advance time in steps until `done` holds, failing once `limit` has passed without it. */ async function advanceUntil(clock: Manual, done: () => boolean, limit: number, step = 50) { for (let elapsed = 0; !done(); elapsed += step) { @@ -2256,7 +2045,7 @@ test.each([ const stream = await nextStream(pair.client); if (!stream) throw new Error("no PUBLISH_NAMESPACE for the broadcast"); expect(await stream.reader.u53()).toBe(PublishNamespace.id); - const msg = await PublishNamespace.decode(stream.reader, VERSION, { cluster: peer !== undefined, epoch: false }); + const msg = await PublishNamespace.decode(stream.reader, VERSION, { cluster: peer !== undefined }); expect(msg.trackNamespace).toBe(Path.from("mine")); await acceptPublishNamespace(stream); diff --git a/js/net/src/ietf/publisher.ts b/js/net/src/ietf/publisher.ts index c55c8169860..ecf29adaf9f 100644 --- a/js/net/src/ietf/publisher.ts +++ b/js/net/src/ietf/publisher.ts @@ -198,13 +198,6 @@ interface Target { /** Advertise a namespace the peer does not hold. */ advertise(key: Path.Valid, next: Advertised): Promise; - /** - * Replace the instance behind a namespace the peer holds with another (MoQ Epoch): the - * new advertisement goes out before the old is withdrawn, so the peer never sees the - * namespace absent. - */ - replace(key: Path.Valid, next: Advertised): Promise; - /** Reprice a namespace the peer holds: the same broadcast at a new hop chain or cost. */ update(key: Path.Valid, next: Advertised, reprice: Reprice): Promise; @@ -379,10 +372,6 @@ export class Publisher { // back came from us. `undefined` when nothing negotiated it. #advert?: Cluster.Advert; - // Whether both SETUPs offered MoQ Epoch: every advertisement names its route's epoch, and - // a request may name the one it expects. - #epoch: boolean; - // Our grant (MoQ Auth): only what it lets us publish is advertised and served, and a // shrink withdraws what it no longer covers. Undefined until the peer answers, which // allows everything. @@ -410,7 +399,6 @@ export class Publisher { hidden = false, activeCount = false, cluster, - epoch = false, grant = new Signal(undefined), auth, ready = Promise.resolve(), @@ -429,8 +417,6 @@ export class Publisher { activeCount?: boolean; /** The Hop IDs the SETUP exchange settled (MoQ Cluster). */ cluster?: Cluster.Hops; - /** Whether both SETUPs offered MoQ Epoch. */ - epoch?: boolean; /** The union of our tokens' grants (MoQ Auth), which bounds what we publish. */ grant?: Getter; /** This session's tokens, which a route names for its request to carry. */ @@ -451,7 +437,6 @@ export class Publisher { this.#hidden = hidden; this.#activeCount = activeCount; this.#advert = Cluster.advertise(cluster); - this.#epoch = epoch; this.#datagramWriter = DatagramStream.datagramWriter(quic); } @@ -478,7 +463,6 @@ export class Publisher { } async #runSubscribe(msg: Subscribe, request: RequestStream) { - this.#pinned(msg.epoch); // Draft-22 replaced joining FETCH with fills. const joinable = !Filter.isDraft22(this.#session.version); if (joinable) this.#setJoin(msg.requestId, "pending"); @@ -530,9 +514,7 @@ export class Publisher { // Legal requests we can't honor are refused one at a time: serving a Range Filter // unfiltered would deliver objects it excluded. - // An instance never comes back, so a request pinned to a gone one is missing, not - // worth waiting for. - const rendezvous = msg.rendezvous && msg.epoch === undefined; + const rendezvous = msg.rendezvous; if (msg.rangeFilters) { refusal = { condition: "invalid_filter", reasonPhrase: "range filters not supported" }; @@ -542,7 +524,7 @@ export class Publisher { refusal = { condition: "unauthorized", reasonPhrase: "not granted" }; } else { try { - broadcast = await this.#resolve(name, left.signal, msg.epoch); + broadcast = await this.#resolve(name, left.signal); } catch (err: unknown) { // Nobody is left to refuse. if (left.signal.aborted) { @@ -1598,16 +1580,14 @@ export class Publisher { // replacement, so repricing one is just sending it again, a new original // publisher included, as Rust does. const namespace = async (suffix: Path.Valid, snap: Advertised): Promise => { - // Either extension puts the Parameters field on NAMESPACE, even an empty one. - const params = this.#advert !== undefined || this.#epoch ? this.#params(snap.route) : undefined; + // MoQ Cluster puts the Parameters field on NAMESPACE. + const params = this.#advert !== undefined ? this.#params(snap.route) : undefined; const entry = new SubscribeNamespaceEntry({ suffix, params }); await Message.write(request.writer, SubscribeNamespaceEntry.id, entry, version); return "held"; }; const target: Target = { advertise: namespace, - // A repeat under another epoch replaces the instance in place. - replace: namespace, update: namespace, held: () => undefined, carry: () => undefined, @@ -1726,7 +1706,6 @@ export class Publisher { const requests: Requests = new Map(); const target: Target = { advertise: (path, snap) => this.#advertise(path, requests, snap.route), - replace: (path, snap) => this.#replace(path, requests, snap.route), update: (path, _snap, reprice) => this.#update(path, requests, reprice), withdraw: (path) => this.#withdraw(path, requests), held: (path) => requests.get(path)?.auth, @@ -1830,9 +1809,8 @@ export class Publisher { * Bring the peer's view in line with `updated`, one namespace at a time, and report * whether anything it should hold is still missing and worth coming back for. * - * Nothing the peer cannot see is sent, a reprice updates the namespace in place, another - * epoch replaces it in place (MoQ Epoch), and anything else is withdrawn first so a - * republish reads as withdraw-then-advertise. + * Nothing the peer cannot see is sent, a reprice updates the namespace in place, and + * a changed instance is withdrawn before it is advertised again. * `ns` records what the peer holds rather than what we attempted: a declined * advertisement or update stays out of it, so the next turn offers it fresh instead * of believing it is already up. @@ -1856,7 +1834,7 @@ export class Publisher { const held = new Map(ns.active); for (const [key, snap] of ns.active) { const next = updated.get(key); - if (this.#change(key, snap, next, target) !== "restart" || this.#replaces(snap, next)) continue; + if (this.#change(key, snap, next, target) !== "restart") continue; await target.withdraw(key); held.delete(key); } @@ -1869,9 +1847,6 @@ export class Publisher { let answer: Answer; if (prev !== undefined && diff !== "restart") { answer = await target.update(key, snap, diff); - } else if (prev !== undefined) { - // Still held through a restart: another epoch replacing it. - answer = await target.replace(key, snap); } else { // A fresh offer waits for what a refusal asked for, whatever brought us back. if (!this.#offerable(key, ns.refused)) continue; @@ -1923,16 +1898,6 @@ export class Publisher { return { ...(diff === "same" ? {} : diff), token: to }; } - /** - * Whether `next` replaces the instance the peer holds in `held` with another, both named - * by an epoch on the wire (MoQ Epoch). Gaining or losing one is withdrawn and advertised - * afresh, and so is any instance change on a peer that cannot tell them apart. - */ - #replaces(held: Advertised, next: Advertised | undefined): boolean { - const [from, to] = [held.route.epoch, next?.route.epoch]; - return this.#epoch && from !== undefined && to !== undefined && from !== to; - } - /** `auth` when a request of this session can carry it. */ #carry(auth: Credential | undefined): Credential | undefined { return this.#auth?.carried(auth) === undefined ? undefined : auth; @@ -1973,11 +1938,10 @@ export class Publisher { } /** - * The extension parameters an advertisement of `route` carries. The epoch is forwarded - * as the route names it, and never invented for one without. + * The extension parameters an advertisement of `route` carries. */ #params(route: Route): AdvertParams { - return { cluster: clusterFor(this.#advert, route), epoch: this.#epoch ? route.epoch : undefined }; + return { cluster: clusterFor(this.#advert, route) }; } /** @@ -2165,19 +2129,6 @@ export class Publisher { return answer; } - /** - * Replace the PUBLISH_NAMESPACE request for `path` with one for another instance. The two - * streams are unordered, so the old one is withdrawn only once the peer answered the new - * one, refused or not: it serves another instance either way. - */ - async #replace(path: Path.Valid, requests: Requests, route: Route): Promise { - const old = requests.get(path); - requests.delete(path); - const answer = await this.#advertise(path, requests, route); - if (old) await this.#end(old); - return answer; - } - async #withdraw(path: Path.Valid, requests: Requests) { const request = requests.get(path); if (!request) return; @@ -2208,7 +2159,6 @@ export class Publisher { } async #runTrackStatusRequest(msg: TrackStatusRequest, request: RequestStream) { - this.#pinned(msg.epoch); if (Namespace.reserved(msg.trackNamespace, this.#session.version)) { await refuseReserved(request); return; @@ -2247,7 +2197,7 @@ export class Publisher { try { let answer: TrackStatusOk; try { - const broadcast = await this.#resolve(name, hold.signal, msg.epoch); + const broadcast = await this.#resolve(name, hold.signal); const info = await wireOf(broadcast).resolveTrackInfo(msg.trackName, hold.signal); const largest = wireOf(broadcast).largest(msg.trackName); answer = new TrackStatusOk({ @@ -2910,7 +2860,6 @@ export class Publisher { } async #runFetch(msg: Fetch, request: RequestStream) { - this.#pinned(msg.epoch); // The FILL_TIMEOUT counts from the request's arrival, whatever it waits on. const deadline = fillDeadline(msg.fillTimeout); const version = this.#session.version; @@ -3054,7 +3003,7 @@ export class Publisher { return { condition: "invalid_range", reasonPhrase: "empty range" }; } - const broadcast = await this.#resolve(named.trackNamespace, signal, msg.epoch); + const broadcast = await this.#resolve(named.trackNamespace, signal); const priority = fromWire(msg.subscriberPriority); const cache = broadcast.track(named.trackName).subscribe({ priority, maxDelay: Milli(Varint.MAX_U53) }); let answer: FetchAnswer | undefined; @@ -3367,22 +3316,14 @@ export class Publisher { /** * Resolve the broadcast a request names for serving: a local publish, or else the * origin's routes and dynamic handlers. Rejects with the abort once `signal` aborts. - * - * A request naming an `epoch` is served only by that instance: one now serving another - * epoch, or none, refuses it as gone rather than answering with other content. */ - async #resolve(name: Path.Valid, signal: AbortSignal, epoch: Epoch.Valid | undefined): Promise { + async #resolve(name: Path.Valid, signal: AbortSignal, epoch?: Epoch.Valid): Promise { const broadcast = this.#publish && (wireOf(this.#publish).local(name, epoch) ?? (await wireOf(this.#publish).demand(name, epoch, signal))); if (!broadcast) throw new NotFound(`broadcast ${name}`); return broadcast; } - - /** Break a session whose peer names an epoch it was never told about: MoQ Epoch was not negotiated. */ - #pinned(epoch: Epoch.Valid | undefined) { - if (epoch !== undefined && !this.#epoch) throw new ProtocolViolation("EPOCH without MoQ Epoch"); - } } /** A `{group, object}` position, in the Location Filter's own units. */ diff --git a/js/net/src/ietf/setup_options.test.ts b/js/net/src/ietf/setup_options.test.ts index afc7a672d53..5d6fb233a01 100644 --- a/js/net/src/ietf/setup_options.test.ts +++ b/js/net/src/ietf/setup_options.test.ts @@ -18,7 +18,6 @@ test("setup option keys match the registries", () => { MaxAge: 0x915c4n, Auth: 0x40b70n, ActiveCount: 0x40b64n, - Epoch: 0x40b68n, }); }); diff --git a/js/net/src/ietf/setup_options.ts b/js/net/src/ietf/setup_options.ts index b984b67b0de..4fe1a61f2f4 100644 --- a/js/net/src/ietf/setup_options.ts +++ b/js/net/src/ietf/setup_options.ts @@ -24,8 +24,6 @@ export const SetupOption = { Auth: 0x40b70n, /** ACTIVE_COUNT, from the MoQ Active Count extension. See `active_count.ts`. */ ActiveCount: 0x40b64n, - /** EPOCH, from the MoQ Epoch extension. See `epoch.ts`. */ - Epoch: 0x40b68n, } as const; // Unknown SETUP options may repeat, including GREASE (draft-22 section 9.1). diff --git a/js/net/src/ietf/subscribe.ts b/js/net/src/ietf/subscribe.ts index 1668402d816..1b0160fb000 100644 --- a/js/net/src/ietf/subscribe.ts +++ b/js/net/src/ietf/subscribe.ts @@ -1,4 +1,3 @@ -import type * as Epoch from "../epoch.ts"; import type * as Path from "../path.ts"; import type { Reader, Writer } from "../stream.ts"; import type { Order } from "../track.ts"; @@ -87,12 +86,6 @@ export class Subscribe { /** Whether RENDEZVOUS_TIMEOUT requested a wait; never encoded. */ rendezvous: boolean; - /** - * The publisher instance the subscriber expects (EPOCH, MoQ Epoch). Only a - * session that negotiated the extension names one; the session refuses one otherwise. - */ - epoch?: Epoch.Valid; - constructor({ requestId, trackNamespace, @@ -106,7 +99,6 @@ export class Subscribe { forward, rangeFilters, rendezvous, - epoch, }: { requestId: bigint; trackNamespace: Path.Valid; @@ -120,7 +112,6 @@ export class Subscribe { forward?: boolean; rangeFilters?: boolean; rendezvous?: boolean; - epoch?: Epoch.Valid; }) { this.requestId = requestId; this.trackNamespace = trackNamespace; @@ -134,7 +125,6 @@ export class Subscribe { this.forward = forward ?? true; this.rangeFilters = rangeFilters ?? false; this.rendezvous = rendezvous ?? false; - this.epoch = epoch; } async #encode(w: Writer, version: IetfVersion): Promise { @@ -160,7 +150,6 @@ export class Subscribe { params.includeProperties = false; } } - params.epoch = this.epoch; await params.encode(w, version); } @@ -215,7 +204,6 @@ export class Subscribe { forward: params.forward ?? true, rangeFilters: params.rangeFilters, rendezvous: (params.vars.get(0x04n) ?? 0n) > 0n, - epoch: params.epoch, }); } } diff --git a/js/net/src/ietf/subscribe_namespace.ts b/js/net/src/ietf/subscribe_namespace.ts index dc893a54aea..df8d0a08c77 100644 --- a/js/net/src/ietf/subscribe_namespace.ts +++ b/js/net/src/ietf/subscribe_namespace.ts @@ -67,10 +67,9 @@ export const SUBSCRIBE_TRACKS_ID = 0x51; /** * NAMESPACE message (0x08), sent on the SUBSCRIBE_NAMESPACE bidi stream. * - * The base message carries only the suffix. A session that negotiated the MoQ Cluster or - * MoQ Epoch extension uses the extended form instead, which appends one Parameters field - * for both, so the advertisement can carry its HOP_PATH and ROUTE_COST (see `cluster.ts`) - * and its EPOCH (see `epoch.ts`). + * The base message carries only the suffix. A session that negotiated the MoQ Cluster + * extension uses the extended form instead, which appends one Parameters field + * so the advertisement can carry its HOP_PATH and ROUTE_COST (see `cluster.ts`). */ export class SubscribeNamespaceEntry { static id = 0x08; diff --git a/js/net/src/ietf/subscriber.test.ts b/js/net/src/ietf/subscriber.test.ts index 10347101841..7a3d34af559 100644 --- a/js/net/src/ietf/subscriber.test.ts +++ b/js/net/src/ietf/subscriber.test.ts @@ -2,7 +2,6 @@ import { expect, jest, onTestFinished, spyOn, test } from "bun:test"; import { Manual, Milli, Nano } from "@moq/clock"; import { Once } from "@moq/signals"; import type * as announce from "../announced.ts"; -import * as Epoch from "../epoch.ts"; import { ProtocolViolation, StreamCode, Stream as StreamError } from "../error.ts"; import { type Hop, HopSchema, UNKNOWN_HOP } from "../hop.ts"; import { hooks } from "../internal.ts"; @@ -127,7 +126,7 @@ test("an unsolicited announcement lands", async () => { /** * A session without the Cluster extension names no publisher, so its advertisement carries - * only the anonymous mark: identity is the epoch's job, and nothing goes in front of the 0. + * only the anonymous mark, and nothing goes in front of the 0. */ test("an advertisement with no path is anonymous", async () => { const pair = createMockTransportPair(ALPN.DRAFT_18); @@ -1732,207 +1731,3 @@ for (const negotiated of [false, true]) { peer.close(); }); } -/** Advertise `path` inline under `epoch`, on a session that negotiated MoQ Epoch alone. */ -async function inlineEpoch(stream: Stream, path: Path.Valid, epoch: Epoch.Valid): Promise { - await stream.writer.u53(SubscribeNamespaceEntry.id); - await new SubscribeNamespaceEntry({ suffix: path, params: { epoch } }).encode(stream.writer, VERSION); -} - -/** Open a PUBLISH_NAMESPACE for `path` under `epoch`, returning the handler and the peer's end. */ -async function publishEpoch( - pair: ReturnType, - subscriber: Subscriber, - path: Path.Valid, - epoch: Epoch.Valid, -): Promise<{ handler: Promise; peer: Stream }> { - const stream = await Stream.open(pair.server, { version: VERSION }); - const handler = subscriber.runPublishNamespace( - new PublishNamespace({ requestId: 0n, trackNamespace: path, params: { epoch } }), - stream, - ); - const peer = await nextStream(pair.client); - if (!peer) throw new Error("no PUBLISH_NAMESPACE stream"); - expect(await peer.reader.u53()).toBe(RequestOk.id); - await RequestOk.decode(peer.reader, VERSION); - return { handler, peer }; -} - -/** The route names the advertised instance, and so does every SUBSCRIBE sent for it. */ -test("an advertised epoch reaches the route and the SUBSCRIBE", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const subscriber = new Subscriber({ session: new NativeSession(pair.server, VERSION, true), epoch: true }); - const announced = subscriber.announced(); - await acceptSubscribeNamespace(pair.client); - - const epoch = Epoch.mint(); - await publishEpoch(pair, subscriber, Path.from("room"), epoch); - expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "start", route: { epoch } }); - - const track = subscriber.consume(Path.from("room")).track("video").subscribe(); - onTestFinished(() => track.close()); - const peer = await nextStream(pair.client); - if (!peer) throw new Error("no SUBSCRIBE stream"); - expect(await peer.reader.u53()).toBe(Subscribe.id); - expect((await Subscribe.decode(peer.reader, VERSION)).epoch).toBe(epoch); - announced.close(); -}); - -test("an inline NAMESPACE route carries its epoch", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const subscriber = new Subscriber({ session: new NativeSession(pair.server, VERSION, true), epoch: true }); - const announced = subscriber.announced(); - const subscription = await acceptSubscribeNamespace(pair.client); - - const epoch = Epoch.mint(); - await inlineEpoch(subscription, Path.from("room"), epoch); - expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "start", route: { epoch } }); - announced.close(); -}); - -/** - * A NAMESPACE repeated under another epoch replaces the instance in place: the path - * restarts and is never absent, and a fresh reader hears the new instance standing. - */ -test("a NAMESPACE repeated under another epoch restarts the path in place", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const subscriber = new Subscriber({ session: new NativeSession(pair.server, VERSION, true), epoch: true }); - const announced = subscriber.announced(); - const subscription = await acceptSubscribeNamespace(pair.client); - - const path = Path.from("room"); - const first = Epoch.mint(); - await inlineEpoch(subscription, path, first); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "start", route: { epoch: first } }); - - const second = Epoch.mint(); - await inlineEpoch(subscription, path, second); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "restart", route: { epoch: second } }); - - const fresh = subscriber.announced(); - expect(await fresh.next()).toMatchObject({ prefix: path, kind: "start", route: { epoch: second } }); - fresh.close(); - announced.close(); -}); - -/** - * A namespace advertised both inline and by a later PUBLISH_NAMESPACE takes another epoch - * from either: an inline repeat under the new epoch is the newest advertisement, not an - * update to the older of the two. - */ -test("a NAMESPACE repeat under another epoch outranks a later PUBLISH_NAMESPACE", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const subscriber = new Subscriber({ session: new NativeSession(pair.server, VERSION, true), epoch: true }); - const announced = subscriber.announced(); - const subscription = await acceptSubscribeNamespace(pair.client); - - const path = Path.from("room"); - const first = Epoch.mint(); - await inlineEpoch(subscription, path, first); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "start", route: { epoch: first } }); - await publishEpoch(pair, subscriber, path, first); - - const second = Epoch.mint(); - await inlineEpoch(subscription, path, second); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "restart", route: { epoch: second } }); - announced.close(); -}); - -/** - * A NAMESPACE that loops back through us detaches its route, but the advertisement stays - * live on the wire until its NAMESPACE_DONE: a repeat that restores a clean path while - * losing its epoch is still the violation it would be without the loop. - */ -test("a reflected NAMESPACE keeps its epoch live", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const session = new NativeSession(pair.server, VERSION, true); - const subscriber = new Subscriber({ session, quic: pair.server, cluster: { self: SELF, peer: PEER }, epoch: true }); - const warn = spyOn(console, "warn").mockImplementation(() => void 0); - onTestFinished(() => warn.mockRestore()); - const announced = subscriber.announced(); - const subscription = await acceptSubscribeNamespace(pair.client); - - const epoch = Epoch.mint(); - const send = async (hops: Hop[], named?: Epoch.Valid) => { - await subscription.writer.u53(SubscribeNamespaceEntry.id); - await new SubscribeNamespaceEntry({ - suffix: Path.from("room"), - params: { cluster: { hops, cost: 0n }, epoch: named }, - }).encode(subscription.writer, VERSION); - }; - await send([PEER], epoch); - expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "start" }); - await send([SELF, PEER], epoch); - expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "end" }); - - await send([PEER]); - await violationClosed(pair); -}); - -/** - * Gaining or losing an epoch is not one instance replacing another, so a repeat that does - * either means the peer skipped the NAMESPACE_DONE. - */ -test.each(["gains", "loses"] as const)("a NAMESPACE repeat that %s an epoch closes the session", async (change) => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const session = new NativeSession(pair.server, VERSION, true); - const subscriber = new Subscriber({ session, quic: pair.server, epoch: true }); - const warn = spyOn(console, "warn").mockImplementation(() => void 0); - onTestFinished(() => warn.mockRestore()); - const announced = subscriber.announced(); - const subscription = await acceptSubscribeNamespace(pair.client); - - const epoch = Epoch.mint(); - const send = async (path: Path.Valid, named?: Epoch.Valid) => { - await subscription.writer.u53(SubscribeNamespaceEntry.id); - await new SubscribeNamespaceEntry({ suffix: path, params: { epoch: named } }).encode( - subscription.writer, - VERSION, - ); - }; - const [before, after] = change === "gains" ? [undefined, epoch] : [epoch, undefined]; - await send(Path.from("room"), before); - expect(await announced.next()).toMatchObject({ prefix: Path.from("room"), kind: "start" }); - - // Control: a repeat that keeps the epoch, or its absence, is not a violation. - await send(Path.from("room"), before); - await send(Path.from("sentinel"), before); - expect(await announced.next()).toMatchObject({ prefix: Path.from("sentinel"), kind: "start" }); - - await send(Path.from("room"), after); - await violationClosed(pair); -}); - -/** - * Two PUBLISH_NAMESPACE requests travel on independent streams, so a restarted publisher's - * new advertisement can land before its old one's withdrawal. The newest stands throughout. - */ -test("a stale instance's withdrawal arriving last keeps the newer epoch", async () => { - const pair = createMockTransportPair(ALPN.DRAFT_18); - const subscriber = new Subscriber({ session: new NativeSession(pair.server, VERSION, true), epoch: true }); - const announced = subscriber.announced(); - await acceptSubscribeNamespace(pair.client); - - const path = Path.from("room"); - const first = Epoch.mint(); - const old = await publishEpoch(pair, subscriber, path, first); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "start", route: { epoch: first } }); - - const second = Epoch.mint(); - await publishEpoch(pair, subscriber, path, second); - expect(await announced.next()).toMatchObject({ prefix: path, kind: "restart", route: { epoch: second } }); - - old.peer.close(); - await old.handler; - - const next = await Promise.race([ - announced.next(), - new Promise<"nothing">((resolve) => setTimeout(() => resolve("nothing"), 250)), - ]); - expect(next).toBe("nothing"); - - // A fresh reader hears the newer instance as the one standing. - const fresh = subscriber.announced(); - expect(await fresh.next()).toMatchObject({ prefix: path, kind: "start", route: { epoch: second } }); - fresh.close(); - announced.close(); -}); diff --git a/js/net/src/ietf/subscriber.ts b/js/net/src/ietf/subscriber.ts index 827954c3496..65ca2882234 100644 --- a/js/net/src/ietf/subscriber.ts +++ b/js/net/src/ietf/subscriber.ts @@ -7,7 +7,6 @@ import * as broadcast from "../broadcast.ts"; import type { Drain } from "../connection/goaway.ts"; import { BroadcastCache } from "../consume.ts"; import * as DatagramStream from "../datagram_stream.ts"; -import type * as Epoch from "../epoch.ts"; import { closeError, error, @@ -137,9 +136,6 @@ export class Subscriber { // to us contains. #cluster?: Cluster.Hops; - // Whether both SETUPs offered MoQ Epoch, so advertisements may name their instance. - #epoch: boolean; - // Publisher-chosen aliases used by incoming group streams. #aliases = new TrackAliases(); @@ -158,7 +154,7 @@ export class Subscriber { // two messages about one source, which the MoQ Solicit draft requires us to tolerate. // Tracking each is what keeps the second from duplicating the announce and the first // to end from retracting what the other still holds. A publisher replacing its instance - // (MoQ Epoch) withdraws one advertisement and makes another, on separate streams that + // withdraws one advertisement and makes another, on separate streams that // can arrive in either order, so the newest stands until it goes and an update to an // older one changes nothing. Each live wire advertisement holds an announce slot, // even while its route loops back through us and is absent from this derived map. @@ -200,7 +196,6 @@ export class Subscriber { session, quic, cluster, - epoch = false, hidden = false, maxAge = false, activeCount = false, @@ -215,8 +210,6 @@ export class Subscriber { quic?: WebTransport; /** The Hop IDs the SETUP exchange settled (MoQ Cluster). */ cluster?: Cluster.Hops; - /** Whether both SETUPs offered MoQ Epoch. */ - epoch?: boolean; /** Whether the peer understands the HIDDEN parameter (MoQ Hidden). */ hidden?: boolean; /** Whether the peer accepts subscriber max age. */ @@ -235,7 +228,6 @@ export class Subscriber { this.#quic = quic; this.#announceSlots = new Slots(limits.announces, { quic, reason: "too many announcements" }); this.#cluster = cluster; - this.#epoch = epoch; this.#hidden = hidden; this.#maxAge = maxAge; this.#activeCount = activeCount; @@ -287,12 +279,10 @@ export class Subscriber { } /** - * The route an advertisement carries; one without a path is anonymous and free. Its - * epoch is taken as given, and absent when the advertisement names none. + * The epochless route an advertisement carries; one without a path is anonymous and free. */ - #route({ cluster, epoch }: AdvertParams): Route { - const route = cluster === undefined ? { hops: [UNKNOWN_HOP], cost: Cost.zero } : { ...cluster }; - return epoch === undefined ? route : { ...route, epoch }; + #route({ cluster }: AdvertParams): Route { + return cluster === undefined ? { hops: [UNKNOWN_HOP], cost: Cost.zero } : { ...cluster }; } /** @@ -366,7 +356,7 @@ export class Subscriber { this.#announced.set(path, entry); this.#consumes.announce(path, entry, route); - console.debug(`announced: broadcast=${path} active=true epoch=${route.epoch}`); + console.debug(`announced: broadcast=${path} active=true`); for (const [consumer, filter] of this.#announcedConsumers) { // A consumer that closed stays registered until its request is off the wire. if (!sees(filter, path) || consumer.closed.peek() !== undefined) continue; @@ -381,12 +371,6 @@ export class Subscriber { const existing = this.#announced.get(path); const advert = existing?.adverts.find((advert) => advert.id === id); if (existing === undefined || advert === undefined) return; - // A repeat under another epoch is a newer advertisement, so it becomes the newest; - // one of the same instance stays where it is. - if (advert.route.epoch !== route.epoch) { - existing.adverts.splice(existing.adverts.indexOf(advert), 1); - existing.adverts.push(advert); - } advert.route = route; this.#settleAnnounce(path, existing); } @@ -394,24 +378,21 @@ export class Subscriber { /** * Route a path by its newest live advertisement. A no-op when that changed nothing. * Otherwise consumers hear `update` for new hops or cost, so a forwarder can reprice - * without retracting and the shared consume stays, or `restart` for another publisher - * instance (MoQ Epoch), so the next consume subscribes afresh. + * without retracting, and the shared consume stays. */ #settleAnnounce(path: Path.Valid, existing: Announced) { const newest = existing.adverts.at(-1); if (newest === undefined) return; const route = this.#priced(newest.route); if (routesEqual(existing.route, route)) return; - const restart = existing.route.epoch !== route.epoch; existing.route = route; - this.#consumes.announce(path, existing, route, restart); - console.debug(`announced: broadcast=${path} ${restart ? `restart=true epoch=${route.epoch}` : "rerouted"}`); - const kind = restart ? "restart" : "update"; + this.#consumes.announce(path, existing, route, false); + console.debug(`announced: broadcast=${path} rerouted`); for (const [consumer, filter] of this.#announcedConsumers) { // A consumer that closed stays registered until its request is off the wire. if (!sees(filter, path) || consumer.closed.peek() !== undefined) continue; const scope = filter.scope; - consumer.append({ prefix: path, captures: scopeCaptures(scope, path), kind, route }); + consumer.append({ prefix: path, captures: scopeCaptures(scope, path), kind: "update", route }); } } @@ -463,11 +444,11 @@ export class Subscriber { ): Promise { const version = this.#session.version; - // Suffixes live on this stream, with the advertisement each holds and the epoch it named, + // Suffixes live on this stream, with the advertisement each holds, // so a repeat is recognized as an update to it rather than a second one, which would leak. // An advertisement stays live on the wire until its NAMESPACE_DONE, even while its // route is detached (`id` unset) for looping back through us. - const live = new SlotMap(this.#announceSlots); + const live = new SlotMap(this.#announceSlots); // Set once `release` has given back everything this stream held. The read loop is not // awaited when the local consumer closes first, and the stream keeps delivering what @@ -591,7 +572,6 @@ export class Subscriber { if (msgType === SubscribeNamespaceEntry.id) { const entry = await SubscribeNamespaceEntry.decode(framed.reader, version, { cluster: Cluster.negotiated(this.#cluster), - epoch: this.#epoch, }); // Counted even when discarded below. if (initial > 0) initial -= 1; @@ -601,15 +581,9 @@ export class Subscriber { const params = entry.params ?? {}; const held = live.get(path); - // A repeat under another epoch replaces the instance in place, but one - // that gains or loses an epoch skipped the NAMESPACE_DONE it needs. - if (held !== undefined && (held.epoch === undefined) !== (params.epoch === undefined)) { - throw new ProtocolViolation(`NAMESPACE repeated gaining or losing an epoch: ${path}`); - } - // The wire still holds a reflected advertisement until DONE, so charge // it before deciding whether its route can be used. Repeats keep the slot. - if (held === undefined) live.set(path, { epoch: params.epoch }); + if (held === undefined) live.set(path, {}); // A repeat updates the advertisement in place, so one that now // loops back through us has taken a route we can't subscribe @@ -617,19 +591,16 @@ export class Subscriber { if (this.#reflected(params.cluster)) { console.debug(`dropping reflected namespace: broadcast=${path}`); if (held?.id !== undefined) this.#detachAnnounce(path, held.id); - live.set(path, { epoch: params.epoch }); + live.set(path, {}); continue; } - // A repeat replaces the advertisement in place: HOP_PATH / ROUTE_COST - // can change without a NAMESPACE_DONE, and another epoch restarts the - // path without it ever going absent. Only the first is a new path. + // A repeat updates HOP_PATH and ROUTE_COST in place. Only the first is a new path. const route = this.#route(params); if (held?.id !== undefined) { - held.epoch = params.epoch; this.#updateAnnounce(path, held.id, route); } else { - live.set(path, { id: this.#attachAnnounce(path, route), epoch: params.epoch }); + live.set(path, { id: this.#attachAnnounce(path, route) }); } } else if (msgType === SubscribeNamespaceEntryDone.id) { const entry = await SubscribeNamespaceEntryDone.decode(framed.reader, version); @@ -696,9 +667,7 @@ export class Subscriber { for (;;) { const request = await wireOf(consumer).requested(); if (!request) break; - // Every request names the instance the consume resolved, so the peer refuses - // rather than answers from another. - void this.#runSubscribe(path, request, instance.validity?.signal, instance.route.epoch); + void this.#runSubscribe(path, request, instance.validity?.signal); } })(); return this.#consumes.insert(path, instance, consumer); @@ -733,7 +702,7 @@ export class Subscriber { ]); } - async #runSubscribe(broadcast: Path.Valid, request: track.Request, valid?: AbortSignal, epoch?: Epoch.Valid) { + async #runSubscribe(broadcast: Path.Valid, request: track.Request, valid?: AbortSignal) { const refused = unauthorized(broadcast); try { for (;;) { @@ -779,7 +748,7 @@ export class Subscriber { // and any registration if setup eventually finishes. const state: SubscribeSetupState = {}; const deadline = new Deadline(); - const setup = this.#openSubscribe(state, broadcast, request, requestId, deadline, epoch); + const setup = this.#openSubscribe(state, broadcast, request, requestId, deadline); // The publisher can be serving before it answers, so waiting only on the response // would miss the local side going away and leave it serving a track nobody reads. @@ -1091,7 +1060,6 @@ export class Subscriber { request: track.Request, requestId: bigint, deadline: Deadline, - epoch: Epoch.Valid | undefined, ): Promise<{ stream: RequestStream; subscription: Subscription; @@ -1128,7 +1096,6 @@ export class Subscriber { // object, and that mid-group stream is dropped, degrading the join to the next // group boundary. filter: joinFilter(version), - epoch, }); await Message.write(state.stream.writer, Subscribe.id, msg, version); state.sent = true; @@ -1195,7 +1162,7 @@ export class Subscriber { staged.commit(); try { - this.#aliases.set(ok.trackAlias, subscription, { broadcast, name: request.name, epoch }); + this.#aliases.set(ok.trackAlias, subscription, { broadcast, name: request.name }); const timescale = ok.properties.timescale; if (timescale !== undefined) { this.#timescales.set(ok.trackAlias, timescale); @@ -1254,8 +1221,6 @@ export class Subscriber { // stream ends. this.#announceSlots.acquire(); let attached: number | undefined; - // Fixed for the advertisement's life: no REQUEST_UPDATE carries one. - const epoch = msg.params.epoch; try { // Send OK first. This must complete before notifying consumers, @@ -1328,9 +1293,9 @@ export class Subscriber { } } else if (attached === undefined) { // Re-attach: a clean path replaced the reflected one we detached from. - attached = this.#attachAnnounce(path, this.#route({ cluster: held, epoch })); + attached = this.#attachAnnounce(path, this.#route({ cluster: held })); } else { - this.#updateAnnounce(path, attached, this.#route({ cluster: held, epoch })); + this.#updateAnnounce(path, attached, this.#route({ cluster: held })); } // Nothing here can fail to apply, so every update is acknowledged. A leaf diff --git a/js/net/src/ietf/track.ts b/js/net/src/ietf/track.ts index 938c6cf9cdb..80522b04f32 100644 --- a/js/net/src/ietf/track.ts +++ b/js/net/src/ietf/track.ts @@ -1,4 +1,3 @@ -import type * as Epoch from "../epoch.ts"; import type * as Path from "../path.ts"; import type { Reader, Writer } from "../stream.ts"; import * as Filter from "./filter.ts"; @@ -18,27 +17,22 @@ export class TrackStatusRequest { trackName: string; /** Whether the requester wants Track Properties on the answer (INCLUDE_PROPERTIES, draft-22). */ propertiesWanted: boolean; - /** The publisher instance the requester expects (EPOCH, MoQ Epoch). */ - epoch?: Epoch.Valid; constructor({ requestId, trackNamespace, trackName, propertiesWanted = true, - epoch, }: { requestId: bigint; trackNamespace: Path.Valid; trackName: string; propertiesWanted?: boolean; - epoch?: Epoch.Valid; }) { this.requestId = requestId; this.trackNamespace = trackNamespace; this.trackName = trackName; this.propertiesWanted = propertiesWanted; - this.epoch = epoch; } async #encode(w: Writer, version: IetfVersion): Promise { @@ -49,7 +43,6 @@ export class TrackStatusRequest { // INCLUDE_PROPERTIES as unknown, which is a protocol violation. const params = new Parameters(); if (!this.propertiesWanted && Filter.isDraft22(version)) params.includeProperties = false; - params.epoch = this.epoch; await params.encode(w, version); } @@ -63,8 +56,8 @@ export class TrackStatusRequest { * subscription for it to configure. */ static async decode(r: Reader, version: IetfVersion): Promise { - const { requestId, trackNamespace, trackName, propertiesWanted, epoch } = await Subscribe.decode(r, version); - return new TrackStatusRequest({ requestId, trackNamespace, trackName, propertiesWanted, epoch }); + const { requestId, trackNamespace, trackName, propertiesWanted } = await Subscribe.decode(r, version); + return new TrackStatusRequest({ requestId, trackNamespace, trackName, propertiesWanted }); } } diff --git a/rs/moq-net/src/fuzz.rs b/rs/moq-net/src/fuzz.rs index 86018d5e628..fdc6ba30bfe 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -859,7 +859,6 @@ impl Default for Messages { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }, ietf_ok: ietf::SubscribeOk { track_alias: 5, @@ -1011,7 +1010,6 @@ pub fn encode_subscribe(broadcast: &Path, track: &str, ietf: bool, out: &mut Vec authorization_token: None, new_group: None, max_age: None, - epoch: None, } .encode(w, BENCH_IETF) .unwrap(), @@ -1336,7 +1334,6 @@ pub fn seeds() -> Vec { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }; fetch.encode_bytes(*version).ok() }) else { diff --git a/rs/moq-net/src/ietf/epoch.rs b/rs/moq-net/src/ietf/epoch.rs deleted file mode 100644 index 34fbe717a93..00000000000 --- a/rs/moq-net/src/ietf/epoch.rs +++ /dev/null @@ -1,97 +0,0 @@ -//! The MoQ Epoch extension (draft-lcurley-moq-epoch-00). -//! -//! moq-transport names content by namespace alone, so a publisher that restarts at the -//! same namespace looks like the same broadcast to every relay. This extension carries -//! the publisher instance, the [`crate::Epoch`] moq-lite 07 puts on its routes and -//! requests, as an EPOCH parameter: on each advertisement (PUBLISH_NAMESPACE and -//! NAMESPACE), and on each request that resolves one (SUBSCRIBE, FETCH, and -//! TRACK_STATUS). A namespace and an EPOCH name one broadcast; a request carrying one -//! is refused rather than served by another instance. -//! -//! Negotiated only when both endpoints declare the option. - -use crate::Epoch; -use crate::coding::{DecodeError, Decoder, EncodeError, Encoder}; - -use super::{Param, Version}; - -/// EPOCH Setup Option: the sender understands the EPOCH parameter. Even, so the value -/// is a bare varint. -pub const EPOCH: u64 = 0x40B68; - -/// EPOCH message parameter: the publisher instance, as a UUIDv7's 16 bytes. Odd, so the -/// value is length-prefixed. -pub const EPOCH_PARAM: u64 = 0x40B69; - -/// Whether the peer declared the option. -pub fn from_setup(params: &super::Parameters) -> bool { - params.get_varint(super::ParameterVarInt::Epoch).is_some() -} - -/// Declare that we understand the EPOCH parameter. -pub fn into_setup(params: &mut super::Parameters) { - params.set_varint(super::ParameterVarInt::Epoch, 1); -} - -impl Param for Epoch { - fn param_encode(&self, w: &mut Encoder<'_>, _version: Version) -> Result<(), EncodeError> { - w.bytes(&self.to_bytes()) - } - - /// Anything but a UUIDv7's 16 bytes is malformed. - fn param_decode(r: &mut Decoder<'_>, _version: Version) -> Result { - Epoch::from_bytes(r.bytes()?).map_err(|_| DecodeError::InvalidValue) - } -} - -#[cfg(test)] -mod tests { - use super::*; - - const VERSION: Version = Version::Draft18; - - #[test] - fn code_point_parity() { - // The parity is load-bearing: odd values are length-prefixed, even ones bare varints. - assert_eq!(EPOCH % 2, 0); - assert_eq!(EPOCH_PARAM % 2, 1); - } - - #[test] - fn declared_option_negotiates() { - let mut params = super::super::Parameters::default(); - assert!(!from_setup(¶ms)); - into_setup(&mut params); - assert!(from_setup(¶ms)); - } - - #[test] - fn round_trips_and_refuses_anything_but_a_uuidv7() { - let epoch = Epoch::mint(); - let mut buf = Vec::new(); - epoch - .param_encode(&mut Encoder::new(&mut buf, VERSION.into()), VERSION) - .unwrap(); - assert_eq!(buf.len(), 17, "a length byte, then the 16 bytes"); - let mut bytes = bytes::Bytes::from(buf); - let decoded = crate::coding::decode_buf(&mut bytes, VERSION, Epoch::param_decode).unwrap(); - assert_eq!(decoded, epoch); - - for value in [ - Vec::new(), - epoch.to_bytes()[..15].to_vec(), - uuid::Builder::from_random_bytes([7; 16]) - .into_uuid() - .as_bytes() - .to_vec(), - ] { - let mut buf = Vec::new(); - Encoder::new(&mut buf, VERSION.into()).bytes(&value).unwrap(); - let mut bytes = bytes::Bytes::from(buf); - assert!( - crate::coding::decode_buf(&mut bytes, VERSION, Epoch::param_decode).is_err(), - "{value:?}" - ); - } - } -} diff --git a/rs/moq-net/src/ietf/fetch.rs b/rs/moq-net/src/ietf/fetch.rs index 136dd2df9f1..190afe5a670 100644 --- a/rs/moq-net/src/ietf/fetch.rs +++ b/rs/moq-net/src/ietf/fetch.rs @@ -10,7 +10,6 @@ use crate::{ }; use super::Message; -use super::epoch; use super::Version; @@ -135,9 +134,6 @@ pub struct Fetch<'a> { /// Whether the requester wants Track Properties in FETCH_OK (INCLUDE_PROPERTIES, /// draft-22). Always `true` before draft-22, which has no way to opt out. pub properties_wanted: bool, - /// The publisher instance the requester expects (MoQ Epoch). Only on a - /// request that names its track: a joining FETCH takes its subscription's. - pub epoch: Option, } impl Fetch<'_> { @@ -187,7 +183,6 @@ impl Fetch<'_> { range_filters: self.range_filters, fill_timeout: self.fill_timeout, properties_wanted: self.properties_wanted, - epoch: self.epoch, } } } @@ -205,11 +200,9 @@ impl<'a> Message<'a> for Fetch<'a> { match version { Version::Draft18 => { self.fetch_type.encode(w, version)?; - let epoch = self.epoch.clone(); encode_params!(w, version, 0x20 => self.subscriber_priority, 0x22 => group_order, - epoch::EPOCH_PARAM => epoch, ); } _ => { @@ -230,7 +223,6 @@ impl<'a> Message<'a> for Fetch<'a> { 0x21 => *filter, 0x22 => group_order, 0x35 => include_properties, - epoch::EPOCH_PARAM => self.epoch.clone(), ); } } @@ -241,7 +233,7 @@ impl<'a> Message<'a> for Fetch<'a> { let request_id = RequestId::decode(buf, version)?; // The token decodes but grants nothing: the session's grant is what authorizes the request. - let (fetch_type, subscriber_priority, group_order, range_filters, fill_timeout, properties_wanted, epoch) = + let (fetch_type, subscriber_priority, group_order, range_filters, fill_timeout, properties_wanted) = match version { Version::Draft18 => { let fetch_type = FetchType::decode(buf, version)?; @@ -250,7 +242,6 @@ impl<'a> Message<'a> for Fetch<'a> { 0x0A => fill_timeout: Option, 0x20 => subscriber_priority: Option, 0x22 => group_order: Option, - epoch::EPOCH_PARAM => epoch: Option, ); super::token::single(authorization_token)?; @@ -261,7 +252,6 @@ impl<'a> Message<'a> for Fetch<'a> { false, fill_timeout.is_some(), true, - epoch, ) } // Draft-22 names the track up front and moves the range into LOCATION_FILTER. @@ -279,7 +269,6 @@ impl<'a> Message<'a> for Fetch<'a> { 0x27 => priority_filter: Vec, 0x28 => object_property_filter: Vec, 0x35 => include_properties: Option, - epoch::EPOCH_PARAM => epoch: Option, ); super::token::single(authorization_token)?; let range_filters = [ @@ -305,20 +294,10 @@ impl<'a> Message<'a> for Fetch<'a> { fill_timeout.is_some(), // Defaults to 1, so an absent parameter means the requester wants them. include_properties.unwrap_or(true), - epoch, ) } }; - // A joining FETCH is served by its subscription's instance; naming one is malformed. - if epoch.is_some() - && matches!( - fetch_type, - FetchType::RelativeJoining { .. } | FetchType::AbsoluteJoining { .. } - ) { - return Err(DecodeError::InvalidValue); - } - Ok(Self { request_id, subscriber_priority: subscriber_priority.unwrap_or(super::priority::DEFAULT_WIRE), @@ -328,7 +307,6 @@ impl<'a> Message<'a> for Fetch<'a> { range_filters, fill_timeout, properties_wanted, - epoch, }) } } @@ -627,7 +605,6 @@ mod tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }; let encoded = encode_message(&msg, Version::Draft18); @@ -735,7 +712,6 @@ mod tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }; #[rustfmt::skip] diff --git a/rs/moq-net/src/ietf/mod.rs b/rs/moq-net/src/ietf/mod.rs index dd187e8f0bb..a194131d424 100644 --- a/rs/moq-net/src/ietf/mod.rs +++ b/rs/moq-net/src/ietf/mod.rs @@ -21,7 +21,6 @@ pub mod cluster; #[cfg(feature = "async")] mod control; mod datagram; -pub(crate) mod epoch; pub(crate) mod error; mod fetch; mod filter; @@ -98,7 +97,6 @@ mod tests { ("HIDDEN", hidden::HIDDEN, 0x40B5C), ("AUTH", auth::AUTH, 0x40B70), ("ACTIVE_COUNT", active_count::ACTIVE_COUNT, 0x40B64), - ("EPOCH", epoch::EPOCH, 0x40B68), ] { assert_eq!(key, spec, "{name}"); } @@ -112,7 +110,6 @@ mod tests { ("ROUTE_COST", cluster::ROUTE_COST, 0x40B58), ("HIDDEN", hidden::HIDDEN_PARAM, 0x40B5E), ("ACTIVE_COUNT", active_count::ACTIVE_COUNT_PARAM, 0x40B66), - ("EPOCH", epoch::EPOCH_PARAM, 0x40B69), ] { assert_eq!(key, spec, "{name}"); } diff --git a/rs/moq-net/src/ietf/parameters.rs b/rs/moq-net/src/ietf/parameters.rs index e84544c4739..1d6531bc429 100644 --- a/rs/moq-net/src/ietf/parameters.rs +++ b/rs/moq-net/src/ietf/parameters.rs @@ -31,8 +31,6 @@ pub enum ParameterVarInt { ActiveCount = super::active_count::ACTIVE_COUNT, /// Subscriber max age, from the MoQ Timestamp extension. MaxAge = super::max_age::OPTION, - /// EPOCH, from the MoQ Epoch extension. - Epoch = super::epoch::EPOCH, /// DEFLATE-compressed tracks, from the MoQ Flate extension. Flate = super::flate::OPTION, #[num_enum(catch_all)] diff --git a/rs/moq-net/src/ietf/peer.rs b/rs/moq-net/src/ietf/peer.rs index 415dc86825c..70bd6103560 100644 --- a/rs/moq-net/src/ietf/peer.rs +++ b/rs/moq-net/src/ietf/peer.rs @@ -30,10 +30,6 @@ pub(crate) struct Peer { /// NAMESPACE messages before the subscription is synced, in both directions. pub active_count: bool, - /// MoQ Epoch: whether both sides offered it, so advertisements and requests carry the - /// publisher's epoch in both directions. - pub epoch: bool, - /// Whether this peer offered DEFLATE-compressed tracks. pub flate: bool, } @@ -47,8 +43,6 @@ pub(crate) struct Peer { #[derive(Clone, Default)] pub(crate) struct PeerSetup { slot: kio::Shared>, - /// What we offered, which an extension negotiated by both sides needs as well. - declined_epoch: bool, /// Where the peer's advertised implementation is published for the session handle. implementation: crate::setup::PeerImplementation, /// The session's auth link to tell once the peer's SETUP accepts the connection. @@ -64,16 +58,6 @@ impl PeerSetup { setup } - /// A slot for a session that offered `offered`. - pub fn new(offered: crate::setup::Extensions) -> Self { - Self { - slot: Default::default(), - declined_epoch: !offered.epoch, - implementation: Default::default(), - accept: None, - } - } - /// Tell `link` once the peer's SETUP arrives that it accepted the connection credential. pub fn accepting(mut self, link: crate::auth::Link) -> Self { link.await_setup(); @@ -99,8 +83,7 @@ impl PeerSetup { /// lifetime while subscription serving re-reads it, so letting a later SETUP /// overwrite the identity would advertise under one exclusion and serve under /// another, which is how a routing loop gets back in. - pub fn set(&self, mut peer: Peer) { - peer.epoch &= !self.declined_epoch; + pub fn set(&self, peer: Peer) { let mut slot = self.slot.lock(); if slot.is_some() { return; @@ -152,7 +135,6 @@ mod tests { max_age: false, auth: false, active_count: false, - epoch: false, flate: false, }; @@ -168,30 +150,9 @@ mod tests { max_age: false, auth: true, active_count: true, - epoch: true, flate: true, }); assert_eq!(slot.get().await, first); } - - /// MoQ Epoch needs both sides: a peer declaring it to a side that declined leaves it off. - #[moq_clock::test] - async fn epoch_needs_our_offer_too() { - let declared = Peer { - epoch: true, - ..Default::default() - }; - - let offered = PeerSetup::new(crate::setup::Extensions::default()); - offered.set(declared); - assert!(offered.get().await.epoch); - - let declined = PeerSetup::new(crate::setup::Extensions { - epoch: false, - ..Default::default() - }); - declined.set(declared); - assert!(!declined.get().await.epoch); - } } diff --git a/rs/moq-net/src/ietf/publish_namespace.rs b/rs/moq-net/src/ietf/publish_namespace.rs index 8dfa0ade274..48ca693f26e 100644 --- a/rs/moq-net/src/ietf/publish_namespace.rs +++ b/rs/moq-net/src/ietf/publish_namespace.rs @@ -1,11 +1,11 @@ //! IETF moq-transport publish namespace messages -use crate::{Epoch, Path, coding::*, ietf::RequestId}; +use super::cluster; +use crate::{Path, coding::*, ietf::RequestId}; use super::Message; use super::namespace::{decode_namespace, encode_namespace}; use super::token::RequestToken; -use super::{cluster, epoch}; use super::Version; @@ -15,14 +15,12 @@ use super::Version; pub struct Negotiated { /// MoQ Cluster: every advertisement carries HOP_PATH, and may carry ROUTE_COST. pub cluster: bool, - /// MoQ Epoch: an advertisement may carry EPOCH. - pub epoch: bool, } impl Negotiated { /// Whether NAMESPACE takes the extended form, with a Parameters field. pub fn extended(&self) -> bool { - self.cluster || self.epoch + self.cluster } } @@ -32,10 +30,6 @@ pub struct AdvertParams { /// The MoQ Cluster parameters (see [`cluster`]). `Some` exactly on a session that /// negotiated the extension. pub cluster: Option, - - /// The MoQ Epoch parameter: the publisher instance the route serves, if it names one. - /// Only on a session that negotiated the extension. - pub epoch: Option, } /// PublishNamespace message (0x06) @@ -69,11 +63,9 @@ impl PublishNamespace { 0x03 => authorization_token: Vec, cluster::HOP_PATH => hops: Option, cluster::ROUTE_COST => cost: Option, - epoch::EPOCH_PARAM => epoch: Option where negotiated.epoch, ); let params = AdvertParams { cluster: cluster_params(negotiated.cluster, hops, cost)?, - epoch, }; // Last, so a malformed field closes the session before a token refusal. let authorization_token = super::token::single(authorization_token)?; @@ -104,7 +96,6 @@ impl<'a> Message<'a> for PublishNamespace { 0x03 => self.authorization_token.clone(), cluster::HOP_PATH => hops, cluster::ROUTE_COST => cost, - epoch::EPOCH_PARAM => self.params.epoch.clone(), ); Ok(()) } @@ -218,7 +209,6 @@ pub(super) fn encode_advert_params( encode_params!(w, version, cluster::HOP_PATH => hops, cluster::ROUTE_COST => cost, - epoch::EPOCH_PARAM => params.epoch.clone(), ); Ok(()) } @@ -232,12 +222,10 @@ pub(super) fn decode_advert_params( decode_params!(r, version, cluster::HOP_PATH => hops: Option, cluster::ROUTE_COST => cost: Option, - epoch::EPOCH_PARAM => epoch: Option where negotiated.epoch, ); Ok(AdvertParams { cluster: cluster_params(negotiated.cluster, hops, cost)?, - epoch, }) } diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index 62e6c8aaada..68e8e3f030d 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -539,9 +539,7 @@ enum Advert { /// Nothing: every route loops through the peer or us, or none is announced. #[default] None, - /// The namespace, with the parameters of the extensions the peer negotiated: the path - /// it traversed and that path's accumulated cost (MoQ Cluster), and the instance it - /// serves (MoQ Epoch). Empty when the peer negotiated neither. + /// The namespace, with its hop path and accumulated cost when MoQ Cluster is negotiated. Some(ietf::AdvertParams), } @@ -658,9 +656,6 @@ struct Namespaces { epoch: u64, /// Whether this discovery cursor includes hidden namespaces. hidden: bool, - /// Whether the peer negotiated MoQ Epoch, so an advertisement names its route's - /// instance. - epochs: bool, } impl Namespaces { @@ -677,7 +672,6 @@ impl Namespaces { gate: None, epoch: 0, hidden: false, - epochs: false, } } @@ -685,7 +679,6 @@ impl Namespaces { fn negotiated(&self) -> ietf::Negotiated { ietf::Negotiated { cluster: self.peer.negotiated(), - epoch: self.epochs, } } @@ -982,7 +975,6 @@ impl Publisher { &self, stream: &mut Stream, path: &crate::Path, - epoch: Option, ) -> Result, Error> { let Some(origin) = self .until_withdrawn(stream, |waiter| self.poll_serving_origin(waiter)) @@ -991,7 +983,7 @@ impl Publisher { return Ok(None); }; // The immediate lookup: answering a peer never starts discovery of its own. - let requesting = origin.lookup(path.clone(), epoch.as_ref()); + let requesting = origin.lookup(path.clone(), None); self.until_withdrawn(stream, |waiter| requesting.poll_ok(waiter)) .await .transpose() @@ -1029,42 +1021,32 @@ impl Publisher { /// /// The origin's announce cursor already filters routes through the peer /// (control-plane split horizon); this only shapes what the wire can carry. - /// `epochs` says the peer negotiated MoQ Epoch, so the route's instance travels too. - fn select(&self, route: &crate::origin::Route, peer: &cluster::Peer, epochs: bool) -> Advert { + fn select(&self, route: &crate::origin::Route, peer: &cluster::Peer) -> Advert { // A route that already passed through us is a reflection. The origin // filters these on receive, so this is defensive. if self.self_origin != crate::Hop::UNKNOWN && route.hops.contains(&self.self_origin) { return Advert::None; } - // Forwarded unchanged, and never invented for a route that arrived without one. - let epoch = route.epoch.clone().filter(|_| epochs); if !peer.negotiated() { - return Advert::Some(ietf::AdvertParams { cluster: None, epoch }); + return Advert::Some(ietf::AdvertParams { cluster: None }); } let cost = route.cost.value(); // Our own Hop ID is always the last entry, so the peer reconstructs the full // path. A chain with no room left is a loop in all but name. match cluster::Advert::forward(&route.hops, cost, self.self_origin) { - Ok(advert) => Advert::Some(ietf::AdvertParams { - cluster: Some(advert), - epoch, - }), + Ok(advert) => Advert::Some(ietf::AdvertParams { cluster: Some(advert) }), Err(_) => Advert::None, } } /// Handle an incoming bidi stream dispatched by the session. - /// - /// `epochs` says both sides negotiated MoQ Epoch: a request naming an instance on a - /// session that did not breaks the session. pub fn handle_stream( &self, id: u64, body: ietf::Body, stream: Stream, - epochs: bool, ) -> Result, Error> { let this = self.clone(); let mut data = body.decoder(this.version); @@ -1088,9 +1070,6 @@ impl Publisher { if !data.is_empty() { return Err(Error::WrongSize); } - if msg.epoch.is_some() && !epochs { - return Err(Error::ProtocolViolation); - } tracing::debug!(message = ?msg, "received subscribe"); let gate = crate::auth::Gate::new( this.auth.clone(), @@ -1120,9 +1099,6 @@ impl Publisher { if !data.is_empty() { return Err(Error::WrongSize); } - if msg.epoch.is_some() && !epochs { - return Err(Error::ProtocolViolation); - } tracing::debug!(message = ?msg, "received fetch"); let gate = this.fetch_gate(&msg); // Owned, since the task outlives the body it was read from. @@ -1207,9 +1183,6 @@ impl Publisher { if !data.is_empty() { return Err(Error::WrongSize); } - if msg.epoch.is_some() && !epochs { - return Err(Error::ProtocolViolation); - } tracing::debug!(message = ?msg, "received track_status"); let gate = crate::auth::Gate::new( this.auth.clone(), @@ -1393,9 +1366,7 @@ impl Publisher { // releasing what it holds upstream, and only then is the peer told. `acked` holds the // group stream count once SUBSCRIBE_OK is buffered, which decides how. let mut acked: Option> = None; - // An instance never comes back, so a request pinned to a gone one is missing, not - // worth waiting for. - let rendezvous = msg.rendezvous && msg.epoch.is_none(); + let rendezvous = msg.rendezvous; let subscribed = { let serve = async { // Stats (subscriptions, viewer refcount, groups/frames/bytes) are counted in @@ -1409,9 +1380,8 @@ impl Publisher { }; // We just received a subscribe for this exact namespace, so the peer must have // already seen the announcement. The immediate lookup resolves it at once, or - // falls back to the route covering it (an `origin::Requests`), if any. Pinned to - // the instance it names, if any: another is refused, never served. - let broadcast = match self.resolve(&mut stream, &msg.track_namespace, msg.epoch.clone()).await { + // falls back to the route covering it (an `origin::Requests`), if any. + let broadcast = match self.resolve(&mut stream, &msg.track_namespace).await { Ok(Some(broadcast)) => broadcast, // The reason is the origin's, not ours: a dynamic router refusing on // authorization or a drain says so, and only an unroutable path means the @@ -2809,9 +2779,6 @@ impl Publisher { .await; } - // Pinned to the instance it names, if any: another is refused, never served. - let epoch = msg.epoch.clone(); - // Draft-22's LOCATION_FILTER is answered as the standalone range it spells. Every other // filter ends at the Largest Object, which resolves once the track does. let mut largest_filter = None; @@ -2888,7 +2855,7 @@ impl Publisher { // The peer must have seen the announcement to name this namespace, so this // resolves like a SUBSCRIBE does. - let broadcast = match gate.guard(self.resolve(&mut stream, &namespace, epoch)).await { + let broadcast = match gate.guard(self.resolve(&mut stream, &namespace)).await { Ok(Some(broadcast)) => broadcast, Ok(None) => return Ok(()), Err(err) => return self.reject_fetch(stream, &err, &err.to_string()).await, @@ -3296,10 +3263,7 @@ impl Publisher { if !gate.allows() { return self.reject_track_status(stream, &Error::Unauthorized).await; } - let broadcast = match gate - .guard(self.resolve(&mut stream, &msg.track_namespace, msg.epoch.clone())) - .await - { + let broadcast = match gate.guard(self.resolve(&mut stream, &msg.track_namespace)).await { Ok(Some(broadcast)) => broadcast, Ok(None) => return Ok(()), Err(err) => return self.reject_track_status(stream, &err).await, @@ -3419,18 +3383,10 @@ impl Publisher { let request = requests.get_mut(suffix); let held_auth = request.as_ref().and_then(|request| request.auth.clone()); let unchanged = advert == watch.sent && auth == held_auth; - // The epoch names the advertisement's instance for as long as it stands, so an - // update never changes it (MoQ Epoch). One instance named by an epoch is replaced - // by another in place, the new advertised before the old is withdrawn, so the peer - // never sees the namespace absent. Gaining or losing an epoch withdraws and - // advertises afresh. - let (held_epoch, epoch) = (watch.sent.params().epoch, advert.params().epoch); - let renamed = wanted && held && held_epoch != epoch; - let replaced = renamed && held_epoch.is_some() && epoch.is_some(); // moq-transport renames a request's auth with REQUEST_UPDATE, but cannot name one on // a request that had none, nor drop one: those withdraw the request and make it // again. - let restart = renamed || held_auth != auth && (held_auth.is_none() || auth.is_none()); + let restart = held_auth != auth && (held_auth.is_none() || auth.is_none()); // An update already waiting or in flight carries whatever is current once it goes // out, and its answer brings the loop back here for anything after that. @@ -3475,21 +3431,8 @@ impl Publisher { } self.withdraw_namespace(target, requests, suffix.clone()).await?; } - (true, Some(_)) if replaced => { - // Separate streams are unordered, so the old one goes only once the - // peer answered the new one, refused or not: it serves another - // instance either way. - tracing::debug!(broadcast = %absolute, "publish_namespace for another epoch"); - let old = requests.remove(suffix); - refused = self - .advertise_namespace(requests, watch, path, suffix.clone(), advert.params(), auth) - .await?; - if let Some(old) = old { - end_request(old.stream); - } - } (true, Some(_)) => { - tracing::debug!(broadcast = %absolute, renamed, "publish_namespace restart"); + tracing::debug!(broadcast = %absolute, "publish_namespace restart"); self.withdraw_namespace(target, requests, suffix.clone()).await?; refused = self .advertise_namespace(requests, watch, path, suffix.clone(), advert.params(), auth) @@ -3517,14 +3460,6 @@ impl Publisher { Target::Inline(stream) => { match (advert.wanted(), held) { (true, _) => { - // A repeat under another epoch replaces the instance in place. - if renamed && !replaced { - tracing::debug!(broadcast = %absolute, "namespace_done for an epoch gained or lost"); - stream - .writer - .encode_message(&ietf::NamespaceDone { suffix: suffix.clone() }) - .await?; - } tracing::debug!(broadcast = %absolute, "namespace"); stream .writer @@ -3676,7 +3611,7 @@ impl Publisher { ) -> Option<(Advert, Option)> { let watch = ns.watched.get(suffix)?; let advert = match ns.permitted(path) { - true => self.select(&watch.route, &ns.peer, ns.epochs), + true => self.select(&watch.route, &ns.peer), false => Advert::None, }; let auth = match (&ns.target, advert.wanted()) { @@ -3940,8 +3875,7 @@ impl Publisher { /// /// Unlike a request, an advertisement refused for credit comes back on the retry timer: /// it is our own state the peer should hold, and credit returning raises no signal the - /// loop could wait on. A replacement under a new epoch needs this too, since the - /// instance it replaces still holds its stream when the new one opens. + /// loop could wait on. async fn open_request(&self) -> Result>, Error> { let mut session = self.session.clone(); let mut open = std::pin::pin!(Stream::open_request(&mut session, self.version)); @@ -4049,8 +3983,7 @@ impl Publisher { .advertising(self.origin.clone(), &peer) .discovery(!self.peer_setup.get().await.hidden || self.origin.includes_hidden()); - let mut ns = Namespaces::new(peer, Target::Requests); - ns.epochs = self.peer_setup.get().await.epoch; + let ns = Namespaces::new(peer, Target::Requests); self.run_namespaces(origin.announced(), crate::Path::empty(), ns, Vec::new()) .await } @@ -4135,7 +4068,7 @@ impl Publisher { let count = initial .iter() .filter(|update| permit.matches(prefix.rejoin(&update.prefix).as_str())) - .filter(|update| self.select(&update.route, &peer, declared.epoch).wanted()) + .filter(|update| self.select(&update.route, &peer).wanted()) .count(); (initial, Some(count as u64)) } @@ -4153,7 +4086,6 @@ impl Publisher { let mut ns = Namespaces::new(peer, target); ns.gate = Some(gate); ns.hidden = !declared.hidden || msg.hidden || self.origin.includes_hidden(); - ns.epochs = declared.epoch; self.run_namespaces(announced, prefix, ns, initial).await } @@ -4249,11 +4181,11 @@ impl Publisher { let event = { let Namespaces { target, - epoch, requests, inflight, woken, updates, + epoch, gate, .. } = &mut ns; @@ -4414,10 +4346,8 @@ impl Publisher { } NamespaceEvent::Update(Some((update, active, restart))) => { // moq-transport has no restart: the peer sees the namespace end and start - // again, and resubscribes. One that tells instances apart (MoQ Epoch) takes - // another epoch in place instead, which `sync_namespace` makes before it - // breaks the old. - if restart && !Self::replaces(&ns, &update) { + // again, and resubscribes. + if restart { self.apply_update(&mut ns, &prefix, update.clone(), false).await?; } self.apply_update(&mut ns, &prefix, update, active).await?; @@ -4431,16 +4361,6 @@ impl Publisher { res } - /// Whether a restart onto `update` replaces one instance the peer holds by epoch with - /// another, rather than ending the advertisement. - fn replaces(ns: &Namespaces, update: &crate::announce::Announce) -> bool { - let held = ns - .watched - .get(&update.prefix) - .and_then(|watch| watch.sent.params().epoch); - ns.epochs && held.is_some() && update.route.epoch.is_some() && held != update.route.epoch - } - /// Reconcile what the peer holds with one route (un)announce. async fn apply_update( &self, @@ -7186,7 +7106,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, } .encode_msg(&mut Encoder::new(&mut fetch_body, version.into()), version) .unwrap(); @@ -7198,10 +7117,7 @@ mod serve_tests { let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) .await .unwrap(); - let task = h - .publisher - .handle_stream(id, ietf::Body(body.clone()), stream, false) - .unwrap(); + let task = h.publisher.handle_stream(id, ietf::Body(body.clone()), stream).unwrap(); assert_eq!(h.publisher.owed.load(Ordering::Relaxed), 1, "count before polling"); drop(task); assert_eq!(h.publisher.owed.load(Ordering::Relaxed), 0, "release a cancelled task"); @@ -7211,7 +7127,7 @@ mod serve_tests { .unwrap(); assert!( h.publisher - .handle_stream(id, ietf::Body(bytes::Bytes::new()), stream, false) + .handle_stream(id, ietf::Body(bytes::Bytes::new()), stream) .is_err() ); assert_eq!(h.publisher.owed.load(Ordering::Relaxed), 0, "release malformed input"); @@ -7220,10 +7136,7 @@ mod serve_tests { let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) .await .unwrap(); - h.publisher - .handle_stream(id, ietf::Body(body), stream, false) - .unwrap() - .await; + h.publisher.handle_stream(id, ietf::Body(body), stream).unwrap().await; assert_eq!(h.publisher.owed.load(Ordering::Relaxed), 0, "release a completed fetch"); } } @@ -8190,12 +8103,7 @@ mod serve_tests { let closed = h .publisher .clone() - .handle_stream( - ietf::TrackStatus::ID, - ietf::Body(bytes::Bytes::from(body)), - stream, - false, - ) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(bytes::Bytes::from(body)), stream) .err(); assert!(matches!(closed, Some(Error::WrongSize)), "{version}: {closed:?}"); } @@ -8514,7 +8422,6 @@ mod serve_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } } @@ -8597,178 +8504,6 @@ mod serve_tests { } /// The refusal of request [`REQUEST_ID`] as gone. - async fn unroutable(version: Version) -> Vec { - let log = crate::lite::test_transport::Log::default(); - let mut writer = crate::coding::Writer::new( - crate::transport::boxed::SendStream::new(crate::lite::test_transport::SinkSend::new(log.clone())), - version, - ); - writer.varint(ietf::RequestError::ID).await.unwrap(); - writer - .encode(&ietf::RequestError { - error_code: 0x10, - reason_phrase: Error::Unroutable.to_string().into(), - retry_interval: 0, - }) - .await - .unwrap(); - log.writes.lock().unwrap().clone() - } - - /// Each request MoQ Epoch pins to an instance, naming `epoch`, encoded for `version`. - fn pinned_requests(version: Version, epoch: &crate::Epoch) -> [(u64, Vec); 3] { - let mut subscribe = subscribe(Filter::NextObject, None); - subscribe.epoch = Some(epoch.clone()); - let fetch = ietf::Fetch { - request_id: RequestId(REQUEST_ID), - subscriber_priority: 128, - group_order: GroupOrder::Ascending, - fetch_type: fetch_range( - version, - "video", - Location { group: 0, object: 0 }, - Location { group: 0, object: 1 }, - ), - range_filters: false, - fill_timeout: false, - properties_wanted: true, - epoch: Some(epoch.clone()), - }; - let status = ietf::TrackStatus { - request_id: RequestId(REQUEST_ID), - track_namespace: crate::Path::from_static("room"), - track_name: "video".into(), - properties_wanted: true, - epoch: Some(epoch.clone()), - }; - let mut bodies: [Vec; 3] = Default::default(); - subscribe - .encode_msg(&mut Encoder::new(&mut bodies[0], version.into()), version) - .unwrap(); - fetch - .encode_msg(&mut Encoder::new(&mut bodies[1], version.into()), version) - .unwrap(); - status - .encode_msg(&mut Encoder::new(&mut bodies[2], version.into()), version) - .unwrap(); - let [subscribe, fetch, status] = bodies; - [ - (ietf::Subscribe::ID, subscribe), - (ietf::Fetch::ID, fetch), - (ietf::TrackStatus::ID, status), - ] - } - - /// MoQ Epoch pins SUBSCRIBE, FETCH and TRACK_STATUS to the instance they name: the - /// broadcast under the path now being another instance, or one with no epoch at all, - /// refuses them as gone instead of serving another instance's content. - #[moq_clock::test] - async fn a_request_for_another_instance_is_refused() { - for version in [Version::Draft22] { - let served = crate::Epoch::mint(); - let stale = crate::Epoch::mint(); - let pinned = crate::origin::Route::default().with_epoch(served.clone()); - for (name, route, named, refused) in [ - ("another epoch", pinned.clone(), &stale, true), - ("no epoch", crate::origin::Route::default(), &stale, true), - ("its epoch", pinned, &served, false), - ] { - let mut h = serve_route(version, crate::track::Info::timed(), route.clone()); - publish_groups(&mut h, 0); - settle().await; - let expected = unroutable(version).await; - for (id, body) in pinned_requests(version, named) { - let mark = h.log.writes.lock().unwrap().len(); - let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) - .await - .unwrap(); - let mut task = h - .publisher - .clone() - .handle_stream(id, ietf::Body(bytes::Bytes::from(body)), stream, true) - .unwrap(); - // A served SUBSCRIBE parks at the live edge, so poll rather than await. - for _ in 0..50 { - if futures::poll!(task.as_mut()).is_ready() { - break; - } - settle().await; - } - let wire = h.log.writes.lock().unwrap()[mark..].to_vec(); - let found = wire.windows(expected.len()).any(|window| window == expected.as_slice()); - assert_eq!(found, refused, "{version} {name}: request {id:#x}"); - } - } - } - } - - /// A SUBSCRIBE pinned to a gone instance is refused as missing even when it asks to - /// wait: an instance never comes back, so there is nothing to rendezvous with. - #[moq_clock::test] - async fn a_pinned_request_never_waits_for_its_instance() { - for version in [Version::Draft22] { - let stale = crate::Epoch::mint(); - let pinned = crate::origin::Route::default().with_epoch(crate::Epoch::mint()); - for (name, route) in [("another epoch", pinned), ("no epoch", crate::origin::Route::default())] { - let mut h = serve_route(version, crate::track::Info::timed(), route); - publish_groups(&mut h, 0); - settle().await; - let expected = unroutable(version).await; - - // Built by hand: we never send RENDEZVOUS_TIMEOUT ourselves. - let encode = |body: &mut Vec| -> Result<(), crate::coding::EncodeError> { - let w = &mut Encoder::new(body, version.into()); - RequestId(REQUEST_ID).encode(w, version)?; - super::super::namespace::encode_track(w, &crate::Path::from_static("room"), "video")?; - encode_params!(w, version, - 0x04 => 7u64, - super::super::epoch::EPOCH_PARAM => Some(stale.clone()), - ); - Ok(()) - }; - let mut body = Vec::new(); - encode(&mut body).unwrap(); - - let mark = h.log.writes.lock().unwrap().len(); - let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) - .await - .unwrap(); - h.publisher - .clone() - .handle_stream(ietf::Subscribe::ID, ietf::Body(body.into()), stream, true) - .unwrap() - .await; - let wire = h.log.writes.lock().unwrap()[mark..].to_vec(); - assert!( - wire.windows(expected.len()).any(|window| window == expected.as_slice()), - "{version} {name}" - ); - } - } - } - - /// An EPOCH on a request breaks a session that did not negotiate MoQ Epoch: the peer - /// cannot have learned an instance it was never told about. - #[moq_clock::test] - async fn an_epoch_without_the_extension_is_a_violation() { - for version in [Version::Draft22] { - let h = serve(version); - for (id, body) in pinned_requests(version, &crate::Epoch::mint()) { - let stream = Stream::open(&mut crate::driver::Transport::new(h.session.clone()), version) - .await - .unwrap(); - let result = h - .publisher - .clone() - .handle_stream(id, ietf::Body(bytes::Bytes::from(body)), stream, false); - assert!( - matches!(result, Err(Error::ProtocolViolation)), - "{version}: request {id:#x}" - ); - } - } - } - const ALL_VERSIONS: [Version; 2] = [Version::Draft18, Version::Draft22]; fn track_status(namespace: &str, wanted: bool, version: Version) -> Vec { @@ -8777,7 +8512,6 @@ mod serve_tests { track_namespace: crate::Path::new(namespace).unwrap(), track_name: "video".into(), properties_wanted: wanted, - epoch: None, }; let mut body = Vec::new(); msg.encode_msg(&mut Encoder::new(&mut body, version.into()), version) @@ -8804,12 +8538,7 @@ mod serve_tests { let body = track_status("room", wanted, version); h.publisher .clone() - .handle_stream( - ietf::TrackStatus::ID, - ietf::Body(bytes::Bytes::from(body)), - stream, - false, - ) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(bytes::Bytes::from(body)), stream) .unwrap() .await; assert!(h.log.resets().is_empty(), "{version}: the answer was reset"); @@ -8889,12 +8618,7 @@ mod serve_tests { let mut answer = std::pin::pin!( h.publisher .clone() - .handle_stream( - ietf::TrackStatus::ID, - ietf::Body(bytes::Bytes::from(body)), - stream, - false - ) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(bytes::Bytes::from(body)), stream,) .unwrap() ); assert!(futures::poll!(answer.as_mut()).is_pending(), "{version}"); @@ -8980,7 +8704,6 @@ mod serve_tests { track_namespace: crate::Path::from_static("room"), track_name: "video".into(), properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -9020,12 +8743,7 @@ mod serve_tests { let mark = h.log.writes.lock().unwrap().len(); h.publisher .clone() - .handle_stream( - ietf::TrackStatus::ID, - ietf::Body(bytes::Bytes::from(body)), - stream, - false, - ) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(bytes::Bytes::from(body)), stream) .unwrap() .await; refusal_code(&h.log.writes.lock().unwrap()[mark..], version) @@ -9094,7 +8812,7 @@ mod serve_tests { let mark = h.log.writes.lock().unwrap().len(); h.publisher .clone() - .handle_stream(id, ietf::Body(bytes::Bytes::from(body)), stream, false) + .handle_stream(id, ietf::Body(bytes::Bytes::from(body)), stream) .unwrap_or_else(|e| panic!("{version}: the request closed the session: {e}")) .await; assert!(h.log.resets().is_empty(), "{version}: refusal was reset"); @@ -9140,7 +8858,6 @@ mod serve_tests { properties_wanted: true, range_filters: true, fill_timeout: false, - epoch: None, }, ) .await @@ -9205,7 +8922,7 @@ mod serve_tests { let mut serving = std::pin::pin!( h.publisher .clone() - .handle_stream(ietf::TrackStatus::ID, ietf::Body(body.into()), stream, false) + .handle_stream(ietf::TrackStatus::ID, ietf::Body(body.into()), stream) .unwrap() ); let done = futures::poll!(serving.as_mut()); @@ -9349,7 +9066,6 @@ mod serve_tests { ietf::SubscribeNamespace::ID, ietf::Body(bytes::Bytes::from(body)), stream, - false, ) .unwrap_or_else(|e| panic!("{version}: the request closed the session: {e}")); let mut task = std::pin::pin!(task); @@ -10104,7 +9820,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await?; @@ -10239,7 +9954,7 @@ mod serve_tests { .unwrap(); let mut serving = h .publisher - .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream, false) + .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream) .unwrap(); let mut fetching = Box::pin(joining_fetch(&h, 0)); assert!( @@ -10276,7 +9991,7 @@ mod serve_tests { .unwrap(); let mut serving = h .publisher - .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream, false) + .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream) .unwrap(); match futures::future::select(&mut fetching, &mut serving).await { futures::future::Either::Left((response, _)) => { @@ -10301,7 +10016,7 @@ mod serve_tests { .unwrap(); let serving = h .publisher - .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream, false) + .handle_stream(ietf::Subscribe::ID, ietf::Body(bytes::Bytes::from(data)), stream) .unwrap(); let mut fetching = Box::pin(joining_fetch(&h, 0)); assert!(futures::poll!(fetching.as_mut()).is_pending()); @@ -10427,7 +10142,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -10656,7 +10370,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted, - epoch: None, }, ) .await @@ -10863,7 +10576,6 @@ mod serve_tests { ietf::TrackStatus::ID, ietf::Body(track_status("room", true, version).into()), stream, - false, ) .unwrap() .await; @@ -11684,7 +11396,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); // Driven until FETCH_OK is out, so the fetch is parked on uni stream credit. @@ -11767,7 +11478,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -11885,7 +11595,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); // Driven until FETCH_OK is out, so the fetch is parked on uni stream credit. @@ -12013,7 +11722,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -12280,7 +11988,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -12295,7 +12002,6 @@ mod serve_tests { track_namespace: crate::Path::from_static("room"), track_name: "video".into(), properties_wanted: true, - epoch: None, }, ) .await @@ -12499,7 +12205,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -12552,7 +12257,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -14413,7 +14117,7 @@ mod tests { let local = announced.assert_next_active("from/us"); announced.assert_next_wait(); - assert_eq!(publisher.select(&local, &peer, false), Advert::Some(Default::default())); + assert_eq!(publisher.select(&local, &peer), Advert::Some(Default::default())); } /// An anonymous chain received from an identified peer keeps the 0 on the wire @@ -14756,89 +14460,6 @@ mod tests { ); } - /// MoQ Epoch: a restart onto another epoch advertises the new instance before it - /// withdraws the old, and only once the peer accepted it, since the two streams are - /// unordered. The peer never sees the namespace absent. A peer without the extension - /// cannot tell the two apart, so it still sees the old one withdrawn first. - #[moq_clock::test] - async fn another_epoch_is_advertised_before_the_old_is_withdrawn() { - use crate::lite::test_transport::Sent; - const VERSION: Version = Version::Draft18; - - for epochs in [true, false] { - let origin = crate::origin::Config::new(crate::Hop::new(1).unwrap()).produce(); - let _old = origin - .announce("cam", crate::origin::Route::default().with_epoch(crate::Epoch::mint())) - .unwrap(); - settle().await; - - let ok = publish_namespace_ok(VERSION).await; - let session = crate::lite::test_transport::ScriptedSession::per_stream(vec![ok.clone(), ok]); - let log = session.log.clone(); - let declared = peer::PeerSetup::default(); - declared.set(peer::Peer { - solicit: Some(false), - epoch: epochs, - ..Default::default() - }); - let publisher = Publisher::new( - crate::time::sim(), - crate::driver::Transport::new(session.clone()), - origin.consume(), - Control::new(false), - None, - declared, - VERSION, - ); - - let mut run = std::pin::pin!(publisher.run_publish_namespaces()); - let mut _new = None; - for count in [1, 2] { - for _ in 0..100 { - assert!(futures::poll!(run.as_mut()).is_pending()); - if occurrences(&log, b"cam") >= count { - break; - } - settle().await; - } - assert_eq!(occurrences(&log, b"cam"), count, "epochs: {epochs}"); - if count == 1 { - // A newer epoch outranks the old at the same path: a restart. - let route = crate::origin::Route::default().with_epoch(crate::Epoch::mint()); - _new = Some(origin.announce("cam", route).unwrap()); - } - } - for _ in 0..10 { - assert!(futures::poll!(run.as_mut()).is_pending()); - settle().await; - } - - // Where each advertisement went out, and where the first one was withdrawn. - let trail = log.trail(); - let advertised: Vec<(usize, usize)> = trail - .iter() - .enumerate() - .filter_map(|(at, (stream, sent))| match sent { - Sent::Write(bytes) if bytes.windows(3).any(|window| window == b"cam") => Some((at, *stream)), - _ => None, - }) - .collect(); - let [(_, old), (made, new)] = advertised[..] else { - panic!("epochs: {epochs}: expected two advertisements, got {advertised:?}"); - }; - assert_ne!(old, new, "epochs: {epochs}: one request carried both"); - let broken = trail - .iter() - .position(|(stream, sent)| *stream == old && matches!(sent, Sent::Reset(_))) - .unwrap_or_else(|| panic!("epochs: {epochs}: the old advertisement was never withdrawn")); - assert_eq!( - made < broken, - epochs, - "epochs: {epochs}: advertised at {made}, withdrew at {broken}" - ); - } - } - async fn publish_namespace_ok(version: Version) -> Vec { let log = crate::lite::test_transport::Log::default(); let mut writer = crate::coding::Writer::new( @@ -15496,7 +15117,6 @@ mod tests { max_age: false, auth: false, active_count: false, - epoch: false, flate: false, }); slot @@ -16665,7 +16285,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }, ) .await @@ -16694,7 +16313,6 @@ mod tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -17122,7 +16740,6 @@ mod range_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } } diff --git a/rs/moq-net/src/ietf/publisher/tracks.rs b/rs/moq-net/src/ietf/publisher/tracks.rs index 066a563f983..42bf68fc327 100644 --- a/rs/moq-net/src/ietf/publisher/tracks.rs +++ b/rs/moq-net/src/ietf/publisher/tracks.rs @@ -1411,7 +1411,7 @@ mod tests { .unwrap(); let id = accepted.reader.varint().await.unwrap(); let body: ietf::Body = accepted.reader.decode().await.unwrap(); - let task = self.publisher.handle_stream(id, body, accepted, false).unwrap(); + let task = self.publisher.handle_stream(id, body, accepted).unwrap(); moq_clock::sim::spawn(task); stream } @@ -1800,7 +1800,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, max_age: None, new_group: None, }; @@ -2313,7 +2312,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, max_age: None, new_group: None, }; diff --git a/rs/moq-net/src/ietf/session.rs b/rs/moq-net/src/ietf/session.rs index 28a7f6f5c14..f23e65d165f 100644 --- a/rs/moq-net/src/ietf/session.rs +++ b/rs/moq-net/src/ietf/session.rs @@ -10,7 +10,7 @@ use crate::{ }; use super::{ - Control, Message, Publisher, Subscriber, Version, active_count, auth, cluster, epoch, hidden, max_age, peer, + Control, Message, Publisher, Subscriber, Version, active_count, auth, cluster, hidden, max_age, peer, request_update, solicit, subscriber::is_protocol_violation, }; @@ -192,7 +192,7 @@ pub fn start(config: Config) -> Result<(Driver, crate::goaway::Handle, Option peer_setup.set(declared), @@ -603,7 +603,6 @@ fn peer_from_params(params: &ietf::Parameters, version: Version) -> Result serve, false => None, }; - // Whether requests and PUBLISH_NAMESPACE may carry EPOCH (MoQ Epoch). - let epoch = declared_setup.epoch; // From the same slot, so this costs nothing extra: it decides whether an unsolicited // advertisement is the peer ignoring our own SETUP (MoQ Solicit). @@ -1064,7 +1058,6 @@ async fn run_dispatch( publisher, subscriber, peer, - epoch, declared, serve, version, @@ -1118,8 +1111,6 @@ struct Bidi { publisher: Publisher, subscriber: Subscriber, peer: cluster::Peer, - /// Whether both sides negotiated MoQ Epoch. - epoch: bool, declared: Option, serve: Option, version: Version, @@ -1133,7 +1124,6 @@ impl Bidi { publisher, mut subscriber, peer, - epoch, declared, serve, version, @@ -1188,11 +1178,11 @@ impl Bidi { | ietf::SubscribeNamespace::ID | ietf::SubscribeTracks::ID | ietf::TrackStatus::ID => { - publisher.handle_stream(id, data, stream, epoch)?.await; + publisher.handle_stream(id, data, stream)?.await; } // Subscriber handles: Publish, PublishNamespace ietf::Publish::ID | ietf::PublishNamespace::ID => { - subscriber.handle_stream(id, data, stream, peer, epoch, declared)?.await; + subscriber.handle_stream(id, data, stream, peer, declared)?.await; } auth::Auth::ID if let Some(serve) = serve => { let mut data = data.decoder(version); @@ -1449,7 +1439,6 @@ mod tests { track_namespace: crate::Path::from_static("test"), track_name: "video".into(), properties_wanted: true, - epoch: None, } .encode_msg(&mut encoder, version) .unwrap(); @@ -2753,7 +2742,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } .encode(&mut encoder, VERSION) .unwrap(); diff --git a/rs/moq-net/src/ietf/subscribe.rs b/rs/moq-net/src/ietf/subscribe.rs index 840e8c589a3..b6dc4000f04 100644 --- a/rs/moq-net/src/ietf/subscribe.rs +++ b/rs/moq-net/src/ietf/subscribe.rs @@ -11,7 +11,6 @@ use crate::{ use super::token::RequestToken; use super::Message; -use super::epoch; use super::namespace::{decode_track, encode_track}; use super::Version; @@ -47,9 +46,6 @@ pub struct Subscribe<'a> { pub new_group: Option, /// Subscriber max age in milliseconds (MoQ Timestamp), if negotiated. pub max_age: Option, - /// The publisher instance the subscriber expects (MoQ Epoch). Only on a - /// session that negotiated it; the session refuses one that arrives otherwise. - pub epoch: Option, } impl Subscribe<'_> { @@ -70,7 +66,6 @@ impl Subscribe<'_> { authorization_token: self.authorization_token, new_group: self.new_group, max_age: self.max_age, - epoch: self.epoch, } } } @@ -104,7 +99,6 @@ impl<'a> Message<'a> for Subscribe<'a> { 0x28 => object_property_filter: Vec where has_range_filters(version), 0x32 => new_group: Option, 0x35 => include_properties: Option where Filter::is_draft22(version), - epoch::EPOCH_PARAM => epoch: Option, super::max_age::PARAMETER => max_age: Option, ); let authorization_token = super::token::single(authorization_token)?; @@ -145,7 +139,6 @@ impl<'a> Message<'a> for Subscribe<'a> { authorization_token, new_group, max_age: super::max_age::validate(max_age)?, - epoch, }) } @@ -162,8 +155,6 @@ impl<'a> Message<'a> for Subscribe<'a> { // arrived in draft-22, and an older peer would read it as an unknown // parameter, which is a protocol violation. let include_properties = (!self.properties_wanted && Filter::is_draft22(version)).then_some(false); - // Only a session that negotiated MoQ Epoch names one. - let epoch = self.epoch.clone(); encode_params!(w, version, 0x03 => self.authorization_token.clone(), @@ -174,7 +165,6 @@ impl<'a> Message<'a> for Subscribe<'a> { 0x23 => fill, 0x32 => self.new_group, 0x35 => include_properties, - epoch::EPOCH_PARAM => epoch, super::max_age::PARAMETER => self.max_age, ); @@ -344,7 +334,6 @@ mod tests { range_filters: false, authorization_token: None, new_group: None, - epoch: None, }; let wire = encode_message(&msg, version); @@ -385,7 +374,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let encoded = encode_message(&msg, Version::Draft18); @@ -420,7 +408,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let wire = encode_message(&subscribe, version); @@ -512,7 +499,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; for version in [Version::Draft18, Version::Draft22] { @@ -548,7 +534,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let encoded = encode_message(&msg, Version::Draft18); @@ -672,7 +657,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let encoded = encode_message(&msg, version); @@ -745,7 +729,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let encoded = encode_message(&msg, Version::Draft18); @@ -933,7 +916,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; #[rustfmt::skip] @@ -990,7 +972,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let wire = encode_message(&msg, version); diff --git a/rs/moq-net/src/ietf/subscribe_namespace.rs b/rs/moq-net/src/ietf/subscribe_namespace.rs index 5ceb1f74fec..fcb2964d782 100644 --- a/rs/moq-net/src/ietf/subscribe_namespace.rs +++ b/rs/moq-net/src/ietf/subscribe_namespace.rs @@ -67,15 +67,14 @@ impl<'a> Message<'a> for SubscribeNamespace { /// Indicates a namespace suffix matching the subscribed prefix is active. /// /// The base message carries only the suffix. A session that negotiated the MoQ Cluster -/// or MoQ Epoch extension uses the extended form instead, which appends one Parameters -/// field for both, so the advertisement can carry its HOP_PATH and ROUTE_COST (see -/// [`super::cluster`]) and its EPOCH (see [`super::epoch`]). +/// extension appends a Parameters field carrying HOP_PATH and ROUTE_COST (see +/// [`super::cluster`]). #[derive(Clone, Debug)] pub struct Namespace { pub suffix: Path, /// The extension parameters. `Some` selects the extended form; `None` the base one. - /// An endpoint must not append them on a session that negotiated neither extension. + /// An endpoint must not append them on a session without MoQ Cluster. pub params: Option, } @@ -150,19 +149,7 @@ mod tests { cluster::HopPath::new(crate::Hops::try_from(hops).unwrap()) } - const CLUSTER: Negotiated = Negotiated { - cluster: true, - epoch: false, - }; - const EPOCH: Negotiated = Negotiated { - cluster: false, - epoch: true, - }; - const BOTH: Negotiated = Negotiated { - cluster: true, - epoch: true, - }; - + const CLUSTER: Negotiated = Negotiated { cluster: true }; fn decode(bytes: Vec, version: Version, negotiated: Negotiated) -> Result<(Namespace, bool), DecodeError> { let mut buf = bytes::Bytes::from(bytes); let decoded = crate::coding::decode_buf(&mut buf, version, |r, v| Namespace::decode_body(r, v, negotiated))?; @@ -175,7 +162,6 @@ mod tests { hops: hop_path(hops), cost, }), - epoch: None, }) } @@ -227,80 +213,6 @@ mod tests { assert_eq!(decoded.params.unwrap().cluster.unwrap().cost, 0); } - /// MoQ Epoch alone extends NAMESPACE too: the block is present, empty for a route - /// without an epoch, and carries EPOCH for one with. - #[test] - fn epoch_namespace_round_trips() { - let version = Version::Draft22; - let epoch = crate::Epoch::mint(); - for epoch in [None, Some(epoch)] { - let msg = Namespace { - suffix: Path::from_static("a"), - params: Some(AdvertParams { - cluster: None, - epoch: epoch.clone(), - }), - }; - let (decoded, consumed) = decode(body(&msg, version), version, EPOCH).unwrap(); - assert!(consumed); - assert_eq!(decoded.params, msg.params, "{epoch:?}"); - } - } - - /// With both extensions, one block holds the parameters of both. - #[test] - fn both_extensions_share_one_block() { - let version = Version::Draft22; - let mut params = clustered(&[7], 3).unwrap(); - params.epoch = Some(crate::Epoch::mint()); - let msg = Namespace { - suffix: Path::from_static("a"), - params: Some(params), - }; - let encoded = body(&msg, version); - let (decoded, consumed) = decode(encoded.clone(), version, BOTH).unwrap(); - assert!(consumed); - assert_eq!(decoded.params, msg.params); - - // Read as the base form, a single block is all that is left over. - let mut suffix = Vec::new(); - encode_namespace(&mut Encoder::new(&mut suffix, version.into()), &Path::from_static("a")).unwrap(); - let mut block = Vec::new(); - super::super::publish_namespace::encode_advert_params( - &mut Encoder::new(&mut block, version.into()), - version, - msg.params.as_ref().unwrap(), - ) - .unwrap(); - assert_eq!(encoded, [suffix, block].concat()); - } - - /// EPOCH on a session that did not negotiate MoQ Epoch is an unknown parameter, and so - /// is a malformed one on a session that did. - #[test] - fn epoch_refused_unless_negotiated_and_well_formed() { - let version = Version::Draft22; - let msg = Namespace { - suffix: Path::from_static("a"), - params: Some(AdvertParams { - cluster: clustered(&[7], 0).unwrap().cluster, - epoch: Some(crate::Epoch::mint()), - }), - }; - assert!(matches!( - decode(body(&msg, version), version, CLUSTER), - Err(DecodeError::InvalidValue) - )); - - let mut buf = Vec::new(); - encode_namespace(&mut Encoder::new(&mut buf, version.into()), &Path::from_static("a")).unwrap(); - let w = &mut Encoder::new(&mut buf, version.into()); - w.varint(1).unwrap(); - w.varint(super::super::epoch::EPOCH_PARAM).unwrap(); - w.bytes(&[0; 16]).unwrap(); - assert!(matches!(decode(buf, version, EPOCH), Err(DecodeError::InvalidValue))); - } - /// A negotiated session that omits HOP_PATH is a protocol violation. #[test] fn cluster_namespace_requires_hop_path() { @@ -330,7 +242,6 @@ mod tests { hops: hop_path(&[7]), cost: 0, }), - epoch: None, }, authorization_token: None, }; diff --git a/rs/moq-net/src/ietf/subscriber.rs b/rs/moq-net/src/ietf/subscriber.rs index ed6fa325a39..60c2f21e299 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -752,12 +752,11 @@ struct TrackState { // stream and the subgroup stream carrying the rest of the group. fill: kio::Producer, - // The broadcast this track was subscribed from. With the track name and the instance - // it names, it forms the full track name, which is what decides whether a repeated + // The broadcast this track was subscribed from. With the track name, it forms the + // full track name, which is what decides whether a repeated // alias is the fatal collision (one alias, two tracks) or the legal sharing of an alias // across subscriptions. broadcast: Path, - epoch: Option, // Units for this track's object Timestamps, from the TIMESCALE Track Property in // SUBSCRIBE_OK. `None` until it arrives, and for a track that declares none: its @@ -805,7 +804,6 @@ impl TrackState { name, alias: None, broadcast, - epoch: None, timescale: None, fill_largest: None, fill_start: None, @@ -885,14 +883,6 @@ struct Advertised { route: crate::origin::Route, } -impl Advertised { - /// The publisher instance the advertisement named (MoQ Epoch), taken as given. - fn with_epoch(mut self, epoch: Option) -> Self { - self.route.epoch = epoch; - self - } -} - /// One NAMESPACE a SUBSCRIBE_NAMESPACE stream holds, live on the wire until its /// NAMESPACE_DONE whether or not its route is attached. struct Advertisement { @@ -900,8 +890,6 @@ struct Advertisement { /// [`Subscriber::update_announce`]; `None` while it loops back through us or falls /// outside the scope. id: Option, - /// The publisher instance it names: a repeat may name another, but not gain or lose one. - epoch: Option, /// Counts it against the session's announce cap until its NAMESPACE_DONE, attached or /// not; the namespace's route shares it rather than taking a second. slot: crate::auth::Hold, @@ -911,9 +899,6 @@ struct Advertisement { struct Held { /// The MoQ Cluster parameters, which a REQUEST_UPDATE carries only when they change. cluster: Option, - /// The MoQ Epoch instance, fixed for the advertisement's life: REQUEST_UPDATE cannot - /// carry one. - epoch: Option, } /// A joining request may be abandoned before it takes an ID. Once committed, its header @@ -963,10 +948,6 @@ impl Drop for JoiningTask { pub(super) struct Subscriber { // Scoped to a minted source on the clone that serves its requests. validity: crate::model::broadcast::RequestValidity, - // The publisher instance the minted source was resolved under (MoQ Epoch), named on - // every request for it, so the peer refuses rather than answer from another. Scoped - // like `validity`, and only ever set on a session that negotiated the extension. - epoch: Option, // Arms the track-alias and request-id timeouts. runtime: crate::time::Deadlines, session: Transport, @@ -1104,7 +1085,6 @@ impl Subscriber { announces: Default::default(), listings: Default::default(), validity: Default::default(), - epoch: None, } } @@ -1321,8 +1301,7 @@ impl Subscriber { let (Some(held), Some(new)) = (state.subscribes.get(&holder), state.subscribes.get(&request_id)) else { return false; }; - - held.broadcast == new.broadcast && held.epoch == new.epoch && held.name == new.name + held.broadcast == new.broadcast && held.name == new.name } /// Take the origin request back out of a subscription that is still setting up. @@ -1461,7 +1440,6 @@ impl Subscriber { let peer = self.peer().await; let negotiated = ietf::Negotiated { cluster: peer.negotiated(), - epoch: declared.epoch, }; self.run_namespace_entries(request, &peer, negotiated, Initial { initial, snapshot }, live) @@ -1570,22 +1548,14 @@ impl Subscriber { let path = prefix.join(&msg.suffix)?; let params = msg.params.unwrap_or_default(); let held = match live.entry(path.clone()) { - // A repeat under another epoch replaces the instance in place, but one that - // gains or loses an epoch skipped the NAMESPACE_DONE it needs. - Entry::Occupied(entry) if entry.get().epoch.is_some() != params.epoch.is_some() => { - tracing::warn!(%path, "namespace repeated gaining or losing an epoch"); - return Err(Error::ProtocolViolation); - } Entry::Occupied(entry) => entry.into_mut(), // The peer holds the namespace until its NAMESPACE_DONE whatever we make // of it, so it takes its announce slot before the decision. Entry::Vacant(entry) => entry.insert(Advertisement { id: None, - epoch: None, slot: std::sync::Arc::new(self.acquire_announce()?), }), }; - held.epoch = params.epoch.clone(); let Some(advert) = self.route(params.cluster.as_ref(), peer) else { // Looped back through us: forwarding it would extend the loop and // subscribing through it would route us back to ourselves. @@ -1594,20 +1564,18 @@ impl Subscriber { // replacement retracts the route we were holding. Keeping it would // leave subscriptions on a path the peer no longer offers. // - // The advertisement itself stays live on the wire, epoch and all. + // The advertisement itself stays live on the wire. tracing::debug!(%path, "dropping reflected namespace"); if let Some(id) = held.id.take() { let _ = self.stop_announce(path, id, false); } continue; }; - let advert = advert.with_epoch(params.epoch.clone()); - tracing::debug!(%path, hops = advert.route.hops.len(), cost = ?advert.route.cost, epoch = ?params.epoch, "namespace"); + tracing::debug!(%path, hops = advert.route.hops.len(), cost = ?advert.route.cost, "namespace"); match held.id { // A repeat replaces the advertisement atomically; nothing is torn - // down merely because an update arrived, and another epoch restarts - // the route without it ever going absent. + // down merely because an update arrived. Some(id) => self.update_announce(path, id, advert)?, None => { match self.start_announce(path.clone(), advert, Admit::Session(Some(held.slot.clone()))) { @@ -1653,7 +1621,6 @@ impl Subscriber { body: ietf::Body, stream: Stream, peer: cluster::Peer, - epoch: bool, declared: Option, ) -> Result, Error> { let mut this = self.clone(); @@ -1688,7 +1655,6 @@ impl Subscriber { // the dispatcher turns into the protocol violation the draft requires. let negotiated = ietf::Negotiated { cluster: peer.negotiated(), - epoch, }; let msg = match ietf::PublishNamespace::decode_body(&mut data, this.version, negotiated) { Err(err) if super::token::refuses_request(&err) => { @@ -1830,7 +1796,6 @@ impl Subscriber { // A path that already contains our own Hop ID looped back. Reject it rather // than attaching a source we would then have to route around. - let epoch = msg.params.epoch.clone(); let Some(advert) = self.route(msg.params.cluster.as_ref(), &peer) else { tracing::debug!(%path, "dropping reflected publish_namespace"); self.write_error(&mut stream, &Error::Unroutable, "route loops through this relay") @@ -1838,7 +1803,6 @@ impl Subscriber { let _ = stream.writer.close().await; return Ok(()); }; - let advert = advert.with_epoch(epoch.clone()); // Our authorization of the peer (the limit) admits an announce without a token, and // holds back one it does not cover until it does. An AUTHORIZATION TOKEN on the @@ -1916,7 +1880,6 @@ impl Subscriber { &path, Held { cluster: msg.params.cluster, - epoch, }, peer, &mut attached, @@ -1977,10 +1940,7 @@ impl Subscriber { attached: &mut Option, token_grant: Option, ) -> Result { - let Held { - cluster: mut held, - epoch, - } = held; + let Held { cluster: mut held } = held; // A REQUEST_UPDATE carrying a fresh token refreshes the announce's request grant (MoQ // request-token); its verify is raced against the stream in the loop's single wait // (never a bare await), so a peer ending the announce ends it whatever the acceptor @@ -2191,8 +2151,6 @@ impl Subscriber { Ok(()) } Some(advert) => { - // The epoch is the advertisement's for as long as it stands. - let advert = advert.with_epoch(epoch.clone()); tracing::debug!(%path, hops = advert.route.hops.len(), cost = ?advert.route.cost, "publish_namespace update"); match *attached { Some(id) => self.update_announce(path.clone(), id, advert), @@ -2450,18 +2408,12 @@ impl Subscriber { Entry::Occupied(entry) => { let entry = entry.into_mut(); match entry.adverts.iter().position(|(advert, _)| *advert == id) { - // A repeat under another epoch is a newer advertisement, so it becomes the - // newest; one of the same instance stays where it is. - Some(index) if entry.adverts[index].1.epoch != route.epoch => { - entry.adverts.remove(index); - entry.adverts.push((id, route)); - } Some(index) => entry.adverts[index].1 = route, None => entry.adverts.push((id, route)), } // The newest advertisement stands, and an update to an older one changes // nothing. A repeat of the same instance re-prices in place and in-flight - // tracks keep flowing; another epoch restarts it. + // tracks keep flowing. let (newest, route) = entry.adverts.last().expect("just recorded"); if *newest == id { entry.route = route.clone(); @@ -2652,22 +2604,19 @@ impl Subscriber { Some(requested) => requested.clone(), None => continue, }; - // The source serves the instance the route names now: every request for it names - // that epoch when the peer can read one, and the source takes new tracks only - // while the peer still selects that instance. - let (validity, epoch) = { + // The source takes new tracks only while the peer still selects that instance. + let validity = { let state = self.state.lock(); let entry = state .broadcasts .get(&path) .filter(|entry| entry.generation == generation); - let validity = entry + entry .and_then(|entry| entry.dynamic.as_ref()) .map(|route| crate::model::broadcast::RequestValidity::for_source(route, request.path())) .unwrap_or_else(|| { crate::model::broadcast::RequestValidity::token(Some(kio::Producer::new(()).consume())) - }); - (validity, entry.and_then(|entry| entry.route.epoch.clone())) + }) }; let source = crate::model::broadcast::SourceGuard::new(self.origin.create_source(requested.clone(), validity)); @@ -2692,7 +2641,6 @@ impl Subscriber { let mut this = self.clone(); this.validity = dynamic.validity().clone(); - this.epoch = epoch; broadcasts.push(async move { if let Err(err) = this.run_broadcast(requested, source, dynamic, route).await { tracing::debug!(%err, "error running broadcast"); @@ -3050,7 +2998,6 @@ impl Subscriber { TrackState { // A resumed copy is the session's to abort from here on. producer: target.producer().cloned(), - epoch: self.epoch.clone(), alias, tail, ..TrackState::pending(track_name.to_owned(), broadcast_path.clone(), fill.clone()) @@ -3105,7 +3052,6 @@ impl Subscriber { rendezvous: false, range_filters: false, authorization_token: None, - epoch: self.epoch.clone(), }) .await } @@ -4104,7 +4050,6 @@ impl Subscriber { fill_timeout: false, properties_wanted: true, // Served by the subscription it joins, which named the instance. - epoch: None, }) .await?; Ok::<(), Error>(()) @@ -4264,7 +4209,6 @@ impl Subscriber { track_namespace: broadcast_path.clone(), track_name: track_name.into(), properties_wanted: true, - epoch: self.epoch.clone(), }) .await } @@ -5394,7 +5338,6 @@ impl Subscriber { // The copy learned the track before any fetch, from SUBSCRIBE_OK or // TRACK_STATUS_OK, so a FETCH_OK repeating it is waste. properties_wanted: false, - epoch: self.epoch.clone(), }) .await?; Ok::<_, Error>(()) @@ -6408,101 +6351,6 @@ mod tests { ); } - /// A NAMESPACE that loops back through us detaches its route, but the advertisement - /// stays live on the wire until its NAMESPACE_DONE: a repeat that restores a clean path - /// while gaining or losing an epoch is still the violation it would be without the loop. - #[moq_clock::test] - async fn a_reflected_namespace_keeps_its_epoch_live() { - const VERSION: Version = Version::Draft18; - let us = crate::Hop::new(5).unwrap(); - let epoch = crate::Epoch::mint(); - - for (reflected, drops) in [(false, true), (true, true), (true, false)] { - let log = crate::lite::test_transport::Log::default(); - let mut writer = crate::coding::Writer::new( - crate::transport::boxed::SendStream::new(crate::lite::test_transport::SinkSend::new(log.clone())), - VERSION, - ); - writer.varint(ietf::RequestOk::ID).await.unwrap(); - writer - .encode(&ietf::RequestOk { - largest: None, - active: None, - }) - .await - .unwrap(); - let mut adverts = vec![(hop_path(&[7, 9]), Some(epoch.clone()))]; - if reflected { - adverts.push((hop_path(&[7, 5, 9]), Some(epoch.clone()))); - } - adverts.push((hop_path(&[7, 9]), (!drops).then(|| epoch.clone()))); - for (hops, epoch) in adverts { - writer.varint(ietf::Namespace::ID).await.unwrap(); - writer - .encode(&ietf::Namespace { - suffix: crate::Path::from_static("room"), - params: Some(ietf::AdvertParams { - cluster: Some(cluster::Advert { hops, cost: 0 }), - epoch, - }), - }) - .await - .unwrap(); - } - let script = log.writes.lock().unwrap().clone(); - - let origin = crate::origin::Config::new(us).produce(); - let session = crate::lite::test_transport::ScriptedSession::new(script); - let (tasks, _task_set) = crate::util::TaskSet::new(); - let peer_setup = peer::PeerSetup::default(); - peer_setup.set(peer::Peer { - cluster: cluster::Peer { - hop: Some(crate::Hop::new(9).unwrap()), - cost: None, - }, - epoch: true, - ..Default::default() - }); - let mut subscriber = Subscriber::new( - crate::time::sim(), - crate::driver::Transport::new(session.clone()), - origin, - Control::new(false), - None, - peer_setup, - us, - None, - VERSION, - tasks, - Default::default(), - ); - - let prefix = crate::model::interest_prefixes(&subscriber.origin.allowed()) - .pop() - .expect("one prefix"); - let (_live, live) = live(); - let stream = Stream::open(&mut crate::driver::Transport::new(session.clone()), VERSION) - .await - .unwrap(); - let mut run = std::pin::pin!(subscriber.run_subscribe_namespace( - stream, - prefix, - crate::model::Snapshot::landed(), - live - )); - let mut result = None; - for _ in 0..100 { - if let std::task::Poll::Ready(done) = futures::poll!(run.as_mut()) { - result = Some(done); - break; - } - settle().await; - } - let violated = matches!(result, Some(Err(ref err)) if is_protocol_violation(err)); - assert_eq!(violated, drops, "reflected: {reflected}, drops: {drops}: {result:?}"); - } - } - /// A namespace the peer holds on a SUBSCRIBE_NAMESPACE stream takes an announce slot /// whatever we make of it, so reflected ones the origin never sees still exhaust the /// session's budget, and a NAMESPACE_DONE gives the slot back. @@ -6528,7 +6376,6 @@ mod tests { hops: hop_path(&[7, 5, 9]), cost: 0, }), - epoch: None, }), }; writer.varint(ietf::Namespace::ID).await.unwrap(); @@ -8673,7 +8520,6 @@ mod tests { hops: hop_path(&[7, 9]), cost, }), - epoch: None, }), }) .await @@ -9063,98 +8909,6 @@ mod tests { assert!(routed_now(&consumer, "room/host").is_none()); } - /// MoQ Epoch: a publisher replacing its instance withdraws one advertisement and makes - /// another, on separate streams that arrive in either order. The newest advertisement - /// stands, so neither the old one's late update nor its withdrawal reverts the route - /// to the instance it named. - #[moq_clock::test] - async fn a_reordered_replacement_keeps_the_new_instance() { - let (mut subscriber, origin) = cluster_subscriber(crate::Hop::new(1).unwrap()); - let consumer = origin.consume(); - let path = crate::Path::from_static("room/host"); - let peer = cluster::Peer::default(); - let (old, new) = (crate::Epoch::mint(), crate::Epoch::mint()); - let advert = |subscriber: &Subscriber, epoch: &crate::Epoch| { - subscriber - .route(None, &peer) - .expect("route") - .with_epoch(Some(epoch.clone())) - }; - let epoch_now = || routed_now(&consumer, "room/host").and_then(|route| route.epoch); - - let first = advert(&subscriber, &old); - let first = subscriber - .start_announce(path.clone(), first, Admit::Session(None)) - .unwrap(); - assert_eq!(epoch_now(), Some(old.clone())); - - // The replacement's PUBLISH_NAMESPACE beats the old one's PUBLISH_NAMESPACE_DONE. - let second = advert(&subscriber, &new); - let second = subscriber - .start_announce(path.clone(), second, Admit::Session(None)) - .unwrap(); - assert_eq!(epoch_now(), Some(new.clone())); - - // A late update to the old advertisement changes nothing. - let stale = advert(&subscriber, &old); - subscriber.update_announce(path.clone(), first, stale).unwrap(); - assert_eq!(epoch_now(), Some(new.clone()), "a stale update reverted the instance"); - - // Its withdrawal, arriving last, leaves the new instance standing. - subscriber.stop_announce(path.clone(), first, false).unwrap(); - assert_eq!( - epoch_now(), - Some(new.clone()), - "the old withdrawal retracted the new instance" - ); - - subscriber.stop_announce(path, second, false).unwrap(); - assert_eq!(routed_now(&consumer, "room/host"), None); - } - - /// MoQ Epoch: a namespace advertised both inline and by a later PUBLISH_NAMESPACE takes - /// another epoch from either. An inline repeat under the new epoch is the newest - /// advertisement, not an update to the older of the two. - #[moq_clock::test] - async fn a_repeat_under_another_epoch_becomes_the_newest() { - let (mut subscriber, origin) = cluster_subscriber(crate::Hop::new(1).unwrap()); - let consumer = origin.consume(); - let path = crate::Path::from_static("room/host"); - let peer = cluster::Peer::default(); - let (old, new) = (crate::Epoch::mint(), crate::Epoch::mint()); - let advert = |subscriber: &Subscriber, epoch: &crate::Epoch| { - subscriber - .route(None, &peer) - .expect("route") - .with_epoch(Some(epoch.clone())) - }; - let epoch_now = || routed_now(&consumer, "room/host").and_then(|route| route.epoch); - - let inline = advert(&subscriber, &old); - let inline = subscriber - .start_announce(path.clone(), inline, Admit::Session(None)) - .unwrap(); - let request = advert(&subscriber, &old); - let request = subscriber - .start_announce(path.clone(), request, Admit::Session(None)) - .unwrap(); - assert_eq!(epoch_now(), Some(old.clone())); - - let repeat = advert(&subscriber, &new); - subscriber.update_announce(path.clone(), inline, repeat).unwrap(); - assert_eq!( - epoch_now(), - Some(new.clone()), - "the older request kept the old instance" - ); - - // The old instance's withdrawal leaves the new one standing. - subscriber.stop_announce(path.clone(), request, false).unwrap(); - assert_eq!(epoch_now(), Some(new)); - subscriber.stop_announce(path, inline, false).unwrap(); - assert_eq!(routed_now(&consumer, "room/host"), None); - } - /// Two *separate* advertisements for one namespace refcount a single route: /// it takes both retractions to retract it. #[moq_clock::test] @@ -9424,7 +9178,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9474,7 +9227,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9564,7 +9316,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9637,7 +9388,6 @@ mod tests { &path, Held { cluster: Some(held.clone()), - epoch: None }, peer, &mut attached, @@ -9689,7 +9439,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9743,7 +9492,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9791,7 +9539,6 @@ mod tests { cost: 0, ..clean.clone() }), - epoch: None, }, authorization_token: None, }) @@ -9812,7 +9559,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -12582,7 +12328,6 @@ mod stitch_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, } .encode_msg(&mut Encoder::new(&mut body, egress.into()), egress) .unwrap(); @@ -12603,7 +12348,6 @@ mod stitch_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } .encode_msg(&mut Encoder::new(&mut body, egress.into()), egress) .unwrap(); @@ -12613,7 +12357,7 @@ mod stitch_tests { .await .unwrap(); publisher - .handle_stream(id, ietf::Body(body.into()), stream, false) + .handle_stream(id, ietf::Body(body.into()), stream) .unwrap() .await; let mut streams = std::collections::BTreeMap::>::new(); @@ -13110,7 +12854,6 @@ mod stitch_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let mut body = Vec::new(); subscribe @@ -13120,7 +12863,7 @@ mod stitch_tests { .await .unwrap(); publisher - .handle_stream(ietf::Subscribe::ID, ietf::Body(body.into()), stream, false) + .handle_stream(ietf::Subscribe::ID, ietf::Body(body.into()), stream) .unwrap() .await; let sent = downstream.log.datagrams.lock().unwrap(); @@ -14439,7 +14182,6 @@ mod stitch_tests { range_filters: false, fill_timeout: false, properties_wanted: false, - epoch: None, } .encode_msg(&mut Encoder::new(&mut body, version.into()), version) .unwrap(); @@ -14461,7 +14203,7 @@ mod stitch_tests { moq_clock::timeout( Duration::from_secs(1), publisher - .handle_stream(ietf::Fetch::ID, ietf::Body(body.into()), stream, false) + .handle_stream(ietf::Fetch::ID, ietf::Body(body.into()), stream) .unwrap(), ) .await diff --git a/rs/moq-net/src/ietf/subscriber/tracks.rs b/rs/moq-net/src/ietf/subscriber/tracks.rs index d27a291ba33..3117d89175b 100644 --- a/rs/moq-net/src/ietf/subscriber/tracks.rs +++ b/rs/moq-net/src/ietf/subscriber/tracks.rs @@ -624,7 +624,6 @@ impl Subscriber { self.state.lock().subscribes.insert( request_id, TrackState { - epoch: self.epoch.clone(), ..TrackState::pending(key.1.to_string(), key.0.clone(), kio::Producer::new(Fill::Done)) }, ); @@ -648,7 +647,6 @@ impl Subscriber { rendezvous: false, range_filters: false, authorization_token: None, - epoch: self.epoch.clone(), }) .await?; let mut response = std::pin::pin!(self.read_subscribe_response(&mut stream, &mut messages)); @@ -838,7 +836,6 @@ impl Subscriber { self.state.lock().subscribes.insert( request_id, TrackState { - epoch: self.epoch.clone(), ..TrackState::pending(key.1.to_string(), key.0.clone(), kio::Producer::new(Fill::Done)) }, ); @@ -1107,7 +1104,6 @@ impl Subscriber { } let parked = TrackState { alias: held.alias, - epoch: held.epoch.clone(), tail: std::mem::take(&mut held.tail), ..TrackState::pending( std::mem::take(&mut held.name), diff --git a/rs/moq-net/src/ietf/track.rs b/rs/moq-net/src/ietf/track.rs index 093c6617f7d..63d84d2100d 100644 --- a/rs/moq-net/src/ietf/track.rs +++ b/rs/moq-net/src/ietf/track.rs @@ -25,8 +25,6 @@ pub struct TrackStatus<'a> { /// Whether the requester wants Track Properties on the answer (INCLUDE_PROPERTIES, /// draft-22). pub properties_wanted: bool, - /// The publisher instance the requester expects (MoQ Epoch). - pub epoch: Option, } impl TrackStatus<'_> { @@ -37,7 +35,6 @@ impl TrackStatus<'_> { track_namespace: self.track_namespace, track_name: Cow::Owned(self.track_name.into_owned()), properties_wanted: self.properties_wanted, - epoch: self.epoch, } } } @@ -52,10 +49,8 @@ impl<'a> Message<'a> for TrackStatus<'a> { // Only the opt-out is worth bytes, and an older peer would read the // parameter as unknown, which is a protocol violation. let include_properties = (!self.properties_wanted && Filter::is_draft22(version)).then_some(false); - let epoch = self.epoch.clone(); encode_params!(w, version, 0x35 => include_properties, - super::epoch::EPOCH_PARAM => epoch, ); Ok(()) } @@ -70,7 +65,6 @@ impl<'a> Message<'a> for TrackStatus<'a> { track_namespace: subscribe.track_namespace, track_name: subscribe.track_name, properties_wanted: subscribe.properties_wanted, - epoch: subscribe.epoch, }) } } @@ -166,7 +160,6 @@ mod tests { track_namespace: Path::from_static("test/ns"), track_name: "video".into(), properties_wanted: true, - epoch: None, }; let encoded = encode_message(&msg, Version::Draft18); @@ -190,7 +183,6 @@ mod tests { track_namespace: Path::from_static("ns"), track_name: "video".into(), properties_wanted: wanted, - epoch: None, }; let wire = encode_message(&msg, version); diff --git a/rs/moq-net/src/setup.rs b/rs/moq-net/src/setup.rs index 230e674fafe..db523bfb025 100644 --- a/rs/moq-net/src/setup.rs +++ b/rs/moq-net/src/setup.rs @@ -74,7 +74,7 @@ pub(crate) fn implementation(value: &str) -> Option { /// The SETUP extensions this side offers. /// /// Turning one off connects as a peer that does not speak that extension. moq-lite carries -/// auth, solicit, and epoch in its core, so those only change moq-transport sessions. +/// auth and solicit in its core, so those only change moq-transport sessions. #[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[serde(default, deny_unknown_fields)] #[non_exhaustive] @@ -84,9 +84,6 @@ pub struct Extensions { /// The MoQ Solicit extension: the peer answers our SUBSCRIBE_NAMESPACE rather than /// announcing unasked (moq-transport only). pub solicit: bool, - /// The MoQ Epoch extension: announcements and requests carry the publisher's - /// [`Epoch`](crate::Epoch), as moq-lite 07 does. - pub epoch: bool, /// The MoQ IETF extension, off by default: a moq-lite 07 hop between relays carries the /// moq-transport object state a relay preserves, such as Object IDs and properties. pub ietf: bool, @@ -97,7 +94,6 @@ impl Default for Extensions { Self { auth: true, solicit: true, - epoch: true, ietf: false, } } diff --git a/rs/moq-net/src/test_interop.rs b/rs/moq-net/src/test_interop.rs index 68c639c2862..812e44dc045 100644 --- a/rs/moq-net/src/test_interop.rs +++ b/rs/moq-net/src/test_interop.rs @@ -63,7 +63,6 @@ fn ietf_range_updates_interop() { authorization_token: None, new_group: None, max_age: None, - epoch: None, } .encode(&mut w, version) .unwrap(); @@ -605,7 +604,6 @@ fn ietf_track_status_interop() { track_namespace: crate::Path::new(namespace).unwrap(), track_name: "video".into(), properties_wanted: wanted, - epoch: None, } .encode(&mut w, version) .unwrap(); diff --git a/rs/moq-net/tests/integration/catalog_acquisition.rs b/rs/moq-net/tests/integration/catalog_acquisition.rs index 78b3430fc64..3d2533055d4 100644 --- a/rs/moq-net/tests/integration/catalog_acquisition.rs +++ b/rs/moq-net/tests/integration/catalog_acquisition.rs @@ -21,8 +21,7 @@ async fn link(version: Version, from: &origin::Producer, to: &origin::Producer, connect_mock(options).await } -/// `carries_epoch`: the wire carries the epoch, as lite-07 and moq-transport with the MoQ -/// Epoch extension do. +/// `carries_epoch`: the wire carries the epoch, as lite-07 does. async fn acquisition(version: &str, carries_epoch: bool) { let version: Version = version.parse().unwrap(); let publisher = origin(1); @@ -81,11 +80,11 @@ async fn acquisition(version: &str, carries_epoch: bool) { #[moq_clock::test] async fn epochless_replacement_refuses_pending_catalog() { acquisition("moq-lite-06", false).await; + acquisition("moq-transport-18", false).await; + acquisition("moq-transport-22", false).await; } #[moq_clock::test] async fn same_epoch_replacement_acquires_pending_catalog() { acquisition("moq-lite-07-wip", true).await; - acquisition("moq-transport-18", true).await; - acquisition("moq-transport-22", true).await; } diff --git a/rs/moq-net/tests/integration/extensions.rs b/rs/moq-net/tests/integration/extensions.rs index 16e2aee3537..56e1a425ba5 100644 --- a/rs/moq-net/tests/integration/extensions.rs +++ b/rs/moq-net/tests/integration/extensions.rs @@ -141,74 +141,3 @@ async fn a_declined_auth_extension_is_not_negotiated() { } } } - -/// The route `path` is announced on in `origin` right now, if any. -fn route(origin: &origin::Producer, path: &str) -> Option { - let mut announced = origin.consume().announced(); - let mut route = None; - while let Some(event) = announced.try_next() { - match event { - moq_net::announce::Event::Start(update) - | moq_net::announce::Event::Update(update) - | moq_net::announce::Event::Restart(update) => { - if update.prefix.as_str() == path { - route = Some(update.route); - } - } - moq_net::announce::Event::End(update) => { - if update.prefix.as_str() == path { - route = None; - } - } - } - } - route -} - -/// MoQ Epoch carries the publisher's epoch, in either direction, only when both sides -/// offer it. A side declining it leaves the route epochless exactly as before the -/// extension, and nothing on the wire breaks the session. -#[moq_clock::test] -async fn an_epoch_crosses_only_when_both_offer_it() { - for name in MOQT { - let version: Version = name.parse().unwrap(); - for server_publishes in [true, false] { - for declines in [None, Some("server"), Some("client")] { - let context = format!("{name}, server publishes: {server_publishes}, declines: {declines:?}"); - let publisher = produce_origin(1); - let subscriber = produce_origin(2); - - let mut options = MockConnectOptions::new(version); - match server_publishes { - true => { - options.server_publish = Some(publisher.consume()); - options.client_subscribe = Some(subscriber.clone()); - } - false => { - options.client_publish = Some(publisher.consume()); - options.server_subscribe = Some(subscriber.clone()); - } - } - let no_epoch = declined(|e| e.epoch = false); - match declines { - Some("server") => options.server_extensions = no_epoch, - Some(_) => options.client_extensions = no_epoch, - None => {} - } - let pair = connect_mock(options).await; - - let epoch = moq_net::Epoch::mint(); - let broadcast = publisher.create_broadcast("room/cam").unwrap(); - broadcast - .announce(origin::Route::default().with_epoch(epoch.clone())) - .unwrap(); - moq_clock::sleep(SETTLE).await; - - let route = route(&subscriber, "room/cam").unwrap_or_else(|| panic!("{context}: never announced")); - let expected = declines.is_none().then_some(epoch); - assert_eq!(route.epoch, expected, "{context}"); - assert_open(&pair, &context); - } - } - } -} diff --git a/rs/moq-net/tests/integration/multi_cdn.rs b/rs/moq-net/tests/integration/multi_cdn.rs index 14f67296342..75212b80586 100644 --- a/rs/moq-net/tests/integration/multi_cdn.rs +++ b/rs/moq-net/tests/integration/multi_cdn.rs @@ -7,8 +7,7 @@ //! [`origin::Producer::with_preference`] while pricing `B` cheaper, so only the //! preference puts `A` ahead. Losing `A` moves `S` to `B`, and `A` returning moves it //! back. Between lite-07 routes with the same epoch each move resumes the subscription. -//! A moq-transport `B` with the MoQ Epoch extension carries the epoch, but its copy's -//! track info records the draft, so the move onto it is refused. +//! A moq-transport `B` carries no epoch, so moving onto it restarts the path. use crate::support; @@ -311,11 +310,8 @@ async fn preferred_cdn_fails_over_and_back() { fails_over_and_back("moq-lite-07-wip").await; } -/// A moq-transport `B` with the MoQ Epoch extension carries `P`'s epoch, so losing `A` is -/// an update, not a restart. Its copy's track info differs from `A`'s, recording the draft -/// it crossed, and one epoch means identical content: `S` refuses the copy, so the track -/// ends with no frame of `B`'s. -async fn refused_across_protocols(secondary: &str) { +/// Losing the epoch-carrying route restarts onto the epochless moq-transport route. +async fn restarts_across_protocols(secondary: &str) { moq_clock::timeout(TEST_TIMEOUT, async { let mut topology = Topology::new(secondary.parse().unwrap()).await; let mut announced = topology.subscriber.consume().announced(); @@ -329,16 +325,23 @@ async fn refused_across_protocols(secondary: &str) { topology.lose_a().await; let update = announced.next().await.expect("announced"); assert!( - matches!(update, announce::Event::Update(_)) && !via_a(&update), - "same epoch over B: {update:?}" + matches!(update, announce::Event::Restart(_)) && !via_a(&update), + "epochless route over B: {update:?}" ); topology.group(); settle().await; let rest: Vec<_> = std::iter::from_fn(|| rx.try_recv().ok()).collect(); assert!( - matches!(rest.as_slice(), [(u64::MAX, Err(Error::Unsupported))]), - "the track did not end with the refusal: {rest:?}" + matches!( + rest.as_slice(), + [(u64::MAX, Err(Error::Session(moq_net::SessionError::Cancel)))] + ), + "the old route did not end its track: {rest:?}" ); + let mut fresh = topology.subscribe().await; + let (sequence, _, bytes) = next(&mut fresh).await; + assert_eq!(sequence, 1, "the fresh subscription joins the current group"); + assert_eq!(bytes, payload(1, 0)); drop((topology.publisher, topology.cdn_b)); }) .await @@ -346,12 +349,12 @@ async fn refused_across_protocols(secondary: &str) { } #[moq_clock::test] -async fn transport_secondary_is_refused() { - refused_across_protocols("moq-transport-22").await; +async fn transport_secondary_restarts() { + restarts_across_protocols("moq-transport-22").await; } -/// The same over the first draft that can carry the epoch. +/// The same over the oldest supported moq-transport draft. #[moq_clock::test] -async fn transport_17_secondary_is_refused() { - refused_across_protocols("moq-transport-18").await; +async fn transport_18_secondary_restarts() { + restarts_across_protocols("moq-transport-18").await; } diff --git a/rs/moq-net/tests/integration/replacement.rs b/rs/moq-net/tests/integration/replacement.rs index 2e94c937366..1eb1b2553c4 100644 --- a/rs/moq-net/tests/integration/replacement.rs +++ b/rs/moq-net/tests/integration/replacement.rs @@ -77,6 +77,7 @@ const WITHIN_HOLD: Duration = Duration::from_millis(10); const PAST_HOLD: Duration = Duration::from_millis(500); async fn replace(version: &str, epoch: Option) { + let carried = (version == "moq-lite-07-wip").then_some(epoch.clone()).flatten(); let version: Version = version.parse().unwrap(); let publisher = produce_origin(1); let viewer = produce_origin(3); @@ -91,7 +92,10 @@ async fn replace(version: &str, epoch: Option) { let _first = link(version, &publisher, &viewer).await; let mut announced = viewer.consume().announced(); match next_event(&mut announced).await { - announce::Event::Start(announce) => assert_eq!(announce.prefix.as_str(), "cam"), + announce::Event::Start(announce) => { + assert_eq!(announce.prefix.as_str(), "cam"); + assert_eq!(announce.route.epoch, carried, "{version}: carried epoch"); + } other => panic!("{version}: expected the broadcast, got {other:?}"), } @@ -112,7 +116,7 @@ async fn replace(version: &str, epoch: Option) { write(&audio, "audio:0"); assert_eq!(read(&mut late).await, "audio:0", "{version}"); - if epoch.is_some() { + if carried.is_some() { // The epoch continues across the replacement: nothing to restart, and the old // handle keeps serving. if let Ok(event) = moq_clock::timeout(PAST_HOLD, announced.next()).await { @@ -171,9 +175,9 @@ async fn epoch_lite07() { .expect("timed out"); } -/// moq-transport carries the epoch with the MoQ Epoch extension. +/// A local epoch never crosses a moq-transport hop. #[moq_clock::test] -async fn epoch_ietf() { +async fn epoch_is_stripped_ietf() { for version in ["moq-transport-18", "moq-transport-22"] { moq_clock::timeout(TEST_TIMEOUT, replace(version, Some(epoch()))) .await @@ -184,7 +188,7 @@ async fn epoch_ietf() { /// Without one, a moq-transport replacement restarts as it does over lite. #[moq_clock::test] async fn epochless_ietf() { - for version in ["moq-transport-22"] { + for version in ["moq-transport-18", "moq-transport-22"] { moq_clock::timeout(TEST_TIMEOUT, replace(version, None)) .await .expect("timed out"); diff --git a/rs/moq-net/tests/integration/route_change.rs b/rs/moq-net/tests/integration/route_change.rs index d384e438774..0f745be2cb5 100644 --- a/rs/moq-net/tests/integration/route_change.rs +++ b/rs/moq-net/tests/integration/route_change.rs @@ -8,8 +8,7 @@ //! every frame exactly once, in order, whether the route changes between groups or //! in the middle of one, and however it changes. //! -//! moq-transport carries the epoch with the MoQ Epoch extension, so it behaves the -//! same. Older lite versions cannot carry the epoch, so `R` cannot tell the +//! moq-transport and older lite versions carry no epoch, so `R` cannot tell the //! two routes serve the same bytes: its subscription stays on its route and ends with //! it, while a better route restarts the path for new requests. //! @@ -467,8 +466,6 @@ macro_rules! route_change_tests { route_change_tests! { lite_07: "moq-lite-07-wip", - ietf_18: "moq-transport-18", - ietf_22: "moq-transport-22", } macro_rules! pinned_tests { @@ -507,6 +504,8 @@ macro_rules! pinned_tests { } pinned_tests! { + ietf_18: "moq-transport-18", + ietf_22: "moq-transport-22", lite_06: "moq-lite-06", lite_05: "moq-lite-05", lite_04: "moq-lite-04", diff --git a/test/interop/clients/js-native/control.ts b/test/interop/clients/js-native/control.ts index 11ddda7b9f4..7f966e6c5b4 100644 --- a/test/interop/clients/js-native/control.ts +++ b/test/interop/clients/js-native/control.ts @@ -20,7 +20,7 @@ const quic = new Qmux(new URL(address), { requireProtocol: true, }); await quic.ready; -const extensions = offered({ auth: false, epoch: false, solicit: false }); +const extensions = offered({ auth: false, solicit: false }); await exchangeSetup(quic, version, "interop-control", { client: true, extensions }); const session = new NativeSession(quic, version, true); diff --git a/test/interop/clients/js-native/goaway.ts b/test/interop/clients/js-native/goaway.ts index 6ed95ee2e90..f113fca0794 100644 --- a/test/interop/clients/js-native/goaway.ts +++ b/test/interop/clients/js-native/goaway.ts @@ -1,4 +1,4 @@ -/** Follow a Rust server's GOAWAY redirect, retaining the reader since the epoch proves continuity. */ +/** Follow a Rust server's epochless GOAWAY redirect by subscribing to its replacement announcement. */ import assert from "node:assert/strict"; import { Milli } from "@moq/clock"; import * as Moq from "@moq/net"; @@ -28,7 +28,9 @@ async function active(request: (typeof requests)[number]) { return broadcast; } try { - const track = (await active(requests[0])).track("video").subscribe({ groups: { start: { included: 0 } } }); + const initial = await active(requests[0]); + assert.equal(initial.epoch, undefined, "moq-transport carries no epoch"); + let track = initial.track("video").subscribe({ groups: { start: { included: 0 } } }); try { for (let sequence = 0; sequence < 3; sequence++) { const group = await track.recvGroup(); @@ -73,11 +75,20 @@ try { } finally { probe.close(); } + let restarted = requests[0].active.peek(); + while (restarted === undefined || restarted === initial) { + await requests[0].active.changed(); + restarted = requests[0].active.peek(); + } + assert.equal(restarted.epoch, undefined, "replacement is epochless"); + const next = restarted.track("video").subscribe({ groups: { start: { included: 2 } } }); + track.close(); + track = next; process.stdout.write("replacement ready\n"); } } // The server only writes group 2 after this acknowledgement and closing `first`. - process.stdout.write("goaway resumed\n"); + process.stdout.write("goaway restarted\n"); } finally { track.close(); } diff --git a/test/interop/clients/js-native/server.ts b/test/interop/clients/js-native/server.ts index 24c6d03f57c..7d1166423f5 100644 --- a/test/interop/clients/js-native/server.ts +++ b/test/interop/clients/js-native/server.ts @@ -143,7 +143,7 @@ try { next.writeFrame({ payload: new Uint8Array(32).fill(1) }); next.finish(); assert.equal((await commands.next()).value, "done"); - console.error("js goaway redirect resumed"); + console.error("js goaway redirect restarted"); } finally { lines.close(); initial?.connection.abort(); diff --git a/test/interop/clients/js/media.ts b/test/interop/clients/js/media.ts index 30096b1a860..2efac39390e 100644 --- a/test/interop/clients/js/media.ts +++ b/test/interop/clients/js/media.ts @@ -1089,7 +1089,9 @@ try { predicate: (s) => s.generation === 0 && !s.audioStalled, }); check( - version === "moq-lite-06" ? first.broadcastEpoch === undefined : first.broadcastEpoch !== undefined, + version === "moq-lite-07-wip" + ? first.broadcastEpoch !== undefined + : first.broadcastEpoch === undefined, "negotiated epoch identity", () => JSON.stringify(first), ); @@ -1121,7 +1123,7 @@ try { predicate: (s) => s.generation === 1 && !s.audioStalled && playsInSync(s), }); const replacementMs = Date.now() - ready; - if (version !== "moq-lite-06") + if (version === "moq-lite-07-wip") check(switched.broadcastEpoch !== first.broadcastEpoch, "replacement has a fresh epoch", () => JSON.stringify(switched), ); diff --git a/test/interop/clients/rust/goaway-client.rs b/test/interop/clients/rust/goaway-client.rs index b4499699885..1c50e4b0a58 100644 --- a/test/interop/clients/rust/goaway-client.rs +++ b/test/interop/clients/rust/goaway-client.rs @@ -1,4 +1,4 @@ -//! Follow a real JS QMux server's redirect, retaining the reader across the epoch-proven handover. +//! Follow a real JS QMux server's epochless redirect through its replacement announcement. use std::process::Stdio; use anyhow::{Context, ensure}; @@ -40,7 +40,8 @@ async fn main() -> anyhow::Result<()> { connection.version() == Some(version.parse().map_err(anyhow::Error::msg)?), "wrong negotiated version" ); - let broadcast = consumer.follow("handover", None)?.available().await?; + let mut following = consumer.follow("handover", None)?; + let broadcast = following.available().await?; let mut track = broadcast.track("video")?.subscribe(None).await?; let input = child.stdin.as_mut().context("stdin")?; for sequence in 0..2 { @@ -62,6 +63,9 @@ async fn main() -> anyhow::Result<()> { marker.read_frame().await?.context("marker frame")?.payload.as_ref() == [42], "wrong marker" ); + let restarted = following.available().await?; + ensure!(!restarted.is_clone(&broadcast), "redirect did not restart the instance"); + track = restarted.track("video")?.subscribe(None).await?; input.write_all(b"replacement ready\n").await?; } } @@ -69,6 +73,6 @@ async fn main() -> anyhow::Result<()> { ensure!(child.wait().await?.success(), "JS server failed"); let _ = connection.close().await; client.close().await; - eprintln!("reverse goaway resumed {version}"); + eprintln!("reverse goaway restarted {version}"); Ok(()) } diff --git a/test/interop/clients/rust/goaway.rs b/test/interop/clients/rust/goaway.rs index 79863b955e1..9161b1898d3 100644 --- a/test/interop/clients/rust/goaway.rs +++ b/test/interop/clients/rust/goaway.rs @@ -76,12 +76,12 @@ async fn main() -> anyhow::Result<()> { let _ = session.closed().await; write(&mut track, 2)?; ensure!( - output.next_line().await?.as_deref() == Some("goaway resumed"), - "JS subscription did not resume" + output.next_line().await?.as_deref() == Some("goaway restarted"), + "JS subscription did not restart" ); ensure!(child.wait().await?.success(), "JS client failed"); replacement.abort(moq_net::Error::Cancel); let _ = replacement.closed().await; - eprintln!("goaway redirect resumed {version}"); + eprintln!("goaway redirect restarted {version}"); Ok(()) } From 46cbf0ef3dbcf1072827a7d3e2a84a95f09c158b Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 29 Oct 2026 07:17:12 -0700 Subject: [PATCH 3/9] chore(quest): record epoch-cut validation still awaiting host admission Co-Authored-By: GPT-6.1 Sol --- doc/concept/standard.md | 3 +- quest/m1/ietf-epoch-cut.md | 67 ++++++++++------------ test/interop/clients/rust/goaway-client.rs | 2 +- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/doc/concept/standard.md b/doc/concept/standard.md index 4c3819b1b71..270d39957e1 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -46,8 +46,7 @@ ignores unknown parameters: [cluster](/draft/moq-cluster) routing hop lists, [hidden](/draft/moq-hidden) to keep `.`-named namespaces out of discovery, [auth](/draft/moq-auth) to tell each peer what it may publish and subscribe to, [active-count](/draft/moq-active-count) to count the `NAMESPACE` messages -before a `SUBSCRIBE_NAMESPACE` is synced, -and +before a `SUBSCRIBE_NAMESPACE` is synced, and [probe](/draft/moq-probe) for bandwidth estimation. Rust sessions request PROBE only while an owned `recv_bandwidth()` consumer is held. Read estimates through its `peek()` or `changed()` methods; session statistics do not request PROBE. diff --git a/quest/m1/ietf-epoch-cut.md b/quest/m1/ietf-epoch-cut.md index 02d6787aae7..b75481fd02a 100644 --- a/quest/m1/ietf-epoch-cut.md +++ b/quest/m1/ietf-epoch-cut.md @@ -46,43 +46,36 @@ Decision prompts: - Docs: ✅ inline fixes only; a separate docs page. - Rank: ✅ m1, after the other moq-transport narrowing quests; m2. -Implementation: - -- **Rust.** Delete `rs/moq-net/src/ietf/epoch.rs`, the `Peer::epoch` flag, - the declined-offer bookkeeping in `ietf/peer.rs`, the SETUP option in - `ietf/session.rs`, and the EPOCH parameter on PUBLISH_NAMESPACE, - NAMESPACE, SUBSCRIBE, FETCH, and TRACK_STATUS in `ietf/publisher.rs`, - `ietf/subscriber.rs`, and the message codecs. Delete the replacement - branches only an epoch-carrying advertisement takes (around `replaces` in - `ietf/publisher.rs`, and the subscriber's refusal of a namespace that gains - or loses an epoch). An inbound EPOCH parameter, now never negotiated, is - handled like any other unknown parameter. Remove `Extensions::epoch` - from `rs/moq-net/src/setup.rs` and its test - `an_epoch_crosses_only_when_both_offer_it` in - `rs/moq-net/tests/integration/extensions.rs`. -- **JS.** Delete `js/net/src/ietf/epoch.ts` and its tests, the `epoch` - option in `js/net/src/connection/extensions.ts`, the handshake's - `Ietf.Epoch.fromSetup`, the `Ietf.Epoch` export, and the EPOCH paths in the - IETF publisher, subscriber, and message codecs. -- **Tests.** The integration tests that run epoch scenarios across versions - (`replacement`, `rejoin`, `route_change`, `catalog_handover`, `multi_cdn`, - and the rest under `rs/moq-net/tests/integration`), and the interop clients - in `test/interop/clients`, expect epochless behavior on moq-transport - instead of epoch behavior. Delete the cases that only pinned EPOCH framing. - [A demoted subscriber priority reaches the publisher](/quest/m1/ts-reliability/stitch-catch-up.md) - has a "moq-transport-18 after an epoch switch, relayed" case. Whichever - lands second turns that case into an epochless restart. If a compat cell - in `test/interop/compat.sh` asserted an epoch across moq-transport, add a - planned break to `test/interop/compat/planned-breaks.json`. -- **Docs.** Say moq-lite 07 only where a doc promises epochs or redundant - ingest over moq-transport: `doc/setup/redundancy.md`, - `doc/concept/moq-lite.md`, `doc/concept/standard.md`, - `doc/concept/stats.md`, and `doc/bin/relay/cluster.md`. Remove the - `epoch` lines from `doc/bin/relay/config.md`. The PR's Impact section says - how to migrate (delete any `epoch` extension setting), for the release cut - to write into `MIGRATE.md`. - -Run `just check`, `just test interop --all`, and the compat lane. +Implemented in this quest's PR: + +- Rust and JS no longer negotiate, encode, or interpret the IETF EPOCH option + or parameter. The IETF replacement and request-pinning paths are removed; + moq-lite and the shared epoch model remain unchanged. +- Removed Rust `Extensions::epoch`, JS `extensions.epoch`, and `Ietf.Epoch`. + Updated the API report and existing docs. The epoch, cluster, and hang + drafts stay unchanged as decided. +- Updated replacement, pending-catalog, route-change, multi-CDN, browser + identity, and cross-language GOAWAY scenarios for epochless IETF restarts. + Local epoch pinning for a publisher's own track-listing resolution remains. + +Remaining work before readiness: + +- Rerun the corrected multi-CDN tests and the full moq-net suite. The last + full run compiled and reached 2,880 passing tests before stopping on the + old multi-CDN error expectation. The test now expects the cancelled old + session and checks a fresh subscription on the IETF route; that change + still needs execution. +- Run `just check`, `just ci`, `just test interop --all`, and + `just test wire-compat`. All four attempts remained at `quest gate` host + admission, with no suite output. Finish the updated GOAWAY clients' runtime + validation as part of interop. +- Complete the quest and remove its file and links only after these checks + pass. JS unit tests passed (2,563), and the JS workspace build and API + report update passed before the last interop-client edits. + +The compat matrix covers only moq-lite, so this cut adds no planned break. +[Wire compatibility remeasurement](/quest/m0/interop-green/wire-compat-remeasure.md) +owns the existing release-pin problem if the compat run reaches it. Public API: breaking. `setup::Extensions::epoch` and JS `extensions.epoch` are removed, and so is `Ietf.Epoch`. Wire: moq-transport sessions stop diff --git a/test/interop/clients/rust/goaway-client.rs b/test/interop/clients/rust/goaway-client.rs index 1c50e4b0a58..6130351d52f 100644 --- a/test/interop/clients/rust/goaway-client.rs +++ b/test/interop/clients/rust/goaway-client.rs @@ -65,7 +65,7 @@ async fn main() -> anyhow::Result<()> { ); let restarted = following.available().await?; ensure!(!restarted.is_clone(&broadcast), "redirect did not restart the instance"); - track = restarted.track("video")?.subscribe(None).await?; + track = restarted.track("video")?.subscribe(None).await?.with_range(1..); input.write_all(b"replacement ready\n").await?; } } From 3b3a10da9656038fae908736f597ae333cde275c Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 22:08:09 -0700 Subject: [PATCH 4/9] fix(net): drop the EPOCH fields main's new tests still set Main's joining-FETCH test and the moq-transport-18 e2ee transport case still expected an epoch over moq-transport, and the priority-update restart reads lite-07 alone as in place. Co-Authored-By: Claude Opus 5.5 --- doc/concept/identity.md | 12 +++++----- js/e2ee/src/transport.test.ts | 2 +- rs/moq-net-tests/tests/integration/restart.rs | 22 +++++++++---------- rs/moq-net/src/ietf/publisher.rs | 1 - 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/doc/concept/identity.md b/doc/concept/identity.md index e1da740269d..0bd922ae201 100644 --- a/doc/concept/identity.md +++ b/doc/concept/identity.md @@ -10,8 +10,7 @@ path, track name, and group sequence, and a subscriber that loses its route resumes by asking for the first frame it lacks. Both are only safe while every source of a name serves the same bytes. This page is the contract publishers, players, and relays share to keep that true across restarts, failover, and work -started on demand. Wire details live in the [moq-lite](/draft/moq-lite) and -[epoch](/draft/moq-epoch) drafts. +started on demand. Wire details live in the [moq-lite](/draft/moq-lite) draft. ## Identity is a path and an epoch @@ -52,11 +51,10 @@ the ingest gateways do it for you; see [publisher runs](/bin/cli#publisher-runs) ## Routes with and without an epoch An epoch reaches readers only over hops that carry it: moq-lite 07 -(`moq-lite-07-wip`, opt-in) and moq-transport with the -[epoch extension](/draft/moq-epoch), which is on by default. Older moq-lite -versions and moq-transport without the extension drop it. The -[moq-lite](/draft/moq-lite) and [epoch](/draft/moq-epoch) drafts say how each -version signals another instance taking the path. +(`moq-lite-07-wip`, opt-in). Older moq-lite versions and moq-transport drop +it, so use moq-lite 07 on every hop where continuity matters. The +[moq-lite draft](/draft/moq-lite) says how each version signals another +instance taking the path. A relay forwards an epoch unchanged and never invents one. Without one, no route can prove it serves the same bytes as another, so any other route diff --git a/js/e2ee/src/transport.test.ts b/js/e2ee/src/transport.test.ts index 6731284b1c0..c372403f458 100644 --- a/js/e2ee/src/transport.test.ts +++ b/js/e2ee/src/transport.test.ts @@ -52,7 +52,7 @@ async function active(origin: Origin.Producer, path: Path.Valid): Promise, to: Option) { assert!(same.is_clone(&stale), "{version}: a re-price replaced the broadcast"); assert_eq!(claim.answered(), 1, "{version}: a re-price asked the handler again"); - // Another epoch, or none, is another instance downstream. lite-07 restarts it in place, - // and so does moq-transport (MoQ Epoch) between two epochs: the new instance is - // advertised before the old is withdrawn, so the path is never absent. - let lite = |name: &str| version == name.parse().unwrap(); - let in_place = lite("moq-lite-07-wip") || !lite("moq-lite-06") && from.is_some() && to.is_some(); + // Another epoch, or none, is another instance downstream. Only lite-07 restarts it in + // place: the new instance is advertised before the old is withdrawn, so the path is + // never absent. + let lite07 = version == "moq-lite-07-wip".parse().unwrap(); claim.update_epoch(to.clone()); - expect_replaced(version, &mut announced, "live", in_place).await; + expect_replaced(version, &mut announced, "live", lite07).await; // The subscription already open stays on the old answer. claim.write(0, "old:2"); @@ -358,11 +357,9 @@ async fn dynamic_epoch(version: &str, from: Option, to: Option) { let (fresh, mut subscription) = subscribe(&viewer, "live/cam").await; assert!(!fresh.is_clone(&stale), "{version}: joined the old instance's copy"); assert_eq!(claim.answered(), 2, "{version}: the old answer was served again"); - // Every wire here but lite-06 carries the epoch: lite-07, and moq-transport with the - // MoQ Epoch extension. - if version != "moq-lite-06".parse().unwrap() { - assert_eq!(fresh.info().epoch, to, "{version}: resolved under the old epoch"); - } + // Only lite-07 carries the epoch; the other wires resolve an epochless instance. + let epoch = if lite07 { to } else { None }; + assert_eq!(fresh.info().epoch, epoch, "{version}: resolved under the old epoch"); claim.write(1, "new:0"); assert_eq!(read(&mut subscription).await, "new:0", "{version}"); @@ -795,7 +792,8 @@ async fn priority_update(version: &str, relayed: bool, switch: bool) { .unwrap() }); if switch { - let in_place = version != "moq-lite-06".parse().unwrap(); + // Only lite-07 carries the epoch, so only it restarts in place. + let in_place = version == "moq-lite-07-wip".parse().unwrap(); expect_replaced(version, &mut announced, "live", in_place).await; } diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index ac1e7db1dbd..32f27789362 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -11460,7 +11460,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { From cb1751501f525335c025681c7b5f14e8e99fcb62 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 00:30:22 -0700 Subject: [PATCH 5/9] test(net): drop moq-transport resumption cases main added Main's moq-cli replacement and route-change suites asserted an in-place restart or a cross-route resume over moq-transport, which carried the epoch until this cut. Epochless moq-transport route loss stays covered by the pinned cases. Co-Authored-By: Claude Opus 5.5 --- rs/moq-cli/tests/integration/epochs.rs | 3 ++- rs/moq-net/tests/integration/route_change.rs | 12 ------------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/rs/moq-cli/tests/integration/epochs.rs b/rs/moq-cli/tests/integration/epochs.rs index e0843551721..7aaf82ef64f 100644 --- a/rs/moq-cli/tests/integration/epochs.rs +++ b/rs/moq-cli/tests/integration/epochs.rs @@ -205,7 +205,8 @@ async fn replacement(version: &str) { (changed(&mut catalog_follow).await, changed(&mut media_follow).await) }) .await; - assert_eq!(catalog_restart, version != "moq-lite-06"); + // Only lite-07 carries the epoch, so only it restarts in place. + assert_eq!(catalog_restart, version == LITE_07); assert_eq!(media_restart, catalog_restart); println!( "{version}: relay replacement observed in {:?} of {:?} (publisher already connected)", diff --git a/rs/moq-net/tests/integration/route_change.rs b/rs/moq-net/tests/integration/route_change.rs index 9e0589b913e..c37433006b4 100644 --- a/rs/moq-net/tests/integration/route_change.rs +++ b/rs/moq-net/tests/integration/route_change.rs @@ -303,7 +303,6 @@ async fn route_flaps(version: &str) { let triggers = [Trigger::BetterRoute, Trigger::BetterRouteDies, Trigger::Disconnect]; let mut expected = Vec::new(); let mut seen = Vec::new(); - // Keep every recovery within the largest group's head, which our IETF publishers serve. let mut group = topology.track.append_group().unwrap(); for frame in 0..FRAMES * (triggers.len() as u64 + 1) { if frame % FRAMES == FRAMES / 2 @@ -605,16 +604,6 @@ async fn lite_resumes_after_a_lagging_route_dies() { lagging_route_dies("moq-lite-07-wip".parse().unwrap()).await; } -#[moq_clock::test] -async fn ietf_17_resumes_after_a_lagging_route_dies() { - lagging_route_dies("moq-transport-18".parse().unwrap()).await; -} - -#[moq_clock::test] -async fn ietf_22_resumes_after_a_lagging_route_dies() { - lagging_route_dies("moq-transport-22".parse().unwrap()).await; -} - /// `P` publishes through the relay `O`, which `M1` and `M2` both pull from, and `E` /// reads through `M1` with `budget`, leaving `M2` cold. `P` writes a one-second group of /// ten frames every second. `M1` is killed partway through group 4: it falls silent @@ -744,7 +733,6 @@ macro_rules! route_flap_tests { route_flap_tests! { flaps_lite_07: "moq-lite-07-wip", - flaps_ietf_22: "moq-transport-22", } /// How the incumbent of a redundant pair goes away. From 60c8cd34250c088cba0820d49952a715fd04981d Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 00:30:56 -0700 Subject: [PATCH 6/9] chore(quest): finish quest/m1/ietf-epoch-cut Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 1 - quest/m1/announce-takeover.md | 5 +- quest/m1/ietf-epoch-cut.md | 93 ----------------------------------- 3 files changed, 3 insertions(+), 96 deletions(-) delete mode 100644 quest/m1/ietf-epoch-cut.md diff --git a/quest/m1/README.md b/quest/m1/README.md index aaebf63bfb1..d1b3ce98f8d 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -150,7 +150,6 @@ removed). - [moq-transport 18 and 22 only](/quest/m1/ietf-drop/README.md) - drafts 14-17 and 19-21 are deleted from Rust, JS, tests, interop lanes, and docs, removing the legacy control-stream adapter and its request limit - [Our moq-transport publishers refuse SUBSCRIBE_TRACKS](/quest/m1/ietf-tracks-refuse.md) - a peer's listing gets NOT_SUPPORTED, while Rust still lists an IETF peer's tracks upstream for the archive - [A moq-transport request token is one auth per distinct token](/quest/m1/ietf-token-auth.md) - requests naming the same token share one verification and grant, on any request type, ending with the last such request -- [moq-transport carries no epoch](/quest/m1/ietf-epoch-cut.md) - Rust and JS moq-transport sessions stop negotiating MoQ Epoch, so every moq-transport hop is epochless; the draft stays - [moq-quic's API improves on quinn's](/quest/m1/quic-api/README.md) - moq-quic and both QUIC drivers ship one mirrored API: `send::`/`recv::` namespaces, one error per direction, consuming terminal operations, plain configs, no quinn baggage - [On-demand JavaScript FETCH](/quest/m1/js-fetch-on-demand.md) - browser publishers answer IETF FETCH for evicted or uncached groups through the JS ranges request surface - [Rust cancels an unclaimed fill head when a subscription ends](/quest/m1/ietf-fill-end-cancel.md) - SUBSCRIPTION_ENDED cancels, not finishes, a fill no group was sent for, as in JS diff --git a/quest/m1/announce-takeover.md b/quest/m1/announce-takeover.md index 00470d8891b..5b5c7a9f111 100644 --- a/quest/m1/announce-takeover.md +++ b/quest/m1/announce-takeover.md @@ -13,8 +13,9 @@ job never inherits those readers. Rust and JS expose the transition as Decided in the 2026-10-10 quest audit interview: replace response-only claim epochs with `ANNOUNCE_TAKEOVER`. Keep this shared-model and lite-07 work in m1 and a prerequisite of the lite-07 cut, not the m0 release. moq-transport -gets no counterpart, since [moq-transport carries no epoch](/quest/m1/ietf-epoch-cut.md) -(decided 2026-10-28), so a moq-transport hop uses Start/Restart. Ordinary +gets no counterpart, since moq-transport carries no epoch (decided 2026-10-28, +removed in [moq-dev/moq#7239](https://github.com/moq-dev/moq/pull/7239)), so a +moq-transport hop uses Start/Restart. Ordinary Start/Restart is a supported fallback, including the accepted cold-start reset before this lands. diff --git a/quest/m1/ietf-epoch-cut.md b/quest/m1/ietf-epoch-cut.md deleted file mode 100644 index e90740778cb..00000000000 --- a/quest/m1/ietf-epoch-cut.md +++ /dev/null @@ -1,93 +0,0 @@ -# [M] moq-transport carries no epoch - -## Goal - -The Rust (`rs/moq-net/src/ietf/`) and JS (`js/net/src/ietf/`) moq-transport -sessions no longer offer, honor, or send MoQ Epoch: no EPOCH Setup Option -(`0x40B68`) and no EPOCH parameter (`0x40B69`). Every moq-transport hop is -epochless, as with a third-party peer: namespace alone names the broadcast, -and a publisher restart there reads as Restart. moq-lite 07 keeps carrying -epochs unchanged, so our own relays, which talk moq-lite to each other, keep -them. - -Non-goals: `drafts/draft-lcurley-moq-epoch.md` stays as an unimplemented -proposal, and the cluster and hang drafts keep their references to it. No -moq-transport takeover is planned. - -## Plan - -Decided with the maintainer on 2026-10-28 (`/quest-plan`, "cut epoch over -moq-transport"). - -Why: no third party implements the extension (a GitHub code search for its -code points finds only this repository), the draft was never submitted to -the datatracker, and the matching and refusal logic already lives in -`rs/moq-net/src/model/origin.rs` and `js/net/src/origin.ts`. What the -moq-transport side adds is about 360 source lines and 580 test lines from -[the feature commit](https://github.com/moq-dev/moq/commit/2dae63603f), much -of it deciding between in-place replacement and DONE plus re-advertising, -since moq-transport has no restart message. It was also the base for an [L] -negotiated takeover, which this cut drops. - -Decision prompts: - -- Scope: ✅ cut the code and the IETF takeover quest; only drop the takeover - quest; keep it all. The maintainer first picked a full cut, then kept the - draft text. -- Shared moq-lite/moq-transport core first, to make epochs cheaper: no. The - epoch semantics are already shared in the model, so a shared core would - move the moq-transport-specific replacement code, not delete it. The - shared serving machines are planned separately in - [Shared group serving and ingest](/quest/m2/shared-serve.md). -- `setup::Extensions.epoch` (Rust, `deny_unknown_fields`) and JS - `extensions.epoch`: ✅ delete, as a breaking `feat(net)!`, so a relay - config still setting `epoch = false` fails loudly at startup; accept and - ignore. -- Docs: ✅ inline fixes only; a separate docs page. -- Rank: ✅ m1, after the other moq-transport narrowing quests; m2. - -Implementation: - -- **Rust.** Delete `rs/moq-net/src/ietf/epoch.rs`, the `Peer::epoch` flag, - the declined-offer bookkeeping in `ietf/peer.rs`, the SETUP option in - `ietf/session.rs`, and the EPOCH parameter on PUBLISH_NAMESPACE, - NAMESPACE, SUBSCRIBE, FETCH, and TRACK_STATUS in `ietf/publisher.rs`, - `ietf/subscriber.rs`, and the message codecs. Delete the replacement - branches only an epoch-carrying advertisement takes (around `replaces` in - `ietf/publisher.rs`, and the subscriber's refusal of a namespace that gains - or loses an epoch). An inbound EPOCH parameter, now never negotiated, is - handled like any other unknown parameter. Remove `Extensions::epoch` - from `rs/moq-net/src/setup.rs` and its test - `an_epoch_crosses_only_when_both_offer_it` in - `rs/moq-net/tests/integration/extensions.rs`. -- **JS.** Delete `js/net/src/ietf/epoch.ts` and its tests, the `epoch` - option in `js/net/src/connection/extensions.ts`, the handshake's - `Ietf.Epoch.fromSetup`, the `Ietf.Epoch` export, and the EPOCH paths in the - IETF publisher, subscriber, and message codecs. -- **Tests.** The integration tests that run epoch scenarios across versions - (`replacement`, `rejoin`, `route_change`, `catalog_handover`, `multi_cdn`, - and the rest under `rs/moq-net/tests/integration`), and the interop clients - in `test/interop/clients`, expect epochless behavior on moq-transport - instead of epoch behavior. Delete the cases that only pinned EPOCH framing. - The priority-update coverage in `rs/moq-net-tests/tests/integration/restart.rs` - has a "moq-transport-18 after an epoch switch, relayed" case; turn it into an - epochless restart. If a compat cell - in `test/interop/compat.sh` asserted an epoch across moq-transport, add a - planned break to `test/interop/compat/planned-breaks.json`. -- **Docs.** Say moq-lite 07 only where a doc promises epochs or redundant - ingest over moq-transport: `doc/setup/redundancy.md`, - `doc/concept/moq-lite.md`, `doc/concept/standard.md`, - `doc/concept/stats.md`, and `doc/bin/relay/cluster.md`. Remove the - `epoch` lines from `doc/bin/relay/config.md`. The PR's Impact section says - how to migrate (delete any `epoch` extension setting), for the release cut - to write into `MIGRATE.md`. - -Run `just check`, `just test interop --all`, and the compat lane. - -Public API: breaking. `setup::Extensions::epoch` and JS `extensions.epoch` -are removed, and so is `Ietf.Epoch`. Wire: moq-transport sessions stop -offering EPOCH and never send its parameter. moq-lite is unchanged. - -## Related - -- [Announcement takeover](/quest/m1/announce-takeover.md) - the lite-07 takeover, which no moq-transport counterpart follows From 46249bbadb5c6646f84e52ddcbef9fb8fc280c41 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 01:32:07 -0700 Subject: [PATCH 7/9] test(e2ee): assert moq-transport delivers no route epoch Co-Authored-By: Claude Opus 5.5 --- js/e2ee/src/transport.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/e2ee/src/transport.test.ts b/js/e2ee/src/transport.test.ts index c372403f458..26967bb40ba 100644 --- a/js/e2ee/src/transport.test.ts +++ b/js/e2ee/src/transport.test.ts @@ -74,8 +74,8 @@ for (const [name, protocol, routed, timed] of transports) { const remote = await active(subscriber, path); // The epoch rides the route where the wire carries it; elsewhere the application supplies it. - if (routed) expect(remote.epoch).toBe(generation.epoch); - const epoch = routed && remote.epoch ? remote.epoch : generation.epoch; + expect(remote.epoch).toBe(routed ? generation.epoch : undefined); + const epoch = remote.epoch ?? generation.epoch; const consumer = await new Protected.Consumer(remote, cred.consume(epoch)).subscribe("video", { maxDelay: Milli(60_000), }); From 846eb146cf1a3927e03327c06630eaecf14c2cf0 Mon Sep 17 00:00:00 2001 From: quest fixer Date: Sat, 31 Oct 2026 21:37:00 -0700 Subject: [PATCH 8/9] docs: repair links to retired epoch removal quest --- quest/m1/api-audit/route/README.md | 2 +- quest/m1/api-audit/route/identity.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/quest/m1/api-audit/route/README.md b/quest/m1/api-audit/route/README.md index 926c5b7d9a1..c216f8298e3 100644 --- a/quest/m1/api-audit/route/README.md +++ b/quest/m1/api-audit/route/README.md @@ -18,7 +18,7 @@ mirror it. Non-goals: the route layer's wire messages and federation ([Routes and announces](/quest/m1/cluster-routing/routes.md)), lite-07 takeover ([announce takeover](/quest/m1/announce-takeover.md)), and any -moq-transport identity ([moq-transport carries no epoch](/quest/m1/ietf-epoch-cut.md)). +moq-transport identity ([moq-transport carries no epoch](https://github.com/moq-dev/moq/pull/7239)). ## Plan diff --git a/quest/m1/api-audit/route/identity.md b/quest/m1/api-audit/route/identity.md index 4563cd9974b..8e2184bc782 100644 --- a/quest/m1/api-audit/route/identity.md +++ b/quest/m1/api-audit/route/identity.md @@ -30,7 +30,7 @@ ends that broadcast, and `follow` yields the next one. Consumers, pins and catalog references see only the identity; the epoch is never public. Non-goals: carrying identity over moq-transport (it carries none, -[decided 2026-10-28](/quest/m1/ietf-epoch-cut.md)), public-key identities +[decided 2026-10-28](https://github.com/moq-dev/moq/pull/7239)), public-key identities (a later option), and the route-handle API shape ([One Route handle](/quest/m1/api-audit/route/handle.md)). From 6fed26889fe8680ec78f51617cc6e9193c5ed665 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 1 Nov 2026 03:17:48 -0800 Subject: [PATCH 9/9] fix(net): format the merged Resolve, drop the IETF resolve's unused epoch The JS moq-transport publisher's #resolve kept an epoch parameter no caller passes since requests no longer carry EPOCH. Co-Authored-By: Claude Opus 5.5 --- js/net/src/ietf/publisher.ts | 5 ++--- rs/moq-net/src/ietf/publisher.rs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/js/net/src/ietf/publisher.ts b/js/net/src/ietf/publisher.ts index bcdb75bbc61..7b2d1d807e9 100644 --- a/js/net/src/ietf/publisher.ts +++ b/js/net/src/ietf/publisher.ts @@ -7,7 +7,6 @@ import { enforceGrant } from "../auth_session.ts"; import type * as broadcast from "../broadcast.ts"; import { Withdrawal } from "../connection/withdrawal.ts"; import * as DatagramStream from "../datagram_stream.ts"; -import type * as Epoch from "../epoch.ts"; import { controlTimeout, error, @@ -2580,10 +2579,10 @@ export class Publisher { * Resolve the broadcast a request names for serving: a local publish, or else the * origin's routes and dynamic handlers. Rejects with the abort once `signal` aborts. */ - async #resolve(name: Path.Valid, signal: AbortSignal, epoch?: Epoch.Valid): Promise { + async #resolve(name: Path.Valid, signal: AbortSignal): Promise { const broadcast = this.#publish && - (wireOf(this.#publish).local(name, epoch) ?? (await wireOf(this.#publish).demand(name, epoch, signal))); + (wireOf(this.#publish).local(name) ?? (await wireOf(this.#publish).demand(name, undefined, signal))); if (!broadcast) throw new NotFound(`broadcast ${name}`); return broadcast; } diff --git a/rs/moq-net/src/ietf/publisher.rs b/rs/moq-net/src/ietf/publisher.rs index 6e86896b377..8f49ed6964f 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -4317,8 +4317,7 @@ impl Resolve { return Poll::Ready(Ok(None)); }; // The immediate lookup: answering a peer never starts discovery of its own. - let requesting: kio::Pending = - origin.lookup(self.path.clone(), None); + let requesting: kio::Pending = origin.lookup(self.path.clone(), None); let found = wait!(Lookup => match publisher.poll_withdrawn(&mut self.session, stream, waiter) { Poll::Ready(()) => Poll::Ready(None), Poll::Pending => requesting.poll_ok(waiter).map(Some),