Skip to content

op-acceptance-tests: make the SafeDB resync tests fail when history is lost #24105

Open

Description

@sebastianst

Follow-up to the review of #23827, which makes these tests run on op-reth.

Problem

TestTruncateDatabaseOnELResync ends with VerifySafeHeadDatabaseMatches(sys.L2CL) and no lower bound. checkSafeHeadConsistent walks the verifier's entries backward and stops silently at the first "not found", so the test passes whether the safe head database was kept, truncated and rebuilt, or cleared and only refilled with entries from after the resync. It cannot fail for the behaviour it is named after.

TestPreserveDatabaseOnCLResync has a floor, the verifier's live safe head at the start of the test, which is looser than the database's own floor.

What the clients do

An experiment on #23827's head recorded the verifier's entries before the wipe and after the resync, with op-node and with kona-node as the verifier CL:

  • Both truncate the database to genesis and rebuild it by re-deriving from L1. Every answer served before the wipe is served again afterwards.
  • On op-node the EL-sync completion policy keeps the database, because its tip is on the synced chain. The truncation comes from the engine reset that follows: after the wipe finalized is genesis and the devnet chain is shorter than the sequencer window, so the reset resumes from genesis.
  • So "truncate" and "preserve" both describe the mechanism loosely. The observable outcome in both tests is that history is served again.

Work

  • Read the database floor just before the wipe and require it afterwards, in both tests. SafeHeadDBFloor() and WithMinRequiredL2Block exist; the restart test in the same file already uses them:

    preWipeFloor := sys.L2CLB.SafeHeadDBFloor()
    sys.L2CLB.VerifySafeHeadDatabaseMatches(sys.L2CL, dsl.WithMinRequiredL2Block(preWipeFloor))
    // stop, wipe, restart, resync
    sys.L2CLB.VerifySafeHeadDatabaseMatches(sys.L2CL, dsl.WithMinRequiredL2Block(preWipeFloor))

    The floor must be read, not hard-coded: after its initial EL sync an op-node verifier has no entries below the block it synced to, while a kona-node verifier re-derives from genesis.

  • Assert the EL is at genesis after the restart, so the test proves the wipe happened (review comment on op-devstack,op-acceptance-tests: run EL-resync tests on op-reth #23827).

  • Rename the tests for the outcome, for example TestSafeHeadDBServesHistoryAfterELResync and …AfterCLResync.

  • docs/ai/safedb-review.md still says kona's safedb is "crate only; not yet wired"; it is wired to derivation and RPC.

The proposed assertions passed in the experiment with both CLs.

🤖 Co-created with Claude Opus 5.5 and Claude Fable 5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions