.github/workflows: nightly fuzzing that keeps its corpus #39
The branch filter only sees the first 100 artifacts with this name. If other branches produce 100 newer artifacts, an unexpired corpus for the current branch is missed, so the job starts from seeds and saves a fresh corpus instead. Paginate the listing and select the newest matching artifact across all pages.
gh api --jq uses an embedded jq evaluator that does not load the process environment, so env.GITHUB_REF_NAME is null rather than the current branch name. The branch filter therefore discards the saved artifacts, and every nightly run starts from seeds again. Pipe the API response to jq and pass the branch explicitly with --arg so the corpus can actually be restored.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The corpus restore workflow filters on an unavailable branch environment value and searches only the first 100 artifacts, causing nightly runs to miss saved corpora and restart from seeds.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds nightly fuzzing that preserves its corpus between runs, complementing the existing short CI fuzz checks.
Changes:
| File | Description |
| ---- | ----------- |
| .github/workflows/fuzz.yml | Adds scheduled and manual fuzzing with corpus persistence and crash artifact uploads. |
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
The artifact lookup checks only the first 100 results, potentially missing an unexpired branch corpus and replacing its accumulated fuzzing data with a seed-only restart.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
Fixed in 36074bc1ea: the lookup now pages through every artifact with this name and takes the newest match. Checked against Erigon's nightly corpus artifacts with 2 per page: it picks the same run as a single page.
gh's --jq does read the process environment: GITHUB_REF_NAME=main gh api repos/erigontech/erigon --jq 'env.GITHUB_REF_NAME' prints main, and this restore step, run locally against Erigon's nightly artifacts, restored a 350-file corpus. Erigon's fuzz workflow uses the same filter. Keeping it.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
There are no active review issues blocking the persistent nightly fuzzing changes.
No open issues 🎉
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
ci.yml does not quite start from the seeds: setup-go's default cache restores GOCACHE, which holds the fuzz cache. For example, FuzzSum256 on macOS logs gathering baseline coverage: 0/18 with 6 seeds. That cache entry is saved once per key, so its corpus never grows. "ci.yml never grows the corpus" would be accurate here and in the description, and it also explains why cache: false is right in this job.
ci.yml makes this claim checkable in its log with the "Report CPU features" step, and this job does not have it. If a runner image loses BMI2 or SHA3, useASM is false and Sum256 falls back to x/crypto. The leg then compares x/crypto with itself and passes. Copying that step makes it visible.
The two arm64 legs fuzz the same code. keccak_arm64.go differs between them only in the init line that sets useASM, and both runners have SHA3 (asimd sha3 in the ci.yml log of ubuntu-24.04-arm). So both run keccakF1600Sha3 and the same Go sponge. Unless the Linux leg is there for the hardware, dropping one arm64 leg saves about 1 runner-hour a night.
This installs exactly Go 1.24.0 (go.mod has no toolchain line), so the golang/go#75804 workaround below stays until go.mod's go directive reaches 1.27. For a library that takes a long time. This job does not test the minimum Go version, so it can pin a recent release like the checks job in ci.yml does; with 1.27.x, lines 86–94 can go.
Does the kept corpus pay for this step and the upload? Coverage guidance sees only the Go code (the assembly is not instrumented), and in short local runs on amd64 (about 1.5 min per target) the corpus stopped growing at about 20–25 inputs per target. A plain nightly run without restore and upload might explore about the same. If you keep it, the corpus counts of the first few nights would show whether it grows.
"A failure here stops the leg" holds only because defaults.run.shell: bash runs the step with -eo pipefail. Under plain bash -e, a failing gh api inside the $(... | sort | tail | cut) pipeline leaves run empty: the step prints the warning, exits 0, and the seed-only corpus is uploaded as the newest one. set -euo pipefail at the top makes it independent of the defaults.
No blocking issues. I checked the restore lookup against Erigon's real corpus artifacts: it picks the newest one of the branch and restores the same $GOCACHE/fuzz/<module>/<FuzzName>/ layout that go test -fuzz reads. I also ran the fuzz step's exit paths with a fake go: the bare deadline output passes, while a reproducer or a real crash fails. The upload conditions also hold for a cancel and a timeout. Comments inline.
The main gap: a nightly failure notifies almost nobody. GitHub sends the failure of a scheduled run only to the user who created the workflow or last changed its cron line. Erigon's test-fuzz.yml has a notify job that opens or updates a nightly-fuzz issue. Without something like it, a crash shows up only as a red run in the Actions tab and a fuzz-crash-* artifact that expires. So either port that job or drop "the same as Erigon's" from the description.
Out of scope: ci.yml uploads its crash reproducers as fuzz-corpus-<os>, which now reads like one of these corpus artifacts. fuzz-crash-<os> would match this workflow.
Fixed in f52ef0f: the comment and the PR body now say ci.yml never grows the corpus.
Added the "Report CPU features" step in f52ef0f.
Dropped the macos-15 leg in f52ef0f; the job keeps amd64 BMI2 and arm64 SHA3 on ubuntu-24.04-arm.
Pinned Go 1.27.4 and removed the golang/go#75804 workaround in f52ef0f. Three 3 s FuzzSum256 runs on 1.27.4 exit 0.
Keeping it: the restore step logs the restored file count, so the first nights show whether the corpus grows. If it stays flat, I will drop the restore and the upload.
Added set -euo pipefail in f52ef0f.
Ported a small notify job in f52ef0f: a failed scheduled run opens or updates a nightly-fuzz issue with the run link. The "same as Erigon's" line is gone from the description. The ci.yml artifact rename is left for a separate change.
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues are reported for the persistent nightly fuzzing changes.
No open issues 🎉
<sub>Review effort: Balanced</sub>
AskAlexSharov
Problem
The fuzz steps in CI run 20 s per target and never grow the corpus: nothing saves it between runs, so the search never gets deeper than one short run.
Fix
A nightly job fuzzes each target for 30 min on each CPU implementation (amd64 BMI2, arm64 SHA3). Each run continues from the corpus the previous run saved as an artifact, and saves the grown corpus back. A crash uploads its reproducer, and a failed nightly run opens or updates a
nightly-fuzzissue.Cost
About 2 runner-hours a night on GitHub-hosted runners. The 20 s PR fuzz steps stay as they are.