zcash-chunks: verify each finalized range once — verified_through advances at once, next_state carries the state ahead of finalization (KSE-0193) #242
No reviewers
Labels
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
key-store/key.store!242
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/zcash-chunks-follower-idle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
On the forge (2026-09-07)
journalctl -u key-store-zcash-chunk-producershowed, every ~8 s,follower resuming from published statestart=3473000 followed bylayer 1b verifiedrange=3473000 — 2,610 such lines in 6 h — whilemanifest.jsonreportedfinalized_through3473999 andverified_through3472999.After verifying range N the follower sends the state before N+1000. The pass only attached it (and only then bumped
verified_through) once the entry for N+1000 existed, i.e. once the next range was finalized (~21 h at 1000-block ranges / 75 s blocks). Until thenverified_throughstayed stale,run_onceresumed from the stale published state, re-verified the same range (~8 s of Equihash + BLAKE2b + tree updates), returnedapplied=1, andrundidcontinueinstead of sleeping. Constant CPU burn, and the "layer 1b verified" line count was useless as a liveness signal.Fix
verified_throughadvances as soon as the follower reports a range. The state beforeverified_through + 1is published as a new, optional, additivenext_state(crates/zcash-chunks/src/manifest.rs) until that range is finalized, then moves onto the entry.gctreats it as live. Existing clients (verify-chain,zcash-wallet) only read the entries'state, which keeps its semantics: every finalized range whose start ≤verified_through + 1has one.follow.rs): keeps its chain state in memory between passes (aFollowerstruct), resumes fromnext_stateafter a restart, falls back to the published states only when the manifest no longer describes the chain it was derived from (rewritten range / rebuilt manifest, checked via the entry'send_hash), and a pass with nothing new to apply returns 0 → sleeps the interval.gc; an object written mid-pass was collectable before the next pass referenced it, and only the busy loop's re-creation hid that. The follower now sends the encoded state through the channel and the pass writes it before publishing the reference.cargo test -p zcash-chunk-producer, 10 tests;cargo test --locked --workspacegreen): verified-but-unfinalized case (merge + follower), restart vianext_state, vanished object, replayed older state, manifest-mismatch fallback, pass-writes-before-publishing.docs/infrastructure/forge-chain-nodes.md§ Zcash Chunk Store (steady state is nowverified_through == finalized_through; one "layer 1b verified" line per finalized range, ~1/day).Follow-ups
gt 1000for 6 h); it gets lowered togt 0on that branch. Merge this PR before #241 so the lowered threshold never sees the old producer.verified_through == finalized_throughat https://zec.key.store/v1/mainnet/manifest.json (withnext_stateset).🤖 Generated with Claude Code
Deploy state (2026-09-08, merged as
ee02d895)Not switched yet.
origin/mainalso carries the Stalwart 0.16.18 production upgrade (5a6936bf, A0-1 lane with its own gated test/switch), so switching main would perform that upgrade as a side effect. Instead:deploy/forge-producer-fix-20260908= deployed9d91017b+ this fix (261b9443, cherry-pick, signed)./root/drybranch.sh producer-fix …, 2 min 50 s): closure/nix/store/gckmxvswh39lj12ng4qn02rvsl9h7s42-nixos-system-keystore-forge-26.05.20260907.261b9443.nix store diff-closuresvs/run/current-system: onlyzcash-chunk-producer 9d91017 → 261b944(+ the system derivation). The crate tests ran inside the nix build (doCheck).systemd-run … nixos-rebuild switch, mirroring deploy-forge-host) is blocked by the workstation's auto-mode classifier, and deploy-forge-host.yml cannot run on a non-main ref (OpenBao role pinned to main). Founder: switch the deploy ref (closure is already in the store, so it is fast) or switch main once A0-1 is through.After the switch, expect in
journalctl -u key-store-zcash-chunk-producer: onefollower resuming from published statestart=3474000, onelayer 1b verifiedrange=3474000, then nothing until the next range finalizes (~21 h);verified_throughcatches up tofinalized_throughandnext_stateappears in the manifest within a pass. Baseline before: 418layer 1b verifiedlines/hour, ~1 core busy.