feat(fault-proof): add state backup/restore to challenger#848
Open
fakedev9999 wants to merge 5 commits into
Open
feat(fault-proof): add state backup/restore to challenger#848fakedev9999 wants to merge 5 commits into
fakedev9999 wants to merge 5 commits into
Conversation
The challenger re-syncs all games from index 0 on every restart. On chains with high dispute game volume, this means thousands of redundant on-chain calls before the challenger becomes operational. Add ChallengerBackup for persisting cursor + game cache to disk. On restart, state is restored from backup and forward sync resumes from cursor+1 instead of 0. Unlike the proposer, the challenger keeps forward sync (not backward) because it must monitor ALL games without gaps — missing one means an invalid game goes unchallenged. Closes #841
Contributor
|
- Use CHALLENGER_BACKUP_PATH env var (not BACKUP_PATH) to avoid collision with proposer when both run on same machine - Extract save_json() helper to deduplicate atomic write logic between ProposerBackup and ChallengerBackup - Use spawn_blocking for challenger backup I/O to avoid blocking the async runtime during fsync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add state backup/restore to the challenger, mirroring the proposer's backup mechanism (#756). The challenger re-syncs all games from index 0 on every restart — on chains with thousands of games this means thousands of redundant on-chain calls.
With backup enabled, the cursor and game cache persist to disk. On restart, state is restored and forward sync resumes from
cursor+1instead of 0.Why forward sync (not backward like proposer)
The proposer uses backward sync (latest → anchor) because it only needs recent games for canonical head calculation. The challenger must monitor all IN_PROGRESS games — missing one means an invalid game goes unchallenged. Forward sync guarantees no gaps.
The problem was "cursor resets to 0 on restart", not "forward direction". Backup solves this.
What's backed up
cursor(U256) — highest processed factory indexgames(Vec<Game>) — cached game metadataOn restore,
sync_state()step 2 recomputes allshould_attempt_to_*flags from on-chain state, so stale flags from backup are overwritten before any action.Closes #841
Configuration
Set
CHALLENGER_BACKUP_PATHin.env.challenger(optional):Note: uses a distinct env var from the proposer's
BACKUP_PATHto avoid conflicts when both run on the same machine.Test plan
cargo check -p op-succinct-fpcargo test -p op-succinct-fp --lib— 47/47 pass (includes new schema guard)cargo test --test backup -p op-succinct-fp— 21/21 pass (12 proposer + 9 challenger)cargo fmt/cargo clippyclean