Repository navigation
test(network-smoke): run scripted and forced prunes end to end, and add compare-chain - #115
Draft
alejoamiras wants to merge 61 commits into
Draft
alejoamiras wants to merge 61 commits into
alejoamiras wants to merge 61 commits into
Conversation
…s its chain `startScriptedNode` serves a fixed script of chain states through the SDK's own JSON-RPC server and `AztecNodeApiSchema`, under both the `aztec` and `node` namespaces, as a real node registers them. It implements what the listeners call; any other method answers "Method not found", as a real node does for an unknown one. A separate control port reads the script and steps it. The script grows blocks 1-10, proves and finalizes 1-6, then prunes 7-10 and grows 7'-12' on 6. Blocks come from the SDK's classes: each header links to its parent's archive and commits to its body. The replacing chain carries a recorded contract deployment again, one height lower than the dead chain did. The unit test walks every state through `createAztecNodeClient`. The Vitest config runs the test harness from source: CI's unit job builds only the shared packages. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…:scripted` `cli.js run scripted` starts the scripted node in place of anvil and the Aztec node, with only `aztec-listener` and `explorer-api`, on the harness's Postgres, Kafka and Redis, with the same per-run isolation and teardown. It installs no toolchain. Before any service starts, it creates the block topic with 3 partitions and checks the count, so blocks sent without a key can reach the API out of order. `src/prune.scripted.ts` steps the node through its script (blocks 1-10, a prune of 7-10, then 7'-12' on 6), waits until two reads of the API six seconds apart agree, and checks through REST only: - heights 1-12 serve the final chain, and nothing exists at 13; - `/l2/reorgs` lists one reorg: height 7, 4 blocks; - the moved tx is not dropped, and its effect and the redeployed contract instance are on 7'; - each dead block is served by its hash, as orphaned. Against the listener and API in this commit, all four fail. The listener rewinds its cursor to the new tip and never fetches 7' (#97). The API orphans by height from 8, so the dead 7 stays canonical, the reorg reads height 8 with 3 blocks, and the tx stays dropped on the orphaned 8 (#98). One run takes about 1 min 40 s. `run` takes the mode, and `missingBuilds`, `prepareDatabases` and `startServices` take the mode's services. `yarn smoke` passes as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `smoke-scripted` job runs `yarn smoke:scripted` under the same `changes` filter, and `network-smoke-status` now needs it and checks its result. It installs neither foundry nor the Aztec toolchain, which the scripted mode never starts, and builds only what it runs. Its logs upload as `network-smoke-scripted` on failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run drew free ports and kept no record of them, so another tool on the same host could take one of them between our check and the service's bind. A run now claims its ports in `~/.agents/ports.md`, the registry other tools on the host read and write under the same lock file, and releases them at teardown and in `down <run>`. - Rows written here carry the `chicmoz-smoke-` service prefix. Every other line is kept byte for byte, and a port that any line lists counts as taken. - A claim drops this package's rows whose owner pid is gone. - The lock is never broken: a claim waits up to 30 s for it, then fails. - A port claimed by someone else between our read and our claim is drawn again, up to 5 times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cenario The scripted scenario judges what the published blocks alone do to the explorer. explorer-api's block reconciliation loop makes its first pass 2 min after it starts, which a slow run can reach, and would then refetch blocks on its own. The scripted mode sets its interval to an hour. `startServices` takes per-service env on top of each service's own, so a mode can set it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s chain against a node's `scripts/compare-chain.ts` reads an Aztec node and an explorer API, both named by environment variables, and prints the first height where the API's canonical block is not the node's. Node 24 runs it as it is. - `sample`: the API's top 40 heights, in 20-block calls, against the node's hashes there. The node's tips are read before and after, and the sample is marked blind when they moved. - `window`: every height from the node's finalized tip to its proposed tip, one API call every 2 s. - `reorgs`: each recorded reorg whose dead root block the node still has. - `watch`: the three on a schedule, reporting a height whose API hash and node hash both changed as a witnessed prune. The URLs can hold a key, so nothing it prints contains them: its own lines are redacted and the SDK client's logging, which names the node's URL on a failed request, is off. The scripted scenario runs it before the prune, where it must find nothing, and after, where it must name the same first divergence as the REST checks without printing either endpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arios The reads the scripted scenario made of blocks, reorgs, dropped txs, tx effects and contract instances, and its wait for the API to settle, move to `src/explorer-reads.ts`, so another scenario file can read the API the same way. The scripted scenario's checks do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rn smoke:prune`
The local network's AutomineSequencer proves every checkpoint within
200 ms unless epoch auto-settle is off, and `aztec start --local-network`
cannot turn it off, so nothing stays unproven long enough to be pruned.
- `toolchain/local-network.mjs` starts the local network through
`createLocalNetwork` with auto-settle off, and serves the node's RPC and
debug API on 127.0.0.1. Node runs a copy from the run directory, whose
`node_modules` links to the installed toolchain's, so nothing is written
into the shared toolchain directory.
- `src/force-prune.ts` proves the chain, builds the blocks to prune, and
warps L1 past their epoch's proof window with `RollupCheatCodes`, after
which the node's archiver removes them.
- The `prune` mode runs two scenarios on one network, with the four
services, the block topic on 3 partitions and the API's repair loop
off. Depths and hashes are read from the run, and each scenario starts
once the API agrees with the node up to the proven base.
- Two account deployments die and the node mines them again at once in
a replacing block. The API must serve the node's chain from its
genesis, record one reorg of the removed depth, keep the txs mined
with their contracts on the new block, and serve the dead blocks by
hash as orphaned.
- Empty blocks die and the node waits on the shorter chain. The
listener must publish no block and no tips while it waits, the API
must keep its blocks, and one tx must then apply the prune.
- The deployments publish their account instances, which an account
deployment skips by default, after one deployment publishes the class.
`yarn smoke` keeps its six checks on the stock CLI.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A smoke-prune job runs `yarn smoke:prune` with the same triggers, filter and status wiring as the other two, and with the foundry install, the toolchain cache and the builds that `smoke` uses. The foundry download and its checksum move to a composite action, so both jobs install the same release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…first In prune mode the listener reads the node through a pass-through proxy on the run's aztecAdmin port (src/rpc-tap.ts), which appends each of its proposed-tip reads, getBlockNumber and getChainTips, with the node's answer to logs/rpc-tap.jsonl. Each scenario prints `listener order: shorter-chain-first` when the listener read the tip at the prune target before the replacement, and `replacement-first` when it went straight to the replacement. The node builds the replacement 0.15-0.35 s after the prune, so a run can see either, and the order comes from the listener's own reads, whatever method it reads with. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK's error for a failed node call names the host, its cause's hostname and the server's error body, and a server can quote a key there as bare text that no redaction of the URL's parts matches. A node call now fails as `node <operation> failed`, with `: HTTP <status>` when the SDK's message has one; an API call that cannot be sent or answers with something other than JSON fails with its path only, since fetch's message quotes the URL and JSON.parse's the body. Node reads are tried once, so a failure is reported at once. The hostname, the user and the decoded user and password join the redacted parts, and the doc says COMPARE_API_URL is a base URL without a query. A unit test runs the script against a closed port, with credentials in the userinfo, the path and the query, and against a server that answers 500 and quotes them bare; neither stdout nor stderr holds any of them or the host. Against the previous script, the 500 case prints the path segment and the query value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Free ports were bound while they were claimed, fixed ones were not, and both teardowns released a run's claims even when some of its process groups survived SIGKILL, so the next run could claim a port a survivor still served and reach the old run's process. Fixed ports are now bound while the claim is made too, and a port in use fails the claim with its name. A teardown with survivors keeps the claims and says so, and a release that fails makes the teardown unclean: the run fails, and `down` exits with an error, instead of carrying on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
forceEpochPrune waited for the chain watch's events, which compare each read with the one before. When a watch read caught the shorter chain, a doomed height went from its old block to absent to the replacement and no read differed from its neighbour, so the wait for the replacement timed out. It now reads the doomed heights every 250 ms and compares each read with the hashes from before the warp. The scripted node now plays both orders of a prune on every run. After the first prune, whose replacing block is there at once, 7'-12' become proven and finalized, 13'-16' grow with a tx at 14', and the node serves the shorter chain, tip 12', until the listener has read it (a per-state count of proposed-tip reads), before it proposes 13'' with that tx. The new scenario checks heights 13-17, the reorg list from before the prune plus one record, the moved tx not dropped and on 13'', and the dead blocks orphaned by hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prune scenario that leaves the node on the shorter chain asserts that no block and no tips reach the websocket for 15 s. That silence also held with a closed socket, a listener that had stopped reading the node, or a stale frame still on its way. Before the warp the scenario now waits until the websocket has relayed each doomed block (by hash) and a tips frame at the doomed tip, so nothing from before the prune can land in the wait. After the wait it fails unless the socket stayed open and the listener read the node's tip at least every 5 s throughout, as the RPC tap records it. The last check compares the whole reorg list with the one read before the prune plus one record, instead of only the records rooted in the dead blocks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…block's tx The scripted run creates the block topic with 3 partitions to show that blocks reach the API in order, but its steps are 2 s apart, so blocks sent to any partition arrive in order anyway. A last check now reads the broker's offsets (kafkajs admin) and requires every block record to sit in one partition. Before the first prune the scenario now also waits until the API has the moved tx's effect and its contract instance on the dead block 8: without that, both checks after the prune could pass on a first insert at 7'. The run hands the broker's address, the harness's local credentials and the namespaced block topic to the tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Both scenario files judged the API settled on two equal reads 6 s apart with listener polls between them. Tip reads prove the listener polled, not that the API consumed what it sent, so two reads could be equally stale while Kafka was behind. settle() now also requires, just before its second read, that every consumer group of the API is stable and has committed past the newest record of each partition it holds, as the kafkajs admin client reads the groups, their assignments and the committed and end offsets. The prune scenarios count the RPC tap's records as the listener's polls. A scenario that does not settle within 90 s now fails with the API's lag, instead of asserting on a state that was still moving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An aborted run left a first toolchain install's `npm ci` running in its staging directory until npm's own 10 minute timeout. The run's abort signal now reaches the execFile, which kills npm with SIGKILL before the staging directory is removed. When the port registry's lock file was created but its token could not be written, the lock stayed on disk holding no token, so no release could ever match it and every writer waited on it until someone removed it by hand. The lock is now removed when writing or closing it fails. A unit test makes writeSync fail and finds no lock afterwards; against the previous code it finds one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compare-chain's watch kept each height's last API and node hashes, blind samples included, and reported a prune whenever both had changed since. A height that vanished from both sides counted, and so did two changes that disagreed with each other. A witness now takes two samples that are not blind, each with the API and the node agreeing on one hash at that height, and the two hashes must differ. A failed sample used to skip that round's reorgs and window checks; each check now catches its own failure and reports it. The SDK's fetch takes no signal, so a node that accepted a request and never answered held a check forever. Node reads now go through a transport with a deadline, COMPARE_TIMEOUT_MS (15 s by default), which the API reads share, and a timeout prints as one. A unit test runs both one-shot checks against a server that never answers; against the previous script the node check hangs until it is killed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The default-export line in the three Vitest configs this harness added and the one over the prune mode's services said what the code shows. The launcher's copy into the run directory was explained twice; the reason it is copied, Node resolving a linked entry's imports from its real path, now sits once beside the code that copies it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fixed text A 200 that failed validation reached the output with Zod's message, and Zod's coercion to a BigInt throws an error that names the value it got. An API that echoed a bare path segment of its base URL into such a field put the key in the output, where the redaction of whole URL parts misses it. Each API parse now throws `API <path>: invalid response` instead. A unit test runs the reorgs, sample and window checks against a server that answers 200 with the key in a height; against the previous script the reorgs check prints it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The registry reaps a claim by its owner's PID. When the runner is SIGKILLed, its detached children run on, and one that has not bound its port yet leaves the port to the next run that claims it. Keeping those claims would take the children's process groups in the registry, which other tools on the host share, so the README states it as a limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shorter-chain scenarios compare the API's reorgs after the prune with the list before it plus one record. A failed read of the list before it stayed a status object, which the comparison passed through unchanged, so the same failure before and after passed the check. The baseline is now read with reorgList, which throws unless the API answers a list it parses, and plusReorg takes only a list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… shows it The order record called a prune shorter-chain-first whenever any answer after the warp named the target, so a target answer that arrived after a replacement answer, from a request sent earlier, overrode it. The earliest answer by arrival now decides. The tip at the target shows the shorter chain. A tip above it shows the replacement when its hash is not the one the node had there before the warp or, without a hash, when it is not the old tip's height, which alone shows neither. Unit tests cover a replacement answer followed by a later target answer, and the old tip with and without a new hash; the previous rule fails them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Settling took two equal snapshots with zero committed lag between them. The lag read the groups' commits before the topics' ends, so a heartbeat or a liveness record landing between the two reads showed lag on a healthy run, and two equal snapshots could both come before the listener published the replacement. A scenario now names the state it expects and waits up to 30 s for the API to serve it. Then it takes the end offsets of every partition the API's groups are assigned, once, waits until the groups have committed through them, and reads the API again after its 6 s cache: the scenario asserts on that read, whether the expected state came or not. Records published after the offsets were taken no longer hold it up, and a consumer that never catches up fails the scenario. Each expected state is written once and the tests compare with it. On today's listener and API no scenario reaches its expected state, so each waits the full 30 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and watch it The scripted node served the shorter chain until it answered one read of the tip. That read could be another poller's or a node election's probe, and the scenario asserted nothing while the chain was short. The node now records each tip read of a state, by method and time. The test holds the shorter chain until two reads by one method come a block poll interval apart, so a pass of the listener that read it has ended, and for at least 7 s, longer than today's 5 s tips poll. While it is held, the block and tips topics must take no record and the API must keep serving the dead blocks and its reorgs. The run hands the tests the listener's poll interval and the tips topic, and the prune mode's bound on a gap between the listener's tip reads is now four poll intervals instead of a fixed 5 s. On today's listener the new check fails: its tips timer publishes the shorter tip while the chain is held. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tory A runner killed during its first toolchain install left its aztec-<hash>.tmp-<run> directory in the shared toolchain directory, and down did not touch it. down now removes that run's staging directories, matched by name, and no other run's or install's. Two leftovers stay, written in the README's limits: the npm ci that such a kill orphans exits on its own and can write into the directory again if it outlives down, and a kill before the harness starts its first container can leave a network or volumes that the harness's ls and down do not see. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… in its own range The scripted scenario expected sample and window to name the same first mismatch, the first divergence anywhere in the API's heights. But sample reads the API's top 40 heights and window the node's finalized to proposed tip: with the API stalled at 10 and the node at 11, sample ends at 10 and finds nothing while window finds 11 missing. Each check's expected first mismatch now comes from its own range, which compare-ranges.ts derives from the API's latest height and the node's tips, and the range each check prints must be that one. A unit test with a head-lag fixture, the API at 10 and the node at 11, finds no mismatch in sample's range and 11 in window's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The partition test's comment and the README said a single partition shows the block records kept the order they were sent in. The test counts records per partition and reads no order, so both now say only that the broker shows where the records went. The forced prune's comment said a height read absent and later holding a new block differs from neither neighbouring read, which is false, as the new block differs from the absent read. It now states the rule the loop follows, against the hashes from before the warp: a doomed height is pruned once a read lacks its old hash, and replaced once a read shows another block there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ks it The hold ended after two tip reads by one method, a poll interval apart. An election probes a node's tips on every pass, whether or not the pass goes on to read that node's chain, so passes that never handled the shorter chain met the rule, and the check that nothing moved could pass against a listener that read nothing. The scripted node now records each block read by height in the current state. The hold ends once the node has answered a read of a height the shorter chain lacks, which the SDK's block stream makes walking back from its longer tip, and a tip read a poll interval after it, which is the next pass's: at least 7 s, at most 15 s. A state no pass handled fails the quiet check rather than the scenario, so the checks after it still run. Today's listener reads no such height, so the quiet check fails on that as well as on the tips record it publishes. The rule's unit test fails against the previous one on election probes alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r it shows A key can come back inside a valid answer: an API that echoes a hex key from its base path as a block hash passes the schema, and sample printed it in its first mismatch. Redacting the whole path and query did not match a segment printed alone, and the script prints hashes in lowercase. Each path segment, query value and fragment of 8 characters or more is now redacted on its own, raw and decoded, and as it reads inside a JSON string, and matching ignores case. Shorter parts stay, so a segment like v1 is still readable. The new test serves a valid block list whose hashes carry such a key, against the scripted node; the previous script prints the key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ld past its tip On the shorter chain, a correct listener's walk back reads the block one past the node's tip, and the 6.0.0 node holds that read for RPC_UNSEEN_BLOCK_BY_NUMBER_WAIT_MS, by default twice the 3 s block duration. Each pass then went 6 s between tip reads, over the bound of 4 polls, and the shorter-chain scenario failed a listener doing nothing wrong. The run now sets the hold explicitly, to the same 6 s, so reads are held as in production, and hands it to the scenario, whose bound is that hold plus 4 polls. The bound's unit test runs on the tip reads such a listener made, recorded from a run, and fails with the previous bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the order label The broker reads behind the settle and the quiet window's count run on KafkaJS's own request timeout and retries, not on the settle's budget, so a stalled broker fails the run on the hook timeout, whose message names nothing that was behind. The listener order line can move with the tap's buffering, and a tip read without a hash inside the old chain counts as the replacement. Neither reaches a check, since the checks hold for both orders. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A crash scenario has to end a service's process group as a crash would and start it again, while the runner stays the owner of every process it tears down. In scripted mode the runner now serves a control on 127.0.0.1, on the port the mode leaves to anvil, which runs none: POST /services/<name>/kill sends SIGKILL to the latest group of that service, as a stop rather than a death, and POST /services/<name>/start starts it again with the command and environment the run first used, only after a kill. The endpoints carry its URL and the run's Postgres access, with each service's database, for the locks a scenario holds. The control's unit test fails without the rule that a running service is never started twice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… run A crash scenario stops a service in the middle of a write by holding a lock on the row the write needs, from a session of the harness's own, and has to prove where the service stopped. row-lock.ts takes such locks with SELECT ... FOR UPDATE, lists the sessions waiting on them from pg_stat_activity, ends a waiting session with pg_terminate_backend so its transaction rolls back and its statement never runs, and releases. The broker reads gain each partition's end offset, the offsets the API's groups have committed on a topic, which outlive a crashed member, and the records of one partition between two offsets, read by a consumer group of the reader's own, so a scenario can compare two copies of a record. pg and bson come in at the versions the lockfile already holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After 13″–16″ the script grows 17″–18″ and replaces them at once with 17‴–19‴ on 16″, then grows 20‴–21‴ and replaces them with 20⁗–22⁗ on 19‴. Each moves a tx from the second dead block to the first replacing one; the txs come from recorded testnet blocks, since only their hashes and effects matter. The scripted node's test walks every state of both, as it does the first two prunes. stepThrough gains an afterPrune hook, which runs once the node serves a prune's first state and before it moves on, so a scenario can act between a prune and the blocks after it. Its unit test fails without the call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…arios Each prune scenario checks its settled state the same four ways: the canonical chain, the reorg records, the moved tx (with the contract, where the scenario names its block) and the dead blocks. One helper now declares them, and another waits for the dead blocks and the moved tx before a prune, so a scenario adds only its own names. The caller names the contract's block, which need not be the prune's replacing block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oring it After 17″–18″ the scripted node prunes them and serves 17‴ at once. The scenario locks the listener store's hash row at height 17 from a session of its own: the prune leaves that row as it is, and the store's write of the replacing batch, which runs only once the batch is sent, writes it first. Once pg_stat_activity shows the listener's write waiting on the lock, the test reads what the batch put on the topic and what the store holds, kills the listener with SIGKILL, ends the waiting session so its transaction rolls back, releases the lock and starts the listener again. A listener that does not reach that write within 15 s fails the scenario's first check, and nothing is killed. At the kill the topic holds one more record and the store is still on 16″, with 17″ at 17. After the restart the topic holds a second copy of 17‴ under the same key. Through REST the API then serves the node's chain above 16″, one more reorg (2 blocks from height 17), the moved tx on 17‴ and not dropped, the contract still on 7′, and the dead blocks as orphaned. The restart waits for the killed member's 30 s Kafka session to end before the listener polls again. A lock's release can now be called twice, so a scenario that fails midway still frees the row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…fset's After 20‴–21‴ the scripted node prunes them and serves 20⁗ at once. Once the API's consumers have committed every record, the scenario locks the API's rollup-version observation rows, which its block handler upserts after it commits a block. The API's chain-info and node-info handlers upsert them too, each while its group holds a record it has not committed, and a group handles one record at a time. So the stop counts as reached only when more of the API's upserts wait on the lock than the API has other groups behind, as pg_stat_activity and then the broker show; a block handler that never waits there fails the first check within 15 s, and nothing is killed. The test then reads the API's database and the broker, kills the API, ends its waiting sessions, releases the lock and starts it again. At the kill the topic holds one more record, 20⁗ is canonical in the API's database and 20‴–21‴ are not, and the block group's committed offset is still that record's. After the restart the group commits past it. Through REST the API then serves the node's chain above 19‴, one more reorg (2 blocks from height 20), the moved tx on 20⁗ and not dropped, the contract still on 7′, and the dead blocks as orphaned. The replayed batch holds that record alone, so the replay has no dead block to bring back and the reorgs are checked exactly. The broker reads gain the API's groups, other than a topic's own, that have not committed what they were sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside a transaction, pg_stat_activity shows every other session's query as it was at the transaction's first read of it, while wait events and pg_blocking_pids are read live. The lock's waiters were read in the lock's own open transaction, so after the first poll a pooled session that went on to wait in the listener store's or the API's upsert still showed the select it had run before. Neither stop matched the write it waits for, and both crash scenarios failed on their stop checks, with nothing killed. The lock now reads its waiters, and ends sessions, from a second session that holds no transaction open. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each scenario's settled read now prints the time since the previous scenario settled; the scenarios run one after another and each ends on that read, so this is the scenario's runtime, and the first's runs from the file's start. The crash scenarios' runtime budget is measured with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scripted mode's section now covers the two prunes played with a service killed: how the test stops a service with a row lock and proves the stop before it kills, what each stop depends on in the listener and the API, what is read at the kill and after the restart, and what each scenario then checks through REST. It names what is not played (a listener restart that finds only lagging nodes, a crash between the API's commit and its chain revision bump) and that a listener without the block stream's store, or one that never sends a prune's replacing block, fails both scenarios at their stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pg_blocking_pids names a session's direct blockers only. When two upserts of the observation row overlap a stop, the second queues for the row's tuple lock behind the first, so it names the first and not the harness. The API stop then counted one waiter where two were held up, and could miss a block handler queued behind a chain-info upsert for its whole wait. The kill ended only the direct waiters, so an autocommit upsert left queued would commit once the lock was released, though its client was dead. A lock's waiters are now every session it holds up, directly or queued behind one another, from one read of the waiting sessions and their blockers. The stop counts them, the kill ends all of the service's and fails if any is left before the lock is released, and the README says so. The unit test fails with direct blockers alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e API's replay Both crash scenarios read the state their stop implies, through SQL and the broker: the batch's one record on the topic, and the listener's store still on the prune's target, or the API's chain change committed with no group past the record. They checked it only after the restart. Each scenario now kills only once that state holds, and reports the stop as missed otherwise. The API's replay was inferred from its group committing past the record after the restart, which a commit landing late from the killed process would show as well. The lock now stays through the restart: the restarted API's block handler has to reach the same upsert, held up by the lock, while the group's committed offset is still the record's. Only then is the lock released, and the commit past the record awaited. The scenario's checks of the replay fail without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…after a crash The second, third and fourth prunes expected the reorg list read from the API before the prune plus the prune's own record, so a record the API added between two scenarios became part of what they expected. Each scenario now expects one reorg per prune the script has played by its end, from the script's facts alone. The crash scenarios read the canonical chain from the prune's height up, so a restart that lost or changed a block below it went unseen. They now read it from height 1, as the first scenario does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crash scenarios read waiters, the listener's store and the API's chain through Postgres sessions of their own, with no bound on a statement. One that stalled, a lock wait included, held its step until the test's timeout. Each of those sessions now has a 10 s statement timeout, longer than the 5 s a termination waits for its session to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ends A crash scenario takes its row lock before the prune's step and releases it when its stop fires, once the node has pruned. A step request that failed in between left the lock held, so the next scenario ran on the same node against a service still blocked on it. The stepping now runs an end hook in a finally, and both crash scenarios release their stop's lock there; a second release does nothing. The unit test fails when the hook runs only after a stepping that succeeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…down The scripted mode's service control stayed open until the teardown's last step, after both process-group sweeps, so a local call could start a killed service again while the stack came down, and the runner could release its ports with that service still running. The control now takes the run's abort signal. From the abort, the first step of the teardown, it refuses every action and closes; a control whose start finished after the abort refuses them too. A service started before the abort is in the run's groups, so the first sweep stops it. The unit test fails without either part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…k do The broker reads were described as admin-only, though a partition's records are read by a consumer of a group of its own. The README and the suite's last describe said the block topic's partitions were checked after every prune; they are checked once, after the last. Two comments that restated their function's signature are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The API stop counts as reached when the lock holds up more upserts of the observation row than other writers could have sent. It took those writers to be every API group behind, and every group without a stable assignment. Once the block handler waited longer than its session, its own group lost its member and counted as another writer, and any group still rejoining did too, so a stop or a replay could be missed with the block handler's upsert still waiting. The other writers are now the four groups whose handlers reach that upsert, by id: catch-up blocks, chain info, staking-asset info and node info. Each is judged by its committed offsets against the end offsets of the topics it committed on or is assigned, whatever its state, so a group whose member expired while its handler waited still counts. The unit test fails when a group's state decides instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… record Before the kill, the API stop checked that every API group with offsets on the record's partition was still at the record. A block handler under another group id passed that check, and the scenario killed the API; only its later assertion on the block group failed. The state at the stop now needs the block group, and no other API group on that partition, at the record. The unit test fails with the check on any group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ts name A crash scenario found the killed service's sessions by their database, which other clients of the run share, and ended only those the lock held up. A session that had sent its statement but was not waiting yet outlived the cleanup: it could queue on the lock afterwards and run once the lock went, or be counted with the restarted service's writes. The run now starts each service with PGAPPNAME set to its name, which pg sends as each session's application_name; the services' pools set none of their own. Stops match a service's writes by that name. After the kill, every session with the name is terminated, whatever it is doing, and the scenario stops if one is left, before any unlock or restart. The scenarios assert the name on each write they catch, so a run whose services do not send it misses both stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A stop waited 15 s for its write, but a read that began before the deadline could prove the stop after it and still lead to the kill. A Vitest hook that times out keeps running, so such a kill could land in a later scenario. The broker reads in a stop had no bound of their own, and the harness's Postgres connections none for connecting. The deadline is now checked again just before the kill, which past it kills nothing and reports the stop as missed. The stop's admin reads of the broker give up after 10 s, and so does connecting a harness session. The unit tests fail without the check and without the bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The README said the restarted API's block handler must reach the same upsert with the group's offset still at the record, and the group then commit past it. The check reads that offset twice, once while the restarted block handler is held up and once after the unlock, and does not trace when a commit is issued. The README now says so. An early commit before the restart fails the first read, and one that lands between that read and the unlock is listed with the known limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…der way The service control allows a service's start once a kill of it has finished. Two overlapping kill requests both awaited the same exit, and each then allowed a start: if a start came between the two, the second kill left a permit for another, which could launch a duplicate service or fail on its ports. A kill of a service that already has one in flight is now refused with 409. The unit test interleaves the two kills with a start, and fails without the refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fails A killed service's session never sees its client go, so a write it had queued on the stop's lock runs once the lock is released, and an autocommit one commits. The stop released the lock on its way out of every failure: a cleanup that failed or left a session, and a kill request that failed after the process had died, so that write could land in what later scenarios read. The stop's hold now owns the kill and the cleanup. Once the kill is sent, a failure or a session left throws and keeps the lock held for the rest of the suite, and a later crash scenario fails at once instead of running into its timeouts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crash-stop scenarios parse `ordered.proposedTip` from the block records on the topic, the listener's new field name, and compare each record's proposed tip with the replacing block's height. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zod 4 has no `ZodTypeDef`, and its `ZodType` takes the output and input types first, so `apiParsed` took no schema type it could check and every parsed API response came back untyped. It now takes `z.ZodType<T, unknown>`: a schema whose output is `T`, accepting any input, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The comment said zod's BigInt coercion throws an error that names the refused value. zod 4 leaves the input out of its issues, so the case no longer exercises a quoting error; it stays as a guard against a parser that does quote. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 6 of 6 of the stack that makes the explorer follow the L2 chain by block hash. Part of #97, #98, #99 and #102.
Parts 1–5 test each rule on its own. This part runs the built listener and API through prunes end to end: against a scripted node that prunes on cue, and on an Aztec local network forced to prune an epoch. It also adds
compare-chain, a read-only check of an explorer API's chain against a node's.What changed
yarn smoke:scripted(src/prune.scripted.ts,vitest.scripted.config.ts):src/scripted-node.ts, chain insrc/scripted-chain.ts) serves the SDK'sAztecNodeApiSchemathrough the SDK's own server, and steps through its states on a control port (src/script-control.ts,src/step-through.ts).aztec-listenerandexplorer-apirun, with the harness's Postgres, Kafka and Redis. No toolchain or foundry is needed. The block topic is created with 3 partitions before any service starts.compare-chain:samplebefore the prune, thensampleandwindow. Each must read its own range, name the API's first divergence from the node within it, if any, and print neither URL.src/crash-stops.ts,src/row-lock.ts,src/service-control.ts,src/broker.ts): the test holds a row lock on a row the service writes at the stop. It proves frompg_stat_activityandpg_blocking_pidsthat the service's write waits on the lock, and checks the state the stop implies through SQL and the broker. It then kills the service's process group, ends every session the service opened, and starts it again with its first command and environment. Each service's Postgres sessions carry its name (PGAPPNAME). A stop not proven, in the expected state, within 15 s fails the scenario, and nothing is killed. If a kill or its cleanup fails, the lock stays held for the rest of the suite.yarn smoke:prune(src/epoch-prune.prune.ts,vitest.prune.config.ts):yarn smoke, with the block topic on 3 partitions.toolchain/local-network.mjsstarts the local network throughcreateLocalNetworkwith the epoch auto-settle off.src/force-prune.tsproves every checkpoint, builds the doomed blocks, and warps L1 past their epoch's proof window, so the node prunes them.src/rpc-tap.ts), and each scenario prints which state of its prune the listener read first.scripts/compare-chain.ts, read-only, run with Node 24:sample: the API's top 40 heights against the node's hashes, marked blind if the node's tips moved during the read;window: every height from the node's finalized tip to its proposed tip;reorgs: each/l2/reorgsrecord whose dead root block is still on the node's chain;watch: the three on a schedule, also reporting each prune it witnesses.src/cli.ts):run [scripted|prune],downandscripted-node.downalso removes a killed install's staging directory. A run claims its ports in the host's port registry (src/port-registry.ts) and binds every port it claims, so it never claims one that another process still holds.network-smoke.yml): new jobssmoke-scripted(20 min timeout) andsmoke-prune(30 min) besidesmoke, all three reported innetwork-smoke-status, which stays a non-required check. Thesmokejob's foundry install moves into a new composite action,.github/actions/install-foundry, whichsmoke-pruneuses too and which still checks the release's SHA-256.smoke:scriptedandsmoke:prune. The workspace's new dependencies are versions already inyarn.lock.services/network-smoke/README.mddescribes both modes,compare-chain, and the known limits of the checks.How it was tested
yarn workspace @chicmoz/network-smoke test, 48 tests, 45 of them in these new or changed files):broker,compare-chain,compare-ranges,crash-stops,explorer-reads,port-registry,port-registry-lock,ports,row-lock,rpc-tap,script-control,scripted-node,service-control,step-throughandtoolchain.yarn smoke:scripted: green on 3 runs in a row.yarn smoke:prune: green on 3 runs in a row. In every run the listener read the replacement first in the first scenario, and the shorter chain first in the second.yarn smoke: green on 3 runs, with its 6 checks unchanged.yarn smoke:scriptedfailed 21 of its 23 checks, andyarn smoke:prune5 of its 7 (4 of 4, and 1 of 3), as Block poller never fetches blocks that replace heights it already processed #97 and A block stored at an occupied height orphans every higher block, including its own chain #98 describe.Smoke wall-clock
yarn smokeyarn smoke:scriptedyarn smoke:pruneEach time runs from the command's start to its exit, setup and teardown included. The
yarn smokerow is one run ofmainand one of this stack, back to back on the same host, each from its own install and a clean build. The two new suites show the range over the 3 runs above.Scenarios
Estimates were written before each scenario's first run. Measurements are the range over the 3 runs, from each scenario's own log.
Migration and rollout
network-smokeis never deployed.🤖 Generated with Claude Code