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

feat(node/sequencer) Break apart Engine operations to prevent blocking#3018

Merged
op-will merged 19 commits intomainfrom
op-will/separateBuildAndSealTasks
Nov 11, 2025
Merged

feat(node/sequencer) Break apart Engine operations to prevent blocking#3018
op-will merged 19 commits intomainfrom
op-will/separateBuildAndSealTasks

Conversation

@op-will
Copy link
Collaborator

@op-will op-will commented Nov 5, 2025

Description

The main goal of this change is to allow engine processing to continue after block building has been initiated but before it has been sealed.

This is accomplished by:

  • Updating the EngineActor to
    • Make the BuildTask only initiate block building
    • Add a new SealTask to seal and insert the initiated block
  • Updating the SequencerActor loop to
    • Seal the last block and start the next block
    • Dynamically set the loop interval to account for sealing duration

Importantly the SequencerActor's build_block function no longer starts and completes block building in a single call but rather seals the last block if there was one, and starts the next. This means that the time spent waiting for the next tick will be during block building.

This also changes the EngineTask pattern within the SealTask such that if there was a caller (i.e. there exists a Sender to use to relay results), the task may not be retried if there is a "temporary" task error. While this diverges from existing patterns, it is a meaningful step toward #3021, which aims to pull logic out of the engine and into the appropriate actor. This gives the Sequencer more insight into and control over block building and timing.

Considerations

This PR creates a number of possible race conditions. One race condition that did not previously exist but has been introduced and mitigated is Build (FCU) -> Reset -> Seal.

A worthwhile exercise for a reviewer is to consider the other possible race conditions introduced and evaluate the feasibility of them occurring and impact if they happen.

Testing

While this PR is ready to review and passes existing e2e and acceptance tests, a byproduct of breaking apart the BuildTask is a number of possible race conditions. This PR aimed to address a number of them (e.g. detecting if the unsafe head changed between Build and Seal operations and retrying), but a worthwhile exercise will be to:

  1. List all possible EngineActor task race conditions that could result from this change
  2. Define expected behavior for each of those conditions
  3. Confirm via unit tests that behavior matches expected behavior.

There is also value in unit testing the logic in the different functions within SequencerActor and the affected EngineActor tasks.

Unfortunately the act of making the SequencerActor, EngineActor, and EngineTasks unit testable is a considerable amount of work. A different PR will be created, branching off of this PR to attempt that. This PR can be merged as is, as it meets current standards, but another reasonable option is to wait until kona is more unit testable and unit tests exist to demonstrate that the changes work as intended.

Other

Fixes #2978
Relates to #2848, #3021

The main goal of this change is to allow engine processing to
continue after block building has been initiated but before
it has been sealed.

This is accomplished by
- Updating the EngineActor to
  - Make the BuildTask only initiate block building
  - Add a new SealTask to seal and insert the initiated block
- Updating the SequencerActor loop to seal the last block and
start the next block. Importantly the build_block function no
longer starts and completes block building in a single call but
rather seals the last block if there was one, and starts the next.
This means that the time spent waiting for the next tick will be
_during block building_.
@claude
Copy link
Contributor

claude bot commented Nov 5, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@codecov
Copy link

codecov bot commented Nov 5, 2025

- Removing unused errors from Engine Tasks
- Renaming structs/variables to be clearer
- Updating documentation
- Extracting helper functions where useful
This allows the sequencer to branch on error type/severity
rather than fail if any error happens
Specifically, this catches the error in which a Build was
performed on a previous block because it had an out of date
view of the chain state
@op-will op-will force-pushed the op-will/separateBuildAndSealTasks branch from 8cb0f52 to e09906e Compare November 8, 2025 01:27
@op-will op-will marked this pull request as ready for review November 8, 2025 18:42
@claude
Copy link
Contributor

claude bot commented Nov 8, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@op-will op-will enabled auto-merge November 11, 2025 21:23
@op-will op-will added this pull request to the merge queue Nov 11, 2025
Merged via the queue into main with commit 1520b6b Nov 11, 2025
45 of 49 checks passed
@op-will op-will deleted the op-will/separateBuildAndSealTasks branch November 11, 2025 22:24
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Dec 10, 2025
op-rs/kona#3018)

# Description
The main goal of this change is to allow engine processing to continue
after block building has been initiated but before it has been sealed.

This is accomplished by:
- Updating the `EngineActor` to
    - Make the `BuildTask` only initiate block building
    - Add a new `SealTask` to seal and insert the initiated block
- Updating the `SequencerActor` loop to 
    - Seal the last block and start the next block
    - Dynamically set the loop interval to account for sealing duration

Importantly the `SequencerActor`'s `build_block` function no longer
starts and completes block building in a single call but rather seals
the last block if there was one, and starts the next. This means that
the time spent waiting for the next tick will be _during block
building_.

This also changes the `EngineTask` pattern within the `SealTask` such
that if there was a caller (i.e. there exists a `Sender` to use to relay
results), the task may not be retried if there is a "temporary" task
error. While this diverges from existing patterns, it is a meaningful
step toward op-rs/kona#3021, which aims to pull logic out of the engine and into
the appropriate actor. This gives the Sequencer more insight into and
control over block building and timing.

## Considerations
This PR creates a number of possible race conditions. One race condition
that did not previously exist but has been introduced and mitigated is
`Build` (FCU) -> `Reset` -> `Seal`.

A worthwhile exercise for a reviewer is to consider the other possible
race conditions introduced and evaluate the feasibility of them
occurring and impact if they happen.

## Testing
While this PR is ready to review and passes existing e2e and acceptance
tests, a byproduct of breaking apart the `BuildTask` is a number of
possible race conditions. This PR aimed to address a number of them
(e.g. detecting if the unsafe head changed between `Build` and `Seal`
operations and retrying), but a worthwhile exercise will be to:
1. List all possible `EngineActor` task race conditions that could
result from this change
1. Define expected behavior for each of those conditions
1. Confirm via unit tests that behavior matches expected behavior.

There is also value in unit testing the logic in the different functions
within `SequencerActor` and the affected `EngineActor` tasks.

Unfortunately the act of making the `SequencerActor`, `EngineActor`, and
`EngineTask`s unit testable is a considerable amount of work. A
different PR will be created, branching off of this PR to attempt that.
This PR _can_ be merged as is, as it meets current standards, but
another reasonable option is to wait until `kona` is more unit testable
and unit tests exist to demonstrate that the changes work as intended.

## Other 

Fixes op-rs/kona#2978
Relates to op-rs/kona#2848, op-rs/kona#3021
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 14, 2026
op-rs/kona#3018)

# Description
The main goal of this change is to allow engine processing to continue
after block building has been initiated but before it has been sealed.

This is accomplished by:
- Updating the `EngineActor` to
    - Make the `BuildTask` only initiate block building
    - Add a new `SealTask` to seal and insert the initiated block
- Updating the `SequencerActor` loop to 
    - Seal the last block and start the next block
    - Dynamically set the loop interval to account for sealing duration

Importantly the `SequencerActor`'s `build_block` function no longer
starts and completes block building in a single call but rather seals
the last block if there was one, and starts the next. This means that
the time spent waiting for the next tick will be _during block
building_.

This also changes the `EngineTask` pattern within the `SealTask` such
that if there was a caller (i.e. there exists a `Sender` to use to relay
results), the task may not be retried if there is a "temporary" task
error. While this diverges from existing patterns, it is a meaningful
step toward #3021, which aims to pull logic out of the engine and into
the appropriate actor. This gives the Sequencer more insight into and
control over block building and timing.

## Considerations
This PR creates a number of possible race conditions. One race condition
that did not previously exist but has been introduced and mitigated is
`Build` (FCU) -> `Reset` -> `Seal`.

A worthwhile exercise for a reviewer is to consider the other possible
race conditions introduced and evaluate the feasibility of them
occurring and impact if they happen.

## Testing
While this PR is ready to review and passes existing e2e and acceptance
tests, a byproduct of breaking apart the `BuildTask` is a number of
possible race conditions. This PR aimed to address a number of them
(e.g. detecting if the unsafe head changed between `Build` and `Seal`
operations and retrying), but a worthwhile exercise will be to:
1. List all possible `EngineActor` task race conditions that could
result from this change
1. Define expected behavior for each of those conditions
1. Confirm via unit tests that behavior matches expected behavior.

There is also value in unit testing the logic in the different functions
within `SequencerActor` and the affected `EngineActor` tasks.

Unfortunately the act of making the `SequencerActor`, `EngineActor`, and
`EngineTask`s unit testable is a considerable amount of work. A
different PR will be created, branching off of this PR to attempt that.
This PR _can_ be merged as is, as it meets current standards, but
another reasonable option is to wait until `kona` is more unit testable
and unit tests exist to demonstrate that the changes work as intended.

## Other 

Fixes #2978
Relates to #2848, #3021
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.

feat(node/engine): don't block the engine when building a new payload for the sequencer

2 participants