Skip to content

feat: add into_block_raw methods to OpExecutionPayload types#570

Merged
mattsse merged 3 commits intomainfrom
feat/add-into-block-raw-methods
Jul 17, 2025
Merged

feat: add into_block_raw methods to OpExecutionPayload types#570
mattsse merged 3 commits intomainfrom
feat/add-into-block-raw-methods

Conversation

@mattsse
Copy link
Copy Markdown
Member

@mattsse mattsse commented Jul 16, 2025

Summary

This PR replicates the changes from alloy-rs/alloy#2684 for the OpExecutionPayload types, adding into_block_raw() methods to centralize block construction logic and eliminate code duplication.

Changes

  • Added into_block_raw() method to OpExecutionPayloadV4 that converts the payload to a block with raw transactions
  • Added into_block_raw() method to OpExecutionPayload enum that delegates to the appropriate variant
  • Added into_block_with_sidecar_raw() method to OpExecutionPayload for creating blocks with sidecar data
  • Refactored try_into_block_with and try_into_block_with_sidecar_with methods to use the new raw methods combined with Block::try_map_transactions

Motivation

The alloy PR #2684 introduced these methods to provide a cleaner API and reduce code duplication. By using into_block_raw() methods that return blocks with raw transaction bytes, we can then use Block::try_map_transactions to convert them to any transaction type, making the code more maintainable and flexible.

Notes

  • The implementation properly handles the fact that upstream alloy types return Result<Block<Bytes>, PayloadError> from their into_block_raw methods
  • All existing validation logic for Optimism-specific requirements (empty L1 withdrawals, no blob transactions) is preserved
  • Tests pass and formatting has been applied

Replicates changes from alloy-rs/alloy#2684 for OpExecutionPayload types:
- Add into_block_raw() to OpExecutionPayloadV4
- Add into_block_raw() to OpExecutionPayload enum
- Add into_block_with_sidecar_raw() to OpExecutionPayload

This provides the raw block construction methods without changing the existing
try_into_block_with implementations, keeping the PR focused on just adding
the new functionality.
@mattsse mattsse force-pushed the feat/add-into-block-raw-methods branch from 39ad3e4 to 50868f9 Compare July 16, 2025 17:09
@mattsse mattsse added this pull request to the merge queue Jul 17, 2025
Merged via the queue into main with commit d30168f Jul 17, 2025
21 checks passed
@mattsse mattsse deleted the feat/add-into-block-raw-methods branch July 17, 2025 14:33
@github-project-automation github-project-automation bot moved this from In Review to Done in Project Tracking Jul 17, 2025
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 21, 2026
…s/op-alloy#570)

## Summary

This PR replicates the changes from
alloy-rs/alloy#2684 for the OpExecutionPayload
types, adding `into_block_raw()` methods to centralize block
construction logic and eliminate code duplication.

## Changes

- Added `into_block_raw()` method to `OpExecutionPayloadV4` that
converts the payload to a block with raw transactions
- Added `into_block_raw()` method to `OpExecutionPayload` enum that
delegates to the appropriate variant
- Added `into_block_with_sidecar_raw()` method to `OpExecutionPayload`
for creating blocks with sidecar data
- Refactored `try_into_block_with` and
`try_into_block_with_sidecar_with` methods to use the new raw methods
combined with `Block::try_map_transactions`

## Motivation

The alloy PR #2684 introduced these methods to provide a cleaner API and
reduce code duplication. By using `into_block_raw()` methods that return
blocks with raw transaction bytes, we can then use
`Block::try_map_transactions` to convert them to any transaction type,
making the code more maintainable and flexible.

## Notes

- The implementation properly handles the fact that upstream alloy types
return `Result<Block<Bytes>, PayloadError>` from their `into_block_raw`
methods
- All existing validation logic for Optimism-specific requirements
(empty L1 withdrawals, no blob transactions) is preserved
- Tests pass and formatting has been applied
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.

2 participants