Skip to content

Commit

Permalink
smol touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Dec 23, 2024
1 parent 9fba491 commit 0650817
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use alloy_eips::{
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_primitives::{InvalidTransactionError, SealedBlock};
use reth_primitives_traits::{BlockBody, GotExpected};
use reth_storage_api::{AccountReader, StateProvider, StateProviderFactory};
use reth_storage_api::{StateProvider, StateProviderFactory};
use reth_tasks::TaskSpawner;
use std::{
marker::PhantomData,
Expand Down Expand Up @@ -182,7 +182,7 @@ where
&self,
origin: TransactionOrigin,
mut transaction: Tx,
state: &mut Option<Box<dyn StateProvider>>,
maybe_state: &mut Option<Box<dyn StateProvider>>,
) -> TransactionValidationOutcome<Tx> {
// Checks for tx_type
match transaction.tx_type() {
Expand Down Expand Up @@ -352,20 +352,19 @@ where
}
}

// Get or create provider
let state = if let Some(state) = state {
state
} else {
// If we don't have a state provider yet, fetch the latest state
if maybe_state.is_none() {
match self.client.latest() {
Ok(new_state) => {
*state = Some(new_state);
state.as_ref().unwrap()
*maybe_state = Some(new_state);
}
Err(err) => {
return TransactionValidationOutcome::Error(*transaction.hash(), Box::new(err))
}
}
};
}

let state = maybe_state.as_deref().expect("provider is set");

// Use provider to get account info
let account = match state.basic_account(transaction.sender()) {
Expand All @@ -383,11 +382,7 @@ where
// transactions.
if account.has_bytecode() {
let is_eip7702 = if self.fork_tracker.is_prague_activated() {
match self
.client
.latest()
.and_then(|state| state.bytecode_by_hash(account.get_bytecode_hash()))
{
match state.bytecode_by_hash(account.get_bytecode_hash()) {
Ok(bytecode) => bytecode.unwrap_or_default().is_eip7702(),
Err(err) => {
return TransactionValidationOutcome::Error(
Expand Down

0 comments on commit 0650817

Please sign in to comment.