Skip to content

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

Closed

Description

@sebastianst

Summary

op-reth's pending block environment is dated parent.timestamp + 12 — Ethereum's L1 slot time, inherited verbatim from upstream reth:

fn build_pending_env(
parent: &crate::SealedHeader<H>,
block_overrides: Option<&alloy_rpc_types_eth::BlockOverrides>,
) -> Self {
let mut attributes = Self {
timestamp: parent.timestamp().saturating_add(12),
suggested_fee_recipient: parent.beneficiary(),
prev_randao: B256::random(),
gas_limit: parent.gas_limit(),
parent_beacon_block_root: parent.parent_beacon_block_root(),
extra_data: parent.extra_data().clone(),
};

On a 2-second OP chain that is up to 5 blocks / 10 seconds ahead of the block the sequencer will actually produce, so eth_call / eth_estimateGas against pending can execute under a hardfork the real next block will not have activated.

What is actually served today

Without flashblocks: op-reth never builds a pending block from the txpool. OpEthApi's LoadPendingBlock impl overrides local_pending_block to return the latest canonical header (with an explicit pointer to op-geth's miner/worker.go), and local_pending_state to return None — so upstream's build_pool_pending_block → build_block path, which would execute pooled transactions, is never reached. Pending state falls through to state_by_block_id(Pending), i.e. the newPayload-not-yet-FCU block if one exists, else latest.

With flashblocks (--flashblocks-url, off by default) the pending block and pending state come from the flashblock overlay, and that block carries the sequencer's real timestamp via From<OpFlashblockPayloadBase> for OpNextBlockEnvAttributes.

But the EVM env is +12 either way. eth_call at pending gets its state from the flashblock overlay and its CfgEnv/BlockEnv from pending_block_env_and_cfg() → build_pending_env(latest_header). The real next-block timestamp is sitting in OpFlashblockPayloadBase and is not used for the env. So flashblocks fix the state path and not the timestamp path.

RPCs that consult the +12 env: eth_call, eth_estimateGas, eth_createAccessList, debug_traceCall, trace_call/trace_callMany, eth_callBundle, mev_simBundle — and every eth_simulateV1 block at any base block id, because upstream computes pending_env_attributes before applying block overrides, so an explicit time override corrects block_env.timestamp but not the spec already chosen from +12. eth_feeHistory rewrites pending → latest first and eth_gasPrice never touches it; both are unaffected.

Why the fork boundary matters, concretely. The pending timestamp reaches spec_by_timestamp_after_bedrock, which picks the OpSpecId. That spec then drives L1BlockInfo::try_fetch, which reads different L1Block storage slots per fork and selects a different L1-fee/operator-fee formula. Across an Isthmus or Jovian boundary a pending call reads the next fork's slots against pre-fork state. Base fee is largely immune (OpChainSpec::next_block_base_fee branches on the parent timestamp for the Holocene/Jovian paths).

Aside found while confirming this: --rollup.compute-pending-block is plumbed into OpPayloadBuilder.compute_pending_block and never read — is_compute_pending_block() has zero call sites. The override above unconditionally wins, so the flag is a no-op and should probably be removed or wired up.

What op-geth does

op-geth serves the head block as pending on every OP chain by default — miner.Pending():

if miner.chainConfig.Optimism != nil && !miner.config.RollupComputePendingBlock {
    // For compatibility when not computing a pending block, we serve the latest block as "pending"

RollupComputePendingBlock defaults to false. This landed in op-geth#93 ("miner,eth: latest block as pending block on rollup", merged 2023-05-26), for two reasons: not leaking txpool contents before the sequencer commits to them, and not paying to rebuild a pending block every 2 seconds. op-geth also skips upstream's nil-ing of hash/nonce/miner on OP chains, so eth_getBlockByNumber("pending") returns a real canonical block identical to latest.

Consequence: op-geth has no timestamp to get wrong. pending ≡ latest, so eth_call at pending executes under the head header — a real, past timestamp. There is no +12 and no L2 block-time constant anywhere in that path. (The opt-in --rollup.computependingblock path uses now() floored at parent.Time + 1, inherited from upstream geth. Upstream go-ethereum itself still builds a pending block from the txpool and is actively maintaining that code.)

Options

  1. Derive the timestamp from the chain's block time. The EL has no block time: OpChainSpec is a single-field newtype over reth's ChainSpec, and neither has any notion of slot duration. The value is already inside the binary — block_time = 2 ships in the embedded res/superchain-configs.tar — and is dropped by the 3-field ChainMetadata deserializer. Plumbing it in means widening ChainMetadata → ChainConfigExtraFields → From<Genesis> for OpChainSpec → a field/accessor on OpChainSpec, then a custom PendingEnvBuilder (today NextEnv = () dispatches to the chainspec-less BuildPendingEnv). Moderate, and it still leaves non-registry devnets uncovered without a CLI flag. kona's RollupConfig.block_time exists but op-reth has zero references to RollupConfig.
  2. parent.timestamp + 1. One line. It is the lower bound of the next block's timestamp for every OP block time, so pending can never activate a fork ahead of the real next block. It under-approximates by block_time - 1 seconds, which means pending behaves like latest w.r.t. forks — exactly what op-geth does. (max(parent+1, now) is worse: on a lagging or syncing node now overshoots arbitrarily.)
  3. Stop serving a locally built pending block. Already the case — op-reth mirrors op-geth here. Nothing to do; the gap is only the env.

Recommendation

Option 2, implemented in #22691. It removes the L1 slot-time assumption, makes pending conservative in the direction that cannot execute under a not-yet-active fork, and matches what op-geth already returns. Option 1 remains the "right" long-term answer if pending should ever model the actual next block (and would also let flashblocks supply their real timestamp to the env) — worth a follow-up, but it is a chainspec-plumbing change, not a one-liner.

There are no tests and no TODOs on build_pending_env today; the fix adds a fork-boundary regression test.

🤖 Co-created with Claude Fable 5

Activity

  1. self-assigned this
    on Sep 29, 2026
  2. removed their assignment
    on Oct 11, 2026
  3. self-assigned this
    on Nov 16, 2026
  4. sebastianst commented on Nov 16, 2026

    @sebastianst
    MemberAuthor

    🤖 Opus 5.5 says: #24078 fixes this with option 1, not option 2: the pending env is dated one block time after its parent. The block time comes from the first source that has one:

    1. a new --rollup.block-time flag
    2. the superchain registry's block_time for the chain ID
    3. the alloy-chains hint
    4. 2 s, with a warning

    Devstack passes the flag from the rollup config. #22691, the option-2 PR, was closed as stale.

    Left open by #24078:

    • eth_simulateV1: it passes each block's overrides into the same pending env builder, so the spec now follows the simulated block's time. Its default spacing between simulated blocks is still upstream's sanitize_chain: the alloy-chains hint, else 12 s. On chains without a hint, such as devnets and swan, simulated blocks without a time override are 12 s apart.
    • Flashblocks: the sequencer's real next-block timestamp in OpFlashblockPayloadBase is still not used for the pending env.
    • --rollup.compute-pending-block: still a no-op. is_compute_pending_block() has no callers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions