Skip to content

refactor: BlockExecutionStrategy API#14480

Merged
klkvr merged 6 commits intomainfrom
klkvr/wip-exec-transaction
Feb 19, 2025
Merged

refactor: BlockExecutionStrategy API#14480
klkvr merged 6 commits intomainfrom
klkvr/wip-exec-transaction

Conversation

@klkvr
Copy link
Member

@klkvr klkvr commented Feb 13, 2025

Based on #14578

Changes in this PR:

  • SystemCaller is refactored so that all its methods take an Evm as input. That way we can avoid having EvmConfig generic on it, and encourage callers to reuse Evms for both transaction and system calls execution, avoiding additional allocations
  • BlockExecutionStrategy is refactored, changes include:
    • It is made disposable, i.e strategy lifespan corresponds to a single executed block
    • a single strategy creates and reuses single Evm for entire block execution
    • strategy API now does not contain any inputs besides transactions

This PR unlocks the following improvements:

  1. None of BlockExecutionStrategy methods now require providing a full block as input making it suitable for re-use in block building. We still need an entire block to initialize the strategy though, and this can be changed by introducing a helper intermiddiate configuration struct for it. This struct would be implementation-specific and can be abstracted away like we do with EvmEnv
  2. Strategy having ownership over an EVM allows us to introduce Strategy::execute_transaction API without perf penalty for re-initializing EVM on every call. The benefit of this API is that it would make strategy API suitable for payload building when a set of transactions is determined dynamically and can't be passed as Vec<Tx> into execute_transactions

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this is fantastic

only have one suggestion

Comment on lines 35 to 36
Copy link
Collaborator

Choose a reason for hiding this comment

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

good change

@mattsse mattsse added A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library labels Feb 13, 2025
@emhane
Copy link
Collaborator

emhane commented Feb 15, 2025

makes impl interop for op-reth a bit easier since will req tx execution without block in tx pool, nice

@klkvr klkvr force-pushed the klkvr/wip-exec-transaction branch from 6101054 to 59546f4 Compare February 19, 2025 09:32
@klkvr klkvr changed the base branch from main to klkvr/refactor-system-caller February 19, 2025 09:32
@klkvr klkvr marked this pull request as ready for review February 19, 2025 09:41
@klkvr klkvr changed the title [wip] refactor: BlockExecutionStrategy API refactor: BlockExecutionStrategy API Feb 19, 2025
Base automatically changed from klkvr/refactor-system-caller to main February 19, 2025 10:21
@github-actions github-actions bot requested a review from rkrasiuk as a code owner February 19, 2025 10:21
@klkvr klkvr force-pushed the klkvr/wip-exec-transaction branch from ba94039 to 62a41a0 Compare February 19, 2025 10:45
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

cool, this should actually give us a nice smol perf boost

{
type Primitives = EthPrimitives;

type Strategy<DB: Database> = EthExecutionStrategy<DB, EvmConfig>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

imo we can erase this becasue this is intended for oneshot usage so can't think of a scenario where we would like to restrict this type

@klkvr klkvr added this pull request to the merge queue Feb 19, 2025
@klkvr klkvr removed this pull request from the merge queue due to a manual request Feb 19, 2025
@klkvr klkvr enabled auto-merge February 19, 2025 12:35
@klkvr klkvr added this pull request to the merge queue Feb 19, 2025
Merged via the queue into main with commit 4f454c9 Feb 19, 2025
41 checks passed
@klkvr klkvr deleted the klkvr/wip-exec-transaction branch February 19, 2025 13:24
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-execution Related to the Execution and EVM A-sdk Related to reth's use as a library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants