Repository navigation
fix(node): retry forge DeployProtocol broadcast-phase non-zero exits (#883) - #897
Conversation
…883) The anvil-e2e deploy retry loop only retried *stalls* (timeouts, #785); a transient non-zero exit during the forge broadcast / tx-submission phase — where the script body already completed (`Script ran successfully`) but tx submission hit a nonce/RPC/anvil hiccup under CPU contention — was treated as a deterministic failure and bailed immediately, flaking unrelated PRs. - Classify non-zero exits via `forge_script_body_completed` (success-marker present ⇒ transient broadcast hiccup ⇒ retry; absent ⇒ genuine revert/script bug ⇒ fail fast with full output). - Bump DEPLOY_ATTEMPTS 2 → 3: the observed flake was stall-then-broadcast-hiccup, two now-retryable classes that each consumed an attempt, so 2 was insufficient. - Fix the misleading "retrying after {timeout}" log (#883 note 4) that implied a 45s sleep that never happens — the retry is immediate. - Unit-test the classifier (retryable broadcast failure, genuine revert, empty). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request improves the resilience of the end-to-end anvil settlement tests by handling transient forge script failures during the broadcast phase. It increases the deployment attempts to 3 and introduces a helper function forge_script_body_completed to detect if a non-zero exit occurred after the script body successfully completed (indicating a transient broadcast/RPC issue rather than a deterministic revert). It also adds unit tests for this classification logic. The reviewer suggested optimizing the forge_script_body_completed function to perform a zero-allocation byte search on the stdout slice instead of allocating a new string via String::from_utf8_lossy.
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 reduces flakiness in the anvil-e2e integration test by retrying forge script DeployProtocol when it exits non-zero after the Solidity script body has already completed (i.e., failures in the broadcast/tx-submission phase), and by increasing deploy attempts to accommodate both stalls and broadcast hiccups.
Changes:
- Add
forge_script_body_completed(stdout)classifier (based on theScript ran successfullymarker) and unit tests for the classifier. - Update the deploy retry loop to retry broadcast-phase non-zero exits, and bump
DEPLOY_ATTEMPTSfrom 2 → 3. - Improve retry logging for stall timeouts to clarify that retries are immediate (no sleep).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…review)
The last-attempt bail messages claimed all attempts shared one failure mode
("…in the broadcast phase on all attempts" / "stalled on all attempts"), but
with mixed retryable modes (e.g. the stall-then-broadcast-hiccup sequence this
PR targets) only the final attempt's mode is known. Reword both to describe the
final attempt rather than asserting uniformity across attempts.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Coverage reportTotal: 86.01% (was 86.01%, ● 0.00%) — 35598/41387 lines No coverage data for changed Rust files. History
|
Summary
Fixes #883. The anvil-e2e
forge DeployProtocoldeploy retry loop (crates/node/tests/anvil_settlement_e2e.rs) only retried stalls (timeouts, #785). A transient non-zero exit during forge's broadcast / tx-submission phase — where the script body already completed (Script ran successfullyprinted, fullDeploymentstruct returned) but tx submission hit a nonce/RPC/anvil hiccup under CPU contention — was misclassified as a deterministic failure and bailed immediately, flaking unrelated PRs (observed on #882, which touches no contracts).The observed flake was stall-then-broadcast-hiccup: attempt 1 stalled (correctly retried), attempt 2 hit a broadcast-phase non-zero exit. With only 2 attempts both transient classes were exhausted and the test failed at ~72s, far under
OVERALL_TIMEOUT(780s).Changes
forge_script_body_completed(stdout) -> boolhelper (keys on forge'sScript ran successfullymarker): present ⇒ transient broadcast hiccup ⇒ retry; absent ⇒ genuine revert/script bug ⇒ fail fast with full output.DEPLOY_ATTEMPTS2 → 3 — the two now-retryable classes (stall + broadcast hiccup) can each consume an attempt, so 2 couldn't recover the observed sequence. Worst case 3×45s = 135s, safely insideOVERALL_TIMEOUT."retrying after {timeout}"implied a 45s sleep that never happens →"stalled (killed after {timeout}), retrying immediately".#[test]fns in theanvil e2eCI binary — no anvil/forge needed.Why not the other directions in the issue
--slow/ inter-tx delay): would lengthen every deploy and risk trippingDEPLOY_TIMEOUT; not needed once retries cover the hiccup.Known limitation
The retry-loop decision matrix (the stall-then-broadcast-hiccup last-attempt bail) is exercised only against live forge, not unit-tested —
run_deploy_scriptinvokesforgeinline, so making the loop unit-testable would require unix-onlystd::process::Outputconstruction or splitting decision from message-formatting (a worse abstraction for CI test infra). The genuinely-new logic (the classifier) is extracted and unit-tested; the loop is 4 plain arms. Deferred deliberately.Verification
The full live e2e (needs foundry) relies on CI; the flake is non-deterministic, so the fix is pinned by the unit-tested classifier rather than by forcing a live broadcast failure.
🤖 Generated with Claude Code