Skip to content

op-reth: default the pending block timestamp to the chain's block time - #24078

Merged
aakoshh merged 4 commits into
developfrom
seb/op-reth-pending-block-time
Nov 16, 2026
Merged

aakoshh merged 4 commits into
developfrom
seb/op-reth-pending-block-time

Conversation

@sebastianst

@sebastianst sebastianst commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Pending-state RPCs date the pending block 12 s, Ethereum's slot time, after its parent. On a 2 s OP chain that runs them up to 10 s ahead. From about five blocks before a hardfork, eth_call, eth_estimateGas, eth_createAccessList, debug_traceCall and trace_call at pending execute under the next fork's rules. The block they simulate is then that fork's activation block, which admits no user transactions. Away from forks, block.timestamp at pending is 10 s later than in the real next block. eth_callBundle at pending and mev_simBundle without a time override are affected the same way.

The pending block is now one block time after its parent. OpPendingEnvBuilder supplies a time override when the request sets none, and leaves the mirrored build_pending_env unchanged.

Block time source, first match wins:

  1. The new --rollup.block-time flag, for chains outside the registry, such as test chains not yet added.
  2. The superchain registry's block_time, looked up by the resolved chain ID, like --testing.sdm-fixed-policy's registry check. op-reth already embeds it; ChainMetadata now keeps it. The op-reth binary resolves this step, since only it builds with the registry; other binaries built on OpNode call superchain_block_time themselves.
  3. alloy-chains' block-time hint, rounded up to whole seconds as upstream's eth_simulateV1 does.
  4. 2 s, with a startup warning that pending timestamps may be off.

Without the registry value, 2 s would be wrong for some registry chains: settlus (mainnet and sepolia), giwa-sepolia and sepolia-devnet-5 (1 s), swan (5 s) and cyber-sepolia (10 s). On the last two the pending block would sit before the real next block, so near a fork pending calls would run under the old rules.

Devstack now passes --rollup.block-time from the rollup config, since devnet chains are in neither source.

eth_simulateV1 passes its per-block overrides through the same builder, so its spec now follows each simulated block's time. Its default spacing between simulated blocks is still upstream's: the alloy-chains hint, else 12 s.

Known gap: no test builds OpEthApi to check that the builder is wired in; the tests cover the builder (including a configured block time beating the hint) and the registry lookup.

Closes #22685

🤖 Co-created with Claude Opus 5.5

@sebastianst
sebastianst force-pushed the seb/op-reth-pending-block-time branch from 156f0e4 to 21f0157 Compare November 11, 2026 21:49
@sebastianst
sebastianst added this pull request to stack #24085 November 12, 2026 08:01
@sebastianst
sebastianst force-pushed the seb/op-reth-pending-block-time branch from bdbc4cc to 2722d62 Compare November 12, 2026 13:39
@sebastianst
sebastianst marked this pull request as ready for review November 12, 2026 13:40
@sebastianst
sebastianst requested a review from a team as a code owner November 12, 2026 13:40
@sebastianst
sebastianst force-pushed the seb/op-reth-pending-block-time branch from e5d0e51 to a0ee5fb Compare November 12, 2026 14:58
Base automatically changed from seb/op-reth-v2.7.0-1-mirrors to develop November 12, 2026 16:05
@sebastianst
sebastianst force-pushed the seb/op-reth-pending-block-time branch from a0ee5fb to 9ad226a Compare November 12, 2026 16:05

@aakoshh aakoshh left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description mentions the alternative of a block-time field in the chain spec, filled from the superchain registry. I think the data below makes that worth the chainspec change, and the change is smaller than it sounds, because op-reth already embeds the value. I compared the 2 s fallback with the registry, and for some chains it's wrong in both directions.

Where alloy-chains is wrong. I checked OpPendingEnvBuilder::new against block_time for all 58 chains in the superchain-registry checkout. alloy-chains 0.2.34 names 19 of them, and all 19 hints match. The other 39 get the 2 s fallback, which is wrong for 6:

Chain Registry block_time This PR pending is dated
settlus (mainnet, sepolia), giwa (sepolia), sepolia-devnet-5 1 s 2 s one block too far ahead
swan (mainnet) 5 s 2 s 3 s before the real next block
cyber (sepolia) 10 s 2 s 8 s before the real next block

The last two are the reverse of the bug this PR fixes: near a fork, pending calls run under the old rules while the real next block already has the new ones. A chain started from a genesis file, such as a 1 s devnet, gets 2 s as well. On the main pending paths a client can't correct it: eth_call, eth_estimateGas and the tracing calls build their environment with None overrides and apply the request's blockOverrides only afterwards (call.rs:923-925 in the fork), and the pool-built pending block takes no input at all.

op-reth already has the exact value. chainspec/build.rs puts each registry TOML into res/superchain-configs.tar in full, so the embedded configs/mainnet/swan.json has "block_time": 5. ChainMetadata is stripped down to chain_id, hardforks and optimism, so the value is dropped when it's parsed. Reading it there and exposing it on OpChainSpec would make the pending timestamp exact for every registry chain, without depending on alloy-chains to list a chain or on a dependency bump after a chain joins the registry.

A setting for the rest. Chains outside the registry still need a source. A --rollup.block-time flag would fit with the existing RollupArgs (--rollup.sequencer, --rollup.compute-pending-block, …). The order I'd suggest:

  1. --rollup.block-time, if set;
  2. the registry's block_time, for a registry chain;
  3. the alloy-chains hint;
  4. 2 s, with a startup warning that pending timestamps may be off.

The registry value being the default means most operators never set the flag, so it rarely gets the chance to disagree with op-node's rollup.json.

sebastianst and others added 4 commits November 16, 2026 19:22
Pending-state RPCs (eth_call, eth_estimateGas, eth_createAccessList,
debug_traceCall and trace_call at `pending`, plus eth_callBundle at
`pending` and mev_simBundle without a time override) derive the pending
block from their parent header with BuildPendingEnv, which dates it 12 s,
Ethereum's slot time, after its parent. On a 2 s OP chain that runs them up to 10 s
ahead: from about five blocks before a hardfork they execute under the
next fork's OpSpecId, and a pending block built on that environment is
the fork's activation block, which admits no user transactions.

OpEthApiBuilder now installs OpPendingEnvBuilder as the EthApi's
PendingEnvBuilder. When a request sets no `time` override, it sets one
of the parent's timestamp plus the chain's block time and leaves the rest
to BuildPendingEnv, so the mirrored build_pending_env stays unchanged.

The block time comes from alloy-chains' average_blocktime_hint for the
chain id, rounded up to whole seconds as upstream's eth_simulateV1 does,
with a 2 s fallback for chains without a hint. A block time field in the
chain spec, from the superchain registry, would be exact for every chain
instead.

eth_simulateV1 is unaffected: it sets every block's time override before
this builder runs (with upstream's 12 s fallback for chains without a
hint), and since #28431 build_pending_env honours it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gistry

The pending block's block time now comes from --rollup.block-time if set,
else the superchain registry's block_time for the resolved chain ID, else the
alloy-chains hint, else 2 s with a warning. The 2 s fallback is wrong for
registry chains with 1 s, 5 s and 10 s blocks; on the slower ones the pending
block sat before the real next block. Devstack passes the flag from the
rollup config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sebastianst
sebastianst force-pushed the seb/op-reth-pending-block-time branch from 9ad226a to 6b84621 Compare November 16, 2026 18:31
@sebastianst

Copy link
Copy Markdown
Member Author

🤖 Opus 5.5 says: Done in 6b84621, with the precedence you suggested:

  1. --rollup.block-time, if set.
  2. The registry's block_time for the resolved chain ID. ChainMetadata now keeps it, and superchain_block_time sits next to is_superchain_chain_id. The op-reth binary resolves this step, since only it builds with the superchain-configs feature.
  3. The alloy-chains hint.
  4. 2 s, with a startup warning.

Devstack also passes the flag from the rollup config, so devnets with 1 s blocks get the right pending timestamp. The branch is rebased onto develop.

@aakoshh aakoshh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@aakoshh
aakoshh added this pull request to the merge queue Nov 16, 2026
Merged via the queue into develop with commit 416bb19 Nov 16, 2026
116 of 117 checks passed
@aakoshh
aakoshh deleted the seb/op-reth-pending-block-time branch November 16, 2026 20:26
jelias2 added a commit that referenced this pull request Nov 16, 2026
rust/op-reth/crates/node/src/args.rs: #24078 on develop and this branch
each added a test after `test_proofs_storage_version_accepts_only_v2`.
Both tests are kept.
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.

op-reth: pending block env uses parent.timestamp + 12 (L1 slot time) on OP chains

2 participants