perf(txpool): reuse state provider across batch validation#87
perf(txpool): reuse state provider across batch validation#87
Conversation
…serde, update geth path
…ool txs are included fix(bench): use txpool path for L2 transactions instead of direct Engine API injection - Send transactions via eth_sendRawTransaction to enter txpool - assembleL2Block with empty transactions array, node pulls from txpool - Raise max_fee_per_gas and priority_fee for txpool acceptance - Add jadeForkTime to genesis for geth compatibility
…rking with resolve_kind fix
…ect Engine API injection
Comprehensive benchmark design covering three test modes (pure execution, end-to-end pipeline, sustained block production), three workloads (eth-transfer, erc20-transfer, uniswap-swap), multi-sender support, state degradation testing, automatic inflection point discovery, and chart generation.
14-task plan covering BenchSwap contract, tx_factory module, three benchmark modes (exec/e2e/sustained), sweep automation, extended metrics, chart generation, and orchestration script.
Avoid creating a new StateProvider for every transaction in validate_all(). Instead, lazily initialize one on the first call and reuse it for the rest of the batch. This leverages the existing validate_one_with_state() API from reth's EthTransactionValidator. The optimization matters as the state trie grows — opening a fresh provider per-tx becomes the dominant cost in txpool validation.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (16)
📝 WalkthroughWalkthroughAdds a comprehensive benchmarking binary Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as bench-block-exec
participant Genesis
participant Engine as Engine RPC
participant Txpool as Txpool
participant Node as L2 Node
User->>CLI: RunWorkload (layer, txs_per_block, blocks)
CLI->>Genesis: Load/read contract artifact (for ERC20)
Genesis-->>CLI: Bytecode
loop For each block
CLI->>CLI: Build transaction batch (eth_transfer or erc20_transfer)
CLI->>Txpool: eth_sendRawTransaction (batch)
Txpool-->>CLI: tx hashes
CLI->>Node: eth_getTransactionCount(..., "pending")
Node-->>CLI: pending nonce (poll until batch submitted)
CLI->>Engine: engine_assembleL2Block(params)
Engine->>Node: Pull txs from txpool
Node-->>Engine: Assembled block with txs
Engine-->>CLI: ExecutableL2Data + timing
CLI->>Engine: engine_newL2Block(data)
Engine->>Node: Import block
Node-->>Engine: Import complete
Engine-->>CLI: Timing measurement
CLI->>CLI: Record BlockTiming (block_number, tx_count, assemble_ms, import_ms, total_ms)
end
CLI->>CLI: Write results to JSONL
CLI-->>User: Summary (avg total_ms, effective TPS)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
StateProvideracross all transactions invalidate_all(), instead of creating a new one per-txvalidate_one_with_state()API from reth'sEthTransactionValidatorChanges
Only
crates/txpool/src/validator.rs:validate_one_with_state()wrapper that accepts&mut Option<Box<dyn AccountInfoReader + Send>>validate_all()to lazily initialize and reuse the state provider across the batchvalidate_one()delegates to the new method with&mut None(no behavior change for single-tx validation)Test plan
Summary by CodeRabbit
Release Notes
New Features
bench-block-execbenchmarking tool with support for genesis generation, transaction workload execution, state verification, and automated results analysis.Documentation