ethereum-optimism / ethereum-optimism/optimism
alloy-op-evm: reuse pool estimated da size and cache da scalar in OpBlockExecutor
- Dominant language
- Go
- Stars
- 6.5k
- Forks
- 4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 145
Description
With jovian active, `OpBlockExecutor::execute_transaction_without_commit` calls `jovian_da_footprint_estimation` for every transaction.
https://github.com/ethereum-optimism/optimism/blob/2258ea57dfad93ed72e7aa250bdcc00eb80dff64/rust/alloy-op-evm/src/block/mod.rs#L927
This is expensive as each call do:
- full fastLZ pass over the tx bytes via `op_revm::estimate_tx_compressed_size`
- 2 storage reads: `basic(L1_BLOCK_CONTRACT)` and `L1BlockInfo::fetch_da_footprint_gas_scalar`
https://github.com/ethereum-optimism/optimism/blob/2258ea57dfad93ed72e7aa250bdcc00eb80dff64/rust/alloy-op-evm/src/block/mod.rs#L507-L525
op-reth pool already lazily compute compressed size which can be used by the builder with `PoolTransaction::estimated_da_size()`
https://github.com/ethereum-optimism/optimism/blob/2258ea57dfad93ed72e7aa250bdcc00eb80dff64/rust/op-reth/crates/txpool/src/transaction.rs#L45
OpBlockExecutor could accept a caller supplied precomputed compressed size, e.g. alongside `WithEncoded` tx used if given, else fallback to compute it. Builder's implementors can then reuse pre-computation done in the pool.
Similarly, scalar is block-constant and can be fetched once and cached per block.
Initial benchmark saw a ~20% execution time improvement over a set of 200 simple txs.
Contributor guide
Research direction
Start in rust/alloy-op-evm/src/block/mod.rs at execute_transaction_without_commit and jovian_da_footprint_estimation, then read rust/op-reth/crates/txpool/src/transaction.rs for PoolTransaction::estimated_da_size(). Verify how WithEncoded transactions are passed and where the scalar is fetched. Done means reusing a supplied compressed-size estimate when available, falling back otherwise, and caching the block-constant scalar without changing execution results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- blockchain, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100