From b95ba948a6e5ac04a75cd4d28ee3ac966dcc72bb Mon Sep 17 00:00:00 2001 From: tv Date: Thu, 19 Nov 2026 17:48:47 +0000 Subject: scripts/wire-check: a swarm of the last release and this tree Four nodes on this host over libp2p on loopback, two of a release tag's build and two of this tree's, in turns, each seeded with the one before. Where the two builds' wire versions meet, each node writes, and the check is that every node reads what each wrote and that none logs a peer of another wire version. Where they don't, that the tag's nodes log this tree's as such, so their operators know to upgrade. scripts/release runs it against the last release, after saying from the two builds' --version how the release upgrades: so a release that says it rolls out node by node has been seen to. docs/development.md says how a change to the wire format is made: a new version beside the ones spoken already, the older kept frozen. --- CHANGELOG.md | 5 ++ docs/development.md | 18 ++++++- scripts/release | 7 ++- scripts/wire-check | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+), 3 deletions(-) create mode 100755 scripts/wire-check diff --git a/CHANGELOG.md b/CHANGELOG.md index 7754a3d..76bc09a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ it from the release before ([`docs/operations.md`](docs/operations.md), ## Unreleased +* `scripts/wire-check` runs a swarm of the last release's nodes and this tree's on one + host, and checks they talk where their wire versions meet, and say so where they + don't; `scripts/release` runs it ([`docs/development.md`](docs/development.md), + [Releasing](docs/development.md#releasing); [`scripts/wire-check`](scripts/wire-check)). + * A node speaks several wire versions side by side and writes each peer the newest both speak, as the peer's SPEAKS says; SPEAKS goes ahead of each WHO and ME now, and WHO and ME read alike in every version. So a release adding a wire version and keeping diff --git a/docs/development.md b/docs/development.md index 39eabdf..f921d22 100644 --- a/docs/development.md +++ b/docs/development.md @@ -123,7 +123,8 @@ and compares what the two say they are (`continuum --version`): * **wire versions**: where they share one, the release rolls out node by node; where they don't, every node upgrades together, which from 1.0.0 on only a major release - may ask; + may ask. `scripts/wire-check` checks it, by a swarm of the last release's nodes and + this tree's (below); * **Automerge**: where it differs, nobody remakes until every node runs the release; * **the federation's revisions**: a release knowing a later one than the last is tagged `federation-.` too, so that later releases are checked against it. @@ -131,3 +132,18 @@ and compares what the two say they are (`continuum --version`): What it finds heads the release's notes in the change log and its tag's message, with what the build speaks and knows, and the notes. Before 1.0.0 every upgrade may still be taken as a flag day, but the notes say when it isn't. + +`scripts/wire-check [TAG]` (the last release unless given) runs four nodes on this host, +over libp2p on loopback: two of the tag's build and two of this tree's, in turns. Where +their wire versions meet, each writes, and it checks that every node reads what each +wrote and that none logs a peer of another wire version; where they don't, that the +tag's nodes log this tree's as such, so their operators know to upgrade. + +```sh +scripts/wire-check v0.0.1 +``` + +A change to the wire format is a new version (`wire::VERSION`) beside the ones the build +speaks already: the messages of the version before keep their types, frozen, and are +encoded and decoded in `transport/wire.rs` beside the newest's, and `golden_bytes` keeps +the bytes of each. A later release raises `wire::OLDEST` to leave the oldest out. diff --git a/scripts/release b/scripts/release index 296766e..62a896a 100755 --- a/scripts/release +++ b/scripts/release @@ -12,8 +12,9 @@ # example too; then `cargo quick`, `cargo sim` and scripts/federation-check pass. # 3. This build's `continuum --version` and the last release's (built in # CONTINUUM_RELEASE_TARGET, ~/.cache/continuum/release unless set) say how one upgrades: -# node by node where their wire versions meet and their Automerge is the same, else -# every node together, which takes a major release from 1.0.0 on. +# node by node where their wire versions meet, else every node together, which takes +# a major release from 1.0.0 on; scripts/wire-check runs a swarm of both and checks +# they do as said. # 4. CHANGELOG.md's Unreleased notes become VERSION's, under a line saying so; the # commit `release VERSION` holds it all, tagged vVERSION, its message saying how to # upgrade, what the build speaks and knows, and the notes. A release knowing a later @@ -141,6 +142,8 @@ if [ -n "$last" ]; then die "$why: from 1.0.0 on, that takes a major release, not $version" fi fi + say "scripts/wire-check $last" + scripts/wire-check "$last" >&2 || die "a swarm of $last and this release doesn't do as said" else upgrade="The first release made by this script." automerge_line="" diff --git a/scripts/wire-check b/scripts/wire-check new file mode 100755 index 0000000..f53dafb --- /dev/null +++ b/scripts/wire-check @@ -0,0 +1,151 @@ +#!/bin/sh +# Runs a swarm of continuum as a release tag builds it and as this tree does, on this +# host over libp2p on loopback, and checks how they get on (docs/development.md: +# Releasing). Where their wire versions meet: every node reads what each wrote, and +# none logs a peer of another wire version. Where they don't: the tag's nodes log this +# tree's as of another wire version, so their operators know to upgrade them. +# +# scripts/wire-check [TAG] +# +# TAG is the latest v* tag unless given. The nodes: a of the tag (the swarm's first), b +# of this tree, c of the tag, d of this tree, each seeded with the one before it. +# CONTINUUM_WIRE_CHECK_FEATURES are the features both are built with, libp2p among them +# (federation,libp2p unless given); the tag's build is kept in CONTINUUM_RELEASE_TARGET +# (~/.cache/continuum/release unless given), as scripts/release keeps it. The nodes +# listen from CONTINUUM_WIRE_CHECK_PORT on (47600 unless given), eight ports. + +set -eu + +cd "$(git rev-parse --show-toplevel)" + +tag=${1:-$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-version:refname | head -n 1)} +if [ -z "$tag" ]; then + echo "wire-check: no v* tag to check against" >&2 + exit 2 +fi +features=${CONTINUUM_WIRE_CHECK_FEATURES:-federation,libp2p} +cache=${XDG_CACHE_HOME:-$HOME/.cache} +target=${CONTINUUM_RELEASE_TARGET:-$cache/continuum/release} +port=${CONTINUUM_WIRE_CHECK_PORT:-47600} +say() { echo "wire-check: $*" >&2; } + +work=$(mktemp -d) +pids="" +failed=false +clean() { + for pid in $pids; do + kill "$pid" 2>/dev/null || true + done + wait 2>/dev/null || true + if $failed; then + for log in "$work"/*/log; do + [ -f "$log" ] || continue + say "the last of $(basename "$(dirname "$log")")'s log:" + tail -n 20 "$log" >&2 + done + fi + git worktree remove --force "$work/tagged" >/dev/null 2>&1 || true + rm -rf "$work" +} +trap clean EXIT +trap 'exit 130' INT TERM +fail() { + failed=true + say "$*" + exit 1 +} + +say "building this tree and $tag (features $features)" +cargo build -q --features "$features" --bin continuum +here_dir=${CARGO_TARGET_DIR:-$(pwd)/target} +cp "$here_dir/debug/continuum" "$work/here" +git worktree add -q --detach "$work/tagged" "$tag" +(cd "$work/tagged" && CARGO_TARGET_DIR=$target cargo build -q --features "$features" --bin continuum) +cp "$target/debug/continuum" "$work/there" + +wire() { "$1" --version | sed -n 's/^wire versions \([0-9]*\) to \([0-9]*\)$/\1 \2/p'; } +set -- $(wire "$work/here") +here_oldest=$1 here_newest=$2 +there=$(wire "$work/there") +if [ -z "$there" ]; then + # Before 0.0.1 a build named no wire versions, and spoke none but its own. + fail "$tag doesn't say which wire versions it speaks" +fi +set -- $there +there_oldest=$1 there_newest=$2 +if [ "$here_oldest" -le "$there_newest" ] && [ "$there_oldest" -le "$here_newest" ]; then + meet=true + say "$tag speaks $there_oldest to $there_newest, this tree $here_oldest to $here_newest: they should talk" +else + meet=false + say "$tag speaks $there_oldest to $there_newest, this tree $here_oldest to $here_newest: they should say they don't" +fi + +http() { echo $((port + $1)); } +p2p() { echo $((port + 4 + $1)); } +seed() { echo "libp2p:/ip4/127.0.0.1/tcp/$(p2p "$1")"; } +start() { # NAME NUMBER BINARY [OPTION...] + name=$1 number=$2 binary=$3 + shift 3 + mkdir "$work/$name" + (cd "$work/$name" && exec "$binary" --bind-addr "127.0.0.1:$(http "$number")" \ + --user-header X-User --node-key-file node.key --node-key-create \ + --state-file state.json --libp2p-enable \ + --libp2p-listen "/ip4/127.0.0.1/tcp/$(p2p "$number")" "$@" >log 2>&1) & + pids="$pids $!" +} +api() { # NUMBER PATH [CURL OPTION...] + number=$1 path=$2 + shift 2 + curl -sf -H 'X-User: wire-check' -H 'Accept: text/plain' "$@" \ + "http://127.0.0.1:$(http "$number")$path" +} +# Whether the command $2... succeeds within $1 seconds, tried every second. +within() { + seconds=$1 + shift + while ! "$@" >/dev/null 2>&1; do + seconds=$((seconds - 1)) + [ "$seconds" -gt 0 ] || return 1 + sleep 1 + done +} + +start a 0 "$work/there" --genesis +within 60 api 0 /ready || fail "a ($tag) isn't ready" +start b 1 "$work/here" --seeds "$(seed 0)" +start c 2 "$work/there" --seeds "$(seed 1)" +start d 3 "$work/here" --seeds "$(seed 2)" + +other_version() { grep -l 'another wire version' "$work"/*/log; } + +if ! $meet; then + # The tag's nodes say so. This tree's say so too where the tag's SPEAKS goes ahead of + # its proofs, as from this tree on. + logged() { grep -q 'another wire version' "$work/a/log" "$work/c/log"; } + within 60 logged || fail "$tag's nodes don't say they share no wire version with this tree's" + say "they share no wire version, and say so:" + grep -h 'another wire version' "$work"/*/log | head -n 4 >&2 + exit 0 +fi + +for number in 1 2 3; do + within 120 api "$number" /ready || fail "node $number isn't ready" +done +for number in 0 1 2 3; do + api "$number" "/store/wire-check/$number" -X PUT -H 'Content-Type: text/plain' \ + -d "written on $number" || fail "node $number didn't take a write" +done +reads_all() { + for number in 0 1 2 3; do + for written in 0 1 2 3; do + [ "$(api "$number" "/store/wire-check/$written")" = "written on $written" ] || + return 1 + done + done +} +within 60 reads_all || fail "not every node reads what each wrote" +if other_version >/dev/null; then + fail "a node logs a peer of another wire version: $(other_version | tr '\n' ' ')" +fi +say "$tag and this tree talk: every node reads what each wrote, and none logs another wire version" -- cgit v1.3.1