Skip to content

bug: Wrong computation of next L1 block timestamp on missed slots #14766

@spalladino

Description

@spalladino

In several places we compute the expected timestamp of the next L1 block as l1Client.getBlock().timestamp + ethereumSlotDuration. This allows us to query the expected state of the rollup contract on the next L1 block.

const time = (currentL1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);

const nextEthTimestamp = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));

const ts = BigInt((await this.publicClient.getBlock()).timestamp + BigInt(this.ethereumSlotDuration));

const timeOfNextL1Slot = (await this.client.getBlock()).timestamp + slotDuration;

const ts = BigInt((await this.l1TxUtils.getBlock()).timestamp + this.ethereumSlotDuration);

However, if there's a missing L1 block, then the next L1 block will land 24 seconds after the latest one, not 12. Using the wrong L1 timestamp affects the resulting L2 slot, which means we may operate under a wrong committee/proposer.

Note that missed L1 blocks are somewhat common, so we can definitely get hit by this.

I'm not sure about the best fix. One option is to avoid relying on l1Client.getBlock().timestamp, and use the system clock instead, assuming it's reasonably synchronized. Another option is to try and hit the consensus endpoint (as opposed to the execution), but I don't know if it'd be consistently reliable. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    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