Repository navigation
test(node): bound flaky forge deploy in anvil-e2e with timeout + retry (#785) - #786
Conversation
#785) The `anvil-e2e` job intermittently hung for many minutes because `forge script DeployProtocol --broadcast` ran via an unbounded blocking `std::process::Command::output()`. `forge script` occasionally stalls in its broadcast/receipt-wait phase against anvil under shared-runner CPU contention; with no per-call timeout, no overall test timeout, and no `timeout-minutes` on the job, one stall froze the whole run until an unrelated `cancel-in-progress` push killed it — surfacing as a misleading "cancelled" rather than a clean red. Three layers of hardening: - CI guard rail: `timeout-minutes: 15` on the `anvil-e2e` job so a hang fails red fast instead of squatting a runner. - Bound the `forge` subprocesses: a `forge_output` helper runs them via `tokio::process::Command` under `tokio::time::timeout` with `kill_on_drop(true)`, so an overrun is SIGKILLed (no orphan `forge`) and reported as a clear `timed out` error. `forge build` is bounded at 180s; the deploy is retried up to 2x45s on a *stall* (timeout). A non-zero exit is treated as deterministic and fails fast with the full stdout+stderr. Retry is safe: each run broadcasts from a fresh deployer nonce (new addresses) and `FORCE_OVERWRITE_MANIFEST` rewrites the manifest. - Defense-in-depth: the test body (extracted to `run_e2e`) is wrapped in an overall 780s `tokio::time::timeout` so any future unbounded await fails fast; RAII (`AnvilGuard`) + `kill_on_drop` preserve cleanup on timeout. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotGas changes vs baseRun: 26839535361 |
Contracts coverageLine coverage: 88.96% (1797/2020 lines) |
There was a problem hiding this comment.
Code Review
This pull request introduces wall-clock timeouts and retry logic for forge subprocesses in the end-to-end payment channel settlement tests to prevent tests from freezing under runner CPU contention. It wraps the entire e2e flow in an overall timeout and implements a helper function, forge_output, to run forge commands with a timeout and kill the child process on drop. The review comments suggest improving forge_output to distinguish between deterministic spawn failures (which should fail fast) and transient timeouts (which are safe to retry) by changing its return type to anyhow::Result<Result<Output, Duration>>, and adapting the call sites accordingly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
This PR addresses intermittent anvil-e2e CI hangs by bounding forge subprocess execution time and adding an explicit workflow job timeout, converting unbounded stalls into fast failures (or safe retries) with clearer diagnostics.
Changes:
- Add wall-clock timeouts for
forge buildandforge script --broadcast, withkill_on_drop(true)to prevent orphaned processes. - Retry the deploy script on timeout-based stalls (while failing fast on non-zero exits).
- Add
timeout-minutes: 15to theanvil-e2eGitHub Actions job.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
crates/node/tests/anvil_settlement_e2e.rs |
Introduces async forge_output with timeouts/kill-on-drop, wraps the e2e flow in an overall timeout, and adds deploy retry logic. |
.github/workflows/ci.yml |
Adds a 15-minute timeout to the anvil-e2e job to cap worst-case hangs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Coverage reportTotal: 86.58% (was 86.58%, ● 0.00%) — 25994/30024 lines No coverage data for changed Rust files. History
|
Address review (gemini-code-assist, Copilot): `forge_output` collapsed a deterministic spawn failure (forge missing / permission error) and a transient receipt-wait stall into a single `anyhow::Error`, so the deploy retry loop retried *both* — a missing `forge` logged "stalled, retrying" and burned a retry before failing. Change `forge_output` to return `anyhow::Result<Result<Output, Duration>>`: `Err` = spawn failure (deterministic — caller `?`-propagates / fails fast), `Ok(Err(timeout))` = stall (retryable), `Ok(Ok(output))` = exited (check status). The deploy loop now retries only the timeout arm; build bails on timeout (not retried). Verified: happy path PASS ~5.8s (no retry); forced 1ms timeout retries then fails `stalled on all 2 attempts` with no orphans; `forge` off PATH fails fast with `(is foundry installed?)` instead of a bogus "stalled" log. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Summary
Fixes #785 — the
anvil-e2eCI job intermittently hung for many minutes becauseforge script DeployProtocol --broadcastran via an unbounded blockingstd::process::Command::output()incrates/node/tests/anvil_settlement_e2e.rs.forge scriptoccasionally stalls in its broadcast/receipt-wait phase against anvil under shared-runner CPU contention; with no per-call timeout, no overall test timeout, and notimeout-minuteson the job, one stall froze the whole run until an unrelatedcancel-in-progresspush killed it — surfacing as a misleading "cancelled" rather than a clean red ❌. Both observed stuck runs leftforge/anvilalive as orphans at teardown.Fix (three layers)
timeout-minutes: 15on theanvil-e2ejob so a hang fails red fast instead of squatting a runner.forgesubprocesses (core fix) — aforge_outputhelper runs them viatokio::process::Commandundertokio::time::timeoutwithkill_on_drop(true): an overrun is SIGKILLed (no orphanforge) and reported as a cleartimed outerror.forge buildis bounded at 180s; the deploy is retried up to 2×45s on a stall (timeout). A non-zero exit is treated as deterministic and fails fast with the full stdout+stderr (no misleading "retrying" line for a hard error). Retry is safe — each run broadcasts from a fresh deployer nonce (new addresses) andFORCE_OVERWRITE_MANIFESTrewrites the manifest the test reads.run_e2e) is wrapped in an overall 780stokio::time::timeout(above the internalpoll_untilbudget sum, below the 15-min job cap) so any future unbounded await fails fast. RAII (AnvilGuard) +kill_on_droppreserve cleanup when either timeout fires.No new dependencies (workspace
tokioalready carriesfeatures = ["full"]). All edits land in test-harness code already exempt from the anti-panic lints.Verification
--features anvil-e2e --tests) +cargo fmt --check: clean; all pre-commit hooks pass.cargo nextest run -p decdn-node --features anvil-e2e --test anvil_settlement_e2e→PASS ~5.7s, first-attempt deploy, no retry log.DEPLOY_TIMEOUTtemporarily set to1ms): failed in 0.48s (not a hang), loggedattempt 1/2 stalled, retrying, returnedstalled on all 2 attempts(timeout chained as source), and left no orphanforge/anvilprocesses. Reverted.Review
This PR incorporated a multi-agent review pass (general code, test quality, silent-failure, comment accuracy). Notable improvements from that pass: the
forge buildfailure message now captures stdout (where forge writes compiler errors), not just stderr; the deploy retry distinguishes a retryable stall from a fail-fast deterministic exit; and the overall-timeout message interpolates the constant to avoid drift.🤖 Generated with Claude Code