refactor(watchdog): simplify to one-shot init/tick and harden for production#16
Merged
Merged
Conversation
…duction
Reshapes the watchdog to a single minimal compare path and closes the issues
found across review.
Simplify:
- One job, one shot. Removed the compare/advance mode split and the daemon loop.
`init` records the canonical bootstrap state once; `tick` runs exactly one
compare cycle and exits 0 (clean/idle) / 1 (transient) / 2 (divergence). Infra
schedules re-runs and enforces non-overlap via flock; no in-process loop/lock.
- Removed the verified-bit / advance-checkpoint provenance machinery: a persisted
checkpoint is verified by construction (only a successful compare writes one),
so the cheap-skip needs no extra state.
Harden / correctness:
- Crash-safe keep-1 checkpointing: atomic head.json pointer flip + predecessor
GC; only ever writes a fresh checkpoint dir (no destructive in-place rewrite).
- Bootstrap is verified at its own block before being trusted; exit 0 means
verified-or-idle on every path (fails closed to 1 or 2, never a false OK).
- Stream bisected eth_getLogs into the CM (no whole-range materialization),
order-equivalent to the global sort.
- L1 RPC URL supplied per tick, never persisted (no provider secret at rest).
Build / CI:
- Vendored lua-cURLv3 in-tree for a hermetic build (no build-time download or pin
to verify); Docker image builds and smoke-runs require('cartesi') in CI;
graceful scheduler Inspect (no guest panic on an unknown query).
- e2e drives the production binding incl. a real-component divergence test;
e2e prerequisites hard-fail instead of skipping vacuously.
Docs updated for init/tick, head.json / config.json / WATCHDOG_STATE_DIR, flock,
and the checkpoint-backup story.
stephenctw
approved these changes
Jun 21, 2026
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.
Reshapes the watchdog to a single minimal compare path and closes the issues found across review.
Simplify:
initrecords the canonical bootstrap state once;tickruns exactly one compare cycle and exits 0 (clean/idle) / 1 (transient) / 2 (divergence). Infra schedules re-runs and enforces non-overlap via flock; no in-process loop/lock.Harden / correctness:
initrecords the operator-provided bootstrap CM snapshot as the watchdog starting checkpoint; subsequenttickruns compare sequencer finalized state against CM replay when finalized inclusion advances.Build / CI:
Docs updated for init/tick, head.json / config.json / WATCHDOG_STATE_DIR, flock, and the checkpoint-backup story.