diff --git a/conformance/README.md b/conformance/README.md index f0b2ef8b..377e204f 100644 --- a/conformance/README.md +++ b/conformance/README.md @@ -2,7 +2,7 @@ Golden test vectors: every implementation's CI must decode each vector's `wire_hex` to its `message` and re-encode `message` back to exactly `wire_hex`. This is the actual forcing function against drift between implementations -- a schema alone never proves interop, only shared vectors do, the same lesson Cascade's own `docs/conformance/*.v1.json` was built to enforce for its XDR-based protocol. -`mint.v1.json` covers the minting of capability tokens, revocation entries and room notices (see below). `handshake.v1.json` covers `handshake-frame`. `tokens.v1.json` covers `capability-token` (including a delegation chain, one token's `parent` pointing at another) and `handle-record`. `frames.v1.json` covers every other `$frame-variant` in `spec/frame.cddl`. `adverts.v1.json` covers `peer-advert` on its own. `secure-channel.v1.json` covers the secure channel's hellos and sealed frames and the cryptography around them. `invalid-frames.v1.json` covers frames a decoder must refuse. `coordinator-election.v1.json` covers the gossiped coordinator claims and the outcome of sequences of them. `data-sync.v1.json` covers the core/data have, request and entries exchange over a key-value store. `file-storage.v1.json` covers the on-disk layout of the file-backed key-value store. `room-params.v1.json` covers the typed core/room and capability verbs and the room-path and hex helpers. `introspection.v1.json` covers core/management's `path:trace` and `topology.get` and the topology they report. +`mint.v1.json` covers the minting of capability tokens, revocation entries and room notices (see below). `handshake.v1.json` covers `handshake-frame`. `tokens.v1.json` covers `capability-token` (including a delegation chain, one token's `parent` pointing at another) and `handle-record`. `frames.v1.json` covers every other `$frame-variant` in `spec/frame.cddl`. `adverts.v1.json` covers `peer-advert` on its own. `secure-channel.v1.json` covers the secure channel's hellos and sealed frames and the cryptography around them. `invalid-frames.v1.json` covers frames a decoder must refuse. `coordinator-election.v1.json` covers the gossiped coordinator claims and the outcome of sequences of them. `data-sync.v1.json` covers the core/data have, request and entries exchange over a key-value store. `file-storage.v1.json` covers the on-disk layout of the file-backed key-value store. `gossip-directory.v1.json` covers what a session does with the gossip it receives and sends. `room-params.v1.json` covers the typed core/room and capability verbs and the room-path and hex helpers. `introspection.v1.json` covers core/management's `path:trace` and `topology.get` and the topology they report. `invalid-frames.v1.json` holds values outside the grammar of the spec's `.regexp` patterns, which match the whole string: a capability verb with two colons, a trailing space or newline or a leading hyphen, a domain with trailing text, a trailing newline or an embedded separator, and the three verb fields of token claims (`capability`, `grants-capability`, `requests-capability`). Each vector is well-formed CBOR in the shape of a valid frame (`kind: "frame"`) or token-claims map (`kind: "token-claims"`) with exactly one such value, so a conformant decoder refuses it at decoding or at validation. It carries `refused: true`, the rule it breaks in `pattern`, and `valid_control_wire_hex`, the same bytes with a value inside the grammar, which every consumer must accept, so a vector cannot be refused for any other reason than its pattern. `message` and `wire_hex` follow the shared round-trip contract, so the round-trip suites read it like any other file. The TypeScript core's conformance test and `rust/crates/wire-mesh-conformance` both check the refusal and the control. The same invalid capability verbs are sealed in `secure-channel.v1.json` (`undecodable_invalid_*capability_verb_*`), where the frame authenticates, is refused as `undecodable` and consumes its counter. The room-path and device-id-hex patterns occur only in room-notice claims; the implementations' own schema and parser tests pin them, edge by edge. @@ -91,6 +91,18 @@ The outcomes are written by hand from the spec, never produced by an implementat The outcomes are written by hand from the spec, never produced by an implementation. Device-ids, keys and signatures are structural bytes and the adverts are not verified. The TypeScript core's `conformance-introspection.unit.test.ts` and `rust/crates/wire-mesh-conformance` run them. +## gossip-directory.v1.json + +`gossip-directory.v1.json` pins what a session does with the gossip it receives and sends. Its top-level `vectors` are the gossip frames the scenarios deliver. The adverts are really signed, with the Ed25519 keys under `identities` (fixed secrets, so every run writes the same bytes). The `gossip_directory` section holds: + +- `identities`: the keys the adverts are signed with, each with its secret, public key and device id; `me` is the node the scenarios run as. +- `extension_validation`: key bags a gossip update may carry, each accepted or refused for one named reason (`reserved_field`, `session_managed`, `reserved_version`, `not_domain_qualified`), naming the first key refused. +- `directory_scenarios`: gossip frames delivered in order. Each step gives what became of every advert in it (`admitted`, `older`, or the reason it was refused: `wrong_device`, `bad_signature`) and the directory held afterwards, as the device and snapshot time of each entry in first-heard order. A scenario with `rust_only` pins a bound only the Rust session applies (the advert size cap): the TypeScript runner skips it. The TypeScript session reports no per-advert outcome, so its runner compares the directory only. +- `self_adverts`: the advert a session builds for a given clock and extension bag: its device, addresses, `snapshot-seconds`, the sorted keys of its open tail (the extensions, `topology/peers` and `wire-mesh/version`) and its topology. Each is signed by `me` and verifies. The version's value is not pinned, since it is each implementation's own. +- `counts`: the number of entries in each list, which both runners check. + +The outcomes are written by hand from the rules of the session, never produced by an implementation. The TypeScript core's `conformance-gossip-directory.unit.test.ts` and `rust/crates/wire-mesh-conformance` run them. + `verify.unit.test.ts` checks only the round trip every vector file shares: this package holds no protocol implementation of its own, so `signing_input_hex`, `verifies` and the `secure_channel` section are checked by the implementations. `ts/packages/core`'s own conformance tests check them for the TypeScript. The Rust binary checks every file: the round trip of each, `adverts.v1.json`'s extra fields, and `secure-channel.v1.json`'s `secure_channel` section, which it recomputes from the fixed inputs and runs step by step against `wire_mesh_core::domain::secure_channel` (the intermediate keys, every sealed ciphertext, every verdict and every open step with its expected class), failing on any field of the section it does not read. ## Regenerating diff --git a/conformance/gossip-directory-vectors.ts b/conformance/gossip-directory-vectors.ts new file mode 100644 index 00000000..1250b0f9 --- /dev/null +++ b/conformance/gossip-directory-vectors.ts @@ -0,0 +1,461 @@ +/* gossip-directory.v1.json: what a session does with the gossip it receives and sends. + + The top-level vectors are the gossip frames the scenarios deliver, round-tripped like any other file. The `gossip_directory` section holds three lists, written by hand from the rules of the TypeScript session and never produced by an implementation: `extension_validation` (the key bags a gossip update may carry, each accepted or refused for one named reason), `directory_scenarios` (frames delivered to a session in order, each step recording what became of every advert and the directory afterwards, as the devices and snapshot times it holds in first-heard order) and `self_adverts` (the structure of the advert a session sends: its device, addresses, time, the extension keys and the topology, which a consumer checks and whose signature it verifies). + + The adverts are signed with Ed25519 keys from fixed seeds, so every advert is the same bytes in every run. A scenario flagged `rust_only` pins a rule only the Rust session applies (it bounds what a hub can make it hold), and the TypeScript runner skips it. */ + +import { + createHash, + createPrivateKey, + createPublicKey, + sign, +} from "node:crypto"; +import { hex, type JsonWire, type Vector } from "@exadev/wire-mesh-conformance"; +import { advertSigningInput, wireHex } from "./adverts.ts"; + +export const GOSSIP_DIRECTORY_LAYOUT_VERSION = 1; + +const EDDSA = -8; +const SEED_BYTES = 32; +const PKCS8_ED25519_PREFIX = Buffer.from( + "302e020100300506032b657004220420", + "hex", +); +/** The largest an encoded gossip frame carrying one advert may be for the Rust directory to admit it. */ +const BYTES_PER_KIB = 1024; +const ADVERT_CAP_KIB = 16; +const MAX_ADVERT_BYTES = ADVERT_CAP_KIB * BYTES_PER_KIB; +/** The snapshot times the scenarios use: a first advert, a later one and one between them. */ +const FIRST = 10; +const BETWEEN = 15; +const LATER = 20; +const LOW_BYTE_MASK = 0xff; +/** The clock the self-advert cases read, in whole seconds. */ +const CLOCK_SECONDS = 1_700_000_000; +const LARGEST_EXACT = Number.MAX_SAFE_INTEGER; + +interface Identity { + name: string; + secretHex: string; + publicKey: Buffer; + deviceHex: string; + sign: (input: Buffer) => Buffer; +} + +function identity(name: string, seedFill: string): Identity { + const secretHex = seedFill.repeat(SEED_BYTES); + const privateKey = createPrivateKey({ + key: Buffer.concat([PKCS8_ED25519_PREFIX, Buffer.from(secretHex, "hex")]), + format: "der", + type: "pkcs8", + }); + const jwk = createPublicKey(privateKey).export({ format: "jwk" }); + if (typeof jwk.x !== "string") { + throw new Error("the Ed25519 public key has no x coordinate"); + } + const publicKey = Buffer.from(jwk.x, "base64url"); + + return { + name, + secretHex, + publicKey, + deviceHex: createHash("sha256").update(publicKey).digest("hex"), + sign: (input) => sign(null, input, privateKey), + }; +} + +const ME = identity("me", "d4"); +const A = identity("a", "a1"); +const B = identity("b", "b2"); +const C = identity("c", "c3"); +const IDENTITIES = [ME, A, B, C]; + +interface Forgery { + signer?: Identity; + naming?: Identity; + flipSignature?: boolean; +} + +/** An advert of `who` carrying `extensions` in its open tail, signed by `who`; `forgery` has it name or be signed by another identity, or have its signature spoilt after signing. */ +function forged( + who: Identity, + seconds: number, + extensions: Readonly>, + forgery: Readonly, +): Record { + const naming = forgery.naming ?? who; + const content: Record = { + ...extensions, + device: hex(naming.deviceHex), + addresses: [], + "snapshot-seconds": seconds, + "identity-key": { + alg: EDDSA, + "public-key": hex(who.publicKey.toString("hex")), + }, + }; + const signature = (forgery.signer ?? who).sign(advertSigningInput(content)); + if (forgery.flipSignature === true) { + signature[0] = (signature[0] ?? 0) ^ LOW_BYTE_MASK; + } + + return { ...content, signature: hex(signature.toString("hex")) }; +} + +function advert( + who: Identity, + seconds: number, + extensions: Readonly>, +): Record { + return forged(who, seconds, extensions, {}); +} + +function gossip(...peers: readonly Record[]): JsonWire { + return { type: "gossip", peers: [...peers] }; +} + +interface Step { + frame: JsonWire; + outcomes: string[]; + directory: { device: string; snapshot_seconds: number }[]; +} + +interface Scenario { + name: string; + rustOnly: boolean; + steps: Step[]; +} + +function entry(who: Identity, seconds: number): Step["directory"][number] { + return { device: who.deviceHex, snapshot_seconds: seconds }; +} + +/** An advert of `who` padded with one extension so its encoded gossip frame is exactly `bytes` long. */ +function paddedTo( + who: Identity, + seconds: number, + bytes: number, +): Record { + const lengthOf = (text: number): number => + wireHex(gossip(advert(who, seconds, { "pad/x": "x".repeat(text) }))) + .length / 2; + let low = 0; + let high = bytes; + while (low < high) { + const middle = Math.floor((low + high) / 2); + if (lengthOf(middle) < bytes) { + low = middle + 1; + } else { + high = middle; + } + } + if (lengthOf(low) !== bytes) { + throw new Error( + `no padding gives an advert frame of ${String(bytes)} bytes`, + ); + } + + return advert(who, seconds, { "pad/x": "x".repeat(low) }); +} + +const SCENARIOS: readonly Scenario[] = [ + { + name: "adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place", + rustOnly: false, + steps: [ + { + frame: gossip(advert(A, FIRST, {})), + outcomes: ["admitted"], + directory: [entry(A, FIRST)], + }, + { + frame: gossip(advert(B, FIRST, {})), + outcomes: ["admitted"], + directory: [entry(A, FIRST), entry(B, FIRST)], + }, + { + frame: gossip(advert(A, LATER, { "presence/status": "busy" })), + outcomes: ["admitted"], + directory: [entry(A, LATER), entry(B, FIRST)], + }, + ], + }, + { + name: "an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces", + rustOnly: false, + steps: [ + { + frame: gossip(advert(A, LATER, { "presence/status": "new" })), + outcomes: ["admitted"], + directory: [entry(A, LATER)], + }, + { + frame: gossip(advert(A, BETWEEN, { "presence/status": "old" })), + outcomes: ["older"], + directory: [entry(A, LATER)], + }, + { + frame: gossip(advert(A, LATER, { "presence/status": "same" })), + outcomes: ["admitted"], + directory: [entry(A, LATER)], + }, + ], + }, + { + name: "an_advert_that_does_not_verify_is_dropped_alone_and_the_rest_of_its_frame_is_admitted", + rustOnly: false, + steps: [ + { + frame: gossip( + forged(B, FIRST, {}, { naming: C }), + advert(A, FIRST, {}), + forged(C, FIRST, {}, { flipSignature: true }), + ), + outcomes: ["wrong_device", "admitted", "bad_signature"], + directory: [entry(A, FIRST)], + }, + ], + }, + { + name: "an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped", + rustOnly: false, + steps: [ + { + frame: gossip(advert(A, LATER, {})), + outcomes: ["admitted"], + directory: [entry(A, LATER)], + }, + { + frame: gossip(forged(A, BETWEEN, {}, { flipSignature: true })), + outcomes: ["older"], + directory: [entry(A, LATER)], + }, + { + frame: gossip(forged(A, LATER + 1, {}, { flipSignature: true })), + outcomes: ["bad_signature"], + directory: [entry(A, LATER)], + }, + ], + }, + { + name: "an_advert_signed_by_another_key_than_its_own_is_dropped", + rustOnly: false, + steps: [ + { + frame: gossip(forged(A, FIRST, {}, { signer: B })), + outcomes: ["bad_signature"], + directory: [], + }, + ], + }, + { + name: "an_advert_exactly_at_the_size_cap_is_admitted", + rustOnly: false, + steps: [ + { + frame: gossip(paddedTo(A, FIRST, MAX_ADVERT_BYTES)), + outcomes: ["admitted"], + directory: [entry(A, FIRST)], + }, + ], + }, + { + name: "an_advert_one_byte_over_the_size_cap_is_refused", + rustOnly: true, + steps: [ + { + frame: gossip(paddedTo(A, FIRST, MAX_ADVERT_BYTES + 1)), + outcomes: ["too_large"], + directory: [], + }, + ], + }, + { + name: "a_snapshot_time_at_the_largest_exact_integer_is_admitted", + rustOnly: false, + steps: [ + { + frame: gossip(advert(A, LARGEST_EXACT, {})), + outcomes: ["admitted"], + directory: [entry(A, LARGEST_EXACT)], + }, + ], + }, +]; + +interface ExtensionCase { + name: string; + keys: string[]; + /** The first key refused and why, or null when the bag is accepted. */ + refused: { key: string; reason: string } | null; +} + +const EXTENSION_CASES: readonly ExtensionCase[] = [ + { name: "an_empty_bag", keys: [], refused: null }, + { name: "a_domain_qualified_key", keys: ["presence/status"], refused: null }, + { + name: "digits_and_hyphens_after_the_first_letter", + keys: ["app-1/x-y2"], + refused: null, + }, + { + name: "a_key_that_only_contains_a_reserved_name", + keys: ["device/status", "wire-mesh/versions"], + refused: null, + }, + ...[ + "device", + "addresses", + "snapshot-seconds", + "identity-key", + "signature", + ].map((key): ExtensionCase => ({ + name: `the_mandatory_field_${key.replaceAll("-", "_")}`, + keys: [key], + refused: { key, reason: "reserved_field" }, + })), + { + name: "the_topology_the_session_computes", + keys: ["topology/peers"], + refused: { key: "topology/peers", reason: "session_managed" }, + }, + { + name: "the_version_this_crate_reports", + keys: ["wire-mesh/version"], + refused: { key: "wire-mesh/version", reason: "reserved_version" }, + }, + { + name: "a_key_with_no_domain", + keys: ["status"], + refused: { key: "status", reason: "not_domain_qualified" }, + }, + { + name: "an_uppercase_domain", + keys: ["Presence/status"], + refused: { key: "Presence/status", reason: "not_domain_qualified" }, + }, + { + name: "an_uppercase_field", + keys: ["presence/Status"], + refused: { key: "presence/Status", reason: "not_domain_qualified" }, + }, + { + name: "three_segments", + keys: ["a/b/c"], + refused: { key: "a/b/c", reason: "not_domain_qualified" }, + }, + { + name: "a_leading_digit", + keys: ["1a/b"], + refused: { key: "1a/b", reason: "not_domain_qualified" }, + }, + { + name: "an_underscore", + keys: ["a_b/c"], + refused: { key: "a_b/c", reason: "not_domain_qualified" }, + }, + { + name: "an_empty_domain", + keys: ["/x"], + refused: { key: "/x", reason: "not_domain_qualified" }, + }, + { + name: "an_empty_field", + keys: ["x/"], + refused: { key: "x/", reason: "not_domain_qualified" }, + }, + { + name: "the_first_bad_key_is_the_one_named", + keys: ["presence/status", "device", "status"], + refused: { key: "device", reason: "reserved_field" }, + }, +]; + +interface SelfAdvertCase { + name: string; + /** The extension a gossip update carried, or none. */ + extensions: Record; + /** The time the session's clock read, in whole seconds. */ + now_seconds: number; +} + +const SELF_ADVERTS: readonly SelfAdvertCase[] = [ + { + name: "a_session_with_no_extensions", + extensions: {}, + now_seconds: CLOCK_SECONDS, + }, + { + name: "a_gossip_update_with_an_extension", + extensions: { "presence/status": "idle" }, + now_seconds: CLOCK_SECONDS, + }, +]; + +export function gossipDirectoryFile(): { + vectors: Vector[]; + extra: Record; +} { + const vectors: Vector[] = []; + const scenarios = SCENARIOS.map((scenario): JsonWire => ({ + name: scenario.name, + rust_only: scenario.rustOnly, + steps: scenario.steps.map((step, index): JsonWire => { + const name = `gossip_${scenario.name}_${String(index)}`; + vectors.push({ + name, + message: step.frame, + wire_hex: wireHex(step.frame), + }); + + return { + vector: name, + outcomes: step.outcomes, + directory: step.directory.map((held) => ({ ...held })), + }; + }), + })); + + return { + vectors, + extra: { + gossip_directory: { + layout_version: GOSSIP_DIRECTORY_LAYOUT_VERSION, + identities: IDENTITIES.map((who): JsonWire => ({ + name: who.name, + secret_hex: who.secretHex, + public_key_hex: who.publicKey.toString("hex"), + device_id_hex: who.deviceHex, + })), + extension_validation: EXTENSION_CASES.map((held): JsonWire => ({ + name: held.name, + keys: held.keys, + refused: held.refused === null ? null : { ...held.refused }, + })), + directory_scenarios: scenarios, + self_adverts: SELF_ADVERTS.map((held): JsonWire => ({ + name: held.name, + identity: ME.name, + extensions: { ...held.extensions }, + now_seconds: held.now_seconds, + expected: { + device_hex: ME.deviceHex, + addresses: [], + snapshot_seconds: held.now_seconds, + extension_keys: [ + ...Object.keys(held.extensions), + "topology/peers", + "wire-mesh/version", + ].sort(), + topology: { direct: [], relayed: [] }, + }, + })), + counts: { + extension_validation: EXTENSION_CASES.length, + directory_scenarios: SCENARIOS.length, + self_adverts: SELF_ADVERTS.length, + }, + }, + }, + }; +} diff --git a/conformance/gossip-directory.v1.json b/conformance/gossip-directory.v1.json new file mode 100644 index 00000000..327d5829 --- /dev/null +++ b/conformance/gossip-directory.v1.json @@ -0,0 +1,880 @@ +{ + "protocol_version": 1, + "description": "Gossip directory vectors for protocol version 1 (gossip-frame in spec/transport.cddl, peer-advert in spec/transport.cddl). The top-level vectors are the gossip frames the scenarios deliver, round-tripped like any other file. The `gossip_directory` section holds `identities` (the fixed Ed25519 keys every advert is signed with), `extension_validation` (the key bags a gossip update may carry, each accepted or refused for one named reason), `directory_scenarios` (frames delivered in order, each step recording what became of every advert and the directory held afterwards, as devices and snapshot times in first-heard order; a scenario with `rust_only` pins a bound only the Rust session applies) and `self_adverts` (the advert a session sends: its device, time, extension keys and topology, whose signature a consumer verifies). Every list's size is in `counts`.", + "vectors": [ + { + "name": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_0", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "d20da3290a6a6380b66cc2d6f8b85223a78664a271287a66440a375974c971b9192db2aba9eb38108cadbe71443691565c8fcbbb43f2f3a6d0bdc71796e7110c" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840d20da3290a6a6380b66cc2d6f8b85223a78664a271287a66440a375974c971b9192db2aba9eb38108cadbe71443691565c8fcbbb43f2f3a6d0bdc71796e7110c6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_1", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "b28baab33e1f95a78c7e9547554c3e95a2e38030a2c64ce45378f15d33a4ddd6" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "55154f42065ea5a1bea05463826be2684eb92df92c100027aabaae57ca554207" + } + }, + "signature": { + "hex": "aa6d14105b814e6db46b697cc78117322633b8111fb86fbcebbde583502ee00b0fec5c23f493f72577fd6515b2bd8adad037fb5b71353437c47659e496714106" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820b28baab33e1f95a78c7e9547554c3e95a2e38030a2c64ce45378f15d33a4ddd66961646472657373657380697369676e61747572655840aa6d14105b814e6db46b697cc78117322633b8111fb86fbcebbde583502ee00b0fec5c23f493f72577fd6515b2bd8adad037fb5b71353437c47659e4967141066c6964656e746974792d6b6579a263616c67276a7075626c69632d6b6579582055154f42065ea5a1bea05463826be2684eb92df92c100027aabaae57ca55420770736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_2", + "message": { + "type": "gossip", + "peers": [ + { + "presence/status": "busy", + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 20, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "705143ab1a759c46560353d27a3eaccdd82d91266a3a059dde55fc7dcac73061dc0c427f54a4d8543401789b7336c60edcf62b1b6d772eba9e42ca9cea94eb06" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840705143ab1a759c46560353d27a3eaccdd82d91266a3a059dde55fc7dcac73061dc0c427f54a4d8543401789b7336c60edcf62b1b6d772eba9e42ca9cea94eb066c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a56f70726573656e63652f737461747573646275737970736e617073686f742d7365636f6e647314" + }, + { + "name": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_0", + "message": { + "type": "gossip", + "peers": [ + { + "presence/status": "new", + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 20, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "4191d93994a6f2e0e668ec9cf96dfd22d67f7d6b118433551570595e07830e194f21bf0f5e7ab8caa7d4c7c014ccefdb1704fb72aba61a02148b0cfc57cb040b" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e617475726558404191d93994a6f2e0e668ec9cf96dfd22d67f7d6b118433551570595e07830e194f21bf0f5e7ab8caa7d4c7c014ccefdb1704fb72aba61a02148b0cfc57cb040b6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a56f70726573656e63652f737461747573636e657770736e617073686f742d7365636f6e647314" + }, + { + "name": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_1", + "message": { + "type": "gossip", + "peers": [ + { + "presence/status": "old", + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 15, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "e9f2c04866419e0bdaa11ab1e5b209189d5cf788e3d5efee74708736f5425490730cbfc8f22b257c0c0d99b95090c4dd06ba2bf4247e42e304dccbde1f16bf01" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840e9f2c04866419e0bdaa11ab1e5b209189d5cf788e3d5efee74708736f5425490730cbfc8f22b257c0c0d99b95090c4dd06ba2bf4247e42e304dccbde1f16bf016c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a56f70726573656e63652f737461747573636f6c6470736e617073686f742d7365636f6e64730f" + }, + { + "name": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_2", + "message": { + "type": "gossip", + "peers": [ + { + "presence/status": "same", + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 20, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "67fd5037f141f359e00ced95ddf81db963d65a9308083ea08e367769746a3a3ae6c0b86f590ebbb1b20be0a3facd2caaa012edd12d0bf7ba99d6508ba2467608" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e6174757265584067fd5037f141f359e00ced95ddf81db963d65a9308083ea08e367769746a3a3ae6c0b86f590ebbb1b20be0a3facd2caaa012edd12d0bf7ba99d6508ba24676086c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a56f70726573656e63652f7374617475736473616d6570736e617073686f742d7365636f6e647314" + }, + { + "name": "gossip_an_advert_that_does_not_verify_is_dropped_alone_and_the_rest_of_its_frame_is_admitted_0", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "24b03a0e3818a49e05631efc80768d08e32a81a944748730f14f613af9e909a6" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "55154f42065ea5a1bea05463826be2684eb92df92c100027aabaae57ca554207" + } + }, + "signature": { + "hex": "81badd4634795b2d7be65295b2187fa3cff3be673d03a9015eb243a49b8c077291eeace4c3fe28894946a502be3d7e34c3e605b24b449159620d7631dac1560b" + } + }, + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "d20da3290a6a6380b66cc2d6f8b85223a78664a271287a66440a375974c971b9192db2aba9eb38108cadbe71443691565c8fcbbb43f2f3a6d0bdc71796e7110c" + } + }, + { + "device": { + "hex": "24b03a0e3818a49e05631efc80768d08e32a81a944748730f14f613af9e909a6" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "d404bc44565aedbb899150e5b0b3b32b9441bf0cb7884c33130da8dbc27dd2cf" + } + }, + "signature": { + "hex": "73562de1e98397a0ab11b664baf055f6f07fb8fb7e25483071d2519b4433ed004545c06d5c3e1810f54541f3d0f209ca8d327700fab94cec10e2175dc9ca800f" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727383a566646576696365582024b03a0e3818a49e05631efc80768d08e32a81a944748730f14f613af9e909a66961646472657373657380697369676e6174757265584081badd4634795b2d7be65295b2187fa3cff3be673d03a9015eb243a49b8c077291eeace4c3fe28894946a502be3d7e34c3e605b24b449159620d7631dac1560b6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b6579582055154f42065ea5a1bea05463826be2684eb92df92c100027aabaae57ca55420770736e617073686f742d7365636f6e64730aa5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840d20da3290a6a6380b66cc2d6f8b85223a78664a271287a66440a375974c971b9192db2aba9eb38108cadbe71443691565c8fcbbb43f2f3a6d0bdc71796e7110c6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730aa566646576696365582024b03a0e3818a49e05631efc80768d08e32a81a944748730f14f613af9e909a66961646472657373657380697369676e6174757265584073562de1e98397a0ab11b664baf055f6f07fb8fb7e25483071d2519b4433ed004545c06d5c3e1810f54541f3d0f209ca8d327700fab94cec10e2175dc9ca800f6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820d404bc44565aedbb899150e5b0b3b32b9441bf0cb7884c33130da8dbc27dd2cf70736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_0", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 20, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "bb9153645e1ee64d1df0d9c10f90139d1e39e143d3452cdb71a7d8c2e5768f3f0b46baf2c29dea0f9653d1e56e8df5d62e2ccc6159ce726e4c32f338c4e4860d" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840bb9153645e1ee64d1df0d9c10f90139d1e39e143d3452cdb71a7d8c2e5768f3f0b46baf2c29dea0f9653d1e56e8df5d62e2ccc6159ce726e4c32f338c4e4860d6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e647314" + }, + { + "name": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_1", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 15, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "15cc95d88296ef6b0aeb595b8ef064f6d6fe64cc253a3603951f71c07b32fa8f6ab6634ec32b48119e23ac1c5c05adab27fd862983c4be7f5ff6a686793cf304" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e6174757265584015cc95d88296ef6b0aeb595b8ef064f6d6fe64cc253a3603951f71c07b32fa8f6ab6634ec32b48119e23ac1c5c05adab27fd862983c4be7f5ff6a686793cf3046c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730f" + }, + { + "name": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_2", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 21, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "e640bd305ef42a1cad4090d7c61d002425ed8e6d196d6d569cbb998b2eca451b68fd7ab72758e7fff1cc81d5c78756735c9ec49eb3733c7d0c82a2aa80675c0a" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840e640bd305ef42a1cad4090d7c61d002425ed8e6d196d6d569cbb998b2eca451b68fd7ab72758e7fff1cc81d5c78756735c9ec49eb3733c7d0c82a2aa80675c0a6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e647315" + }, + { + "name": "gossip_an_advert_signed_by_another_key_than_its_own_is_dropped_0", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "e3660920c80cd252ce8c9ecd7fa0e526b46765e5e7dbc26419d7a7441945b5d5298d2bf41c321ee9995a5d8a7a800f68df8d6a802819ea4e207a62d2eb800d0c" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840e3660920c80cd252ce8c9ecd7fa0e526b46765e5e7dbc26419d7a7441945b5d5298d2bf41c321ee9995a5d8a7a800f68df8d6a802819ea4e207a62d2eb800d0c6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_an_advert_exactly_at_the_size_cap_is_admitted_0", + "message": { + "type": "gossip", + "peers": [ + { + "pad/x": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "1898619d5e1b364b2a551a7d930ec83a29eaf46e5e9e20d8148adece516866612a36d8578bf16ec0d7cebb03200106e1880fbb4444edf0db0ecb352ce305f102" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6657061642f78793f1078787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e617475726558401898619d5e1b364b2a551a7d930ec83a29eaf46e5e9e20d8148adece516866612a36d8578bf16ec0d7cebb03200106e1880fbb4444edf0db0ecb352ce305f1026c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_an_advert_one_byte_over_the_size_cap_is_refused_0", + "message": { + "type": "gossip", + "peers": [ + { + "pad/x": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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10, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "b2fe8a07adb7595ac6bf0701451073c364ae30d7731267022848144c05b7a037079ffd05d1277423a0cdef1c6c9994b57a28126500b22973c94a87398c9d5101" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a6657061642f78793f117878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840b2fe8a07adb7595ac6bf0701451073c364ae30d7731267022848144c05b7a037079ffd05d1277423a0cdef1c6c9994b57a28126500b22973c94a87398c9d51016c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64730a" + }, + { + "name": "gossip_a_snapshot_time_at_the_largest_exact_integer_is_admitted_0", + "message": { + "type": "gossip", + "peers": [ + { + "device": { + "hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + "addresses": [], + "snapshot-seconds": 9007199254740991, + "identity-key": { + "alg": -8, + "public-key": { + "hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5" + } + }, + "signature": { + "hex": "c82379e3afea7f54c4ef04e289adb61e02e528a52bfa459064ae068fcf34eedc2691a63ac15d166c24fb39542bd19ceed6f01d19baab4ab740f0f2147361fd0c" + } + } + ] + }, + "wire_hex": "a2647479706566676f7373697065706565727381a5666465766963655820730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a86961646472657373657380697369676e61747572655840c82379e3afea7f54c4ef04e289adb61e02e528a52bfa459064ae068fcf34eedc2691a63ac15d166c24fb39542bd19ceed6f01d19baab4ab740f0f2147361fd0c6c6964656e746974792d6b6579a263616c67276a7075626c69632d6b65795820bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a570736e617073686f742d7365636f6e64731b001fffffffffffff" + } + ], + "gossip_directory": { + "layout_version": 1, + "identities": [ + { + "name": "me", + "secret_hex": "d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4d4", + "public_key_hex": "ed3234b276d4ceda57d59bad14fbaf5a773c0f318c999de3a60d53c5a5b34c05", + "device_id_hex": "5292550d8c0f651237b6885fd72580c3af63620a211e2a886dbc4ef7c3ef27cf" + }, + { + "name": "a", + "secret_hex": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", + "public_key_hex": "bc7cbcb5636375fa1d82434d466724d92377f53b980695dd49d26d0ce12205a5", + "device_id_hex": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8" + }, + { + "name": "b", + "secret_hex": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", + "public_key_hex": "55154f42065ea5a1bea05463826be2684eb92df92c100027aabaae57ca554207", + "device_id_hex": "b28baab33e1f95a78c7e9547554c3e95a2e38030a2c64ce45378f15d33a4ddd6" + }, + { + "name": "c", + "secret_hex": "c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3", + "public_key_hex": "d404bc44565aedbb899150e5b0b3b32b9441bf0cb7884c33130da8dbc27dd2cf", + "device_id_hex": "24b03a0e3818a49e05631efc80768d08e32a81a944748730f14f613af9e909a6" + } + ], + "extension_validation": [ + { + "name": "an_empty_bag", + "keys": [], + "refused": null + }, + { + "name": "a_domain_qualified_key", + "keys": [ + "presence/status" + ], + "refused": null + }, + { + "name": "digits_and_hyphens_after_the_first_letter", + "keys": [ + "app-1/x-y2" + ], + "refused": null + }, + { + "name": "a_key_that_only_contains_a_reserved_name", + "keys": [ + "device/status", + "wire-mesh/versions" + ], + "refused": null + }, + { + "name": "the_mandatory_field_device", + "keys": [ + "device" + ], + "refused": { + "key": "device", + "reason": "reserved_field" + } + }, + { + "name": "the_mandatory_field_addresses", + "keys": [ + "addresses" + ], + "refused": { + "key": "addresses", + "reason": "reserved_field" + } + }, + { + "name": "the_mandatory_field_snapshot_seconds", + "keys": [ + "snapshot-seconds" + ], + "refused": { + "key": "snapshot-seconds", + "reason": "reserved_field" + } + }, + { + "name": "the_mandatory_field_identity_key", + "keys": [ + "identity-key" + ], + "refused": { + "key": "identity-key", + "reason": "reserved_field" + } + }, + { + "name": "the_mandatory_field_signature", + "keys": [ + "signature" + ], + "refused": { + "key": "signature", + "reason": "reserved_field" + } + }, + { + "name": "the_topology_the_session_computes", + "keys": [ + "topology/peers" + ], + "refused": { + "key": "topology/peers", + "reason": "session_managed" + } + }, + { + "name": "the_version_this_crate_reports", + "keys": [ + "wire-mesh/version" + ], + "refused": { + "key": "wire-mesh/version", + "reason": "reserved_version" + } + }, + { + "name": "a_key_with_no_domain", + "keys": [ + "status" + ], + "refused": { + "key": "status", + "reason": "not_domain_qualified" + } + }, + { + "name": "an_uppercase_domain", + "keys": [ + "Presence/status" + ], + "refused": { + "key": "Presence/status", + "reason": "not_domain_qualified" + } + }, + { + "name": "an_uppercase_field", + "keys": [ + "presence/Status" + ], + "refused": { + "key": "presence/Status", + "reason": "not_domain_qualified" + } + }, + { + "name": "three_segments", + "keys": [ + "a/b/c" + ], + "refused": { + "key": "a/b/c", + "reason": "not_domain_qualified" + } + }, + { + "name": "a_leading_digit", + "keys": [ + "1a/b" + ], + "refused": { + "key": "1a/b", + "reason": "not_domain_qualified" + } + }, + { + "name": "an_underscore", + "keys": [ + "a_b/c" + ], + "refused": { + "key": "a_b/c", + "reason": "not_domain_qualified" + } + }, + { + "name": "an_empty_domain", + "keys": [ + "/x" + ], + "refused": { + "key": "/x", + "reason": "not_domain_qualified" + } + }, + { + "name": "an_empty_field", + "keys": [ + "x/" + ], + "refused": { + "key": "x/", + "reason": "not_domain_qualified" + } + }, + { + "name": "the_first_bad_key_is_the_one_named", + "keys": [ + "presence/status", + "device", + "status" + ], + "refused": { + "key": "device", + "reason": "reserved_field" + } + } + ], + "directory_scenarios": [ + { + "name": "adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place", + "rust_only": false, + "steps": [ + { + "vector": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_0", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 10 + } + ] + }, + { + "vector": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_1", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 10 + }, + { + "device": "b28baab33e1f95a78c7e9547554c3e95a2e38030a2c64ce45378f15d33a4ddd6", + "snapshot_seconds": 10 + } + ] + }, + { + "vector": "gossip_adverts_enter_in_first_heard_order_and_a_newer_one_replaces_in_place_2", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + }, + { + "device": "b28baab33e1f95a78c7e9547554c3e95a2e38030a2c64ce45378f15d33a4ddd6", + "snapshot_seconds": 10 + } + ] + } + ] + }, + { + "name": "an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces", + "rust_only": false, + "steps": [ + { + "vector": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_0", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + }, + { + "vector": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_1", + "outcomes": [ + "older" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + }, + { + "vector": "gossip_an_older_advert_a_hub_replays_does_not_displace_a_newer_one_and_one_of_the_same_time_replaces_2", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + } + ] + }, + { + "name": "an_advert_that_does_not_verify_is_dropped_alone_and_the_rest_of_its_frame_is_admitted", + "rust_only": false, + "steps": [ + { + "vector": "gossip_an_advert_that_does_not_verify_is_dropped_alone_and_the_rest_of_its_frame_is_admitted_0", + "outcomes": [ + "wrong_device", + "admitted", + "bad_signature" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 10 + } + ] + } + ] + }, + { + "name": "an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped", + "rust_only": false, + "steps": [ + { + "vector": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_0", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + }, + { + "vector": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_1", + "outcomes": [ + "older" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + }, + { + "vector": "gossip_an_advert_older_than_the_one_held_is_ignored_whether_or_not_it_is_genuine_and_a_newer_forged_one_is_dropped_2", + "outcomes": [ + "bad_signature" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 20 + } + ] + } + ] + }, + { + "name": "an_advert_signed_by_another_key_than_its_own_is_dropped", + "rust_only": false, + "steps": [ + { + "vector": "gossip_an_advert_signed_by_another_key_than_its_own_is_dropped_0", + "outcomes": [ + "bad_signature" + ], + "directory": [] + } + ] + }, + { + "name": "an_advert_exactly_at_the_size_cap_is_admitted", + "rust_only": false, + "steps": [ + { + "vector": "gossip_an_advert_exactly_at_the_size_cap_is_admitted_0", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 10 + } + ] + } + ] + }, + { + "name": "an_advert_one_byte_over_the_size_cap_is_refused", + "rust_only": true, + "steps": [ + { + "vector": "gossip_an_advert_one_byte_over_the_size_cap_is_refused_0", + "outcomes": [ + "too_large" + ], + "directory": [] + } + ] + }, + { + "name": "a_snapshot_time_at_the_largest_exact_integer_is_admitted", + "rust_only": false, + "steps": [ + { + "vector": "gossip_a_snapshot_time_at_the_largest_exact_integer_is_admitted_0", + "outcomes": [ + "admitted" + ], + "directory": [ + { + "device": "730a5edc28c2f8daf2d9dce3a01d5f205e35e55582eed2ba26219fabdd4cc9a8", + "snapshot_seconds": 9007199254740991 + } + ] + } + ] + } + ], + "self_adverts": [ + { + "name": "a_session_with_no_extensions", + "identity": "me", + "extensions": {}, + "now_seconds": 1700000000, + "expected": { + "device_hex": "5292550d8c0f651237b6885fd72580c3af63620a211e2a886dbc4ef7c3ef27cf", + "addresses": [], + "snapshot_seconds": 1700000000, + "extension_keys": [ + "topology/peers", + "wire-mesh/version" + ], + "topology": { + "direct": [], + "relayed": [] + } + } + }, + { + "name": "a_gossip_update_with_an_extension", + "identity": "me", + "extensions": { + "presence/status": "idle" + }, + "now_seconds": 1700000000, + "expected": { + "device_hex": "5292550d8c0f651237b6885fd72580c3af63620a211e2a886dbc4ef7c3ef27cf", + "addresses": [], + "snapshot_seconds": 1700000000, + "extension_keys": [ + "presence/status", + "topology/peers", + "wire-mesh/version" + ], + "topology": { + "direct": [], + "relayed": [] + } + } + } + ], + "counts": { + "extension_validation": 20, + "directory_scenarios": 8, + "self_adverts": 2 + } + } +} diff --git a/conformance/vector-files.ts b/conformance/vector-files.ts index 1c102ae3..7a82a791 100644 --- a/conformance/vector-files.ts +++ b/conformance/vector-files.ts @@ -2,6 +2,7 @@ import { writeFileSync } from "node:fs"; import type { JsonWire, Vector } from "@exadev/wire-mesh-conformance"; +import { gossipDirectoryFile } from "./gossip-directory-vectors.ts"; import { introspectionFile } from "./introspection-vectors.ts"; import { roomParamsFile } from "./room-params-vectors.ts"; import { fileStorageFile } from "./file-storage-vectors.ts"; @@ -34,6 +35,8 @@ const DESCRIPTIONS: Readonly> = { "File-backed key-value storage vectors for protocol version 1: the layout both implementations' file storage shares. There are no wire vectors. The `file_storage` section holds `key_layout`, which gives for each key the path of the file that holds it or the reason the layout refuses it (an empty key, a NUL, a backslash, a leading slash, an empty, `.` or `..` segment), and `scenarios`, which start from a directory (every file under it as a `/`-joined path with its content in hex), run operations on a storage over a copy of it, and record what each returns and the whole directory after it. A value is the whole content of its file, nothing added. The outcomes are written by hand from the layout, never produced by an implementation.", "room-params.v1.json": "Typed core/room and capability vectors for protocol version 1 (spec/room.cddl, spec/management.cddl). The top-level vectors are manage-request and manage-response frames carrying room.send, room.read, room.leave, room.invite and capability.request params and room-join-ok, room-members-ok and capability-grant-ok outcomes, round-tripped like any other file. The `room_params` section gives, for each frame, the shape a typed decoder must read it as and the value of every field and the keys of its open tail; a list of frames each breaking one rule of a shape, which a typed decoder must refuse, each naming the valid vector it varies; and the cases of the room-path and hex helpers. Every outcome is written by hand from the spec, never produced by an implementation. Device-ids and tokens are structural bytes.", + "gossip-directory.v1.json": + "Gossip directory vectors for protocol version 1 (gossip-frame in spec/transport.cddl, peer-advert in spec/transport.cddl). The top-level vectors are the gossip frames the scenarios deliver, round-tripped like any other file. The `gossip_directory` section holds `identities` (the fixed Ed25519 keys every advert is signed with), `extension_validation` (the key bags a gossip update may carry, each accepted or refused for one named reason), `directory_scenarios` (frames delivered in order, each step recording what became of every advert and the directory held afterwards, as devices and snapshot times in first-heard order; a scenario with `rust_only` pins a bound only the Rust session applies) and `self_adverts` (the advert a session sends: its device, time, extension keys and topology, whose signature a consumer verifies). Every list's size is in `counts`.", "introspection.v1.json": "core/management introspection vectors for protocol version 1 (spec/management.cddl): path:trace and topology.get. The top-level vectors are the manage-request and manage-response frames the cases use and gossip frames each holding one peer-advert, round-tripped like any other file. The `introspection` section gives, for each frame, the shape a typed decoder must read it as and every field; frames each breaking one rule of a shape, which a typed decoder must refuse; the answer built for a path.trace; traces run against a scripted peer and clock; the topology read from an advert's `topology/peers` extension; the graph assembled from a directory; and topology.get run against a scripted peer. Every outcome is written by hand from the spec, never produced by an implementation. Device-ids, keys and signatures are structural bytes and the adverts are not verified.", "frames.v1.json": @@ -90,4 +93,10 @@ export function writeVectorFiles( write("room-params.v1.json", roomParams.vectors, roomParams.extra); const introspection = introspectionFile(); write("introspection.v1.json", introspection.vectors, introspection.extra); + const gossipDirectory = gossipDirectoryFile(); + write( + "gossip-directory.v1.json", + gossipDirectory.vectors, + gossipDirectory.extra, + ); } diff --git a/conformance/verify.unit.test.ts b/conformance/verify.unit.test.ts index c9ee5af0..89c321ac 100644 --- a/conformance/verify.unit.test.ts +++ b/conformance/verify.unit.test.ts @@ -12,6 +12,10 @@ const SHARED_KEYS = ["protocol_version", "description", "vectors"]; const SIDECAR_SECTIONS: Readonly< Record>> > = { + "gossip-directory.v1.json": { + gossip_directory: + "ts/packages/core/test/conformance-gossip-directory.unit.test.ts", + }, "introspection.v1.json": { introspection: "ts/packages/core/test/conformance-introspection.unit.test.ts", diff --git a/rust/crates/wire-mesh-conformance/src/gossip_directory.rs b/rust/crates/wire-mesh-conformance/src/gossip_directory.rs new file mode 100644 index 00000000..3814cdd1 --- /dev/null +++ b/rust/crates/wire-mesh-conformance/src/gossip_directory.rs @@ -0,0 +1,266 @@ +//! The `gossip_directory` section of `gossip-directory.v1.json`: the extension rules against the real validator, each scenario against the real directory, and each self-advert against the real builder, whose signature is verified. + +use std::collections::HashMap; + +use serde_json::Value; +use wire_mesh_core::adapters::NodeIdentity; +use wire_mesh_core::domain::gossip_directory::{AdvertOutcome, GossipDirectory}; +use wire_mesh_core::domain::gossip_extensions::validate_gossip_extensions; +use wire_mesh_core::domain::peer_advert::{verify_peer_advert, PeerAdvertVerdict}; +use wire_mesh_core::domain::room_path::bytes_to_hex; +use wire_mesh_core::domain::self_advert::{ + build_self_advert, compute_topology_peers, TopologyInputs, +}; +use wire_mesh_core::ports::Identity; +use wire_mesh_wire::value::CborValue; +use wire_mesh_wire::{decode_frame, Frame}; + +use super::obj::{Check, Obj}; + +/// The layout of the `gossip_directory` section this binary reads. +const LAYOUT_VERSION: i64 = 1; + +/// The identity the scenarios run as, which verifies every advert it is given. +const VERIFIER: &str = "me"; + +fn outcome_name(outcome: &AdvertOutcome) -> &'static str { + match outcome { + AdvertOutcome::Admitted(_) => "admitted", + AdvertOutcome::Older(_) => "older", + AdvertOutcome::Refused(_, why) => why.as_str(), + } +} + +fn identities(section: &mut Obj) -> Result, String> { + let mut held = HashMap::new(); + for mut who in section.objects("identities")? { + let name = who.string("name")?; + let secret = who.hex("secret_hex")?; + let public_key = who.hex("public_key_hex")?; + let device = who.hex("device_id_hex")?; + who.finish()?; + let identity = NodeIdentity::from_ed25519_secret(&secret).map_err(|e| e.to_string())?; + if identity.identity_key().public_key != public_key { + return Err(format!( + "identity {name}: the secret gives another public key" + )); + } + if identity.device_id().as_bytes().as_slice() != device.as_slice() { + return Err(format!( + "identity {name}: the secret gives another device id" + )); + } + held.insert(name, identity); + } + Ok(held) +} + +fn check_extension(mut case: Obj) -> Check { + let keys = case.strings("keys")?; + let refused = case.optional_object("refused")?; + let expected = match refused { + None => None, + Some(mut refused) => { + let key = refused.string("key")?; + let reason = refused.string("reason")?; + refused.finish()?; + Some((key, reason)) + } + }; + case.string("name")?; + case.finish()?; + let got = validate_gossip_extensions(keys.iter().map(String::as_str)) + .err() + .map(|refused| (refused.key, refused.refusal.as_str().to_owned())); + if got == expected { + Ok(()) + } else { + Err(format!("refused {got:?}, the file records {expected:?}")) + } +} + +async fn check_scenario( + mut scenario: Obj, + verifier: &NodeIdentity, + wires: &HashMap>, +) -> Check { + scenario.string("name")?; + scenario.boolean("rust_only")?; + let mut directory = GossipDirectory::new(); + for (index, mut step) in scenario.objects("steps")?.into_iter().enumerate() { + let vector = step.string("vector")?; + let outcomes = step.strings("outcomes")?; + let mut held = Vec::new(); + for mut entry in step.objects("directory")? { + held.push((entry.string("device")?, entry.integer("snapshot_seconds")?)); + entry.finish()?; + } + step.finish()?; + let wire = wires + .get(&vector) + .ok_or_else(|| format!("step {index}: no vector {vector}"))?; + let Frame::Gossip(frame) = decode_frame(wire).map_err(|e| e.to_string())? else { + return Err(format!("step {index}: {vector} is not a gossip frame")); + }; + let got: Vec<&str> = { + let applied = directory.apply(verifier, &frame).await; + applied.iter().map(outcome_name).collect() + }; + if got != outcomes.iter().map(String::as_str).collect::>() { + return Err(format!( + "step {index}: outcomes {got:?}, the file records {outcomes:?}" + )); + } + let have: Vec<(String, i64)> = directory + .entries() + .iter() + .map(|entry| { + ( + bytes_to_hex(entry.device.as_bytes()), + entry.advert.snapshot_seconds, + ) + }) + .collect(); + if have != held { + return Err(format!( + "step {index}: directory {have:?}, the file records {held:?}" + )); + } + } + scenario.finish() +} + +async fn check_self_advert(mut case: Obj, who: &HashMap) -> Check { + case.string("name")?; + let name = case.string("identity")?; + let identity = who + .get(&name) + .ok_or_else(|| format!("no identity {name}"))?; + let mut extensions = Vec::new(); + let mut given = case.object("extensions")?; + let keys: Vec = given.map.keys().cloned().collect(); + for key in keys { + let value = given.string(&key)?; + extensions.push((key, CborValue::Text(value))); + } + given.finish()?; + let now = case.unsigned("now_seconds")?; + let mut expected = case.object("expected")?; + let device = expected.hex("device_hex")?; + let addresses = expected.strings("addresses")?; + let snapshot = expected.integer("snapshot_seconds")?; + let key_names = expected.strings("extension_keys")?; + let mut topology = expected.object("topology")?; + let direct = topology.take("direct")?; + let relayed = topology.take("relayed")?; + topology.finish()?; + expected.finish()?; + case.finish()?; + if direct != Value::Array(Vec::new()) || relayed != Value::Array(Vec::new()) { + return Err("a self-advert with no connection has an empty topology".to_owned()); + } + let advert = build_self_advert( + identity, + &[], + now, + &extensions, + &compute_topology_peers(&TopologyInputs::default()), + ) + .await + .map_err(|e| e.to_string())?; + if advert.device.as_bytes().as_slice() != device.as_slice() { + return Err("the advert names another device".to_owned()); + } + if !addresses.is_empty() || !advert.addresses.is_empty() { + return Err(format!("addresses {:?}", advert.addresses)); + } + if advert.snapshot_seconds != snapshot { + return Err(format!( + "snapshot {} not {snapshot}", + advert.snapshot_seconds + )); + } + let mut got: Vec = advert.extra.iter().map(|(key, _)| key.clone()).collect(); + got.sort(); + if got != key_names { + return Err(format!( + "extension keys {got:?}, the file records {key_names:?}" + )); + } + match verify_peer_advert(identity, &advert).await { + PeerAdvertVerdict::Valid => Ok(()), + PeerAdvertVerdict::Invalid(why) => Err(format!("the advert does not verify: {why:?}")), + } +} + +pub async fn check_section( + value: &Value, + wires: &HashMap>, +) -> Vec<(String, Check)> { + let mut section = Obj::new(value, "gossip_directory").expect("an object"); + let layout = section.integer("layout_version").expect("layout_version"); + assert!( + layout == LAYOUT_VERSION, + "gossip-directory.v1.json: layout_version {layout}" + ); + let who = identities(&mut section).expect("identities"); + let verifier = who.get(VERIFIER).expect("the verifier identity"); + let extension_cases = section + .objects("extension_validation") + .expect("extension_validation"); + let scenarios = section + .objects("directory_scenarios") + .expect("directory_scenarios"); + let self_adverts = section.objects("self_adverts").expect("self_adverts"); + let mut counts = section.object("counts").expect("counts"); + for (name, held) in [ + ("extension_validation", extension_cases.len()), + ("directory_scenarios", scenarios.len()), + ("self_adverts", self_adverts.len()), + ] { + let said = counts.unsigned(name).expect("a count"); + assert!( + said == held as u64, + "gossip-directory.v1.json: counts.{name} says {said} and the list holds {held}" + ); + } + counts.finish().expect("counts are all read"); + section.finish().expect("sections are all read"); + + let mut results = Vec::new(); + for mut case in extension_cases { + let name = case.string("name").expect("a name"); + // `name` is read twice by `check_extension`; put it back for its own read. + case.map + .insert("name".to_owned(), Value::String(name.clone())); + results.push(( + format!("gossip_directory:extension:{name}"), + check_extension(case), + )); + } + for scenario in scenarios { + let name = scenario + .map + .get("name") + .and_then(Value::as_str) + .unwrap_or("?") + .to_owned(); + results.push(( + format!("gossip_directory:scenario:{name}"), + check_scenario(scenario, verifier, wires).await, + )); + } + for case in self_adverts { + let name = case + .map + .get("name") + .and_then(Value::as_str) + .unwrap_or("?") + .to_owned(); + results.push(( + format!("gossip_directory:self_advert:{name}"), + check_self_advert(case, &who).await, + )); + } + results +} diff --git a/rust/crates/wire-mesh-conformance/src/main.rs b/rust/crates/wire-mesh-conformance/src/main.rs index e9d94faa..ae30fa5d 100644 --- a/rust/crates/wire-mesh-conformance/src/main.rs +++ b/rust/crates/wire-mesh-conformance/src/main.rs @@ -48,6 +48,7 @@ use wire_mesh_wire::{decode_frame, encode_frame, minicbor, DecodeError}; mod coordinator_election; mod data_sync; mod file_storage; +mod gossip_directory; mod introspection; mod mint; mod mint_notice; @@ -57,7 +58,7 @@ mod room_params; mod secure_channel; /// The vector files this binary checks, each with the top-level keys it reads. -const CONSUMED: [&str; 12] = [ +const CONSUMED: [&str; 13] = [ "frames.v1.json", "handshake.v1.json", "tokens.v1.json", @@ -70,6 +71,7 @@ const CONSUMED: [&str; 12] = [ FILE_STORAGE_FILE, ROOM_PARAMS_FILE, INTROSPECTION_FILE, + GOSSIP_DIRECTORY_FILE, ]; /// The vector file whose `secure_channel` section [`secure_channel`] checks. @@ -93,6 +95,9 @@ const FILE_STORAGE_FILE: &str = "file-storage.v1.json"; /// The vector file whose `room_params` section [`room_params`] checks. const ROOM_PARAMS_FILE: &str = "room-params.v1.json"; +/// The vector file whose `gossip_directory` section [`gossip_directory`] checks. +const GOSSIP_DIRECTORY_FILE: &str = "gossip-directory.v1.json"; + /// The vector file whose `introspection` section [`introspection`] checks. const INTROSPECTION_FILE: &str = "introspection.v1.json"; @@ -100,7 +105,7 @@ const INTROSPECTION_FILE: &str = "introspection.v1.json"; const CONSUMED_KEYS: [&str; 3] = ["protocol_version", "description", "vectors"]; /// The top-level section a file carries besides the shared keys, with the file that carries it. -const SECTIONS: [(&str, &str); 8] = [ +const SECTIONS: [(&str, &str); 9] = [ (SECURE_CHANNEL_FILE, "secure_channel"), (SECURE_CHANNEL_FILE, "handshake_scenarios"), (MINT_FILE, "mint"), @@ -108,6 +113,7 @@ const SECTIONS: [(&str, &str); 8] = [ (DATA_SYNC_FILE, "data_sync"), (FILE_STORAGE_FILE, "file_storage"), (ROOM_PARAMS_FILE, "room_params"), + (GOSSIP_DIRECTORY_FILE, "gossip_directory"), (INTROSPECTION_FILE, "introspection"), ]; @@ -250,6 +256,9 @@ async fn main() { (DATA_SYNC_FILE, _) => data_sync::check_section(section, &wires).await, (FILE_STORAGE_FILE, _) => file_storage::check_section(section).await, (ROOM_PARAMS_FILE, _) => room_params::check_section(section, &wires), + (GOSSIP_DIRECTORY_FILE, _) => { + gossip_directory::check_section(section, &wires).await + } (INTROSPECTION_FILE, _) => introspection::check_section(section, &wires).await, (_, RELAY_SCENARIOS_SECTION) => { relay_scenarios::check_section(section, &wires).await @@ -385,8 +394,14 @@ async fn check_vector(file: &str, vector: Vector, verifier: &NodeIdentity) -> Re let expected = decode_hex(&vector.wire_hex)?; // Primary loop: typed decode -> validate -> re-encode -> byte-exact. match file { - "frames.v1.json" | "handshake.v1.json" | ELECTION_FILE | DATA_SYNC_FILE - | FILE_STORAGE_FILE | ROOM_PARAMS_FILE | INTROSPECTION_FILE => { + "frames.v1.json" + | "handshake.v1.json" + | ELECTION_FILE + | DATA_SYNC_FILE + | FILE_STORAGE_FILE + | ROOM_PARAMS_FILE + | INTROSPECTION_FILE + | GOSSIP_DIRECTORY_FILE => { let frame = decode_frame(&expected).map_err(|e| format!("typed decode failed: {e}"))?; frame .validate() diff --git a/rust/crates/wire-mesh-core/examples/relay_peer.rs b/rust/crates/wire-mesh-core/examples/relay_peer.rs index c161830c..abf99b27 100644 --- a/rust/crates/wire-mesh-core/examples/relay_peer.rs +++ b/rust/crates/wire-mesh-core/examples/relay_peer.rs @@ -3,6 +3,7 @@ //! ```text //! relay_peer request //! relay_peer serve +//! relay_peer gossip //! ``` //! //! Lines: `DEVICE ` (this node's device-id, first), `RESULT ` (one per request: `ok`, `timeout` or `error `), `HANDLED ` (a request reached a handler) and `DATA ` (a core/data frame arrived through a relay). @@ -10,12 +11,14 @@ use std::sync::Arc; use std::time::Duration; -use wire_mesh_core::adapters::{MonotonicClock, NodeIdentity, TcpTransport}; +use wire_mesh_core::adapters::{MonotonicClock, NodeIdentity, SystemClock, TcpTransport}; + use wire_mesh_core::domain::peer_advert::sign_peer_advert; use wire_mesh_core::domain::relay_channels::{RelayChannels, RelayOptions}; use wire_mesh_core::domain::relay_client::{HubLink, RelayClient}; use wire_mesh_core::domain::session::{ - HandlerRegistry, IncomingManageRequest, ManageRequestHandler, Session, SessionEvent, + GossipConfig, HandlerRegistry, IncomingManageRequest, ManageRequestHandler, Session, + SessionEvent, SessionOptions, HANDSHAKE_TIMEOUT, }; use wire_mesh_core::ports::{Identity, Transport}; use wire_mesh_wire::identity::DeviceId; @@ -88,31 +91,49 @@ async fn main() -> Result<(), String> { .map_err(|error| error.to_string())?; let registry = HandlerRegistry::new().register("relay:echo", Arc::new(Reporting)); let signer = Arc::clone(&identity); - let (session, mut events) = Session::accept_relayed( + // The session announces itself in gossip mode, so the hub learns this node from the session's own advert; the other modes announce by hand. + let gossiping = mode == "gossip"; + let mut options = SessionOptions::new().relayed(move |link: Arc| { + let channels = Arc::new(RelayChannels::new( + signer, + RelayClient::hello_sender(Arc::clone(&link)), + Arc::new(MonotonicClock::new()), + RelayOptions::default(), + )); + Arc::new(RelayClient::new(link, channels)) + }); + if gossiping { + options = options.gossiping(GossipConfig { + identity: Arc::clone(&identity) as Arc, + clock: Arc::new(SystemClock), + addresses: Vec::new(), + accepted: false, + handshake_timeout: HANDSHAKE_TIMEOUT, + }); + } + let (session, mut events) = Session::accept_with( connection, ["core/management".to_owned()], registry, - move |link: Arc| { - let channels = Arc::new(RelayChannels::new( - signer, - RelayClient::hello_sender(Arc::clone(&link)), - Arc::new(MonotonicClock::new()), - RelayOptions::default(), - )); - Arc::new(RelayClient::new(link, channels)) - }, + options, ) .await .map_err(|error| error.to_string())?; - session - .announce(advert(&identity).await?) - .await - .map_err(|error| error.to_string())?; + if !gossiping { + session + .announce(advert(&identity).await?) + .await + .map_err(|error| error.to_string())?; + } println!("ANNOUNCED"); tokio::spawn(async move { while let Some(event) = events.recv().await { - if let SessionEvent::RelayedData { from, .. } = event { - println!("DATA {}", hex(&from.0)); + match event { + SessionEvent::RelayedData { from, .. } => println!("DATA {}", hex(&from.0)), + SessionEvent::DirectoryChanged { device } => { + println!("DIRECTORY {}", hex(&device.0)); + } + _ => {} } } }); @@ -160,7 +181,7 @@ async fn main() -> Result<(), String> { } } } - ("serve", []) => {} + ("serve" | "gossip", []) => {} _ => return Err("unknown mode or arguments".to_owned()), } // Ends when standard input closes, so the test decides how long this node stays on the hub. diff --git a/rust/crates/wire-mesh-core/src/domain/gossip_directory.rs b/rust/crates/wire-mesh-core/src/domain/gossip_directory.rs new file mode 100644 index 00000000..7b7f7795 --- /dev/null +++ b/rust/crates/wire-mesh-core/src/domain/gossip_directory.rs @@ -0,0 +1,425 @@ +//! The peer directory a session builds from the gossip it receives, and the self-advert it sends: the mirror of the directory handling in the TypeScript `createMeshSession`. +//! +//! An advert reaching a session was very often forwarded by a hub or a gateway rather than sent by the device it names, so it is verified here, never taken on the sender's word: the identity key it carries must hash to the device it names and its signature must verify under that key ([`verify_peer_advert`]). One refused advert says nothing about the others in its frame. The newest advert per device wins, by the device's own signed `snapshot-seconds` and never by arrival, so an older advert a hub replays cannot displace a newer one; a re-advert replaces in place, so the directory keeps the order devices were first heard in. +//! +//! The directory is bounded, which the TypeScript is not: adverts come from a hub that is not trusted to bound them. At most [`MAX_DIRECTORY_DEVICES`] devices are held and no advert whose encoding is longer than [`MAX_ADVERT_BYTES`] is admitted; beyond either the advert is refused and the refusal is reported, and nothing already held is evicted (a full directory therefore stays full until the session ends, so an owner that must keep learning devices rebuilds the session or applies a policy above it), because an advert is data this node cannot ask for again and may be what it is talking to a device by. + +use wire_mesh_wire::encode_frame; +use wire_mesh_wire::identity::DeviceId; +use wire_mesh_wire::transport::{GossipFrame, PeerAdvert}; +use wire_mesh_wire::Frame; + +use crate::domain::mint::MAX_EXACT_INTEGER; +use crate::domain::peer_advert::{verify_peer_advert, PeerAdvertRejection, PeerAdvertVerdict}; +use crate::domain::topology::DirectoryEntry; +use crate::ports::Identity; + +/// The most devices a directory holds. One entry is an advert of at most [`MAX_ADVERT_BYTES`] encoded, so a full directory is under 16 MiB, whatever a hub sends. +pub const MAX_DIRECTORY_DEVICES: usize = 1024; + +/// The longest encoded advert a directory admits: 16 KiB. An honest advert is an identity key, a handful of addresses and a few small extensions (a presence status, a policy, the topology of the node), a few hundred bytes to a few kilobytes. +pub const MAX_ADVERT_BYTES: usize = 16 * 1024; + +/// Why an advert did not enter the directory. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum AdvertRefusal { + /// The advert did not verify. + Unverified(PeerAdvertRejection), + /// Its `snapshot-seconds` is outside what a TypeScript peer holds exactly (|value| above 2^53 - 1). + SnapshotOutOfRange, + /// Its encoding is longer than [`MAX_ADVERT_BYTES`]. + TooLarge, + /// The directory already holds [`MAX_DIRECTORY_DEVICES`] devices and this one is not among them. + DirectoryFull, +} + +impl AdvertRefusal { + /// The name the conformance vectors use for this refusal. + #[must_use] + pub fn as_str(self) -> &'static str { + match self { + AdvertRefusal::Unverified(PeerAdvertRejection::WrongDevice) => "wrong_device", + AdvertRefusal::Unverified(PeerAdvertRejection::BadSignature) => "bad_signature", + AdvertRefusal::SnapshotOutOfRange => "snapshot_out_of_range", + AdvertRefusal::TooLarge => "too_large", + AdvertRefusal::DirectoryFull => "directory_full", + } + } +} + +/// What applying one advert of a gossip frame did. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum AdvertOutcome { + /// The advert entered the directory, as a new device or in place of an older advert (or one of the same time). + Admitted(DeviceId), + /// The directory holds a newer advert for the device, so this one was ignored. + Older(DeviceId), + /// The advert was refused. + Refused(DeviceId, AdvertRefusal), +} + +/// The directory: the latest verified advert per device, in the order devices were first heard. +#[derive(Debug, Default)] +pub struct GossipDirectory { + entries: Vec, +} + +impl GossipDirectory { + /// An empty directory. + #[must_use] + pub fn new() -> Self { + Self::default() + } + + /// The devices heard of and their latest advert, in first-heard order. + #[must_use] + pub fn entries(&self) -> &[DirectoryEntry] { + &self.entries + } + + /// Verifies and applies every advert of one gossip frame, in order, and returns what became of each. A refused advert is dropped alone. + pub async fn apply( + &mut self, + identity: &dyn Identity, + frame: &GossipFrame, + ) -> Vec { + let mut outcomes = Vec::with_capacity(frame.peers.len()); + for advert in &frame.peers { + outcomes.push(self.apply_one(identity, advert).await); + } + outcomes + } + + /// Applies one advert. The decisions that need no signature come first (size, snapshot range, an older advert for a known device, a full directory for an unknown one), and only an advert that would change the directory is verified: a hub that replays old adverts, or fills the directory and keeps sending new device ids, costs this node no signature check per advert. The refusal reported for a forged advert in those cases is the cheap one, which is fine since nothing from it is trusted either way. + async fn apply_one(&mut self, identity: &dyn Identity, advert: &PeerAdvert) -> AdvertOutcome { + let device = advert.device; + if advert.snapshot_seconds.unsigned_abs() > MAX_EXACT_INTEGER { + return AdvertOutcome::Refused(device, AdvertRefusal::SnapshotOutOfRange); + } + if encode_frame(&Frame::Gossip(GossipFrame { + peers: vec![advert.clone()], + })) + .len() + > MAX_ADVERT_BYTES + { + return AdvertOutcome::Refused(device, AdvertRefusal::TooLarge); + } + let held = self.entries.iter().position(|entry| entry.device == device); + match held { + Some(at) if advert.snapshot_seconds < self.entries[at].advert.snapshot_seconds => { + return AdvertOutcome::Older(device); + } + None if self.entries.len() >= MAX_DIRECTORY_DEVICES => { + return AdvertOutcome::Refused(device, AdvertRefusal::DirectoryFull); + } + _ => {} + } + if let PeerAdvertVerdict::Invalid(why) = verify_peer_advert(identity, advert).await { + return AdvertOutcome::Refused(device, AdvertRefusal::Unverified(why)); + } + let entry = DirectoryEntry { + device, + advert: advert.clone(), + }; + match held { + Some(at) => self.entries[at] = entry, + None => self.entries.push(entry), + } + AdvertOutcome::Admitted(device) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::adapters::NodeIdentity; + use crate::domain::self_advert::{build_self_advert, compute_topology_peers, TopologyInputs}; + use wire_mesh_wire::value::{CanonicalMap, CborValue}; + + /// A time well after the earliest a self-advert accepts; the tests count seconds from it. + const T0: u64 = 1_700_000_000; + + async fn advert_at( + identity: &NodeIdentity, + seconds: u64, + extension: Option<&str>, + ) -> PeerAdvert { + let extensions: Vec<(String, CborValue)> = extension + .map(|text| { + vec![( + "presence/status".to_owned(), + CborValue::Text(text.to_owned()), + )] + }) + .unwrap_or_default(); + build_self_advert( + identity, + &[], + T0 + seconds, + &extensions, + &compute_topology_peers(&TopologyInputs::default()), + ) + .await + .expect("an advert") + } + + fn frame(peers: Vec) -> GossipFrame { + GossipFrame { peers } + } + + #[tokio::test] + async fn a_valid_advert_is_admitted_and_one_that_does_not_verify_is_dropped_alone() { + let me = NodeIdentity::generate_ed25519(); + let (a, b, c) = ( + NodeIdentity::generate_ed25519(), + NodeIdentity::generate_ed25519(), + NodeIdentity::generate_ed25519(), + ); + let mut directory = GossipDirectory::new(); + let good_a = advert_at(&a, 10, None).await; + let mut wrong_device = advert_at(&b, 10, None).await; + wrong_device.device = *c.device_id(); + let mut bad_signature = advert_at(&c, 10, None).await; + bad_signature.signature[0] ^= 0xff; + let outcomes = directory + .apply( + &me, + &frame(vec![wrong_device, good_a.clone(), bad_signature]), + ) + .await; + assert_eq!( + outcomes, + vec![ + AdvertOutcome::Refused( + *c.device_id(), + AdvertRefusal::Unverified(PeerAdvertRejection::WrongDevice) + ), + AdvertOutcome::Admitted(*a.device_id()), + AdvertOutcome::Refused( + *c.device_id(), + AdvertRefusal::Unverified(PeerAdvertRejection::BadSignature) + ), + ] + ); + assert_eq!(directory.entries().len(), 1); + assert_eq!(directory.entries()[0].advert, good_a); + } + + #[tokio::test] + async fn the_newest_advert_per_device_wins_in_place_and_an_older_one_is_ignored() { + let me = NodeIdentity::generate_ed25519(); + let (a, b) = ( + NodeIdentity::generate_ed25519(), + NodeIdentity::generate_ed25519(), + ); + let mut directory = GossipDirectory::new(); + let (first_a, first_b) = ( + advert_at(&a, 10, Some("one")).await, + advert_at(&b, 10, None).await, + ); + directory.apply(&me, &frame(vec![first_a, first_b])).await; + let newer = advert_at(&a, 20, Some("two")).await; + assert_eq!( + directory.apply(&me, &frame(vec![newer.clone()])).await, + vec![AdvertOutcome::Admitted(*a.device_id())] + ); + // Replaced in place: a is still first. + assert_eq!(directory.entries()[0].device, *a.device_id()); + assert_eq!(directory.entries()[0].advert, newer); + // An older advert replayed by a hub does not displace it. + let older = advert_at(&a, 15, Some("old")).await; + assert_eq!( + directory.apply(&me, &frame(vec![older])).await, + vec![AdvertOutcome::Older(*a.device_id())] + ); + assert_eq!(directory.entries()[0].advert, newer); + // One of the same time replaces. + let same = advert_at(&a, 20, Some("same")).await; + assert_eq!( + directory.apply(&me, &frame(vec![same.clone()])).await, + vec![AdvertOutcome::Admitted(*a.device_id())] + ); + assert_eq!(directory.entries()[0].advert, same); + assert_eq!(directory.entries().len(), 2); + } + + #[tokio::test] + async fn a_snapshot_time_a_peer_cannot_hold_exactly_is_refused() { + let me = NodeIdentity::generate_ed25519(); + let a = NodeIdentity::generate_ed25519(); + let mut advert = advert_at(&a, 10, None).await; + advert.snapshot_seconds = i64::try_from(MAX_EXACT_INTEGER).expect("fits") + 1; + crate::domain::peer_advert::sign_peer_advert(&a, &mut advert) + .await + .expect("signs"); + let mut directory = GossipDirectory::new(); + assert_eq!( + directory.apply(&me, &frame(vec![advert])).await, + vec![AdvertOutcome::Refused( + *a.device_id(), + AdvertRefusal::SnapshotOutOfRange + )] + ); + assert!(directory.entries().is_empty()); + } + + #[tokio::test] + async fn an_advert_longer_than_the_cap_is_refused_and_one_at_the_cap_is_not() { + let me = NodeIdentity::generate_ed25519(); + let a = NodeIdentity::generate_ed25519(); + let mut directory = GossipDirectory::new(); + let padded = |text: usize| { + let a_ref = &a; + async move { + let mut advert = advert_at(a_ref, 10, None).await; + advert.extra = CanonicalMap::new(); + advert + .extra + .insert("pad/x".to_owned(), CborValue::Text("x".repeat(text))) + .expect("unique"); + crate::domain::peer_advert::sign_peer_advert(a_ref, &mut advert) + .await + .expect("signs"); + advert + } + }; + // Find the text length whose advert encodes to exactly the cap. + let measure = |advert: &PeerAdvert| { + encode_frame(&Frame::Gossip(GossipFrame { + peers: vec![advert.clone()], + })) + .len() + }; + let base = measure(&padded(0).await); + let fill = MAX_ADVERT_BYTES - base; + // A text of this size has a three-byte length head, one more than the empty text's, so it adds two bytes beyond its own length. + let at_the_cap = padded(fill - 2).await; + assert_eq!(measure(&at_the_cap), MAX_ADVERT_BYTES); + let over = padded(fill - 1).await; + assert_eq!(measure(&over), MAX_ADVERT_BYTES + 1); + assert_eq!( + directory.apply(&me, &frame(vec![over])).await, + vec![AdvertOutcome::Refused( + *a.device_id(), + AdvertRefusal::TooLarge + )] + ); + assert_eq!( + directory.apply(&me, &frame(vec![at_the_cap])).await, + vec![AdvertOutcome::Admitted(*a.device_id())] + ); + } + + #[tokio::test] + async fn the_directory_stops_at_its_bound_one_under_at_and_one_over_and_evicts_nothing() { + let me = NodeIdentity::generate_ed25519(); + let mut directory = GossipDirectory::new(); + let mut first = None; + for n in 0..MAX_DIRECTORY_DEVICES { + let identity = NodeIdentity::generate_ed25519(); + let advert = advert_at(&identity, 10, None).await; + if n == 0 { + first = Some(advert.device); + } + assert_eq!( + directory.apply(&me, &frame(vec![advert.clone()])).await, + vec![AdvertOutcome::Admitted(advert.device)], + "device {n}" + ); + } + assert_eq!(directory.entries().len(), MAX_DIRECTORY_DEVICES); + let extra = NodeIdentity::generate_ed25519(); + let beyond = advert_at(&extra, 10, None).await; + assert_eq!( + directory.apply(&me, &frame(vec![beyond.clone()])).await, + vec![AdvertOutcome::Refused( + beyond.device, + AdvertRefusal::DirectoryFull + )] + ); + assert_eq!(directory.entries().len(), MAX_DIRECTORY_DEVICES); + assert_eq!(Some(directory.entries()[0].device), first); + // A device already held can still be updated at the bound. + let held = directory.entries()[0].advert.clone(); + assert_eq!( + directory.apply(&me, &frame(vec![held.clone()])).await, + vec![AdvertOutcome::Admitted(held.device)] + ); + } + + fn forged(mut advert: PeerAdvert) -> PeerAdvert { + advert.signature[0] ^= 0xff; + advert + } + + #[tokio::test] + async fn the_decisions_that_need_no_signature_are_made_before_one_is_checked() { + let me = NodeIdentity::generate_ed25519(); + let a = NodeIdentity::generate_ed25519(); + let mut directory = GossipDirectory::new(); + directory + .apply(&me, &frame(vec![advert_at(&a, 20, None).await])) + .await; + // A forged advert older than the one held is ignored as older, without being verified. + let older = forged(advert_at(&a, 15, None).await); + assert_eq!( + directory.apply(&me, &frame(vec![older])).await, + vec![AdvertOutcome::Older(*a.device_id())] + ); + // One that would replace the entry is verified, and is refused for its signature. + let newer = forged(advert_at(&a, 30, None).await); + assert_eq!( + directory.apply(&me, &frame(vec![newer])).await, + vec![AdvertOutcome::Refused( + *a.device_id(), + AdvertRefusal::Unverified(PeerAdvertRejection::BadSignature) + )] + ); + // A forged advert out of range or over the cap is refused for that, not for its signature. + let mut out_of_range = forged(advert_at(&a, 10, None).await); + out_of_range.snapshot_seconds = i64::try_from(MAX_EXACT_INTEGER).expect("fits") + 1; + assert_eq!( + directory.apply(&me, &frame(vec![out_of_range])).await, + vec![AdvertOutcome::Refused( + *a.device_id(), + AdvertRefusal::SnapshotOutOfRange + )] + ); + let mut huge = advert_at(&a, 40, None).await; + huge.extra + .insert( + "pad/x".to_owned(), + CborValue::Text("x".repeat(MAX_ADVERT_BYTES)), + ) + .expect("unique"); + assert_eq!( + directory.apply(&me, &frame(vec![forged(huge)])).await, + vec![AdvertOutcome::Refused( + *a.device_id(), + AdvertRefusal::TooLarge + )] + ); + } + + #[tokio::test] + async fn a_forged_advert_for_a_new_device_meets_the_full_directory_before_its_signature_is_checked( + ) { + let me = NodeIdentity::generate_ed25519(); + let mut directory = GossipDirectory::new(); + for _ in 0..MAX_DIRECTORY_DEVICES { + let identity = NodeIdentity::generate_ed25519(); + directory + .apply(&me, &frame(vec![advert_at(&identity, 10, None).await])) + .await; + } + let stranger = NodeIdentity::generate_ed25519(); + let forged_new = forged(advert_at(&stranger, 10, None).await); + assert_eq!( + directory.apply(&me, &frame(vec![forged_new.clone()])).await, + vec![AdvertOutcome::Refused( + forged_new.device, + AdvertRefusal::DirectoryFull + )] + ); + } +} diff --git a/rust/crates/wire-mesh-core/src/domain/gossip_extensions.rs b/rust/crates/wire-mesh-core/src/domain/gossip_extensions.rs new file mode 100644 index 00000000..02edf245 --- /dev/null +++ b/rust/crates/wire-mesh-core/src/domain/gossip_extensions.rs @@ -0,0 +1,186 @@ +//! Validation of the extension bag a caller hands to a gossip update, the mirror of the TypeScript `validateGossipExtensions`: a pure function of the keys, with no dependency on session state. +//! +//! A key is refused when it would shadow one of a peer-advert's own mandatory fields, when it is one the session manages itself (`topology/peers`) or one this crate reserves for its own version, or when it is not domain-qualified as `/` in lowercase kebab-case, which is what keeps two independent applications that share one gossip tail from silently overwriting each other's keys (`spec/CONVENTIONS.md`). + +use crate::domain::topology::TOPOLOGY_PEERS_GOSSIP_KEY; + +/// The gossip extension key this crate injects into every self-advert to report its own version, reserved so a caller can never also supply it. +pub const CORE_VERSION_GOSSIP_KEY: &str = "wire-mesh/version"; + +/// The peer-advert fields the session sets itself, which an extension may never shadow. +pub const RESERVED_PEER_ADVERT_KEYS: [&str; 5] = [ + "device", + "addresses", + "snapshot-seconds", + "identity-key", + "signature", +]; + +/// Why an extension key was refused, named as the conformance vectors name it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ExtensionRefusal { + /// The key is one of the peer-advert's own mandatory fields. + ReservedField, + /// The key is `topology/peers`, which the session computes. + SessionManaged, + /// The key is the one reserved for this crate's own version. + ReservedVersion, + /// The key is not `/` in lowercase kebab-case. + NotDomainQualified, +} + +impl ExtensionRefusal { + /// The name the conformance vectors use for this refusal. + #[must_use] + pub fn as_str(self) -> &'static str { + match self { + ExtensionRefusal::ReservedField => "reserved_field", + ExtensionRefusal::SessionManaged => "session_managed", + ExtensionRefusal::ReservedVersion => "reserved_version", + ExtensionRefusal::NotDomainQualified => "not_domain_qualified", + } + } +} + +/// A refused key and why. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RefusedExtension { + pub key: String, + pub refusal: ExtensionRefusal, +} + +impl std::fmt::Display for RefusedExtension { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.refusal { + ExtensionRefusal::ReservedField => write!( + f, + "the extension key \"{}\" collides with a mandatory peer-advert field", + self.key + ), + ExtensionRefusal::SessionManaged => write!( + f, + "the extension key \"{}\" collides with a session-managed gossip field", + self.key + ), + ExtensionRefusal::ReservedVersion => write!( + f, + "the extension key \"{}\" is reserved for wire-mesh-core's own self-reported version", + self.key + ), + ExtensionRefusal::NotDomainQualified => write!( + f, + "the extension key \"{}\" must be domain-qualified as \"/\" (for example \"presence/status\")", + self.key + ), + } + } +} + +impl std::error::Error for RefusedExtension {} + +/// Whether `part` is lowercase kebab-case: a letter, then letters, digits and hyphens, all lowercase. +fn is_kebab(part: &str) -> bool { + let mut bytes = part.bytes(); + bytes.next().is_some_and(|first| first.is_ascii_lowercase()) + && bytes.all(|byte| byte.is_ascii_lowercase() || byte.is_ascii_digit() || byte == b'-') +} + +/// Whether `key` is `/`, each side lowercase kebab-case. +fn is_domain_qualified(key: &str) -> bool { + key.split_once('/') + .is_some_and(|(domain, field)| is_kebab(domain) && is_kebab(field)) +} + +/// Checks each key of an extension bag in the order given. The first key that fails is the refusal; for one key the checks run in the order reserved field, session-managed, reserved version, domain qualification. +/// +/// # Errors +/// +/// The first [`RefusedExtension`]. +pub fn validate_gossip_extensions<'a>( + keys: impl IntoIterator, +) -> Result<(), RefusedExtension> { + for key in keys { + let refusal = if RESERVED_PEER_ADVERT_KEYS.contains(&key) { + Some(ExtensionRefusal::ReservedField) + } else if key == TOPOLOGY_PEERS_GOSSIP_KEY { + Some(ExtensionRefusal::SessionManaged) + } else if key == CORE_VERSION_GOSSIP_KEY { + Some(ExtensionRefusal::ReservedVersion) + } else if !is_domain_qualified(key) { + Some(ExtensionRefusal::NotDomainQualified) + } else { + None + }; + if let Some(refusal) = refusal { + return Err(RefusedExtension { + key: key.to_owned(), + refusal, + }); + } + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn refusal(keys: &[&str]) -> Option<(String, ExtensionRefusal)> { + validate_gossip_extensions(keys.iter().copied()) + .err() + .map(|refused| (refused.key, refused.refusal)) + } + + #[test] + fn each_reason_names_its_own_refusal() { + for key in RESERVED_PEER_ADVERT_KEYS { + assert_eq!( + refusal(&[key]), + Some((key.to_owned(), ExtensionRefusal::ReservedField)) + ); + } + assert_eq!( + refusal(&["topology/peers"]), + Some(( + "topology/peers".to_owned(), + ExtensionRefusal::SessionManaged + )) + ); + assert_eq!( + refusal(&["wire-mesh/version"]), + Some(( + "wire-mesh/version".to_owned(), + ExtensionRefusal::ReservedVersion + )) + ); + for key in [ + "status", + "Presence/status", + "presence/Status", + "a/b/c", + "/x", + "x/", + "1a/b", + "a_b/c", + "", + ] { + assert_eq!( + refusal(&[key]), + Some((key.to_owned(), ExtensionRefusal::NotDomainQualified)), + "{key:?}" + ); + } + } + + #[test] + fn domain_qualified_keys_are_accepted_and_the_first_bad_key_is_the_one_named() { + assert_eq!(refusal(&["presence/status", "app-1/x-y2"]), None); + assert_eq!( + refusal(&["presence/status", "device", "status"]), + Some(("device".to_owned(), ExtensionRefusal::ReservedField)) + ); + // A key that merely contains a reserved name is an ordinary key. + assert_eq!(refusal(&["device/status", "wire-mesh/versions"]), None); + assert_eq!(refusal(&[]), None); + } +} diff --git a/rust/crates/wire-mesh-core/src/domain/mod.rs b/rust/crates/wire-mesh-core/src/domain/mod.rs index 2e8484a0..d83b1bec 100644 --- a/rust/crates/wire-mesh-core/src/domain/mod.rs +++ b/rust/crates/wire-mesh-core/src/domain/mod.rs @@ -6,6 +6,8 @@ pub mod data_sync; pub mod erasure_coding; pub mod fault_report; pub mod fs_layout; +pub mod gossip_directory; +pub mod gossip_extensions; pub mod group_key; pub mod handshake; pub mod identity_key; @@ -20,6 +22,7 @@ pub mod room; pub mod room_path; pub mod room_token_verification; pub mod secure_channel; +pub mod self_advert; #[cfg(feature = "net")] pub mod session; pub mod shard_manifest; diff --git a/rust/crates/wire-mesh-core/src/domain/self_advert.rs b/rust/crates/wire-mesh-core/src/domain/self_advert.rs new file mode 100644 index 00000000..8b47f073 --- /dev/null +++ b/rust/crates/wire-mesh-core/src/domain/self_advert.rs @@ -0,0 +1,303 @@ +//! This node's own signed advert and the topology it advertises: the mirror of the TypeScript `buildSelfAdvert` and `computeTopologyPeers`. +//! +//! Every advert carries this crate's own version under [`CORE_VERSION_GOSSIP_KEY`] and the current topology under `topology/peers`, recomputed on every call, never cached, since the connection and the pairings change between one advert and the next. A caller's extensions are validated first ([`validate_gossip_extensions`]), so none can shadow a mandatory field, the topology or the version. + +use wire_mesh_wire::identity::DeviceId; +use wire_mesh_wire::introspection::{RelayedPeer, TopologyPeers}; +use wire_mesh_wire::transport::PeerAdvert; +use wire_mesh_wire::value::{CanonicalMap, CborValue}; + +use crate::domain::gossip_extensions::{ + validate_gossip_extensions, RefusedExtension, CORE_VERSION_GOSSIP_KEY, +}; +use crate::domain::mint::MAX_EXACT_INTEGER; +use crate::domain::peer_advert::sign_peer_advert; +use crate::domain::topology::TOPOLOGY_PEERS_GOSSIP_KEY; +use crate::ports::{CoreError, Identity}; + +/// This crate's own version, as every self-advert and the `version.get` answer report it. It is read when this crate is compiled, so it is the version `cargo publish` ships, with none of the staleness the TypeScript has to avoid by reading its manifest at run time. +pub const OWN_VERSION: &str = env!("CARGO_PKG_VERSION"); + +/// The earliest time, in Unix seconds (the start of 2001), a self-advert's clock may read. A clock that reads earlier is not a wall clock (a monotonic clock counts from the process start and gives a few seconds), and an advert stamped with it would look older than every advert a hub holds and be ignored without a sign. +pub const EARLIEST_PLAUSIBLE_SECONDS: u64 = 978_307_200; + +/// What a self-advert's topology is computed from. +#[derive(Debug, Clone, Default)] +pub struct TopologyInputs { + /// The transport-authenticated direct peer, when the transport gives one. It takes priority over `first_advertised_peer`. The connection port has no peer-identity accessor and the only adapter, plain TCP, authenticates nobody, so a session passes `None`. + pub authenticated_peer: Option, + /// The device named by the first advert this session applied to its directory. Trusted only when `accepted`: a dial-side session may end up naming a merely relayed third device. It is a first-heard assumption and no proof: on an accepted connection a peer that first sends a genuine, correctly signed advert of another device (one it has seen) makes this node's self-adverts name that device as the direct peer, an edge that does not exist. The topology is not secret and names only devices whose adverts the peer holds, so this misstates the graph and grants nothing; an authenticating transport removes it by supplying `authenticated_peer`. + pub first_advertised_peer: Option, + /// Whether this connection was accepted (not dialled), where `first_advertised_peer` is structurally sound. + pub accepted: bool, + /// Every device this connection holds a relay pairing with. + pub relayed: Vec, +} + +/// This node's current topology: the direct peer, when it can be honestly known, and every relay pairing, each named with the hub it is reached through when that is known. +#[must_use] +pub fn compute_topology_peers(inputs: &TopologyInputs) -> TopologyPeers { + let direct = inputs.authenticated_peer.or(if inputs.accepted { + inputs.first_advertised_peer + } else { + None + }); + TopologyPeers { + direct: direct.into_iter().collect(), + relayed: inputs + .relayed + .iter() + .map(|device| RelayedPeer { + device: *device, + via: direct, + }) + .collect(), + } +} + +/// Why a self-advert could not be built. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum SelfAdvertError { + /// An extension key was refused. + Extension(RefusedExtension), + /// The clock reads a time a TypeScript peer cannot hold exactly as `snapshot-seconds`. + ClockOutOfRange, + /// The clock reads a time before [`EARLIEST_PLAUSIBLE_SECONDS`]: it is not a wall clock. + ClockImplausible, + /// The advert could not be signed. + Signing(CoreError), +} + +impl std::fmt::Display for SelfAdvertError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SelfAdvertError::Extension(refused) => write!(f, "{refused}"), + SelfAdvertError::ClockOutOfRange => { + f.write_str("the clock reads a time beyond what a peer can hold exactly") + } + SelfAdvertError::ClockImplausible => { + f.write_str("the clock reads a time before 2001, so it is not a wall clock") + } + SelfAdvertError::Signing(error) => write!(f, "the advert could not be signed: {error}"), + } + } +} + +impl std::error::Error for SelfAdvertError {} + +fn topology_value(topology: &TopologyPeers) -> CborValue { + let bytes = minicbor::to_vec(topology) + .unwrap_or_else(|_| unreachable!("Vec writes are infallible")); + let mut decoder = minicbor::Decoder::new(&bytes); + CborValue::decode_strict(&mut decoder) + .unwrap_or_else(|_| unreachable!("a topology this crate encoded decodes as a CBOR value")) +} + +/// Builds and signs this node's own advert: its device, `addresses`, `now_seconds` as `snapshot-seconds`, its identity key, the caller's `extensions` (validated), this crate's version and `topology`. +/// +/// # Errors +/// +/// [`SelfAdvertError::Extension`] for a refused extension key, [`SelfAdvertError::ClockOutOfRange`] when `now_seconds` is above 2^53 - 1, [`SelfAdvertError::ClockImplausible`] when it is before [`EARLIEST_PLAUSIBLE_SECONDS`], and [`SelfAdvertError::Signing`] when the identity cannot sign. +pub async fn build_self_advert( + identity: &dyn Identity, + addresses: &[String], + now_seconds: u64, + extensions: &[(String, CborValue)], + topology: &TopologyPeers, +) -> Result { + validate_gossip_extensions(extensions.iter().map(|(key, _)| key.as_str())) + .map_err(SelfAdvertError::Extension)?; + if now_seconds > MAX_EXACT_INTEGER { + return Err(SelfAdvertError::ClockOutOfRange); + } + if now_seconds < EARLIEST_PLAUSIBLE_SECONDS { + return Err(SelfAdvertError::ClockImplausible); + } + let mut extra = CanonicalMap::new(); + for (key, value) in extensions { + // A key given twice keeps the later value, as an object literal does in the TypeScript. + let _ = extra.remove(key); + extra.insert(key.clone(), value.clone()).map_err(|_| { + SelfAdvertError::Signing(CoreError::Wire("a duplicate extension key".to_owned())) + })?; + } + extra + .insert( + CORE_VERSION_GOSSIP_KEY.to_owned(), + CborValue::Text(OWN_VERSION.to_owned()), + ) + .map_err(|_| { + SelfAdvertError::Signing(CoreError::Wire("a duplicate version key".to_owned())) + })?; + extra + .insert( + TOPOLOGY_PEERS_GOSSIP_KEY.to_owned(), + topology_value(topology), + ) + .map_err(|_| { + SelfAdvertError::Signing(CoreError::Wire("a duplicate topology key".to_owned())) + })?; + let mut advert = PeerAdvert { + device: *identity.device_id(), + addresses: addresses.to_vec(), + snapshot_seconds: i64::try_from(now_seconds) + .map_err(|_| SelfAdvertError::ClockOutOfRange)?, + identity_key: identity.identity_key().clone(), + signature: Vec::new(), + extra, + }; + sign_peer_advert(identity, &mut advert) + .await + .map_err(SelfAdvertError::Signing)?; + Ok(advert) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::adapters::NodeIdentity; + use crate::domain::gossip_extensions::ExtensionRefusal; + use crate::domain::peer_advert::{verify_peer_advert, PeerAdvertVerdict}; + + fn device(n: u8) -> DeviceId { + DeviceId([n; 32]) + } + + #[test] + fn the_topology_names_the_authenticated_peer_first_and_the_first_advertised_one_only_when_accepted( + ) { + let inputs = TopologyInputs { + authenticated_peer: Some(device(1)), + first_advertised_peer: Some(device(2)), + accepted: false, + relayed: vec![device(3)], + }; + let topology = compute_topology_peers(&inputs); + assert_eq!(topology.direct, vec![device(1)]); + assert_eq!( + topology.relayed, + vec![RelayedPeer { + device: device(3), + via: Some(device(1)) + }] + ); + let dialled = compute_topology_peers(&TopologyInputs { + authenticated_peer: None, + ..inputs.clone() + }); + assert!(dialled.direct.is_empty()); + assert_eq!( + dialled.relayed, + vec![RelayedPeer { + device: device(3), + via: None + }] + ); + let accepted = compute_topology_peers(&TopologyInputs { + authenticated_peer: None, + accepted: true, + ..inputs + }); + assert_eq!(accepted.direct, vec![device(2)]); + } + + #[tokio::test] + async fn a_self_advert_verifies_and_carries_the_version_and_the_topology() { + let identity = NodeIdentity::generate_ed25519(); + let topology = compute_topology_peers(&TopologyInputs { + authenticated_peer: Some(device(1)), + relayed: vec![device(3)], + ..TopologyInputs::default() + }); + let advert = build_self_advert( + &identity, + &["127.0.0.1:1".to_owned()], + 1_700_000_000, + &[], + &topology, + ) + .await + .expect("an advert"); + assert_eq!( + verify_peer_advert(&identity, &advert).await, + PeerAdvertVerdict::Valid + ); + assert_eq!(advert.device, *identity.device_id()); + assert_eq!(advert.snapshot_seconds, 1_700_000_000); + assert_eq!( + advert.extra.get(&CORE_VERSION_GOSSIP_KEY.to_owned()), + Some(&CborValue::Text(OWN_VERSION.to_owned())) + ); + assert_eq!( + crate::domain::topology::read_topology_peers(&advert), + Some(topology) + ); + } + + #[tokio::test] + async fn an_extension_that_would_shadow_a_field_or_the_version_is_refused_before_anything_is_signed( + ) { + let identity = NodeIdentity::generate_ed25519(); + let topology = TopologyPeers::default(); + for (key, refusal) in [ + ("device", ExtensionRefusal::ReservedField), + ("topology/peers", ExtensionRefusal::SessionManaged), + ("wire-mesh/version", ExtensionRefusal::ReservedVersion), + ("plain", ExtensionRefusal::NotDomainQualified), + ] { + let result = build_self_advert( + &identity, + &[], + 1, + &[(key.to_owned(), CborValue::Text("x".to_owned()))], + &topology, + ) + .await; + assert_eq!( + result.err(), + Some(SelfAdvertError::Extension(RefusedExtension { + key: key.to_owned(), + refusal + })), + "{key}" + ); + } + } + + #[tokio::test] + async fn a_clock_beyond_the_exact_integers_builds_no_advert() { + let identity = NodeIdentity::generate_ed25519(); + let topology = TopologyPeers::default(); + assert!( + build_self_advert(&identity, &[], MAX_EXACT_INTEGER, &[], &topology) + .await + .is_ok() + ); + assert_eq!( + build_self_advert(&identity, &[], MAX_EXACT_INTEGER + 1, &[], &topology) + .await + .err(), + Some(SelfAdvertError::ClockOutOfRange) + ); + } + + #[tokio::test] + async fn a_clock_that_is_not_a_wall_clock_builds_no_advert() { + let identity = NodeIdentity::generate_ed25519(); + let topology = TopologyPeers::default(); + assert!( + build_self_advert(&identity, &[], EARLIEST_PLAUSIBLE_SECONDS, &[], &topology) + .await + .is_ok() + ); + for seconds in [0, 3, EARLIEST_PLAUSIBLE_SECONDS - 1] { + assert_eq!( + build_self_advert(&identity, &[], seconds, &[], &topology) + .await + .err(), + Some(SelfAdvertError::ClockImplausible), + "{seconds}" + ); + } + } +} diff --git a/rust/crates/wire-mesh-core/src/domain/session.rs b/rust/crates/wire-mesh-core/src/domain/session.rs index 1ab69b7a..25660817 100644 --- a/rust/crates/wire-mesh-core/src/domain/session.rs +++ b/rust/crates/wire-mesh-core/src/domain/session.rs @@ -31,7 +31,8 @@ use tokio::sync::{mpsc, oneshot, Mutex as AsyncMutex}; use tokio::task::AbortHandle; use wire_mesh_wire::handshake::{DomainId, HandshakeFrame, ProtocolVersion}; use wire_mesh_wire::management::{ - ManageCommand, ManageError, ManageOk, ManageOutcome, ManageRequestFrame, ManageResponseFrame, + ManageCommand, ManageError, ManageOk, ManageOutcome, ManageParams, ManageRequestFrame, + ManageResponseFrame, }; use wire_mesh_wire::tokens::{CapabilityScope, CoseSign1}; use wire_mesh_wire::value::{CanonicalMap, CborValue}; @@ -39,11 +40,16 @@ use wire_mesh_wire::Frame; use wire_mesh_wire::identity::DeviceId; +use crate::domain::gossip_directory::{AdvertOutcome, GossipDirectory}; use crate::domain::handshake::{negotiate, SUPPORTED_PROTOCOL_VERSION}; use crate::domain::mint::MAX_EXACT_INTEGER; use crate::domain::relay_channels::SealPurpose; use crate::domain::relay_client::{HubLink, RelayClient, RelayEvent}; -use crate::ports::{Connection, CoreError}; +use crate::domain::self_advert::{ + build_self_advert, compute_topology_peers, SelfAdvertError, TopologyInputs, OWN_VERSION, +}; +use crate::domain::topology::DirectoryEntry; +use crate::ports::{Clock, Connection, CoreError, Identity}; /// A connection shared between the dispatch loop (which reads frames) /// and every caller of `send_manage_request`/`send_data_frame` (which @@ -127,24 +133,9 @@ impl HandlerRegistry { } } -/// The core/version domain's own version-get verb (issue #179), answered with -/// this crate's actual, currently-compiled version -- `CARGO_PKG_VERSION` is -/// resolved from `Cargo.toml`'s own `version.workspace = true` at compile -/// time, so unlike the TypeScript core's own equivalent (which has to read -/// its `package.json` at runtime, since semantic-release/npm rewrites that -/// file only in the tarball it publishes, after the package has already -/// been built) there is no build-vs-publish staleness risk here: this crate's -/// `Cargo.toml` version IS the version `cargo publish` ships. +/// The core/version domain's version-get verb (issue #179), answered with this crate's actual, currently-compiled version: `CARGO_PKG_VERSION` is resolved from `Cargo.toml`'s own `version.workspace = true` at compile time, so there is no build-versus-publish staleness risk, unlike the TypeScript core, which has to read its `package.json` at run time. /// -/// Deliberately NOT auto-answered the way `mesh-session.ts`'s own -/// `applyManageRequest` bypasses `incomingManageRequests` for this same verb: -/// this runtime dispatches every manage-request through `HandlerRegistry` -/// with no built-in behaviour for any verb, gossip included (see this -/// module's own doc comment), so a universal, bypass-the-registry special -/// case here would be the one inconsistent exception to that design rather -/// than a parity fix. A consumer that wants version.get support registers -/// this handler explicitly, the same way it registers any other: -/// `HandlerRegistry::new().register("core:version", Arc::new(VersionHandler))`. +/// Every session answers a manage-request whose params carry the verb `version.get` itself, bypassing the registry, as the TypeScript `applyManageRequest` does. This handler is for a consumer that registers the version under a capability verb of its own (`HandlerRegistry::new().register("core:version", Arc::new(VersionHandler))`); it answers every request it is given with the same version. pub struct VersionHandler; #[async_trait::async_trait] @@ -200,11 +191,109 @@ pub enum SessionEvent { to_device: Option, frame: DataFrame, }, + /// A gossiped advert entered the peer directory (as a new device, or in place of an older advert). + DirectoryChanged { device: DeviceId }, + /// Adverts of one gossip frame were refused: one did not verify, its time or size is out of range, or the directory is full. One refused advert says nothing about the others of its frame, which are applied. A frame produces one event whatever its number of refusals (a hub can put thousands of forged adverts in a frame at no cost to itself, and an event per advert would grow this session's unbounded queue with them): `first` and `reason` are those of the first refusal and `count` is how many the frame had. + AdvertsRefused { + first: DeviceId, + reason: &'static str, + count: usize, + }, + /// The peer sent no handshake within the handshake timeout. A relay-only hub never sends one, which is a state to report and not an error: the session carries on. + HandshakeUnanswered, /// The connection ended, whether the peer closed it, the underlying /// transport failed, or `Session::close` was called locally. Disconnected { reason: String }, } +/// How long a session waits for the peer's handshake before it reports [`SessionEvent::HandshakeUnanswered`]: the same 3 s the TypeScript session waits. +pub const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(3); + +/// What a session needs to take part in gossip: to sign its own advert, read the time, say where it can be reached and whether the connection was accepted. Without it a session ignores gossip frames, as the runtime did before. +pub struct GossipConfig { + /// Signs this node's own advert and verifies the adverts it receives. + pub identity: Arc, + /// The time the advert's `snapshot-seconds` is read from: a wall clock (Unix milliseconds). A clock that reads before 2001, such as a monotonic one, fails the session's first advert with an error instead of producing adverts every hub ignores. + pub clock: Arc, + /// The `host:port` addresses this node can be reached on directly; none for a node that cannot accept connections. + pub addresses: Vec, + /// Whether this connection was accepted and not dialled, which decides whether the first advertised peer may be taken as the direct peer. + pub accepted: bool, + /// How long to wait for the peer's handshake. [`HANDSHAKE_TIMEOUT`] unless a test needs another. + pub handshake_timeout: Duration, +} + +/// Builds the relay client of a session from the link the session sends through. +type RelayBuilder = Box) -> Arc + Send>; + +/// What a session is built from besides its connection, domains and handlers. +#[derive(Default)] +pub struct SessionOptions { + relay: Option, + gossip: Option, +} + +impl SessionOptions { + /// Options for a plain session. + #[must_use] + pub fn new() -> Self { + Self::default() + } + + /// A session over a connection to a relay hub: `relay` is given the link the session sends through and returns the relay client the session then drives. + #[must_use] + pub fn relayed( + mut self, + relay: impl FnOnce(Arc) -> Arc + Send + 'static, + ) -> Self { + self.relay = Some(Box::new(relay)); + self + } + + /// A session that takes part in gossip. + #[must_use] + pub fn gossiping(mut self, gossip: GossipConfig) -> Self { + self.gossip = Some(gossip); + self + } +} + +/// The gossip state of a session: its configuration, the directory it builds, and the first peer an advert named. +struct GossipState { + config: GossipConfig, + directory: AsyncMutex, + first_advertised: StdMutex>, +} + +impl GossipState { + async fn self_advert( + &self, + relay: Option<&Arc>, + extensions: &[(String, CborValue)], + ) -> Result { + let first = *self + .first_advertised + .lock() + .unwrap_or_else(|e| e.into_inner()); + let topology = compute_topology_peers(&TopologyInputs { + // The connection port names no authenticated peer (the only adapter, plain TCP, authenticates nobody), so the first-heard rule in `TopologyInputs` applies. + authenticated_peer: None, + first_advertised_peer: first, + accepted: self.config.accepted, + relayed: relay.map(|relay| relay.paired()).unwrap_or_default(), + }); + let seconds = self.config.clock.now_unix_ms() / 1_000; + build_self_advert( + &*self.config.identity, + &self.config.addresses, + seconds, + extensions, + &topology, + ) + .await + } +} + async fn next_frame(stream: &mut Pin + Send>>) -> Option { poll_fn(|cx| stream.as_mut().poll_next(cx)).await } @@ -265,6 +354,9 @@ impl HubLink for ConnectionLink { } } +/// The params verb of the core/version domain's version-get command. +const VERSION_GET_VERB: &str = "version.get"; + /// Answers one incoming manage-request with the handler registered for its verb, or `unknown-verb`. async fn answer( registry: &HandlerRegistry, @@ -273,6 +365,17 @@ async fn answer( scope: CapabilityScope, token: Option, ) -> ManageOutcome { + // The core/version domain's version-get is answered by every session and bypasses the registry, as in the TypeScript: it is deliberately unauthenticated and carries nothing but this crate's own version. + if let ManageParams::Json(params) = &command.params { + if params.get(&"verb".to_owned()) == Some(&CborValue::Text(VERSION_GET_VERB.to_owned())) { + let mut extra = CanonicalMap::new(); + let _ = extra.insert( + "version".to_owned(), + CborValue::Text(OWN_VERSION.to_owned()), + ); + return ManageOutcome::Ok(ManageOk { extra }); + } + } let verb = command.verb.0.clone(); match registry.get(&verb) { Some(handler) => { @@ -312,6 +415,8 @@ async fn run_dispatch_loop( local_handshake: HandshakeFrame, closed: Arc, relay: Option>, + gossip: Option>, + handshake_settled_flag: Arc, ) { let mut handshake_settled = false; while let Some(frame) = next_frame(&mut inbound).await { @@ -321,6 +426,7 @@ async fn run_dispatch_loop( continue; } handshake_settled = true; + handshake_settled_flag.store(true, Ordering::SeqCst); match negotiate(&local_handshake, &remote) { Ok(result) => { let _ = events_tx.send(SessionEvent::HandshakeNegotiated { @@ -357,6 +463,52 @@ async fn run_dispatch_loop( let _ = send_frame(&connection, response).await; }); } + Frame::Gossip(gossiped) => { + let Some(gossip) = gossip.as_ref() else { + continue; + }; + // Verified here, never taken on the sender's word: an advert reaching this session was very often forwarded by a hub or a gateway. + let outcomes = gossip + .directory + .lock() + .await + .apply(&*gossip.config.identity, &gossiped) + .await; + // One event per distinct device changed and one for all the refusals, so a frame's size does not set the number of events. + let mut changed: Vec = Vec::new(); + let mut refused: Option<(DeviceId, &'static str, usize)> = None; + for outcome in outcomes { + match outcome { + AdvertOutcome::Admitted(device) => { + gossip + .first_advertised + .lock() + .unwrap_or_else(|e| e.into_inner()) + .get_or_insert(device); + if !changed.contains(&device) { + changed.push(device); + } + } + AdvertOutcome::Older(_) => {} + AdvertOutcome::Refused(device, why) => { + refused = Some(match refused { + None => (device, why.as_str(), 1), + Some((first, reason, count)) => (first, reason, count + 1), + }); + } + } + } + for device in changed { + let _ = events_tx.send(SessionEvent::DirectoryChanged { device }); + } + if let Some((first, reason, count)) = refused { + let _ = events_tx.send(SessionEvent::AdvertsRefused { + first, + reason, + count, + }); + } + } Frame::RelayInbound(_) | Frame::RelayData(_) => { let Some(relay) = relay.as_ref() else { continue; @@ -447,6 +599,7 @@ pub struct Session { events_tx: mpsc::UnboundedSender, closed: Arc, relay: Option>, + gossip: Option>, } impl Session { @@ -461,13 +614,7 @@ impl Session { local_domains: impl IntoIterator, registry: HandlerRegistry, ) -> Result<(Session, mpsc::UnboundedReceiver), CoreError> { - Self::accept_with( - connection, - local_domains, - registry, - None::) -> Arc>, - ) - .await + Self::accept_with(connection, local_domains, registry, SessionOptions::new()).await } /// [`Session::accept`] for a connection to a relay hub: `relay` is given the link the session sends through (build the secure channels' hello sender from it with [`RelayClient::hello_sender`]) and returns the relay client the session then drives. Frames that arrive as `relay-inbound` or `relay-data` go to it, and [`Session::send_manage_request_via`] and [`Session::send_data_frame_via`] send through it. @@ -479,17 +626,29 @@ impl Session { connection: Box, local_domains: impl IntoIterator, registry: HandlerRegistry, - relay: impl FnOnce(Arc) -> Arc, + relay: impl FnOnce(Arc) -> Arc + Send + 'static, ) -> Result<(Session, mpsc::UnboundedReceiver), CoreError> { - Self::accept_with(connection, local_domains, registry, Some(relay)).await + Self::accept_with( + connection, + local_domains, + registry, + SessionOptions::new().relayed(relay), + ) + .await } - async fn accept_with( + /// [`Session::accept`] with every option: a relay client, gossip, or both. A session that gossips sends its own signed advert right after its handshake, verifies and keeps the adverts it receives in a directory ([`Session::directory`]), and sends a fresh advert with caller extensions on [`Session::send_gossip_update`]. + /// + /// # Errors + /// + /// As [`Session::accept`], and a [`CoreError::Crypto`] when the first advert could not be built or signed. + pub async fn accept_with( connection: Box, local_domains: impl IntoIterator, registry: HandlerRegistry, - relay: Option) -> Arc>, + options: SessionOptions, ) -> Result<(Session, mpsc::UnboundedReceiver), CoreError> { + let SessionOptions { relay, gossip } = options; let mut connection = connection; let inbound = connection.receive()?; let shared: SharedConnection = Arc::new(AsyncMutex::new(connection)); @@ -502,9 +661,46 @@ impl Session { }; send_frame(&shared, Frame::Handshake(local_handshake.clone())).await?; + let gossip = gossip.map(|config| { + Arc::new(GossipState { + config, + directory: AsyncMutex::new(GossipDirectory::new()), + first_advertised: StdMutex::new(None), + }) + }); + if let Some(gossip) = &gossip { + // The node's own advert follows its handshake, as in the TypeScript, so a hub can route to it. + let advert = gossip + .self_advert(relay.as_ref(), &[]) + .await + .map_err(|error| CoreError::Crypto(error.to_string()))?; + send_frame( + &shared, + Frame::Gossip(wire_mesh_wire::transport::GossipFrame { + peers: vec![advert], + }), + ) + .await?; + } + let pending: PendingMap = Arc::new(StdMutex::new(HashMap::new())); let (events_tx, events_rx) = mpsc::unbounded_channel(); let closed = Arc::new(AtomicBool::new(false)); + let handshake_settled = Arc::new(AtomicBool::new(false)); + + if let Some(gossip) = &gossip { + // A relay-only hub never sends a handshake: that is a state to report, not an error. + let waiting = Arc::clone(&handshake_settled); + let ended = Arc::clone(&closed); + let events = events_tx.clone(); + let timeout = gossip.config.handshake_timeout; + tokio::spawn(async move { + tokio::time::sleep(timeout).await; + if !waiting.load(Ordering::SeqCst) && !ended.load(Ordering::SeqCst) { + let _ = events.send(SessionEvent::HandshakeUnanswered); + } + }); + } let task = tokio::spawn(run_dispatch_loop( inbound, @@ -515,6 +711,8 @@ impl Session { local_handshake, Arc::clone(&closed), relay.clone(), + gossip.clone(), + handshake_settled, )); Ok(( @@ -526,11 +724,52 @@ impl Session { events_tx, closed, relay, + gossip, }, events_rx, )) } + /// The peer directory built from the gossip received so far: the latest verified advert per device, in the order devices were first heard. Empty for a session that does not gossip. + pub async fn directory(&self) -> Vec { + match &self.gossip { + Some(gossip) => gossip.directory.lock().await.entries().to_vec(), + None => Vec::new(), + } + } + + /// Sends a fresh signed advert of this node with `extensions` merged in, the way a gossiped fact (a presence status, a policy) is kept live over a connection's lifetime. Every key is validated first ([`crate::domain::gossip_extensions`]): none may shadow a mandatory field, the topology or the version. + /// + /// # Errors + /// + /// A [`CoreError::Crypto`] naming a refused extension key or an advert that could not be built, a [`CoreError::Transport`] when the session is closed, has no gossip, or the frame could not be sent. + pub async fn send_gossip_update( + &self, + extensions: Vec<(String, CborValue)>, + ) -> Result<(), CoreError> { + if self.closed.load(Ordering::SeqCst) { + return Err(CoreError::Transport("session is closed".to_owned())); + } + let gossip = self + .gossip + .as_ref() + .ok_or_else(|| CoreError::Transport("this session does not gossip".to_owned()))?; + let advert = gossip + .self_advert(self.relay.as_ref(), &extensions) + .await + .map_err(|error| match error { + SelfAdvertError::Extension(refused) => CoreError::Crypto(refused.to_string()), + other => CoreError::Crypto(other.to_string()), + })?; + send_frame( + &self.connection, + Frame::Gossip(wire_mesh_wire::transport::GossipFrame { + peers: vec![advert], + }), + ) + .await + } + /// Sends a manage-request and resolves with the matching /// manage-response's outcome, correlated by request-id. When /// `timeout` is given, elapsing it resolves @@ -1046,3 +1285,7 @@ mod tests { #[cfg(test)] #[path = "session_relay_tests.rs"] mod relay_tests; + +#[cfg(test)] +#[path = "session_gossip_tests.rs"] +mod gossip_tests; diff --git a/rust/crates/wire-mesh-core/src/domain/session_gossip_tests.rs b/rust/crates/wire-mesh-core/src/domain/session_gossip_tests.rs new file mode 100644 index 00000000..8d96edb2 --- /dev/null +++ b/rust/crates/wire-mesh-core/src/domain/session_gossip_tests.rs @@ -0,0 +1,590 @@ +//! Sessions that gossip, over a real TCP loopback pair: the self-advert on connect, the directory built from verified adverts, a gossip update with extensions, the unanswered handshake and the version answer. One test per rule the TypeScript session applies. + +use std::net::SocketAddr; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::Arc; +use std::time::Duration; + +use tokio::sync::mpsc as tokio_mpsc; +use wire_mesh_wire::identity::DeviceId; +use wire_mesh_wire::introspection::TopologyPeers; +use wire_mesh_wire::management::{ManageCommand, ManageOutcome, ManageParams}; +use wire_mesh_wire::tokens::{CapabilityScope, CapabilityVerb}; +use wire_mesh_wire::transport::GossipFrame; +use wire_mesh_wire::value::{CanonicalMap, CborValue}; +use wire_mesh_wire::Frame; + +use super::*; +use crate::adapters::{NodeIdentity, TcpTransport}; +use crate::domain::self_advert::{build_self_advert, compute_topology_peers, TopologyInputs}; +use crate::ports::{OnConnection, Transport}; + +struct Fixed(AtomicU64); + +impl Clock for Fixed { + fn now_unix_ms(&self) -> u64 { + self.0.load(Ordering::SeqCst) + } +} + +async fn tcp_pair() -> (Box, Box) { + let transport = TcpTransport::new(); + let (accepted_tx, mut accepted_rx) = tokio_mpsc::unbounded_channel::>(); + let on_connection: OnConnection = Arc::new(move |connection| { + let _ = accepted_tx.send(connection); + }); + let guard = transport + .listen("127.0.0.1:0", on_connection) + .await + .expect("listen"); + let bound = guard.address().parse::().expect("address"); + let dialled = transport + .connect(&format!("127.0.0.1:{}", bound.port())) + .await + .expect("connect"); + let accepted = accepted_rx.recv().await.expect("accepted"); + // The listener must outlive the connection it handed out. + std::mem::forget(guard); + (dialled, accepted) +} + +fn config(identity: &Arc, seconds: u64, accepted: bool) -> GossipConfig { + GossipConfig { + identity: identity.clone(), + clock: Arc::new(Fixed(AtomicU64::new(seconds * 1_000))), + addresses: Vec::new(), + accepted, + handshake_timeout: Duration::from_millis(300), + } +} + +async fn gossiping( + connection: Box, + identity: &Arc, + seconds: u64, + accepted: bool, +) -> (Session, mpsc::UnboundedReceiver) { + Session::accept_with( + connection, + ["core/management".to_owned()], + HandlerRegistry::new(), + SessionOptions::new().gossiping(config(identity, seconds, accepted)), + ) + .await + .expect("accept") +} + +async fn next_matching( + events: &mut mpsc::UnboundedReceiver, + mut pick: impl FnMut(SessionEvent) -> Option, +) -> T { + tokio::time::timeout(Duration::from_secs(10), async { + loop { + let event = events.recv().await.expect("the session ended"); + if let Some(found) = pick(event) { + return found; + } + } + }) + .await + .expect("the event did not arrive in time") +} + +/// A clock reading well after the earliest time a self-advert accepts. +const NOW: u64 = 1_700_000_000; + +fn scope() -> CapabilityScope { + CapabilityScope { + kind: "folder".to_owned(), + path: None, + } +} + +#[tokio::test] +async fn each_side_sends_its_own_advert_on_connect_and_learns_the_others() { + let (a_conn, b_conn) = tcp_pair().await; + let (a_id, b_id) = ( + Arc::new(NodeIdentity::generate_ed25519()), + Arc::new(NodeIdentity::generate_ed25519()), + ); + let (a, mut a_events) = gossiping(a_conn, &a_id, NOW, false).await; + let (b, mut b_events) = gossiping(b_conn, &b_id, NOW, true).await; + let seen_by_a = next_matching(&mut a_events, |event| match event { + SessionEvent::DirectoryChanged { device } => Some(device), + _ => None, + }) + .await; + let seen_by_b = next_matching(&mut b_events, |event| match event { + SessionEvent::DirectoryChanged { device } => Some(device), + _ => None, + }) + .await; + assert_eq!(seen_by_a, *b_id.device_id()); + assert_eq!(seen_by_b, *a_id.device_id()); + let directory = a.directory().await; + assert_eq!(directory.len(), 1); + assert_eq!(directory[0].device, *b_id.device_id()); + // The advert carries this crate's version and a topology. + assert_eq!( + directory[0] + .advert + .extra + .get(&"wire-mesh/version".to_owned()), + Some(&CborValue::Text(OWN_VERSION.to_owned())) + ); + assert_eq!(b.directory().await[0].device, *a_id.device_id()); +} + +#[tokio::test] +async fn a_gossip_update_carries_its_extensions_and_a_refused_key_is_an_error_and_sends_nothing() { + let (a_conn, b_conn) = tcp_pair().await; + let (a_id, b_id) = ( + Arc::new(NodeIdentity::generate_ed25519()), + Arc::new(NodeIdentity::generate_ed25519()), + ); + let (a, _a_events) = gossiping(a_conn, &a_id, NOW, false).await; + let (b, mut b_events) = gossiping(b_conn, &b_id, NOW, true).await; + next_matching(&mut b_events, |event| match event { + SessionEvent::DirectoryChanged { .. } => Some(()), + _ => None, + }) + .await; + // Not domain-qualified: refused, and nothing is sent. + assert!(a + .send_gossip_update(vec![( + "status".to_owned(), + CborValue::Text("busy".to_owned()) + )]) + .await + .is_err()); + assert!(a + .send_gossip_update(vec![("topology/peers".to_owned(), CborValue::Null)]) + .await + .is_err()); + // A later snapshot time and an extension: the directory entry is replaced in place. + a.send_gossip_update(vec![( + "presence/status".to_owned(), + CborValue::Text("busy".to_owned()), + )]) + .await + .expect("sent"); + let advert = tokio::time::timeout(Duration::from_secs(10), async { + loop { + let entry = b.directory().await.into_iter().next(); + if let Some(entry) = entry { + if entry + .advert + .extra + .get(&"presence/status".to_owned()) + .is_some() + { + return entry.advert; + } + } + tokio::time::sleep(Duration::from_millis(10)).await; + } + }) + .await + .expect("the update arrived"); + assert_eq!( + advert.extra.get(&"presence/status".to_owned()), + Some(&CborValue::Text("busy".to_owned())) + ); +} + +#[tokio::test] +async fn an_advert_that_does_not_verify_is_refused_and_the_rest_of_its_frame_is_admitted() { + let (a_conn, raw) = tcp_pair().await; + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let (a, mut a_events) = gossiping(a_conn, &a_id, NOW, false).await; + let (good_id, bad_id) = ( + NodeIdentity::generate_ed25519(), + NodeIdentity::generate_ed25519(), + ); + let topology = compute_topology_peers(&TopologyInputs::default()); + let good = build_self_advert(&good_id, &[], NOW, &[], &topology) + .await + .expect("advert"); + let mut bad = build_self_advert(&bad_id, &[], NOW, &[], &topology) + .await + .expect("advert"); + bad.signature[0] ^= 0xff; + raw.send(Frame::Gossip(GossipFrame { + peers: vec![bad.clone(), good.clone()], + })) + .await + .expect("sent"); + let admitted = next_matching(&mut a_events, |event| match event { + SessionEvent::DirectoryChanged { device } => Some(device), + _ => None, + }) + .await; + assert_eq!(admitted, *good_id.device_id()); + let refused = next_matching(&mut a_events, |event| match event { + SessionEvent::AdvertsRefused { + first, + reason, + count, + } => Some((first, reason, count)), + _ => None, + }) + .await; + assert_eq!(refused, (*bad_id.device_id(), "bad_signature", 1)); + let directory = a.directory().await; + assert_eq!(directory.len(), 1); + assert_eq!(directory[0].device, *good_id.device_id()); +} + +#[tokio::test] +async fn a_frame_of_thousands_of_forged_adverts_gives_a_bounded_number_of_events() { + const FORGED: usize = 5_000; + let (a_conn, raw) = tcp_pair().await; + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let (a, mut a_events) = gossiping(a_conn, &a_id, NOW, false).await; + let signer = NodeIdentity::generate_ed25519(); + let topology = compute_topology_peers(&TopologyInputs::default()); + let mut forged = build_self_advert(&signer, &[], NOW, &[], &topology) + .await + .expect("advert"); + forged.signature[0] ^= 0xff; + let good_id = NodeIdentity::generate_ed25519(); + let good = build_self_advert(&good_id, &[], NOW, &[], &topology) + .await + .expect("advert"); + let mut peers = vec![forged; FORGED]; + peers.push(good); + raw.send(Frame::Gossip(GossipFrame { peers })) + .await + .expect("sent"); + next_matching(&mut a_events, |event| match event { + SessionEvent::DirectoryChanged { device } if device == *good_id.device_id() => Some(()), + _ => None, + }) + .await; + tokio::time::sleep(Duration::from_millis(300)).await; + let mut refusals = Vec::new(); + while let Ok(event) = a_events.try_recv() { + if let SessionEvent::AdvertsRefused { count, .. } = event { + refusals.push(count); + } + } + // The refusals arrived as one event for the frame, counting every forged advert, and the genuine advert of the same frame was applied. + assert_eq!(refusals, vec![FORGED]); + assert_eq!(a.directory().await.len(), 1); +} + +#[tokio::test] +async fn a_peer_that_never_sends_a_handshake_is_reported_once_and_the_session_carries_on() { + let (a_conn, _silent) = tcp_pair().await; + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let (a, mut a_events) = gossiping(a_conn, &a_id, NOW, false).await; + next_matching(&mut a_events, |event| match event { + SessionEvent::HandshakeUnanswered => Some(()), + _ => None, + }) + .await; + assert!(a.directory().await.is_empty()); +} + +#[tokio::test] +async fn a_peer_that_answers_its_handshake_is_not_reported_unanswered() { + let (a_conn, b_conn) = tcp_pair().await; + let (a_id, b_id) = ( + Arc::new(NodeIdentity::generate_ed25519()), + Arc::new(NodeIdentity::generate_ed25519()), + ); + let (_a, mut a_events) = gossiping(a_conn, &a_id, NOW, false).await; + let (_b, _b_events) = gossiping(b_conn, &b_id, NOW, true).await; + // Past the handshake timeout, no unanswered event has arrived among the ones that did. + tokio::time::sleep(Duration::from_millis(600)).await; + let mut kinds = Vec::new(); + while let Ok(event) = a_events.try_recv() { + kinds.push(event); + } + assert!(kinds + .iter() + .any(|event| matches!(event, SessionEvent::HandshakeNegotiated { .. }))); + assert!(!kinds + .iter() + .any(|event| matches!(event, SessionEvent::HandshakeUnanswered))); +} + +#[tokio::test] +async fn version_get_is_answered_by_every_session_with_this_crates_version() { + let (a_conn, b_conn) = tcp_pair().await; + // Neither side registers anything: the version is answered without a handler. + let (a, _a_events) = Session::accept( + a_conn, + ["core/management".to_owned()], + HandlerRegistry::new(), + ) + .await + .expect("accept"); + let (_b, _b_events) = Session::accept( + b_conn, + ["core/management".to_owned()], + HandlerRegistry::new(), + ) + .await + .expect("accept"); + let mut params = CanonicalMap::new(); + params + .insert("verb".to_owned(), CborValue::Text("version.get".to_owned())) + .expect("unique"); + let outcome = a + .send_manage_request( + ManageCommand { + verb: CapabilityVerb("core:version".to_owned()), + params: ManageParams::Json(params), + }, + scope(), + None, + Some(Duration::from_secs(5)), + ) + .await + .expect("an outcome"); + let ManageOutcome::Ok(ok) = outcome else { + panic!("not answered: {outcome:?}"); + }; + assert_eq!( + ok.extra.get(&"version".to_owned()), + Some(&CborValue::Text(OWN_VERSION.to_owned())) + ); +} + +#[tokio::test] +async fn a_session_that_does_not_gossip_ignores_gossip_and_cannot_send_it() { + let (a_conn, raw) = tcp_pair().await; + let (a, mut a_events) = Session::accept( + a_conn, + ["core/management".to_owned()], + HandlerRegistry::new(), + ) + .await + .expect("accept"); + let identity = NodeIdentity::generate_ed25519(); + let advert = build_self_advert( + &identity, + &[], + NOW, + &[], + &compute_topology_peers(&TopologyInputs::default()), + ) + .await + .expect("advert"); + raw.send(Frame::Gossip(GossipFrame { + peers: vec![advert], + })) + .await + .expect("sent"); + tokio::time::sleep(Duration::from_millis(200)).await; + assert!(a.directory().await.is_empty()); + while let Ok(event) = a_events.try_recv() { + assert!(!matches!(event, SessionEvent::DirectoryChanged { .. })); + } + assert!(a.send_gossip_update(Vec::new()).await.is_err()); +} + +/// The topology of the advert last sent over `session`, read back by the peer that received it. +async fn topology_heard_from( + sender: &Session, + receiver: &Session, + receiver_events: &mut mpsc::UnboundedReceiver, + sender_device: DeviceId, +) -> TopologyPeers { + sender + .send_gossip_update(vec![( + "presence/status".to_owned(), + CborValue::Text("marker".to_owned()), + )]) + .await + .expect("sent"); + loop { + next_matching(receiver_events, |event| match event { + SessionEvent::DirectoryChanged { device } => Some(device), + _ => None, + }) + .await; + let entry = receiver + .directory() + .await + .into_iter() + .find(|entry| entry.device == sender_device) + .expect("the sender is in the directory"); + if entry + .advert + .extra + .get(&"presence/status".to_owned()) + .is_some() + { + return crate::domain::topology::read_topology_peers(&entry.advert) + .expect("a topology"); + } + } +} + +#[tokio::test] +async fn the_first_advertised_peer_is_the_direct_peer_only_on_an_accepted_connection() { + let (dialled, accepted) = tcp_pair().await; + let (d_id, a_id) = ( + Arc::new(NodeIdentity::generate_ed25519()), + Arc::new(NodeIdentity::generate_ed25519()), + ); + let (dial_side, mut dial_events) = gossiping(dialled, &d_id, NOW, false).await; + let (accept_side, mut accept_events) = gossiping(accepted, &a_id, NOW, true).await; + // Each has heard the other's first advert before it sends an update. + next_matching(&mut dial_events, |event| match event { + SessionEvent::DirectoryChanged { .. } => Some(()), + _ => None, + }) + .await; + next_matching(&mut accept_events, |event| match event { + SessionEvent::DirectoryChanged { .. } => Some(()), + _ => None, + }) + .await; + // The accepted side names the dialler directly; the dialling side, which cannot know whether the first advert came from the far end or was forwarded, names nobody. + let from_accepted = topology_heard_from( + &accept_side, + &dial_side, + &mut dial_events, + *a_id.device_id(), + ) + .await; + assert_eq!(from_accepted.direct, vec![*d_id.device_id()]); + let from_dialler = topology_heard_from( + &dial_side, + &accept_side, + &mut accept_events, + *d_id.device_id(), + ) + .await; + assert!(from_dialler.direct.is_empty()); +} + +#[tokio::test] +async fn the_first_advertised_peer_stays_the_direct_peer_when_a_later_device_is_heard() { + let (a_conn, mut raw) = tcp_pair().await; + let mut raw_frames = raw.receive().expect("receive"); + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let (a, mut a_events) = gossiping(a_conn, &a_id, NOW, true).await; + let (first, second) = ( + NodeIdentity::generate_ed25519(), + NodeIdentity::generate_ed25519(), + ); + let topology = compute_topology_peers(&TopologyInputs::default()); + for identity in [&first, &second] { + let advert = build_self_advert(identity, &[], NOW, &[], &topology) + .await + .expect("advert"); + raw.send(Frame::Gossip(GossipFrame { + peers: vec![advert], + })) + .await + .expect("sent"); + next_matching(&mut a_events, |event| match event { + SessionEvent::DirectoryChanged { device } if device == *identity.device_id() => { + Some(()) + } + _ => None, + }) + .await; + } + a.send_gossip_update(Vec::new()).await.expect("sent"); + // The update is the second gossip frame this session sent, after its own advert on connect. + let mut gossips = 0; + let sent = loop { + let frame = tokio::time::timeout(Duration::from_secs(10), next_frame(&mut raw_frames)) + .await + .expect("a frame") + .expect("open"); + if let Frame::Gossip(gossip) = frame { + gossips += 1; + if gossips == 2 { + break gossip.peers.into_iter().next().expect("an advert"); + } + } + }; + let topology = crate::domain::topology::read_topology_peers(&sent).expect("a topology"); + assert_eq!(topology.direct, vec![*first.device_id()]); +} + +#[tokio::test] +async fn a_self_advert_names_every_device_the_connection_is_paired_with() { + use crate::domain::relay_channels::{RelayChannels, RelayOptions}; + use crate::domain::relay_client::{HubLink, RelayClient}; + use wire_mesh_wire::transport::RelayInboundFrame; + + let (a_conn, mut raw) = tcp_pair().await; + let mut raw_frames = raw.receive().expect("receive"); + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let signer = Arc::clone(&a_id); + let (a, _events) = Session::accept_with( + a_conn, + ["core/management".to_owned()], + HandlerRegistry::new(), + SessionOptions::new() + .relayed(move |link: Arc| { + let channels = Arc::new(RelayChannels::new( + signer, + RelayClient::hello_sender(Arc::clone(&link)), + Arc::new(crate::adapters::MonotonicClock::new()), + RelayOptions::default(), + )); + Arc::new(RelayClient::new(link, channels)) + }) + .gossiping(config(&a_id, NOW, false)), + ) + .await + .expect("accept"); + let far = NodeIdentity::generate_ed25519(); + raw.send(Frame::RelayInbound(RelayInboundFrame { + source_device: *far.device_id(), + target_device: None, + })) + .await + .expect("sent"); + // The pairing is recorded when the dispatch loop reads the frame; a gossip update sent after it is built from the pairings then held. + let sent = tokio::time::timeout(Duration::from_secs(10), async { + loop { + a.send_gossip_update(Vec::new()).await.expect("sent"); + // Drain what has arrived; the last advert is the newest. + let mut newest = None; + while let Ok(Some(frame)) = + tokio::time::timeout(Duration::from_millis(100), next_frame(&mut raw_frames)).await + { + if let Frame::Gossip(gossip) = frame { + newest = gossip.peers.into_iter().next(); + } + } + if let Some(advert) = newest { + let topology = + crate::domain::topology::read_topology_peers(&advert).expect("topology"); + if !topology.relayed.is_empty() { + return topology; + } + } + } + }) + .await + .expect("the pairing reached an advert"); + assert_eq!(sent.relayed.len(), 1); + assert_eq!(sent.relayed[0].device, *far.device_id()); +} + +#[tokio::test] +async fn a_session_whose_clock_is_not_a_wall_clock_is_refused_at_accept() { + let (a_conn, _peer) = tcp_pair().await; + let a_id = Arc::new(NodeIdentity::generate_ed25519()); + let mut gossip = config(&a_id, NOW, false); + // A monotonic clock reads the seconds since the process started. + gossip.clock = Arc::new(Fixed(AtomicU64::new(3_000))); + let result = Session::accept_with( + a_conn, + ["core/management".to_owned()], + HandlerRegistry::new(), + SessionOptions::new().gossiping(gossip), + ) + .await; + assert!(result.is_err()); +} diff --git a/ts/packages/core/test/conformance-gossip-directory.unit.test.ts b/ts/packages/core/test/conformance-gossip-directory.unit.test.ts new file mode 100644 index 00000000..66ce93e2 --- /dev/null +++ b/ts/packages/core/test/conformance-gossip-directory.unit.test.ts @@ -0,0 +1,278 @@ +/* Checks every case of conformance/gossip-directory.v1.json against the real session and the real extension validation: + + - each key bag is accepted, or refused with the reason the file names for the first key refused; + - each scenario delivers its gossip frames to a connected session in order and compares the directory it holds after each frame, as the devices and snapshot times in first-heard order (a scenario marked `rust_only` pins a bound only the Rust session applies and is skipped); + - each self-advert case builds the session's own advert under the file's identity and clock and compares its device, addresses, snapshot time, the keys of its open tail and its topology, then verifies its signature; + - every list holds the number of entries the file's header says. + + Not compared, because they only name: every `name`, and the layout version (checked to be the one this test reads). The TypeScript session reports no outcome per advert, so the outcomes the file records are checked by the Rust runner only. The version an advert reports is this package's own and is compared with it, not with the file. */ + +import { readFileSync } from "node:fs"; +import { webcrypto } from "node:crypto"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; +import { z } from "zod"; +import { cdeDecodeOptions, decode } from "cbor2"; +import { createNodeIdentity } from "../src/adapters/node-identity.js"; +import { bytesToHex } from "../src/domain/device-id.js"; +import { validateGossipExtensions } from "../src/domain/gossip-extensions.js"; +import { createMeshSession } from "../src/domain/mesh-session.js"; +import { readTopologyPeers } from "../src/domain/topology.js"; +import { frameSchema, type Frame } from "../src/generated/protocol.js"; +import { eachInOrder } from "../src/domain/sequential.js"; +import { bytesFromHex } from "./hex.js"; +import { repeatInSequence } from "./sequence.js"; +import { + fakeTransport, + MS_PER_SECOND, + OWN_VERSION, + testClock, +} from "./mesh-session-fixtures.js"; +import { verifyPeerAdvert } from "../src/domain/peer-advert.js"; + +const LAYOUT_VERSION = 1; +const EDDSA = -8; +const PKCS8_ED25519_PREFIX = "302e020100300506032b657004220420"; +const EVENTS_THROUGH_CONNECT = 3; +const hexString = z.string().regex(/^(?:[0-9a-f]{2})*$/); + +const file = z + .object({ + vectors: z.array(z.looseObject({ name: z.string(), wire_hex: hexString })), + gossip_directory: z.strictObject({ + layout_version: z.literal(LAYOUT_VERSION), + identities: z.array( + z.strictObject({ + name: z.string(), + secret_hex: hexString, + public_key_hex: hexString, + device_id_hex: hexString, + }), + ), + extension_validation: z.array( + z.strictObject({ + name: z.string(), + keys: z.array(z.string()), + refused: z + .strictObject({ key: z.string(), reason: z.string() }) + .nullable(), + }), + ), + directory_scenarios: z.array( + z.strictObject({ + name: z.string(), + rust_only: z.boolean(), + steps: z.array( + z.strictObject({ + vector: z.string(), + outcomes: z.array(z.string()), + directory: z.array( + z.strictObject({ + device: hexString, + snapshot_seconds: z.number().int(), + }), + ), + }), + ), + }), + ), + self_adverts: z.array( + z.strictObject({ + name: z.string(), + identity: z.string(), + extensions: z.record(z.string(), z.string()), + now_seconds: z.number().int(), + expected: z.strictObject({ + device_hex: hexString, + addresses: z.array(z.string()), + snapshot_seconds: z.number().int(), + extension_keys: z.array(z.string()), + topology: z.strictObject({ + direct: z.array(z.string()), + relayed: z.array(z.string()), + }), + }), + }), + ), + counts: z.strictObject({ + extension_validation: z.number().int(), + directory_scenarios: z.number().int(), + self_adverts: z.number().int(), + }), + }), + }) + .parse( + JSON.parse( + readFileSync( + fileURLToPath( + new URL( + "../../../../conformance/gossip-directory.v1.json", + import.meta.url, + ), + ), + "utf8", + ), + ), + ); +const section = file.gossip_directory; + +function frameOf(vector: string): Frame { + const held = file.vectors.find((candidate) => candidate.name === vector); + if (held === undefined) { + throw new Error(`no vector ${vector}`); + } + + return frameSchema.parse( + decode(bytesFromHex(held.wire_hex), cdeDecodeOptions), + ); +} + +async function identityNamed(name: string) { + const held = section.identities.find((candidate) => candidate.name === name); + if (held === undefined) { + throw new Error(`no identity ${name}`); + } + const privateKey = await webcrypto.subtle.importKey( + "pkcs8", + bytesFromHex(PKCS8_ED25519_PREFIX + held.secret_hex), + { name: "Ed25519" }, + false, + ["sign"], + ); + + return createNodeIdentity( + privateKey, + bytesFromHex(held.public_key_hex), + EDDSA, + ); +} + +describe("the gossip-directory vectors", () => { + it("hold the number of entries their header says", () => { + expect(section.extension_validation.length).toBe( + section.counts.extension_validation, + ); + expect(section.directory_scenarios.length).toBe( + section.counts.directory_scenarios, + ); + expect(section.self_adverts.length).toBe(section.counts.self_adverts); + }); + + it("have identities whose secrets give the public keys and device ids the file names", async () => { + await eachInOrder(section.identities, async (held) => { + const identity = await identityNamed(held.name); + expect(bytesToHex(identity.identityKey["public-key"])).toBe( + held.public_key_hex, + ); + expect(bytesToHex(identity.deviceId)).toBe(held.device_id_hex); + }); + }); + + describe("extension validation", () => { + for (const held of section.extension_validation) { + it(held.name, () => { + const bag: Record = {}; + for (const key of held.keys) { + bag[key] = null; + } + if (held.refused === null) { + expect(() => { + validateGossipExtensions(bag); + }).not.toThrow(); + + return; + } + const pattern = { + reserved_field: /collides with a mandatory peer-advert field/, + session_managed: /collides with a session-managed gossip field/, + reserved_version: /reserved for wire-mesh-core's own/, + not_domain_qualified: /must be domain-qualified/, + }[held.refused.reason]; + expect(pattern).toBeDefined(); + expect(() => { + validateGossipExtensions(bag); + }).toThrow(`"${held.refused.key}"`); + expect(() => { + validateGossipExtensions(bag); + }).toThrow(pattern); + }); + } + }); + + describe("directory scenarios", () => { + for (const scenario of section.directory_scenarios) { + it.skipIf(scenario.rust_only)(scenario.name, async () => { + const me = await identityNamed("me"); + const { transport, connection } = fakeTransport(); + const session = createMeshSession(transport, me, testClock); + await session.connect("ws://node", ["core/data"]); + const events = session.events[Symbol.asyncIterator](); + await repeatInSequence(EVENTS_THROUGH_CONNECT, async () => { + await events.next(); + }); + await eachInOrder(scenario.steps, async (step) => { + connection.push(frameOf(step.vector)); + const event = (await events.next()).value as { + directory: { + device: Uint8Array; + advert: Record; + }[]; + }; + expect( + event.directory.map((entry) => ({ + device: bytesToHex(entry.device), + snapshot_seconds: entry.advert["snapshot-seconds"], + })), + ).toEqual(step.directory); + }); + await session.close(); + }); + } + }); + + describe("self adverts", () => { + for (const held of section.self_adverts) { + it(held.name, async () => { + const identity = await identityNamed(held.identity); + const { transport, connection } = fakeTransport(); + const session = createMeshSession(transport, identity, { + now: () => held.now_seconds * MS_PER_SECOND, + }); + await session.connect("ws://node", ["core/data"]); + if (Object.keys(held.extensions).length > 0) { + await session.sendGossipUpdate(held.extensions); + } + const sent = connection.sent.at(-1); + if (sent?.type !== "gossip") { + throw new Error("the session sent no gossip"); + } + const advert = sent.peers[0]; + if (advert === undefined) { + throw new Error("the gossip held no advert"); + } + const mandatory = [ + "device", + "addresses", + "snapshot-seconds", + "identity-key", + "signature", + ]; + expect(bytesToHex(advert.device)).toBe(held.expected.device_hex); + expect(advert.addresses).toEqual(held.expected.addresses); + expect(advert["snapshot-seconds"]).toBe(held.expected.snapshot_seconds); + expect( + Object.keys(advert) + .filter((key) => !mandatory.includes(key)) + .sort(), + ).toEqual(held.expected.extension_keys); + expect(advert["wire-mesh/version"]).toBe(OWN_VERSION); + expect(readTopologyPeers(advert)).toEqual({ + direct: held.expected.topology.direct, + relayed: held.expected.topology.relayed, + }); + expect(await verifyPeerAdvert(identity, advert)).toBe(true); + await session.close(); + }); + } + }); +}); diff --git a/ts/packages/core/test/conformance.unit.test.ts b/ts/packages/core/test/conformance.unit.test.ts index ce2d0d6c..488bcff0 100644 --- a/ts/packages/core/test/conformance.unit.test.ts +++ b/ts/packages/core/test/conformance.unit.test.ts @@ -94,6 +94,7 @@ const CHECKED_HERE = [ ]; const CHECKED_ELSEWHERE: Readonly> = { "introspection.v1.json": "conformance-introspection.unit.test.ts", + "gossip-directory.v1.json": "conformance-gossip-directory.unit.test.ts", "room-params.v1.json": "conformance-room-params.unit.test.ts", "file-storage.v1.json": "conformance-file-storage.unit.test.ts", "data-sync.v1.json": "conformance-data-sync.unit.test.ts", diff --git a/ts/packages/core/test/relay-interop.integration.test.ts b/ts/packages/core/test/relay-interop.integration.test.ts index ec6b1891..71e53711 100644 --- a/ts/packages/core/test/relay-interop.integration.test.ts +++ b/ts/packages/core/test/relay-interop.integration.test.ts @@ -19,7 +19,7 @@ import { import { createTcpTransport } from "../src/adapters/tcp-transport.js"; import { deviceIdToHex } from "../src/domain/device-id.js"; import { createMeshSession } from "../src/domain/mesh-session.js"; -import { signPeerAdvert } from "../src/domain/peer-advert.js"; +import { signPeerAdvert, verifyPeerAdvert } from "../src/domain/peer-advert.js"; import { createRelayHub } from "../src/domain/relay-hub.js"; import { beginHandshake, @@ -39,6 +39,10 @@ import { generateEd25519Identity } from "./tokens-fixtures.js"; const RUST_DIR = fileURLToPath(new URL("../../../../rust", import.meta.url)); const BUILD_TIMEOUT_MS = 900_000; +const BYTES_PER_KIB = 1024; +const BUILD_OUTPUT_LIMIT_MIB = 64; +const BUILD_OUTPUT_LIMIT_BYTES = + BUILD_OUTPUT_LIMIT_MIB * BYTES_PER_KIB * BYTES_PER_KIB; const CASE_TIMEOUT_MS = 60_000; const POLL_MS = 20; const SETTLE_MS = 400; @@ -111,6 +115,9 @@ async function startHub(options: HubOptions = {}): Promise<{ /** Where the built example is, set once by the build before any case runs: the cases start this binary directly, so stopping a case stops the example itself and a case does not pay for cargo. */ let exampleBinary = ""; +/** The most recently started hub address and Rust node, for the one test that checks a failed start-up leaves nothing behind. */ +let lastStarted: { pid: number | undefined; address: string } | undefined; + /** The Rust example, started and read line by line. */ class RustPeer { private readonly child: ChildProcess; @@ -121,6 +128,7 @@ class RustPeer { this.child = spawn(exampleBinary, [...args], { stdio: ["pipe", "pipe", "inherit"], }); + lastStarted = { pid: this.child.pid, address: args[0] ?? "" }; if (this.child.stdout === null) { throw new Error("the Rust peer has no standard output"); } @@ -153,6 +161,10 @@ class RustPeer { return bytesFromHex(await this.line("DEVICE ")); } + get pid(): number | undefined { + return this.child.pid; + } + stop(): void { this.child.stdin?.end(); this.child.kill(); @@ -372,7 +384,13 @@ describeRust("the Rust relay client against the TypeScript hub", () => { "relay_peer", "--message-format=json-render-diagnostics", ], - { cwd: RUST_DIR, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] }, + { + cwd: RUST_DIR, + encoding: "utf8", + // The build prints one JSON line per artefact; the default limit (1 MiB) is easily passed by a workspace this size, and the call fails when it is. + maxBuffer: BUILD_OUTPUT_LIMIT_BYTES, + stdio: ["ignore", "pipe", "inherit"], + }, ); if (built.status !== 0) { throw new Error("the relay_peer example did not build"); @@ -446,6 +464,42 @@ describeRust("the Rust relay client against the TypeScript hub", () => { CASE_TIMEOUT_MS, ); + it( + "learns a TypeScript peer from the hub's gossip and is learnt in turn, its advert verifying and naming its version", + async () => { + const hub = await startHub(); + const far = await answeringSession(hub); + const rust = new RustPeer([hub.address, "gossip"]); + try { + expect(await rust.line("DIRECTORY ")).toBe(deviceIdToHex(far.device)); + const rustDevice = deviceIdToHex(await rust.device()); + const sent = await vi.waitFor( + () => { + const advert = hub.observed.frames + .flatMap((entry) => + entry.frame.type === "gossip" ? entry.frame.peers : [], + ) + .find((peer) => deviceIdToHex(peer.device) === rustDevice); + if (advert === undefined) { + throw new Error("the hub has not seen the Rust node's advert"); + } + + return advert; + }, + { interval: POLL_MS, timeout: CASE_TIMEOUT_MS }, + ); + const verifier = await generateEd25519Identity(); + expect(await verifyPeerAdvert(verifier, sent)).toBe(true); + expect(typeof sent["wire-mesh/version"]).toBe("string"); + } finally { + rust.stop(); + await far.close(); + await hub.close(); + } + }, + CASE_TIMEOUT_MS, + ); + it( "gets nothing through a hub that alters the sealed data it carries", async () => { @@ -540,7 +594,10 @@ describeRust("the Rust relay client against the TypeScript hub", () => { ); describe("a Rust node serving requests", () => { - async function serving(): Promise<{ + /** Starts the hub, the Rust node serving and a raw peer. A failure at any step stops what was started and closes the hub before it is rethrown, so a case that fails to start leaves no process behind. `afterRust` runs once the Rust node has announced, so a test can force a failure there. */ + async function serving( + afterRust: () => Promise = async () => Promise.resolve(), + ): Promise<{ hub: Awaited>; rust: RustPeer; peer: RawPeer; @@ -548,15 +605,61 @@ describeRust("the Rust relay client against the TypeScript hub", () => { }> { const hub = await startHub(); const rust = new RustPeer([hub.address, "serve"]); - const rustDevice = await rust.device(); - await rust.line("ANNOUNCED"); - await announcedAt(hub, 1); - const peer = await RawPeer.join(hub.address); - await announcedAt(hub, 2); - - return { hub, rust, peer, rustDevice }; + let peer: RawPeer | undefined; + try { + const rustDevice = await rust.device(); + await rust.line("ANNOUNCED"); + await announcedAt(hub, 1); + await afterRust(); + peer = await RawPeer.join(hub.address); + await announcedAt(hub, 2); + + return { hub, rust, peer, rustDevice }; + } catch (error) { + rust.stop(); + await peer?.close(); + await hub.close(); + throw error; + } } + it( + "leaves no process and no listener behind when a case fails to start", + async () => { + let started: { pid: number | undefined; address: string } | undefined; + await expect( + serving(async () => { + // The hub and the Rust node are up by now: this is the failure. + started = { + pid: lastStarted?.pid, + address: lastStarted?.address ?? "", + }; + + return Promise.reject(new Error("the start-up failed")); + }), + ).rejects.toThrow("the start-up failed"); + const info = started; + expect(info?.pid).toBeDefined(); + await vi.waitFor( + () => { + const pid = info?.pid; + if (pid === undefined) throw new Error("no pid was recorded"); + try { + process.kill(pid, 0); + } catch { + return; + } + throw new Error("the Rust node is still running"); + }, + { interval: POLL_MS, timeout: CASE_TIMEOUT_MS }, + ); + await expect( + createTcpTransport().connect(info?.address ?? ""), + ).rejects.toBeDefined(); + }, + CASE_TIMEOUT_MS, + ); + it( "drops a manage-request sent in the clear inside relay-data, and answers the same request sealed", async () => {