diff --git a/doc/bin/cli.md b/doc/bin/cli.md index dc972443de1..b7dd5cb32a3 100644 --- a/doc/bin/cli.md +++ b/doc/bin/cli.md @@ -400,8 +400,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 0c6dfab9e42..f0bccd5574e 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 3dcedf0a3fa..8351e75d9f5 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 @@ -328,7 +327,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/identity.md b/doc/concept/identity.md index 0e707c6be72..3b97e804373 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/doc/concept/moq-lite.md b/doc/concept/moq-lite.md index 8b23bace25c..4e5b157ef7d 100644 --- a/doc/concept/moq-lite.md +++ b/doc/concept/moq-lite.md @@ -145,13 +145,8 @@ authorization and hidden names work exactly as without one. The epoch and the restart and takeover messages travel on moq-lite 07, which is opt-in. Older versions carry a takeover as an ordinary announcement, so the first subscription through a claim is reset once the output's route arrives. -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 -over the same path, since nothing says it serves the same bytes. A peer that +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. @@ -172,8 +167,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 c58b6019909..ae384cd4d08 100644 --- a/doc/concept/standard.md +++ b/doc/concept/standard.md @@ -46,15 +46,15 @@ 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, -[epoch](/draft/moq-epoch) to carry [publisher epochs](/concept/moq-lite#publisher-epochs) -without changing a path, 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. -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 971ca8b7438..8f9dbe55733 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 bd47398d026..95a81efaea5 100644 --- a/doc/setup/redundancy.md +++ b/doc/setup/redundancy.md @@ -29,9 +29,7 @@ promise. See [identity and recovery](/concept/identity) for the whole contract. 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 bb20728bb01..5a4877034eb 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -67,9 +67,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/e2ee/src/transport.test.ts b/js/e2ee/src/transport.test.ts index 42ae2e5ccaa..06ae66d3efd 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 { 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 74f9cfa71bf..24bc0ca32ac 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, @@ -390,7 +381,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 d5902668b7f..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_20, 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 9b4a5f0652e..5202dca454b 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 629c1861a79..bc70b703f21 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 = @@ -80,7 +77,6 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool const fill = id === MSG_PARAM_FILL_PARAMETERS && from20; const include = id === MSG_PARAM_INCLUDE_PROPERTIES && from20; const newGroup = id === MSG_PARAM_NEW_GROUP_REQUEST; - const epoch = id === MSG_PARAM_EPOCH; switch (message) { case "subscribe-tracks": @@ -114,8 +110,7 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool fill || range || newGroup || - include || - epoch + include ); case "subscribe-ok": return expires || largest; @@ -151,24 +146,15 @@ function allows(message: ControlMessage, version: IetfVersion, id: bigint): bool (order && from20) ); 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 && from20) || - order || - range || - include || - epoch - ); + return auth || id === MSG_PARAM_FILL_TIMEOUT || priority || (filter && from20) || 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; } } @@ -218,7 +204,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"; @@ -439,17 +424,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; @@ -595,14 +569,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 28215feab9a..748185dba30 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; @@ -159,7 +159,6 @@ function publisher( grant, activeCount, auth, - epoch, }: { requiresSolicitation?: boolean; session?: Session; @@ -167,7 +166,6 @@ function publisher( grant?: Signal; activeCount?: boolean; auth?: Tokens; - epoch?: boolean; } = {}, ): { pub: Publisher; origin: OriginProducer } { const origin = new OriginProducer(); @@ -182,7 +180,6 @@ function publisher( grant, activeCount, auth, - epoch, }), origin, }; @@ -1437,214 +1434,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) { @@ -2258,7 +2047,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 6d11a5eff7d..04392b27e70 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, @@ -199,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; @@ -353,10 +345,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. @@ -384,7 +372,6 @@ export class Publisher { hidden = false, activeCount = false, cluster, - epoch = false, grant = new Signal(undefined), auth, ready = Promise.resolve(), @@ -403,8 +390,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. */ @@ -425,7 +410,6 @@ export class Publisher { this.#hidden = hidden; this.#activeCount = activeCount; this.#advert = Cluster.advertise(cluster); - this.#epoch = epoch; this.#datagramWriter = DatagramStream.datagramWriter(quic); } @@ -452,7 +436,6 @@ export class Publisher { } async #runSubscribe(msg: Subscribe, request: RequestStream) { - this.#pinned(msg.epoch); // Draft-22 replaced joining FETCH with fills. const joinable = !Filter.isDraft20(this.#session.version); if (joinable) this.#setJoin(msg.requestId, "pending"); @@ -483,9 +466,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" }; @@ -495,7 +476,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) { @@ -1516,16 +1497,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, @@ -1644,7 +1623,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, @@ -1748,9 +1726,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. @@ -1774,7 +1751,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); } @@ -1787,9 +1764,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; @@ -1841,16 +1815,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; @@ -1891,11 +1855,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) }; } /** @@ -2083,19 +2046,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; @@ -2126,7 +2076,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; @@ -2165,7 +2114,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({ @@ -2264,7 +2213,6 @@ export class Publisher { } async #runFetch(msg: Fetch, request: RequestStream) { - this.#pinned(msg.epoch); // FILL_TIMEOUT is accepted and ignored: a one-group read ends with the group. const version = this.#session.version; const type = msg.type; @@ -2407,7 +2355,7 @@ export class Publisher { if (!relative && start.group !== end.group) return { condition: "not_supported", reasonPhrase: "FETCH spans more than one group" }; - 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; @@ -2639,22 +2587,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): 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; } - - /** 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 a9946d69197..41984268004 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"; @@ -92,12 +91,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, @@ -111,7 +104,6 @@ export class Subscribe { forward, rangeFilters, rendezvous, - epoch, }: { requestId: bigint; trackNamespace: Path.Valid; @@ -125,7 +117,6 @@ export class Subscribe { forward?: boolean; rangeFilters?: boolean; rendezvous?: boolean; - epoch?: Epoch.Valid; }) { this.requestId = requestId; this.trackNamespace = trackNamespace; @@ -139,7 +130,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 { @@ -165,7 +155,6 @@ export class Subscribe { params.includeProperties = false; } } - params.epoch = this.epoch; await params.encode(w, version); } @@ -220,7 +209,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 08ff79220e4..05b72dbd2fd 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 { Elapsed, Manual, Milli, Nano, sleep, timeout, yieldNow } 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"; @@ -123,7 +122,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); @@ -1756,207 +1755,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(), - sleep(Nano.fromMilli(Milli(250))).then(() => "nothing" as const), - ]); - 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 5261886d61c..efe2fe9198d 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, @@ -168,9 +167,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(); @@ -194,7 +190,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. @@ -231,7 +227,6 @@ export class Subscriber { session, quic, cluster, - epoch = false, hidden = false, maxAge = false, activeCount = false, @@ -246,8 +241,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. */ @@ -266,7 +259,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; @@ -318,12 +310,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 }; } /** @@ -405,7 +395,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; @@ -420,12 +410,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); } @@ -433,24 +417,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 }); } } @@ -502,11 +483,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 @@ -630,7 +611,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; @@ -640,15 +620,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 @@ -656,19 +630,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); @@ -735,9 +706,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); @@ -772,7 +741,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 (;;) { @@ -818,7 +787,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. @@ -1231,7 +1200,6 @@ export class Subscriber { request: track.Request, requestId: bigint, deadline: Deadline, - epoch: Epoch.Valid | undefined, ): Promise<{ stream: RequestStream; subscription: Subscription; @@ -1265,7 +1233,6 @@ export class Subscriber { // objects after Largest, and the group's head before it comes on a fetch stream // (see {@link Join}). Fixed for the subscription's life. ...joinFilter(version), - epoch, }); if (msg.fill) { // The fill names this request and can overtake SUBSCRIBE_OK, so it waits on it here. @@ -1347,7 +1314,7 @@ export class Subscriber { state.fill?.(subscription); 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); @@ -1406,8 +1373,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, @@ -1480,9 +1445,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 537f6ab97fc..b3dac21e13d 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.isDraft20(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/quest/m1/README.md b/quest/m1/README.md index dc9f82fc224..10c46b93117 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -143,7 +143,6 @@ removed). - [A smaller, safer API than release](/quest/m1/api-audit/README.md) - every surface added since release has a consumer or is gone, overlapping operations are collapsed, names mirror across Rust, JS, and the bindings, and every break says how to migrate - [moq-transport 18, 20, and 22 only](/quest/m1/ietf-drop/README.md) - drafts 14-17, 19, and 21 are deleted from Rust, JS, tests, interop lanes, and docs, removing the legacy control-stream adapter and its request limit - [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 fcee6f58a0c..b65fb866c63 100644 --- a/quest/m1/announce-takeover.md +++ b/quest/m1/announce-takeover.md @@ -19,7 +19,8 @@ predecessor fields in moq-ffi and the C ABI, and the takeover text in the lite draft and the concept docs. No wire message or public event replaces it. Non-goals: moq-transport, which keeps the cold-start reset -([moq-transport carries no epoch](/quest/m1/ietf-epoch-cut.md), and an +(moq-transport carries no epoch (decided 2026-10-28, removed in +[moq-dev/moq#7239](https://github.com/moq-dev/moq/pull/7239)), and an edge mints a new identity for each announcement, [Identity and epoch](/quest/m1/api-audit/route/identity.md)). 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)). 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 diff --git a/rs/moq-cli/tests/integration/epochs.rs b/rs/moq-cli/tests/integration/epochs.rs index 8094e67b5e6..5a3f3df3c7c 100644 --- a/rs/moq-cli/tests/integration/epochs.rs +++ b/rs/moq-cli/tests/integration/epochs.rs @@ -207,7 +207,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/tests/integration/restart.rs b/rs/moq-net-tests/tests/integration/restart.rs index af3214481be..2f2baf3aa74 100644 --- a/rs/moq-net-tests/tests/integration/restart.rs +++ b/rs/moq-net-tests/tests/integration/restart.rs @@ -342,13 +342,12 @@ async fn dynamic_epoch(version: &str, from: Option, 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}"); @@ -793,7 +790,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/fuzz.rs b/rs/moq-net/src/fuzz.rs index 762cfbea50a..c223068bb1b 100644 --- a/rs/moq-net/src/fuzz.rs +++ b/rs/moq-net/src/fuzz.rs @@ -881,7 +881,6 @@ impl Default for Messages { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }, ietf_ok: ietf::SubscribeOk { track_alias: 5, @@ -1033,7 +1032,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(), @@ -1375,7 +1373,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 41fc167ab01..015e09598f1 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 9776a3c055d..bfc349d728a 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; @@ -104,7 +103,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}"); } @@ -118,7 +116,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 82b65ebfc46..38a1e7d3970 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 5150035d1fa..bc518ddc8d5 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. - #[kio::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 369a08bbe46..5dffa0ef2c8 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 a934a151fdc..8f49ed6964f 100644 --- a/rs/moq-net/src/ietf/publisher.rs +++ b/rs/moq-net/src/ietf/publisher.rs @@ -532,9 +532,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), } @@ -651,9 +649,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 { @@ -670,7 +665,6 @@ impl Namespaces { gate: None, epoch: 0, hidden: false, - epochs: false, } } @@ -678,7 +672,6 @@ impl Namespaces { fn negotiated(&self) -> ietf::Negotiated { ietf::Negotiated { cluster: self.peer.negotiated(), - epoch: self.epochs, } } @@ -987,9 +980,8 @@ impl Publisher { &self, stream: &mut Stream, path: &crate::Path, - epoch: Option, ) -> Result, Error> { - let mut resolve = Resolve::new(self.session.clone(), path.clone(), epoch); + let mut resolve = Resolve::new(self.session.clone(), path.clone()); kio::wait(|waiter| resolve.poll(waiter, self, stream)).await } @@ -1025,42 +1017,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); @@ -1087,9 +1069,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(), @@ -1119,9 +1098,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. @@ -1214,9 +1190,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(), @@ -1381,9 +1354,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 @@ -1397,9 +1368,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 @@ -2735,9 +2705,6 @@ impl Publisher { // FILL_TIMEOUT is accepted and ignored: a one-group read ends with the group. - // 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; @@ -2822,7 +2789,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, @@ -3199,10 +3166,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, @@ -3312,21 +3276,13 @@ impl Publisher { let request = ns.requests.get(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()); // Keep one opening advertisement per namespace. Its answer reconciles the latest - // route, so epoch churn cannot accumulate replacement streams behind a stalled write. + // route, so route churn cannot accumulate replacement streams behind a stalled write. if wanted && request.is_some_and(|request| !request.accepted) { return Ok(()); } @@ -3375,24 +3331,8 @@ impl Publisher { self.withdraw_namespace(&mut ns.target, &mut ns.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 = ns.requests.remove(suffix); - refused = self - .advertise_namespace(ns, path, suffix.clone(), advert.params(), auth) - .await?; - if let Some(old) = old { - match ns.requests.get_mut(suffix) { - Some(request) => request.previous = Some(Box::new(old)), - None => end_request(old.stream), - } - } - } (true, Some(_)) => { - tracing::debug!(broadcast = %absolute, renamed, "publish_namespace restart"); + tracing::debug!(broadcast = %absolute, "publish_namespace restart"); self.withdraw_namespace(&mut ns.target, &mut ns.requests, suffix.clone()) .await?; refused = self @@ -3421,14 +3361,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 @@ -3497,7 +3429,6 @@ impl Publisher { stream: request, auth, accepted: false, - previous: None, queued: false, pending: Some(NamespacePending::Writing { _auth: None }), waiter: None, @@ -3520,7 +3451,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()) { @@ -3718,9 +3649,6 @@ impl Publisher { }; let initial = !request.accepted; let idle = request.pending.take().is_none(); - if let Some(previous) = request.previous.take() { - end_request(previous.stream); - } let absolute = self.origin.root().rejoin(&request.path); // A reset stream ends only this request, like a FIN; a malformed answer is the peer's @@ -3822,8 +3750,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)); @@ -3856,9 +3783,6 @@ impl Publisher { match target { Target::Requests => { if let Some(request) = requests.remove(&suffix) { - if let Some(previous) = request.previous { - end_request(previous.stream); - } end_request(request.stream); } } @@ -3907,8 +3831,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 } @@ -3993,7 +3916,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)) } @@ -4011,7 +3934,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 } @@ -4111,11 +4033,11 @@ impl Publisher { let event = { let Namespaces { target, - epoch, requests, inflight, woken, updates, + epoch, gate, .. } = &mut ns; @@ -4281,10 +4203,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?; @@ -4298,16 +4218,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, @@ -4380,17 +4290,15 @@ struct LiveGroup { struct Resolve { session: Transport, path: crate::Path, - epoch: Option, state: ResolveState, } #[kio::machine(self.state: ResolveState)] impl Resolve { - fn new(session: Transport, path: crate::Path, epoch: Option) -> Self { + fn new(session: Transport, path: crate::Path) -> Self { Self { session, path, - epoch, state: ResolveState::Start, } } @@ -4409,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(), self.epoch.as_ref()); + 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), @@ -5817,9 +5724,6 @@ struct NamespaceRequest { auth: Option, /// Whether the peer accepted the initial advertisement. accepted: bool, - /// The previous epoch's request and credential, kept until its replacement answers. - /// Only accepted requests can be replaced, so this holds at most one predecessor. - previous: Option>, /// Waiting in [`Namespaces::updates`] for a request ID. queued: bool, /// The one message still writing or awaiting an answer. @@ -6881,7 +6785,6 @@ mod serve_tests { answer: None, auth: None, accepted: true, - previous: None, queued: false, pending: None, waiter: None, @@ -7169,7 +7072,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(); @@ -7181,10 +7083,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"); @@ -7194,7 +7093,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"); @@ -7203,10 +7102,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"); } } @@ -8173,12 +8069,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:?}"); } @@ -8497,7 +8388,6 @@ mod serve_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } } @@ -8579,179 +8469,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. - #[kio::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. - #[kio::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. - #[kio::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; 3] = [Version::Draft18, Version::Draft20, Version::Draft22]; fn track_status(namespace: &str, wanted: bool, version: Version) -> Vec { @@ -8760,7 +8477,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) @@ -8787,12 +8503,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"); @@ -8872,12 +8583,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}"); @@ -8963,7 +8669,6 @@ mod serve_tests { track_namespace: crate::Path::from_static("room"), track_name: "video".into(), properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -9003,12 +8708,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) @@ -9081,7 +8781,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"); @@ -9127,7 +8827,6 @@ mod serve_tests { properties_wanted: true, range_filters: true, fill_timeout: false, - epoch: None, }, ) .await @@ -9195,7 +8894,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()); @@ -9320,7 +9019,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); @@ -10003,7 +9701,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await?; @@ -10138,7 +9835,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!( @@ -10175,7 +9872,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, _)) => { @@ -10200,7 +9897,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()); @@ -10322,7 +10019,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -10560,7 +10256,6 @@ mod serve_tests { range_filters: false, fill_timeout: true, properties_wanted, - epoch: None, }, ) .await @@ -10767,7 +10462,6 @@ mod serve_tests { ietf::TrackStatus::ID, ietf::Body(track_status("room", true, version).into()), stream, - false, ) .unwrap() .await; @@ -11463,7 +11157,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. @@ -11569,7 +11262,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. @@ -11719,7 +11411,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -11862,7 +11553,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, )); for _ in 0..100 { @@ -12173,7 +11863,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -12188,7 +11877,6 @@ mod serve_tests { track_namespace: crate::Path::from_static("room"), track_name: "video".into(), properties_wanted: true, - epoch: None, }, ) .await @@ -12393,7 +12081,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -12442,7 +12129,6 @@ mod serve_tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -14304,7 +13990,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 @@ -14647,89 +14333,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. - #[kio::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( @@ -15387,7 +14990,6 @@ mod tests { max_age: false, auth: false, active_count: false, - epoch: false, flate: false, }); slot @@ -16452,104 +16054,6 @@ mod tests { } } - /// A blocked replacement retains the previous epoch until its answer, coalesces later - /// epochs, and withdraws both streams when the namespace goes away. Even an early OK - /// must not let churn build more streams behind a write the peer has not taken. - #[kio::test] - async fn a_stalled_epoch_replacement_is_bounded_and_withdrawn() { - use crate::lite::test_transport::{Log, ScriptedSession, Sent, SinkSend}; - - for version in [Version::Draft18, Version::Draft22] { - let origin = unheld_origin(); - let epoch = crate::Epoch::mint(); - let auth = crate::auth::Link::ietf(false); - let first = auth.present(bytes::Bytes::from_static(b"first"), false).unwrap(); - let mut routes = vec![ - origin - .announce( - "cam", - crate::origin::Route::default() - .with_epoch(epoch.clone()) - .with_auth(first), - ) - .unwrap(), - ]; - settle().await; - let encoded = Log::default(); - let mut writer = Writer::new(SinkSend::new(encoded.clone()), version); - writer - .encode_message(&ietf::PublishNamespace { - request_id: RequestId(1), - track_namespace: crate::Path::from_static("cam"), - params: ietf::AdvertParams { - epoch: Some(epoch), - ..Default::default() - }, - authorization_token: Some(auth_token(b"first")), - }) - .await - .unwrap(); - let window = encoded.writes.lock().unwrap().len(); - let ok = publish_namespace_ok(version).await; - let session = ScriptedSession::per_stream(vec![ok.clone(), ok]).with_send_window(window); - let log = session.log.clone(); - let setup = peer::PeerSetup::default(); - setup.set(peer::Peer { - epoch: true, - solicit: Some(false), - ..Default::default() - }); - let publisher = Publisher::new( - crate::time::sim(), - crate::driver::Transport::new(session), - origin.consume(), - Control::new(false), - None, - setup, - version, - ) - .with_auth(auth.clone()); - let mut run = std::pin::pin!(publisher.run_publish_namespaces()); - assert!(futures::poll!(run.as_mut()).is_pending()); - assert_eq!(log.bi_opens(), 1); - assert_eq!(log.writes.lock().unwrap().len(), window); - - for _ in 0..4 { - let token = auth - .present(bytes::Bytes::from_static(b"a-longer-token"), false) - .unwrap(); - routes.push( - origin - .announce( - "cam", - crate::origin::Route::default() - .with_epoch(crate::Epoch::mint()) - .with_auth(token), - ) - .unwrap(), - ); - settle().await; - assert!(futures::poll!(run.as_mut()).is_pending()); - assert_eq!(log.bi_opens(), 2, "{version}: epoch churn accumulated streams"); - assert!( - log.resets().is_empty(), - "{version}: withdrew before the replacement answered" - ); - } - assert_eq!( - log.writes.lock().unwrap().len(), - 2 * window, - "{version}: the replacement is stalled" - ); - drop(routes); - settle().await; - assert!(futures::poll!(run.as_mut()).is_pending()); - assert_eq!(log.resets(), vec![super::super::error::CANCELLED; 2], "{version}"); - assert_eq!(log.stops(), vec![super::super::error::CANCELLED; 2]); - assert!(!log.trail().iter().any(|(_, sent)| matches!(sent, Sent::Finish))); - } - } - /// An advertisement the peer never answers is given up at its deadline: its own stream's /// reset ends it. #[kio::test] @@ -16765,7 +16269,6 @@ mod tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }, ) .await @@ -16794,7 +16297,6 @@ mod tests { range_filters: false, fill_timeout: false, properties_wanted: true, - epoch: None, }, ) .await @@ -17212,7 +16714,6 @@ mod range_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, } } diff --git a/rs/moq-net/src/ietf/session.rs b/rs/moq-net/src/ietf/session.rs index 8facb2303f5..5965acdb780 100644 --- a/rs/moq-net/src/ietf/session.rs +++ b/rs/moq-net/src/ietf/session.rs @@ -11,7 +11,7 @@ use crate::{ use futures::FutureExt as _; 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, }; @@ -193,7 +193,7 @@ pub fn start(config: Config) -> Result<(Driver, crate::goaway::Handle, Option peer_setup.set(declared), @@ -601,7 +601,6 @@ pub(crate) fn decode_peer_setup(parameters: &[u8], version: Version, client: boo max_age: max_age::from_setup(¶ms, version), auth: auth::from_setup(¶ms) == Some(true), active_count: active_count::from_setup(¶ms), - epoch: epoch::from_setup(¶ms), flate: super::flate::from_setup(¶ms)?, }, }) @@ -665,9 +664,6 @@ async fn run_setup( auth::into_setup(&mut parameters); } active_count::into_setup(&mut parameters); - if extensions.epoch { - epoch::into_setup(&mut parameters); - } request_update::into_setup(&mut parameters, version); super::flate::into_setup(&mut parameters); let parameters = parameters.encode_bytes(version)?; @@ -1049,8 +1045,6 @@ async fn run_dispatch( true => 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). @@ -1067,7 +1061,6 @@ async fn run_dispatch( publisher, subscriber, peer, - epoch, declared, serve, version, @@ -1121,8 +1114,6 @@ struct Bidi { publisher: Publisher, subscriber: Subscriber, peer: cluster::Peer, - /// Whether both sides negotiated MoQ Epoch. - epoch: bool, declared: Option, serve: Option, version: Version, @@ -1136,7 +1127,6 @@ impl Bidi { publisher, mut subscriber, peer, - epoch, declared, serve, version, @@ -1191,11 +1181,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); @@ -1478,7 +1468,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(); @@ -2782,7 +2771,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 29b0c0a6c87..e676b01d4f8 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_draft20(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_draft20(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::Draft20, 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 cf96ba117e0..bc81892ffdc 100644 --- a/rs/moq-net/src/ietf/subscriber.rs +++ b/rs/moq-net/src/ietf/subscriber.rs @@ -776,12 +776,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 @@ -835,7 +834,6 @@ impl TrackState { name, alias: None, broadcast, - epoch: None, timescale: None, fill_largest: None, fill_start: None, @@ -916,14 +914,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 { @@ -931,8 +921,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, @@ -942,9 +930,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, the session @@ -995,10 +980,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, @@ -1136,7 +1117,6 @@ impl Subscriber { announces: Default::default(), listings: Default::default(), validity: Default::default(), - epoch: None, } } @@ -1349,8 +1329,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. @@ -1491,7 +1470,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) @@ -1615,22 +1593,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. @@ -1639,20 +1609,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()))) { @@ -1698,7 +1666,6 @@ impl Subscriber { body: ietf::Body, stream: Stream, peer: cluster::Peer, - epoch: bool, declared: Option, ) -> Result, Error> { let mut this = self.clone(); @@ -1733,7 +1700,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) => { @@ -1875,7 +1841,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") @@ -1883,7 +1848,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 @@ -1961,7 +1925,6 @@ impl Subscriber { &path, Held { cluster: msg.params.cluster, - epoch, }, peer, &mut attached, @@ -2022,10 +1985,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 @@ -2240,8 +2200,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), @@ -2483,18 +2441,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(); @@ -2685,22 +2637,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)); @@ -2725,7 +2674,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"); @@ -3127,7 +3075,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()) @@ -3186,7 +3133,6 @@ impl Subscriber { rendezvous: false, range_filters: false, authorization_token: None, - epoch: self.epoch.clone(), }, ), }; @@ -4250,7 +4196,6 @@ impl Subscriber { fill_timeout: false, properties_wanted: true, // Served by the subscription it joins, which named the instance. - epoch: None, }, )?; this.finish_joining_fetch(stream, progress).await @@ -4450,7 +4395,6 @@ impl Subscriber { track_namespace: broadcast_path.clone(), track_name: track_name.into(), properties_wanted: true, - epoch: self.epoch.clone(), }, ); if let Err(err) = written { @@ -5607,7 +5551,6 @@ impl Subscriber { Some(Ok(timescale)) => timescale.is_some(), _ => true, }, - epoch: self.epoch.clone(), }, ); let mut messages = super::request_stream::Messages::new(self.session.clone(), self.control.client()); @@ -6758,101 +6701,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. - #[kio::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. @@ -6878,7 +6726,6 @@ mod tests { hops: hop_path(&[7, 5, 9]), cost: 0, }), - epoch: None, }), }; writer.varint(ietf::Namespace::ID).await.unwrap(); @@ -9188,7 +9035,6 @@ mod tests { hops: hop_path(&[7, 9]), cost, }), - epoch: None, }), }) .await @@ -9578,98 +9424,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. - #[kio::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. - #[kio::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. #[kio::test] @@ -9939,7 +9693,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -9989,7 +9742,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -10079,7 +9831,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -10152,7 +9903,6 @@ mod tests { &path, Held { cluster: Some(held.clone()), - epoch: None }, peer, &mut attached, @@ -10204,7 +9954,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -10258,7 +10007,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -10306,7 +10054,6 @@ mod tests { cost: 0, ..clean.clone() }), - epoch: None, }, authorization_token: None, }) @@ -10327,7 +10074,6 @@ mod tests { &path, Held { cluster: Some(clean.clone()), - epoch: None }, peer, &mut attached, @@ -13133,7 +12879,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(); @@ -13154,7 +12899,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(); @@ -13164,7 +12908,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(); @@ -13661,7 +13405,6 @@ mod stitch_tests { rendezvous: false, range_filters: false, authorization_token: None, - epoch: None, }; let mut body = Vec::new(); subscribe @@ -13671,7 +13414,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(); diff --git a/rs/moq-net/src/ietf/subscriber/tracks.rs b/rs/moq-net/src/ietf/subscriber/tracks.rs index 86b295e8695..c12b89b13d4 100644 --- a/rs/moq-net/src/ietf/subscriber/tracks.rs +++ b/rs/moq-net/src/ietf/subscriber/tracks.rs @@ -629,7 +629,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)) }, ); @@ -655,7 +654,6 @@ impl Subscriber { rendezvous: false, range_filters: false, authorization_token: None, - epoch: self.epoch.clone(), }, )?; let mut response = std::pin::pin!(async { @@ -848,7 +846,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)) }, ); @@ -1132,7 +1129,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 3dec6d9b87d..d962a6f5884 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_draft20(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 e0d98a0a983..05d245b670f 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 cb1689a4f9a..94932fde69f 100644 --- a/rs/moq-net/src/test_interop.rs +++ b/rs/moq-net/src/test_interop.rs @@ -70,7 +70,6 @@ fn ietf_range_updates_interop() { authorization_token: None, new_group: None, max_age: None, - epoch: None, } .encode(&mut w, version) .unwrap(); @@ -640,7 +639,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 f18f1cf9bf3..dfd10c8f986 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) { #[kio::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; } #[kio::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 6b1acb95b2a..a477925cf59 100644 --- a/rs/moq-net/tests/integration/extensions.rs +++ b/rs/moq-net/tests/integration/extensions.rs @@ -142,75 +142,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) - | moq_net::announce::Event::Takeover { announce: 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. -#[kio::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(); - kio::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 005e99dbd5c..1e4871eadb9 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; @@ -314,11 +313,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) { kio::clock::timeout(TEST_TIMEOUT, async { let mut topology = Topology::new(secondary.parse().unwrap()).await; let mut announced = topology.subscriber.consume().announced(); @@ -332,16 +328,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 @@ -349,12 +352,12 @@ async fn refused_across_protocols(secondary: &str) { } #[kio::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. #[kio::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 05c51b24d48..b9adc68ac46 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) = kio::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. #[kio::test] -async fn epoch_ietf() { +async fn epoch_is_stripped_ietf() { for version in ["moq-transport-18", "moq-transport-22"] { kio::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. #[kio::test] async fn epochless_ietf() { - for version in ["moq-transport-22"] { + for version in ["moq-transport-18", "moq-transport-22"] { kio::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 a19a209941b..fb5d8da7b7e 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. //! @@ -304,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 @@ -466,8 +464,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 { @@ -506,6 +502,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", @@ -606,16 +604,6 @@ async fn lite_resumes_after_a_lagging_route_dies() { lagging_route_dies("moq-lite-07-wip".parse().unwrap()).await; } -#[kio::test] -async fn ietf_17_resumes_after_a_lagging_route_dies() { - lagging_route_dies("moq-transport-18".parse().unwrap()).await; -} - -#[kio::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 @@ -745,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. 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 5b758c8bcb0..f175fc78630 100644 --- a/test/interop/clients/js/media.ts +++ b/test/interop/clients/js/media.ts @@ -1307,7 +1307,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), ); @@ -1339,7 +1341,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..6130351d52f 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?.with_range(1..); 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(()) }