diff --git a/crates/evm/src/eth/block.rs b/crates/evm/src/eth/block.rs index 24cf34a6..b3f116ca 100644 --- a/crates/evm/src/eth/block.rs +++ b/crates/evm/src/eth/block.rs @@ -38,6 +38,8 @@ pub struct EthBlockExecutionCtx<'a> { pub withdrawals: Option>, /// Block extra data. pub extra_data: Bytes, + /// Block transactions count hint. Used to preallocate the receipts vector. + pub tx_count_hint: Option, } /// Block executor for Ethereum. @@ -72,10 +74,11 @@ where { /// Creates a new [`EthBlockExecutor`] pub fn new(evm: Evm, ctx: EthBlockExecutionCtx<'a>, spec: Spec, receipt_builder: R) -> Self { + let tx_count_hint = ctx.tx_count_hint.unwrap_or_default(); Self { evm, ctx, - receipts: Vec::new(), + receipts: Vec::with_capacity(tx_count_hint), gas_used: 0, blob_gas_used: 0, system_caller: SystemCaller::new(spec.clone()),