op-supernode: Full rewind deletes backfilled logs and invalidates valid blocks
Claude: I found this while I reviewed ethereum-optimism/optimism#22846.
A full rewind deletes every chain's logsDB, including the cold-start backfill. The backfill is the history the node needs to verify the timestamps it is about to replay. After the delete, the node invalidates valid blocks.
Event sequence
buildRewindPlanreturns a plan with a nilTargetHeadswhenlastTS <= firstVerifiableTimestamp(interop.go:953-961).applyRewindPlanthen callsdb.Clear()on every chain (interop.go:1065-1070).clearLockeddeletes the whole range and resetsfirstBlockto 0 (db.go:474-484).- Verification resumes at the first verifiable timestamp with an empty logsDB.
verifyExecutingMessagecallsContainsfor an initiating message that the backfill held (algo.go:229-231).Containsreturnsinterop.ErrFuturebecausehasBlocksis false (db.go:287-289).verifyInteropMessagestreats the error as an invalid executing message (algo.go:129-141).- The round applies
DecisionInvalidateand replaces a valid block.
Why the delete is wrong
The logsDB holds history below firstVerifiableTimestamp on purpose. runColdStartBackfill seals one message expiry window of history before the first verified timestamp (log_backfill.go:100-166). A rewind of the verified state to that timestamp does not make the backfill invalid. It is exactly the history the node needs to verify that timestamp again.
Why the node does not recover
Cold start runs once, from Start (interop.go:333). waitingForSync never returns to true, so no backfill re-runs in process.
A restart repairs the node only if the verifiedDB also emptied. If any commit survives, tryInitFromVerifiedDB resumes and skips backfill (interop.go:342-350).
Reachability
The window is narrow. A rewind removes one timestamp per round.
progressInterop calls buildRewindPlan(*obs.LastVerifiedTS) (interop.go:736). observeRound sets LastVerifiedTS from verifiedDB.LastTimestamp() (interop.go:600-603). So the plan always targets the last verified timestamp, not a reorg depth. The loop then re-checks SameL1Chain on the new last entry (interop.go:635-643) and repeats.
The verifiedDB has no pruning. firstTimestamp moves only in Rewind, and only downward or to empty (verified_db.go:254-290). So first stays at the first round the node ever verified, for the life of the data directory.
To reach lastTS <= first, the node must walk its verified DB back to the single first entry. The L1 reorg must invalidate the L1 inclusion of every verified timestamp. In practice the reorg depth must exceed the age of the verified DB. That gives two reachable cases:
- A young verified DB. A node that cold-started minutes ago holds a recent
L1Inclusionon its first entry. An ordinary one or two block L1 reorg reaches past it. If the node has verified exactly one timestamp,last == firstand any L1 inconsistency triggers the clear at once. - After an operator wipes the data directory, which is the documented recovery path. That returns the node to case 1.
A mature node is effectively immune. The reorg would have to be deeper than the whole run.
A rewind to the interop activation timestamp is harmless. runColdStartBackfill clamps commonStart to activationTimestamp (log_backfill.go:122), so nothing is retained below activation, and a message cannot reference a pre-activation block anyway.
The damaging case is a node that cold-starts long after activation. advanceColdStartInit sets verificationStartTimestamp to max(activation, max_c firstSafeHeadTS) (log_backfill.go:31-38). The backfill below that point is real data, and the clear destroys it.
Expected behavior
Truncate the logsDB to the last block that backfill sealed, instead of a full delete. Keep every block below firstVerifiableTimestamp. Clear the database only when the rewind reaches the interop activation timestamp.
In process, this is sufficient. After the verifiedDB empties, observeRound reads firstVerifiableTimestamp, which falls back to the unchanged verificationStartTimestamp (interop.go:235-245). So verification resumes at the same point that backfill ended.
Re-run backfill if the resume point can ever move later than the backfill end. verifyCanAddTimestamp rejects a gap larger than one block time (logdb.go:193-198), so a later resume point would wedge the seal path.
Related
- ethereum-optimism/optimism#20627 added
reconcileLogsDBTailand the backfill-path clear. - ethereum-optimism/optimism#19287 introduced the L1 reorg rewind handling.
- ethereum-optimism/optimism#22846 covers storage errors that cause invalidation. This issue is a separate cause of the same outcome.
Source: ethereum-optimism/optimism