|
3 | 3 | use std::{collections::HashMap, sync::Arc, time::Instant}; |
4 | 4 |
|
5 | 5 | use alloy_consensus::{BlockHeader, Transaction as _, transaction::SignerRecoverable}; |
6 | | -use alloy_primitives::{B256, U256}; |
| 6 | +use alloy_primitives::{Address, B256, U256}; |
7 | 7 | use base_bundles::{BundleExtensions, BundleTxs, ParsedBundle, TransactionResult}; |
8 | 8 | use eyre::{Result as EyreResult, eyre}; |
9 | 9 | use op_revm::l1block::L1BlockInfo; |
10 | 10 | use reth_evm::{ConfigureEvm, execute::BlockBuilder}; |
11 | 11 | use reth_optimism_chainspec::OpChainSpec; |
12 | 12 | use reth_optimism_evm::{OpEvmConfig, OpNextBlockEnvAttributes}; |
13 | | -use reth_primitives_traits::SealedHeader; |
| 13 | +use reth_primitives_traits::{Account, SealedHeader}; |
14 | 14 | use reth_revm::{database::StateProviderDatabase, db::State}; |
15 | 15 | use reth_trie_common::TrieInput; |
16 | 16 | use revm_database::states::{BundleState, bundle_state::BundleRetention}; |
@@ -153,7 +153,7 @@ where |
153 | 153 |
|
154 | 154 | // Pre-fetch account information for all transactions before creating builder. The |
155 | 155 | // account information is used to validate the transaction. |
156 | | - let mut accounts = HashMap::new(); |
| 156 | + let mut accounts: HashMap<Address, Option<Account>> = HashMap::new(); |
157 | 157 | for tx in bundle.transactions() { |
158 | 158 | let from = tx.recover_signer()?; |
159 | 159 | let account = db.database.basic_account(&from)?; |
@@ -181,9 +181,10 @@ where |
181 | 181 | let gas_price = tx.max_fee_per_gas(); |
182 | 182 | let account = accounts |
183 | 183 | .get(&from) |
184 | | - .ok_or_else(|| eyre!("Account not found for address: {}", from))? |
| 184 | + .ok_or_else(|| eyre!("Account not found in HashMap for address: {}", from))? |
185 | 185 | .ok_or_else(|| eyre!("Account is none for tx: {}", tx_hash))?; |
186 | 186 |
|
| 187 | + // Don't waste resources metering invalid transactions |
187 | 188 | validate_tx(account, tx, &mut l1_block_info) |
188 | 189 | .map_err(|e| eyre!("Transaction {} validation failed: {}", tx_hash, e))?; |
189 | 190 |
|
@@ -256,6 +257,7 @@ mod tests { |
256 | 257 | use reth_provider::StateProviderFactory; |
257 | 258 | use reth_revm::{bytecode::Bytecode, primitives::KECCAK_EMPTY, state::AccountInfo}; |
258 | 259 | use reth_transaction_pool::test_utils::TransactionBuilder; |
| 260 | + use revm_context_interface::transaction::{AccessList, AccessListItem}; |
259 | 261 |
|
260 | 262 | use super::*; |
261 | 263 |
|
@@ -685,8 +687,6 @@ mod tests { |
685 | 687 |
|
686 | 688 | #[tokio::test] |
687 | 689 | async fn meter_bundle_err_interop_tx() -> eyre::Result<()> { |
688 | | - use revm_context_interface::transaction::{AccessList, AccessListItem}; |
689 | | - |
690 | 690 | let harness = TestHarness::new().await?; |
691 | 691 | let latest = harness.latest_block(); |
692 | 692 | let header = latest.sealed_header().clone(); |
|
0 commit comments