feat: exported in-process testing network - #24629
Conversation
The pure-Node signal/exit handlers in startAnvil only reap anvil when node runs its own handlers (explicit stop, Ctrl+C, normal exit, uncaught exception). On a parent hard-kill (SIGKILL/crash/OOM) they never run, and the detached anvil is orphaned — verified empirically. That is the exact failure the removed anvil_kill_wrapper.sh guarded against and a known source of CI flakiness. Spawn anvil under a small inlined bash watchdog that polls its parent (this node process) and reaps anvil via an EXIT/INT/TERM trap when the parent dies for any reason. Inlined (not a shipped .sh) so it works from the published npm tarball, with the resolved anvil binary passed via $ANVIL_BIN so it works without anvil on PATH.
The watchdog trapped cleanup on EXIT/INT/TERM, but a trapped TERM does not terminate bash — it ran cleanup and then resumed the parent-poll loop, so the supervisor never exited on stop() until killChild's 5s SIGKILL escalation. That 5s collided with jest's 5s hook timeout and hung afterEach teardown (forwarder_l1_tx_utils.test.ts). Trap the kill on EXIT only and have INT/TERM just exit (firing the EXIT trap); use 'sleep & wait' so the poll is interruptible. stop() now returns in ~1s; orphan-on-parent-death still holds.
| await stopNode(); | ||
| await stopAnvil(); |
There was a problem hiding this comment.
Should we run them in parallel? So that if the first fails, the second one is also stopped?
| const envBin = process.env.ANVIL_BIN; | ||
| if (envBin && existsSync(envBin)) { | ||
| return envBin; | ||
| } |
There was a problem hiding this comment.
I understand having defaults if $ANVIL_BIN is not set. But if it is set and it doesn't exist, then we should probably fail, instead of using default version
There was a problem hiding this comment.
mmm, yeah reworked this part
| () => {}, | ||
| ); | ||
|
|
||
| return { |
There was a problem hiding this comment.
Claude suggested we also implement asyncDispose
There was a problem hiding this comment.
I did and I don't know if I'm a fan of the syntax, but removing the finally is neat
| * `maxFeesPerGas.feePerL2Gas must be >= gasFees.feePerL2Gas`. Apply via | ||
| * `wallet.setMinFeePadding(TEST_FEE_PADDING)` on every test wallet that sends txs. | ||
| */ | ||
| export const TEST_FEE_PADDING = 30; |
There was a problem hiding this comment.
Is this the same as PIPELINED_FEE_PADDING for the same reasons? Just checking if we could re-use it or if they are different things
There was a problem hiding this comment.
It is, but for dependency reasons made PIPELINED_FEE_PADDING an alias
| /** Override the default per-address fee juice granted at genesis to funded addresses. */ | ||
| initialAccountFeeJuice: Fr; |
There was a problem hiding this comment.
Should this be optional if it's a default override?
| expect(await a.node.getBlockNumber()).toBeGreaterThanOrEqual(0); | ||
| expect(await b.node.getBlockNumber()).toBeGreaterThanOrEqual(0); |
There was a problem hiding this comment.
Should we test strictly greater, to make sure block production works?
| if (envBin && existsSync(envBin)) { | ||
| return envBin; | ||
| } |
There was a problem hiding this comment.
Should we also test it's executable?
| /** anvil block time in seconds. Omit for automine (the default). */ | ||
| l1BlockTime?: number; |
There was a problem hiding this comment.
Heads up that createLocalNetwork sets useAutomineSequencer to true by default, which sets anvil to automine during startup (see sequencer-client/src/sequencer/automine/automine_sequencer.ts start()). So a user setting eg l1BlockTime=12 will see their anvil still set to automine. I'd remove this option altogether for now, or add proper support for it if we really have a need for it.
| * Necessary because `deployAztecL1Contracts` shells out to bare `forge`/`solc`, and those inherit | ||
| * PATH from us. Since the aztec-up change that stopped polluting the user's interactive PATH, | ||
| * `forge`/`cast`/`anvil`/`nargo` are only reachable via `~/.aztec/current/internal-bin/`. |
There was a problem hiding this comment.
I'd rather modify deployAztecL1Contracts than meddling with PATH
There was a problem hiding this comment.
Right, this is reworked now
…ec-packages into gj/upstream_testing_utils
spalladino
left a comment
There was a problem hiding this comment.
Looks good. One thing to look out for is whether the user has a local anvil version that works with Aztec. Problem is, I don't know what's the min version we need (I guess the one pinned in the docker image?).
We can refine this, but I think ATM we can assume that if they're deep enough to have an e2e test that uses this external network, they also have the toolchain installed |
Upstreaming the utilities build for `aztec-kit` so external projects can benefit from our e2e scaffolding. Essentially the same thing we already use, but pure ts rather than the unpublishable .sh script. Verified with `ci-full-no-test-cache` (cherry picked from commit 7e09008)
Upstreaming the utilities build for `aztec-kit` so external projects can benefit from our e2e scaffolding. Essentially the same thing we already use, but pure ts rather than the unpublishable .sh script. Verified with `ci-full-no-test-cache` (cherry picked from commit 7e09008)
Upstreaming the utilities build for `aztec-kit` so external projects can benefit from our e2e scaffolding. Essentially the same thing we already use, but pure ts rather than the unpublishable .sh script. Verified with `ci-full-no-test-cache` (cherry picked from commit 7e09008)
…o next (AztecProtocol#24933) Forward-ports the **prover** and **node / world-state / barretenberg** slices of the v5-next → next backlog (work merged to `v5-next` after the ~2026-07-08 cut that reshaped `next`). ## Applied (clean cherry-picks, chronological) - feat(prover): revive cancelled proving jobs from a persisted aborted state (AztecProtocol#24578) - fix(prover-node): rebuild pruned checkpoint provers and recover the epoch (AztecProtocol#24436) - feat: exported in-process testing network (AztecProtocol#24629) - fix(validator): sync world state before forking in checkpoint proposal validation (AztecProtocol#24694) ##⚠️ Needs owner conflict-resolution (conflict against reshaped `next`; not included here) Cherry-pick onto this branch and resolve: - [ ] `git cherry-pick -x a4e3a44` — feat(world-state): support prefilled nullifiers in genesis state (AztecProtocol#24567) **[RESHAPE — v6 subsystem rewritten; re-implement, do not merge]** - [ ] `git cherry-pick -x c44e74e` — fix(prover-node): do not abort in-flight proving jobs on a clean shutdown (AztecProtocol#24579) - [ ] `git cherry-pick -x 1039d38` — feat: allow custom proof submission target address (AztecProtocol#24270) Part of the manual v5-next → next backlog sweep. Draft until conflicts are resolved and CI is green.
Upstreaming the utilities build for
aztec-kitso external projects can benefit from our e2e scaffolding. Essentially the same thing we already use, but pure ts rather than the unpublishable .sh script. Verified withci-full-no-test-cache