Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDhejavu committed Dec 12, 2024
1 parent 328d493 commit 9f65bb0
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use reth_storage_api::{AccountReader, StateProviderFactory};
use reth_tasks::TaskSpawner;
use std::{
marker::PhantomData,
sync::{atomic::AtomicBool, Arc},
sync::{
atomic::{AtomicBool, AtomicU64},
Arc,
},
};
use tokio::sync::Mutex;

Expand Down Expand Up @@ -141,7 +144,7 @@ pub(crate) struct EthTransactionValidatorInner<Client, T> {
/// Fork indicator whether we are using EIP-7702 type transactions.
eip7702: bool,
/// The current max gas limit
block_gas_limit: u64,
block_gas_limit: AtomicU64,
/// Minimum priority fee to enforce for acceptance into the pool.
minimum_priority_fee: Option<u128>,
/// Stores the setup and parameters needed for validating KZG proofs.
Expand Down Expand Up @@ -245,12 +248,12 @@ where

// Checks for gas limit
let transaction_gas_limit = transaction.gas_limit();
if transaction_gas_limit > self.block_gas_limit {
if transaction_gas_limit > self.block_gas_limit.load(std::sync::atomic::Ordering::Relaxed) {
return TransactionValidationOutcome::Invalid(
transaction,
InvalidPoolTransactionError::ExceedsGasLimit(
transaction_gas_limit,
self.block_gas_limit,
self.block_gas_limit.load(std::sync::atomic::Ordering::Relaxed),
),
)
}
Expand Down Expand Up @@ -484,11 +487,16 @@ where
if self.chain_spec.is_prague_active_at_timestamp(new_tip_block.timestamp()) {
self.fork_tracker.prague.store(true, std::sync::atomic::Ordering::Relaxed);
}

if new_tip_block.gas_limit() > 0 {
self.block_gas_limit
.store(new_tip_block.gas_limit(), std::sync::atomic::Ordering::Relaxed);
}
}
}

/// A builder for [`TransactionValidationTaskExecutor`]
#[derive(Debug, Clone)]
#[derive(Debug)]
pub struct EthTransactionValidatorBuilder {
chain_spec: Arc<ChainSpec>,
/// Fork indicator whether we are in the Shanghai stage.
Expand All @@ -506,7 +514,7 @@ pub struct EthTransactionValidatorBuilder {
/// Whether using EIP-7702 type transactions is allowed
eip7702: bool,
/// The current max gas limit
block_gas_limit: u64,
block_gas_limit: AtomicU64,
/// Minimum priority fee to enforce for acceptance into the pool.
minimum_priority_fee: Option<u128>,
/// Determines how many additional tasks to spawn
Expand All @@ -533,7 +541,7 @@ impl EthTransactionValidatorBuilder {
/// - EIP-4844
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
Self {
block_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
block_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT.into(),
chain_spec,
minimum_priority_fee: None,
additional_tasks: 1,
Expand Down Expand Up @@ -670,8 +678,8 @@ impl EthTransactionValidatorBuilder {
/// Sets the block gas limit
///
/// Transactions with a gas limit greater than this will be rejected.
pub const fn set_block_gas_limit(mut self, block_gas_limit: u64) -> Self {
self.block_gas_limit = block_gas_limit;
pub fn set_block_gas_limit(self, block_gas_limit: u64) -> Self {
self.block_gas_limit.store(block_gas_limit, std::sync::atomic::Ordering::Relaxed);
self
}

Expand Down

0 comments on commit 9f65bb0

Please sign in to comment.