Skip to content

Commit 26e20ac

Browse files
committed
explicit
1 parent 37ac939 commit 26e20ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

crates/client/metering/src/meter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
use std::{collections::HashMap, sync::Arc, time::Instant};
44

55
use alloy_consensus::{BlockHeader, Transaction as _, transaction::SignerRecoverable};
6-
use alloy_primitives::{B256, U256};
6+
use alloy_primitives::{Address, B256, U256};
77
use base_bundles::{BundleExtensions, BundleTxs, ParsedBundle, TransactionResult};
88
use eyre::{Result as EyreResult, eyre};
99
use op_revm::l1block::L1BlockInfo;
1010
use reth_evm::{ConfigureEvm, execute::BlockBuilder};
1111
use reth_optimism_chainspec::OpChainSpec;
1212
use reth_optimism_evm::{OpEvmConfig, OpNextBlockEnvAttributes};
13-
use reth_primitives_traits::SealedHeader;
13+
use reth_primitives_traits::{Account, SealedHeader};
1414
use reth_revm::{database::StateProviderDatabase, db::State};
1515
use reth_trie_common::TrieInput;
1616
use revm_database::states::{BundleState, bundle_state::BundleRetention};
@@ -153,7 +153,7 @@ where
153153

154154
// Pre-fetch account information for all transactions before creating builder. The
155155
// account information is used to validate the transaction.
156-
let mut accounts = HashMap::new();
156+
let mut accounts: HashMap<Address, Option<Account>> = HashMap::new();
157157
for tx in bundle.transactions() {
158158
let from = tx.recover_signer()?;
159159
let account = db.database.basic_account(&from)?;
@@ -181,9 +181,10 @@ where
181181
let gas_price = tx.max_fee_per_gas();
182182
let account = accounts
183183
.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))?
185185
.ok_or_else(|| eyre!("Account is none for tx: {}", tx_hash))?;
186186

187+
// Don't waste resources metering invalid transactions
187188
validate_tx(account, tx, &mut l1_block_info)
188189
.map_err(|e| eyre!("Transaction {} validation failed: {}", tx_hash, e))?;
189190

@@ -256,6 +257,7 @@ mod tests {
256257
use reth_provider::StateProviderFactory;
257258
use reth_revm::{bytecode::Bytecode, primitives::KECCAK_EMPTY, state::AccountInfo};
258259
use reth_transaction_pool::test_utils::TransactionBuilder;
260+
use revm_context_interface::transaction::{AccessList, AccessListItem};
259261

260262
use super::*;
261263

@@ -685,8 +687,6 @@ mod tests {
685687

686688
#[tokio::test]
687689
async fn meter_bundle_err_interop_tx() -> eyre::Result<()> {
688-
use revm_context_interface::transaction::{AccessList, AccessListItem};
689-
690690
let harness = TestHarness::new().await?;
691691
let latest = harness.latest_block();
692692
let header = latest.sealed_header().clone();

0 commit comments

Comments
 (0)