From 9f65bb05e9a3de711e33cf58448b65cf53b265c8 Mon Sep 17 00:00:00 2001 From: Ayodeji Akinola Date: Thu, 12 Dec 2024 02:03:58 +0100 Subject: [PATCH] fix conflict --- crates/transaction-pool/src/validate/eth.rs | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/crates/transaction-pool/src/validate/eth.rs b/crates/transaction-pool/src/validate/eth.rs index 1092a2702f7e..f5a67549df69 100644 --- a/crates/transaction-pool/src/validate/eth.rs +++ b/crates/transaction-pool/src/validate/eth.rs @@ -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; @@ -141,7 +144,7 @@ pub(crate) struct EthTransactionValidatorInner { /// 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, /// Stores the setup and parameters needed for validating KZG proofs. @@ -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), ), ) } @@ -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, /// Fork indicator whether we are in the Shanghai stage. @@ -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, /// Determines how many additional tasks to spawn @@ -533,7 +541,7 @@ impl EthTransactionValidatorBuilder { /// - EIP-4844 pub fn new(chain_spec: Arc) -> 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, @@ -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 }