Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.

fix(protocol/derive): fix singular batch extraction error handling#3059

Merged
theochap merged 2 commits intomainfrom
seb/fix-singular-batch-extr-err
Dec 3, 2025
Merged

fix(protocol/derive): fix singular batch extraction error handling#3059
theochap merged 2 commits intomainfrom
seb/fix-singular-batch-extr-err

Conversation

@sebastianst
Copy link
Contributor

@sebastianst sebastianst commented Nov 19, 2025

This is the same fix as ethereum-optimism/optimism#18283 for Kona.

Fixed for the post-Holocene BatchValidator and old BatchQueue. Unit tests added.

The derivation rule was technically in the specs already, but they get clarified with ethereum-optimism/specs#863.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

❌ Patch coverage is 97.77778% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.3%. Comparing base (e800861) to head (437c084).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
crates/protocol/protocol/src/batch/span.rs 96.6% 5 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch from a315f6c to f13c6ec Compare November 19, 2025 22:33
@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch 2 times, most recently from b6e55ee to b229171 Compare November 20, 2025 21:58
@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch 4 times, most recently from 390f77c to bc7f8e5 Compare December 1, 2025 12:09
@sebastianst sebastianst marked this pull request as ready for review December 1, 2025 12:09
Copilot AI review requested due to automatic review settings December 1, 2025 12:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes singular batch extraction error handling in the protocol derivation pipeline for post-Holocene batch validation. It addresses a scenario where overlapping span batches can pass prefix checks but contain batches with outdated L1 origins after the safe head. When such invalid batches are detected during extraction, the stage is now properly flushed and the error is handled consistently with dropped batches during prefix checks.

Key Changes:

  • Added validation check to detect and reject batches with L1 origins before the safe head L1 origin
  • Improved error handling in BatchStream to flush the stage when singular batch extraction fails
  • Refactored batch validation logic with clearer variable naming (batch_timestamp, batch_epoch)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
crates/protocol/protocol/src/batch/errors.rs Adds L1OriginBeforeSafeHead error variant for detecting outdated batch origins
crates/protocol/protocol/src/batch/span.rs Implements validation check in both get_singular_batches and check_batch methods, improves variable naming consistency, adds comprehensive test coverage
crates/protocol/derive/src/stages/batch/batch_stream.rs Updates error handling to properly catch extraction failures, flush the stage, and propagate errors; consolidates metrics code under feature flag

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch from bc7f8e5 to 08102f1 Compare December 1, 2025 21:09
@sebastianst sebastianst self-assigned this Dec 2, 2025
@theochap
Copy link
Member

theochap commented Dec 3, 2025

@sebastianst there are still a couple of tests failing. Can we fix those before we merge this PR?

@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch from 08102f1 to 0328a23 Compare December 3, 2025 18:18
@sebastianst sebastianst force-pushed the seb/fix-singular-batch-extr-err branch from 0328a23 to fe938c7 Compare December 3, 2025 18:24
@theochap theochap enabled auto-merge December 3, 2025 18:26
@theochap
Copy link
Member

theochap commented Dec 3, 2025

It seems that CI is stuck for this one. I am going to force merge it. I need to get this in asap

@theochap theochap disabled auto-merge December 3, 2025 20:26
@theochap theochap merged commit a52de0d into main Dec 3, 2025
40 of 46 checks passed
@theochap theochap deleted the seb/fix-singular-batch-extr-err branch December 3, 2025 20:26
theochap added a commit to ethereum-optimism/optimism that referenced this pull request Dec 10, 2025
…p-rs/kona#3059)

This is the same fix as
#18283 for Kona. Still
WIP.

Only fixed for the post-Holocene `BatchValidator` so far, old
`BatchQueue` still todo, but should be easy. Tests also still todo.

The derivation rule was technically in the specs already, but they get
clarified with ethereum-optimism/specs#863.

Co-authored-by: theo <80177219+theochap@users.noreply.github.com>
theochap added a commit to ethereum-optimism/optimism that referenced this pull request Jan 14, 2026
…p-rs/kona#3059)

This is the same fix as
#18283 for Kona. Still
WIP.

Only fixed for the post-Holocene `BatchValidator` so far, old
`BatchQueue` still todo, but should be easy. Tests also still todo.

The derivation rule was technically in the specs already, but they get
clarified with ethereum-optimism/specs#863.

Co-authored-by: theo <80177219+theochap@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants