feat(rollup): persist block hash and resume via set_with_head#60
Open
temrjan wants to merge 1 commit into
Open
feat(rollup): persist block hash and resume via set_with_head#60temrjan wants to merge 1 commit into
temrjan wants to merge 1 commit into
Conversation
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>
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.
What
Adds a
hashcolumn to theblocktable so the rollup can record the hash of every block it processes. On startup, a newDatabase::highest_blockreads the latest persisted(number, hash)andRollup::newcallsExExNotificationsStream::set_with_headwith it — reth backfills any L1 blocks committed while the rollup was offline.Why — and fixes two pre-existing bugs
reth_revm::Database::block_hashwas unusable. It selected ahashcolumn fromblock, but the schema never had one. Any EVM execution touching theBLOCKHASHopcode would crash on startup. The new column makes the trait method actually work.ORDER BY number DESCsorted lexicographically.numberisTEXT, so"9"ranked above"10". BothDatabase::highest_block(new) andDatabase::revert_tip_block(pre-existing) now useORDER 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.dbbefore running this version. The previously committedrollup.dbfixture is removed as part of this change.Testing
cargo build -p rollupcargo test -p rollup— 4 passed (was 1; added: empty DB, latest persisted, numeric ordering regression)cargo clippy -p rollup --all-targets --all-features -- -Dwarningscargo +nightly fmt --all --checkcargo +nightly doc -p rollup --all-features --no-deps --document-private-itemswithRUSTDOCFLAGS="-D warnings"@mattsse happy to adjust the schema migration approach (currently relies on "delete old DB") or the location of the
set_with_headcall if you'd prefer a different design.Refs: #25