Skip to content

feat(rollup): persist block hash and resume via set_with_head#60

Open
temrjan wants to merge 1 commit into
paradigmxyz:mainfrom
temrjan:feat/rollup-resume-with-head
Open

feat(rollup): persist block hash and resume via set_with_head#60
temrjan wants to merge 1 commit into
paradigmxyz:mainfrom
temrjan:feat/rollup-resume-with-head

Conversation

@temrjan

@temrjan temrjan commented May 16, 2026

Copy link
Copy Markdown

What

Adds a hash column to the block table so the rollup can record the hash of every block it processes. On startup, a new Database::highest_block reads the latest persisted (number, hash) and Rollup::new calls ExExNotificationsStream::set_with_head with it — reth backfills any L1 blocks committed while the rollup was offline.

Why — and fixes two pre-existing bugs

  1. reth_revm::Database::block_hash was unusable. It selected a hash column from block, but the schema never had one. Any EVM execution touching the BLOCKHASH opcode would crash on startup. The new column makes the trait method actually work.

  2. ORDER BY number DESC sorted lexicographically. number is TEXT, so "9" ranked above "10". Both Database::highest_block (new) and Database::revert_tip_block (pre-existing) now use ORDER BY CAST(number AS INTEGER) DESC. A regression test guards it.

This is the rollup half of #25; op-bridge half is in #59.

Migration note

Schema changed — delete any existing rollup.db before running this version. The previously committed rollup.db fixture is removed as part of this change.

Testing

  • cargo build -p rollup
  • cargo test -p rollup — 4 passed (was 1; added: empty DB, latest persisted, numeric ordering regression)
  • cargo clippy -p rollup --all-targets --all-features -- -Dwarnings
  • cargo +nightly fmt --all --check
  • cargo +nightly doc -p rollup --all-features --no-deps --document-private-items with RUSTDOCFLAGS="-D warnings"

@mattsse happy to adjust the schema migration approach (currently relies on "delete old DB") or the location of the set_with_head call if you'd prefer a different design.

Refs: #25

Add a `hash` column to the `block` table so the rollup can record the
hash of every block it processes. On startup, the new
`Database::highest_block` method reads the latest persisted
`(number, hash)` and `Rollup::new` calls
`ExExNotificationsStream::set_with_head` with it, letting reth backfill
any L1 blocks committed while the rollup was offline.

This also fixes two pre-existing bugs:

* `reth_revm::Database::block_hash` selected a non-existent `hash`
  column from the `block` table. Adding the column makes the trait
  method work — previously every EVM execution touching the BLOCKHASH
  opcode would crash on startup.

* `ORDER BY number DESC` on a TEXT-typed `number` column sorted
  lexicographically — `"9"` ranked above `"10"`. Both
  `Database::highest_block` (new) and `Database::revert_tip_block`
  (pre-existing) now `ORDER BY CAST(number AS INTEGER) DESC`. A
  regression test guards against future reintroduction.

Note: schema changed — delete any existing `rollup.db` before running
this version. The previously committed `rollup.db` fixture is removed
as part of this change.

Refs: paradigmxyz#25

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant