Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ reth-evm = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e1
reth-evm-ethereum = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1" }
reth-exex = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1" }
reth-exex-test-utils = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1" }
reth-execution-cache = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1" }
reth-execution-errors = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1", default-features = false }
reth-execution-types = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1", default-features = false }
reth-fs-util = { git = "https://github.com/op-rs/reth", rev = "aef8d3ef92117f91455e16969f0adf5bf7c6e9e1" }
Expand Down
1 change: 1 addition & 0 deletions rust/op-reth/crates/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ reth-revm = { workspace = true, features = ["witness"] }
reth-transaction-pool.workspace = true
reth-storage-api.workspace = true
reth-evm.workspace = true
reth-execution-cache.workspace = true
reth-execution-types.workspace = true
reth-payload-builder-primitives.workspace = true
reth-payload-util.workspace = true
Expand Down
26 changes: 24 additions & 2 deletions rust/op-reth/crates/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use reth_evm::{
BlockBuilder, BlockBuilderOutcome, BlockExecutionError, BlockExecutor, BlockValidationError,
},
};
use reth_execution_cache::{CachedStateMetrics, CachedStateMetricsSource, CachedStateProvider};
use reth_execution_types::BlockExecutionOutput;
use reth_metrics::{
Metrics,
Expand Down Expand Up @@ -254,7 +255,9 @@ where
Txs:
PayloadTransactions<Transaction: PoolTransaction<Consensus = N::SignedTx> + OpPooledTx>,
{
let BuildArguments { mut cached_reads, config, cancel, best_payload, .. } = args;
let BuildArguments {
mut cached_reads, execution_cache, config, cancel, best_payload, ..
} = args;

let ctx = OpPayloadBuilderCtx {
evm_config: self.evm_config.clone(),
Expand All @@ -267,7 +270,26 @@ where

let builder = OpBuilder::new(best);

let state_provider = self.client.state_by_block_hash(ctx.parent().hash())?;
let mut state_provider = self.client.state_by_block_hash(ctx.parent().hash())?;

// Serve account, storage and bytecode reads from the engine's cache when it shares one.
// Trie and proof reads still go to the inner provider, which `CachedStateProvider`
// delegates to, so the state root walk in `BlockBuilder::finish` is unaffected. The
// provider reads without ever filling (`CacheFillMode::LookupOnly`), keeping the builder
// out of the engine's way.
if let Some(execution_cache) = execution_cache {
// The cache is only sound on the parent it was populated against. `get_cache_for`
// repairs a stale slot with `clear_with_hash(parent_hash)` before handing it out, so a
// mismatch means reth broke that contract, not a case to handle at runtime.
debug_assert_eq!(execution_cache.executed_block_hash(), ctx.parent().hash());

state_provider = Box::new(CachedStateProvider::new(
state_provider,
execution_cache.cache().clone(),
Some(CachedStateMetrics::zeroed(CachedStateMetricsSource::Builder)),
));
}

let state = StateProviderDatabase::new(&state_provider);

if ctx.attributes().no_tx_pool() {
Expand Down
Loading