Repository navigation
Description
Summary
e2e_onchain_payment_channel_settlement (crates/node/tests/anvil_settlement_e2e.rs) intermittently fails during contract deployment in a way the existing retry logic does not recover from. This is a follow-up to the now-closed #785 (unbounded deploy hang → bounded timeout + retry): #785 made stalls retryable, but a transient non-zero exit during the forge broadcast phase is still treated as a hard, non-retryable failure and fails the whole test.
Observed on CI for an unrelated node-crate PR (#882): run 27443826381, job anvil e2e. The PR touches only the node→node buyer-side pull reputation path; it does not touch contracts, PaymentChannel settlement, or anvil, so the failure is purely infrastructural.
What happened
WARN anvil_settlement_e2e: forge script DeployProtocol attempt 1/2 stalled, retrying after 45s
Error: forge script DeployProtocol exited non-zero:
No files changed, compilation skipped
Script ran successfully.
== Return ==
d: struct BaseProtocolDeploy.Deployment Deployment({ token: 0x959…, …, paymentChannel: 0x4ed…, … })
## Setting up 1 EVM.
- Attempt 1 hit
DEPLOY_TIMEOUT(45s) and was killed — the Flaky anvil-e2e:forge scriptdeploy subprocess hangs unbounded, freezing the test for minutes #785-handled stall path, correctly retried. - Attempt 2 ran ~27s and exited non-zero, but its stdout shows the Solidity script body completed:
Script ran successfully, a fullDeployment { … }struct was returned, and output then cut off at## Setting up 1 EVM.— i.e. the failure was in the broadcast/transaction-submission phase, not the script logic. run_deploy_script(anvil_settlement_e2e.rs:~1240) classifies any non-zero exit as deterministic andbail!s immediately:
// A *non-zero exit* (revert, script bug, RPC rejection) is almost always
// deterministic, so it fails fast ... rather than retrying a guaranteed-
// identical failure.
Ok(out) => anyhow::bail!("forge script DeployProtocol exited non-zero:\n{}\n{}", …),The test failed at ~72s, well under OVERALL_TIMEOUT (780s), so the overall guard never engaged.
Root cause
The "non-zero exit is deterministic" assumption does not hold for the broadcast phase: once the script body has produced a Deployment, a non-zero exit is almost always a transient RPC/nonce/anvil hiccup under CPU contention (the same contention #785 cites for stalls), not a revert or script bug. Those transient broadcast failures are exactly the ones worth retrying, but the loop only retries the Err(timeout) (stall) arm.
Impact
Blocks merges on unrelated PRs (the only fix today is a manual re-run), and silently re-tars the test's reliability for changes that have nothing to do with on-chain settlement.
Possible directions (not yet decided)
- Retry broadcast-phase non-zero exits too, distinguished from genuine reverts. A real revert/script bug surfaces a
Revert/Errorline or omits theScript ran successfully/Returnblock; a broadcast hiccup shows the script succeeded then failed duringSetting up … EVM/ broadcast. Retry only when the script-success markers are present (so true reverts still fail fast with full output). - Reduce broadcast contention — e.g.
--slowon the forge broadcast, or a small inter-tx delay, to cut the RPC-races that produce these non-zero exits. - Treat any forge deploy failure (stall or non-zero) as retryable up to
DEPLOY_ATTEMPTS, surfacing the last attempt's full output. Simpler but loses the fast-fail on genuine reverts — acceptable sinceDEPLOY_ATTEMPTSis small (2). - Fix the misleading log:
retrying after {timeout:?}prints the stall duration (DEPLOY_TIMEOUT), implying a 45s sleep that doesn't happen (the loop retries immediately). Minor, but it confused diagnosis here.
Not caused by
PR #882 — included only as the run where this surfaced.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon Jun 12, 2026
🎯 Triage report
A second mode of forge deploy flakiness in
anvil_settlement_e2e— transient non-zero exits during the broadcast phase — slips through the retry logic introduced in #785, which only retried on stall/timeout. The issue provides a concrete CI failure trace (run 27443826381), identifies the exact line inrun_deploy_script(~L1240) where the hard bail happens, and proposes four concrete fix directions with clear tradeoffs. Actively blocks merges of unrelated PRs, requiring manual re-runs.📊 Assessment
bugadded; existingtechnical,medium,rust,testingretainedbugwas absent but clearly applicable;mediumpriority is consistent with the author's assessment (blocks PRs but has a manual workaround — re-run)🔗 Similar issues
forge scriptdeploy subprocess hangs unbounded, freezing the test for minutes #785 (related, closed) — Direct predecessor: fixed the stall/hang path by adding timeout + retry, but the non-zero-exit path was explicitly left as "deterministic" — this issue is the gap that remained💡 Notes and suggestions
Key diagnostic signal (for the fix author): the difference between a transient broadcast failure and a genuine revert can be reliably detected via stdout content:
Script ran successfully.+ aReturn ==/Deployment { ... }block, then cuts off at## Setting up 1 EVM.Revert/Errorline present, or theScript ran successfully./Returnblock is absent entirelyRecommended approach — direction 1 (smartest retry):
In
run_deploy_script, on a non-zero exit, inspect stdout for the script-success markers before deciding whether to bail or retry. Pseudocode:This preserves fast-fail on genuine reverts while making broadcast hiccups retryable.
Direction 3 (simpler): If the marker-inspection approach feels fragile, treating all non-zero exits as retryable up to
DEPLOY_ATTEMPTS(already small at 2) is a safe fallback — worst case you see one extra attempt on a real revert, which still fails with the full output.Direction 4 (quick win, independent): Fix the misleading
retrying after {timeout:?}log — it implies a 45s sleep but the loop retries immediately. This is a one-line fix and should be done regardless of which retry strategy is chosen.Also consider: adding
--slowto theforge script --broadcastinvocation (direction 2) as defense-in-depth; it reduces inter-tx RPC races that cause these broadcast hiccups without changing retry logic.Sub-task checklist:
run_deploy_scriptto retry broadcast-phase non-zero exits (directions 1 or 3)retrying after {timeout:?}log message (direction 4, independent)--slowto forge broadcast invocation to reduce RPC contentionAdd this agentic workflows to your repo
To install this agentic workflow, run
yigitdot commentedon Jun 13, 2026
Recurred on CI for PR #886 (a node-only region-accounting change that touches no contracts/anvil — purely infrastructural): stall on deploy attempt 1, then a broadcast-phase non-zero exit on attempt 2 (
Failed to send transaction after 4 attempts … replacement transaction underpriced/nonce too low, error-32003), with the script body itself having completed (Script ran successfully+ a fullDeployment { … }returned).On re-running: it's a real but unreliable workaround. Because the failure is driven by runner CPU contention, a re-run often clears it — but not always. The retry budget is only
DEPLOY_ATTEMPTS = 2, and both the stall path and the broadcast-race path draw from it; this run burned attempt 1 on a stall and attempt 2 on a broadcast hiccup, so the whole test failed with no attempts left. A fresh CI re-run can land in the same contention and fail again. So 'just re-run it' sometimes works, sometimes doesn't, and it always costs a manual round-trip on PRs unrelated to on-chain settlement.Suggestion (durable fix, in
run_deploy_script):--slowto the forge broadcast so transactions are submitted sequentially and each receipt is awaited before the next — removes the concurrent-sendnonce too low/replacement transaction underpricedclass at the source (negligible wall-clock on instant-mining anvil).Script ran successfullymarker (present → script body completed → transient broadcast failure → retry; absent → real revert/script bug → fail fast with full output, as today).DEPLOY_ATTEMPTSto 3 for headroom, since stalls and broadcast hiccups now share one budget.Until that lands, re-running remains the only mitigation and is not guaranteed to pass.
fix(node): make final-attempt deploy bail messages mode-accurate (#883 …
fix(node): retry forge DeployProtocol broadcast-phase non-zero exits (#…