Skip to content

Wait for caffeination height before starting Espresso batcher#367

Merged
philippecamacho merged 9 commits intocelo-integration-rebase-14.2from
ag/batcher-timestamp
Mar 20, 2026
Merged

Wait for caffeination height before starting Espresso batcher#367
philippecamacho merged 9 commits intocelo-integration-rebase-14.2from
ag/batcher-timestamp

Conversation

@QuentinI
Copy link
Copy Markdown
Collaborator

@QuentinI QuentinI commented Mar 5, 2026

Block batcher startup until the L2 unsafe head reaches CaffeinationHeightL2, preventing the batcher from submitting blocks below the caffeination threshold. The block loader also clamps its start range to the caffeination height so pre-caffeination blocks are never enqueued.

Closes https://app.asana.com/1/1208976916964769/project/1209976130071762/task/1213545066241809

This PR:

Makes espresso-mode batcher respect CaffeinationHeightL2 - it will not start posting before the chain reaches that height

This PR does not:

Change anything else

Key places to review:

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Espresso batcher's operational logic by introducing a "caffeination height" mechanism. This ensures that the batcher only becomes active and processes blocks once the underlying L2 chain has reached a specified block height. This change prevents the batcher from interacting with or submitting blocks that are considered too early in the chain's progression, thereby aligning its behavior with specific chain state requirements.

Highlights

  • Batcher Startup Control: The Espresso batcher's startup is now blocked until the L2 unsafe head reaches a configured CaffeinationHeightL2, preventing it from submitting blocks below this threshold.
  • Block Loading Range Adjustment: The block loader's starting range for enqueuing blocks is clamped to CaffeinationHeightL2, ensuring that blocks prior to this height are never processed.
  • New Configuration Parameter: A new configuration parameter, CaffeinationHeightL2, has been introduced to specify the required L2 block height for the Espresso batcher to begin operation.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • op-batcher/batcher/driver.go
    • Introduced a call to waitForCaffeinationHeight to ensure the L2 chain reaches the specified height before the batcher registers.
  • op-batcher/batcher/espresso.go
    • Modified nextBlockRange to clamp the starting block number for enqueuing to CaffeinationHeightL2, preventing pre-caffeination blocks from being processed.
    • Implemented waitForCaffeinationHeight function, which actively polls the L2 sync status and blocks the batcher's operation until the L2 unsafe head reaches the configured CaffeinationHeightL2.
  • op-batcher/batcher/service.go
    • Introduced CaffeinationHeightL2 field to the BatcherConfig struct to store the required L2 block height for batcher activation.
    • Configured CaffeinationHeightL2 during the initialization of the Espresso batcher service.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a mechanism to delay the Espresso batcher startup until the L2 chain reaches a configurable CaffeinationHeightL2. This is achieved by adding a waiting loop at the beginning of the batcher startup process and clamping the block loading range to respect this height. The changes are logical and well-implemented. I have one suggestion to improve the polling logic in waitForCaffeinationHeight to avoid an unnecessary initial delay.

@jjeangal
Copy link
Copy Markdown
Member

One comment I thought about when reviewing this PR is that liveness can be broken by hardcoding the caffeinated height in the config to a very high value. This would prevent the batcher from posting anything and is a value that we don't include or planned to include in the enclave hash measurement.

@QuentinI
Copy link
Copy Markdown
Collaborator Author

QuentinI commented Mar 18, 2026

liveness can be broken by hardcoding the caffeinated height in the config to a very high value

@jjeangal can't one just not run the batcher at all if they wanted to? Enclave operator can always break liveness.

@QuentinI QuentinI force-pushed the ag/batcher-timestamp branch from 304daab to 13385d3 Compare March 18, 2026 11:38
@jjeangal
Copy link
Copy Markdown
Member

liveness can be broken by hardcoding the caffeinated height in the config to a very high value

@jjeangal can't one just not run the batcher at all if they wanted to? Enclave operator can always break liveness.

Yes that is true, just thinking out loud!

Copy link
Copy Markdown
Collaborator

@philippecamacho philippecamacho left a comment

Choose a reason for hiding this comment

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

LGTM

Note: I added some unit tests and have them run in CI.

Copy link
Copy Markdown
Collaborator

@philippecamacho philippecamacho left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@philippecamacho this is unnecessary, all espresso tests are run by integration tests job and all batcher tests are run by vanilla OP pipeline in CircleCI.

Copy link
Copy Markdown
Collaborator

@philippecamacho philippecamacho Mar 20, 2026

Choose a reason for hiding this comment

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

Ok, removed in 6e54181.

Base automatically changed from ag/move-batch-auth-to-derivation-pipeline to celo-integration-rebase-14.2 March 20, 2026 11:51
@QuentinI QuentinI force-pushed the ag/batcher-timestamp branch from 4ea8191 to 8d9a97e Compare March 20, 2026 12:04
QuentinI and others added 9 commits March 20, 2026 16:27
Block batcher startup until the L2 unsafe head reaches CaffeinationHeightL2,
preventing the batcher from submitting blocks below the caffeination threshold.
The block loader also clamps its start range to the caffeination height so
pre-caffeination blocks are never enqueued.

Co-authored-by: OpenCode <noreply@opencode.ai>
@philippecamacho philippecamacho merged commit 88a929e into celo-integration-rebase-14.2 Mar 20, 2026
46 of 47 checks passed
@philippecamacho philippecamacho deleted the ag/batcher-timestamp branch March 20, 2026 20:16
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.

3 participants