Skip to content

Commit 941ffb5

Browse files
authored
chore: rm chainspec max gas limit (#13308)
1 parent 8fd305a commit 941ffb5

File tree

18 files changed

+39
-67
lines changed

18 files changed

+39
-67
lines changed

crates/blockchain-tree/src/blockchain_tree.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,10 @@ where
13761376
mod tests {
13771377
use super::*;
13781378
use alloy_consensus::{Header, TxEip1559, EMPTY_ROOT_HASH};
1379-
use alloy_eips::{eip1559::INITIAL_BASE_FEE, eip4895::Withdrawals};
1379+
use alloy_eips::{
1380+
eip1559::{ETHEREUM_BLOCK_GAS_LIMIT, INITIAL_BASE_FEE},
1381+
eip4895::Withdrawals,
1382+
};
13801383
use alloy_genesis::{Genesis, GenesisAccount};
13811384
use alloy_primitives::{keccak256, Address, PrimitiveSignature as Signature, B256};
13821385
use assert_matches::assert_matches;
@@ -1618,7 +1621,7 @@ mod tests {
16181621
number,
16191622
parent_hash: parent.unwrap_or_default(),
16201623
gas_used: body.len() as u64 * MIN_TRANSACTION_GAS,
1621-
gas_limit: chain_spec.max_gas_limit,
1624+
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
16221625
mix_hash: B256::random(),
16231626
base_fee_per_gas: Some(INITIAL_BASE_FEE),
16241627
transactions_root,

crates/chain-state/src/test_utils.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use crate::{
55
CanonStateSubscriptions,
66
};
77
use alloy_consensus::{Header, Transaction as _, TxEip1559, EMPTY_ROOT_HASH};
8-
use alloy_eips::{eip1559::INITIAL_BASE_FEE, eip7685::Requests};
8+
use alloy_eips::{
9+
eip1559::{ETHEREUM_BLOCK_GAS_LIMIT, INITIAL_BASE_FEE},
10+
eip7685::Requests,
11+
};
912
use alloy_primitives::{Address, BlockNumber, B256, U256};
1013
use alloy_signer::SignerSync;
1114
use alloy_signer_local::PrivateKeySigner;
@@ -137,8 +140,8 @@ impl TestBlockBuilder {
137140
number,
138141
parent_hash,
139142
gas_used: transactions.len() as u64 * MIN_TRANSACTION_GAS,
140-
gas_limit: self.chain_spec.max_gas_limit,
141143
mix_hash: B256::random(),
144+
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
142145
base_fee_per_gas: Some(INITIAL_BASE_FEE),
143146
transactions_root: calculate_transaction_root(
144147
&transactions.clone().into_iter().map(|tx| tx.into_signed()).collect::<Vec<_>>(),

crates/chainspec/src/api.rs

-7
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
4949
/// The genesis block specification.
5050
fn genesis(&self) -> &Genesis;
5151

52-
/// The block gas limit.
53-
fn max_gas_limit(&self) -> u64;
54-
5552
/// The bootnodes for the chain, if any.
5653
fn bootnodes(&self) -> Option<Vec<NodeRecord>>;
5754

@@ -105,10 +102,6 @@ impl EthChainSpec for ChainSpec {
105102
self.genesis()
106103
}
107104

108-
fn max_gas_limit(&self) -> u64 {
109-
self.max_gas_limit
110-
}
111-
112105
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
113106
self.bootnodes()
114107
}

crates/chainspec/src/spec.rs

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
pub use alloy_eips::eip1559::BaseFeeParams;
22

3+
use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec, LazyLock, OnceLock};
34
use alloc::{boxed::Box, sync::Arc, vec::Vec};
45
use alloy_chains::{Chain, NamedChain};
5-
use alloy_consensus::constants::EMPTY_WITHDRAWALS;
6+
use alloy_consensus::{
7+
constants::{
8+
DEV_GENESIS_HASH, EMPTY_WITHDRAWALS, HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH,
9+
SEPOLIA_GENESIS_HASH,
10+
},
11+
Header,
12+
};
613
use alloy_eips::{
714
eip1559::INITIAL_BASE_FEE, eip6110::MAINNET_DEPOSIT_CONTRACT_ADDRESS,
815
eip7685::EMPTY_REQUESTS_HASH,
916
};
1017
use alloy_genesis::Genesis;
1118
use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256};
1219
use derive_more::From;
13-
14-
use alloy_consensus::{
15-
constants::{
16-
DEV_GENESIS_HASH, HOLESKY_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH,
17-
},
18-
Header,
19-
};
20-
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
2120
use reth_ethereum_forks::{
2221
ChainHardforks, DisplayHardforks, EthereumHardfork, EthereumHardforks, ForkCondition,
2322
ForkFilter, ForkFilterKey, ForkHash, ForkId, Hardfork, Hardforks, Head, DEV_HARDFORKS,
@@ -29,8 +28,6 @@ use reth_network_peers::{
2928
use reth_primitives_traits::SealedHeader;
3029
use reth_trie_common::root::state_root_ref_unhashed;
3130

32-
use crate::{constants::MAINNET_DEPOSIT_CONTRACT, once_cell_set, EthChainSpec, LazyLock, OnceLock};
33-
3431
/// The Ethereum mainnet spec
3532
pub static MAINNET: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {
3633
let mut spec = ChainSpec {
@@ -52,7 +49,6 @@ pub static MAINNET: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {
5249
b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"),
5350
)),
5451
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
55-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
5652
prune_delete_limit: 20000,
5753
};
5854
spec.genesis.config.dao_fork_support = true;
@@ -77,7 +73,6 @@ pub static SEPOLIA: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {
7773
b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"),
7874
)),
7975
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
80-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
8176
prune_delete_limit: 10000,
8277
};
8378
spec.genesis.config.dao_fork_support = true;
@@ -100,7 +95,6 @@ pub static HOLESKY: LazyLock<Arc<ChainSpec>> = LazyLock::new(|| {
10095
b256!("649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"),
10196
)),
10297
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
103-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
10498
prune_delete_limit: 10000,
10599
};
106100
spec.genesis.config.dao_fork_support = true;
@@ -208,9 +202,6 @@ pub struct ChainSpec {
208202
/// The parameters that configure how a block's base fee is computed
209203
pub base_fee_params: BaseFeeParamsKind,
210204

211-
/// The maximum gas limit
212-
pub max_gas_limit: u64,
213-
214205
/// The delete limit for pruner, per run.
215206
pub prune_delete_limit: usize,
216207
}
@@ -226,7 +217,6 @@ impl Default for ChainSpec {
226217
hardforks: Default::default(),
227218
deposit_contract: Default::default(),
228219
base_fee_params: BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()),
229-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
230220
prune_delete_limit: MAINNET.prune_delete_limit,
231221
}
232222
}

crates/consensus/beacon/src/engine/sync.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ impl<N: ProviderNodeTypes> PipelineState<N> {
427427
mod tests {
428428
use super::*;
429429
use alloy_consensus::Header;
430+
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
430431
use assert_matches::assert_matches;
431432
use futures::poll;
432433
use reth_chainspec::{ChainSpec, ChainSpecBuilder, MAINNET};
@@ -633,7 +634,7 @@ mod tests {
633634
let client = TestFullBlockClient::default();
634635
let header = Header {
635636
base_fee_per_gas: Some(7),
636-
gas_limit: chain_spec.max_gas_limit,
637+
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
637638
..Default::default()
638639
};
639640
let header = SealedHeader::seal(header);

crates/engine/tree/src/backfill.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ mod tests {
231231
use super::*;
232232
use crate::test_utils::{insert_headers_into_client, TestPipelineBuilder};
233233
use alloy_consensus::Header;
234+
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
234235
use alloy_primitives::{BlockNumber, B256};
235236
use assert_matches::assert_matches;
236237
use futures::poll;
@@ -264,13 +265,13 @@ mod tests {
264265
checkpoint: StageCheckpoint::new(BlockNumber::from(pipeline_done_after)),
265266
done: true,
266267
})]))
267-
.build(chain_spec.clone());
268+
.build(chain_spec);
268269

269270
let pipeline_sync = PipelineSync::new(pipeline, Box::<TokioTaskExecutor>::default());
270271
let client = TestFullBlockClient::default();
271272
let header = Header {
272273
base_fee_per_gas: Some(7),
273-
gas_limit: chain_spec.max_gas_limit,
274+
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
274275
..Default::default()
275276
};
276277
let header = SealedHeader::seal(header);

crates/engine/tree/src/download.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ mod tests {
321321
use super::*;
322322
use crate::test_utils::insert_headers_into_client;
323323
use alloy_consensus::Header;
324+
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
324325
use assert_matches::assert_matches;
325326
use reth_beacon_consensus::EthBeaconConsensus;
326327
use reth_chainspec::{ChainSpecBuilder, MAINNET};
@@ -346,7 +347,7 @@ mod tests {
346347
let client = TestFullBlockClient::default();
347348
let header = Header {
348349
base_fee_per_gas: Some(7),
349-
gas_limit: chain_spec.max_gas_limit,
350+
gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
350351
..Default::default()
351352
};
352353
let header = SealedHeader::seal(header);

crates/optimism/chainspec/src/base.rs

-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pub static BASE_MAINNET: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
2929
]
3030
.into(),
3131
),
32-
max_gas_limit: crate::constants::BASE_MAINNET_MAX_GAS_LIMIT,
33-
prune_delete_limit: 10000,
3432
..Default::default()
3533
},
3634
}

crates/optimism/chainspec/src/base_sepolia.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub static BASE_SEPOLIA: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
2929
]
3030
.into(),
3131
),
32-
max_gas_limit: crate::constants::BASE_SEPOLIA_MAX_GAS_LIMIT,
3332
prune_delete_limit: 10000,
3433
..Default::default()
3534
},

crates/optimism/chainspec/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,6 @@ impl EthChainSpec for OpChainSpec {
317317
self.inner.genesis()
318318
}
319319

320-
fn max_gas_limit(&self) -> u64 {
321-
self.inner.max_gas_limit()
322-
}
323-
324320
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
325321
self.inner.bootnodes()
326322
}
@@ -1079,7 +1075,6 @@ mod tests {
10791075
paris_block_and_final_difficulty: Some((0, U256::from(0))),
10801076
hardforks,
10811077
base_fee_params: BASE_SEPOLIA.inner.base_fee_params.clone(),
1082-
max_gas_limit: crate::constants::BASE_SEPOLIA_MAX_GAS_LIMIT,
10831078
prune_delete_limit: 10000,
10841079
..Default::default()
10851080
},

crates/optimism/chainspec/src/op.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
//! Chain specification for the Optimism Mainnet network.
22
3+
use crate::{LazyLock, OpChainSpec};
34
use alloc::{sync::Arc, vec};
4-
55
use alloy_chains::Chain;
6-
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
76
use alloy_primitives::{b256, U256};
87
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
98
use reth_ethereum_forks::EthereumHardfork;
109
use reth_optimism_forks::OpHardfork;
1110

12-
use crate::{LazyLock, OpChainSpec};
13-
1411
/// The Optimism Mainnet spec
1512
pub static OP_MAINNET: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
1613
OpChainSpec {
@@ -32,7 +29,6 @@ pub static OP_MAINNET: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
3229
]
3330
.into(),
3431
),
35-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
3632
prune_delete_limit: 10000,
3733
..Default::default()
3834
},

crates/optimism/chainspec/src/op_sepolia.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
//! Chain specification for the Optimism Sepolia testnet network.
22
3+
use crate::{LazyLock, OpChainSpec};
34
use alloc::{sync::Arc, vec};
4-
55
use alloy_chains::{Chain, NamedChain};
6-
use alloy_eips::eip1559::ETHEREUM_BLOCK_GAS_LIMIT;
76
use alloy_primitives::{b256, U256};
87
use reth_chainspec::{once_cell_set, BaseFeeParams, BaseFeeParamsKind, ChainSpec};
98
use reth_ethereum_forks::EthereumHardfork;
109
use reth_optimism_forks::OpHardfork;
1110

12-
use crate::{LazyLock, OpChainSpec};
13-
1411
/// The OP Sepolia spec
1512
pub static OP_SEPOLIA: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
1613
OpChainSpec {
@@ -30,7 +27,6 @@ pub static OP_SEPOLIA: LazyLock<Arc<OpChainSpec>> = LazyLock::new(|| {
3027
]
3128
.into(),
3229
),
33-
max_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
3430
prune_delete_limit: 10000,
3531
..Default::default()
3632
},

crates/optimism/node/src/engine.rs

-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ mod test {
212212
.paris_block_and_final_difficulty,
213213
hardforks,
214214
base_fee_params: BASE_SEPOLIA.inner.base_fee_params.clone(),
215-
max_gas_limit: BASE_SEPOLIA.inner.max_gas_limit,
216215
prune_delete_limit: 10000,
217216
..Default::default()
218217
},

crates/rpc/rpc-eth-api/src/helpers/estimate.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use crate::{AsEthApiError, FromEthApiError, IntoEthApiError};
55
use alloy_primitives::U256;
66
use alloy_rpc_types_eth::{state::StateOverride, transaction::TransactionRequest, BlockId};
77
use futures::Future;
8-
use reth_chainspec::{EthChainSpec, MIN_TRANSACTION_GAS};
9-
use reth_provider::{ChainSpecProvider, StateProvider};
8+
use reth_chainspec::MIN_TRANSACTION_GAS;
9+
use reth_provider::StateProvider;
1010
use reth_revm::{
1111
database::StateProviderDatabase,
1212
db::CacheDB,
@@ -116,9 +116,7 @@ pub trait EstimateCall: Call {
116116
}
117117

118118
// We can now normalize the highest gas limit to a u64
119-
let mut highest_gas_limit: u64 = highest_gas_limit
120-
.try_into()
121-
.unwrap_or_else(|_| self.provider().chain_spec().max_gas_limit());
119+
let mut highest_gas_limit = highest_gas_limit.saturating_to::<u64>();
122120

123121
// If the provided gas limit is less than computed cap, use that
124122
env.tx.gas_limit = env.tx.gas_limit.min(highest_gas_limit);

crates/rpc/rpc/src/eth/core.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,13 @@ where
452452

453453
#[cfg(test)]
454454
mod tests {
455+
use crate::EthApi;
455456
use alloy_consensus::Header;
456457
use alloy_eips::BlockNumberOrTag;
457458
use alloy_primitives::{PrimitiveSignature as Signature, B256, U64};
458459
use alloy_rpc_types::FeeHistory;
459460
use jsonrpsee_types::error::INVALID_PARAMS_CODE;
460-
use reth_chainspec::{BaseFeeParams, ChainSpec, EthChainSpec};
461+
use reth_chainspec::{BaseFeeParams, ChainSpec};
461462
use reth_evm_ethereum::EthEvmConfig;
462463
use reth_network_api::noop::NoopNetwork;
463464
use reth_primitives::{Block, BlockBody, TransactionSigned};
@@ -467,7 +468,7 @@ mod tests {
467468
};
468469
use reth_rpc_eth_api::EthApiServer;
469470
use reth_rpc_eth_types::{
470-
EthStateCache, FeeHistoryCache, FeeHistoryCacheConfig, GasPriceOracle,
471+
EthStateCache, FeeHistoryCache, FeeHistoryCacheConfig, GasCap, GasPriceOracle,
471472
};
472473
use reth_rpc_server_types::constants::{
473474
DEFAULT_ETH_PROOF_WINDOW, DEFAULT_MAX_SIMULATE_BLOCKS, DEFAULT_PROOF_PERMITS,
@@ -476,8 +477,6 @@ mod tests {
476477
use reth_testing_utils::{generators, generators::Rng};
477478
use reth_transaction_pool::test_utils::{testing_pool, TestPool};
478479

479-
use crate::EthApi;
480-
481480
fn build_test_eth_api<
482481
P: BlockReaderIdExt<
483482
Block = reth_primitives::Block,
@@ -497,14 +496,13 @@ mod tests {
497496
let cache = EthStateCache::spawn(provider.clone(), Default::default());
498497
let fee_history_cache = FeeHistoryCache::new(FeeHistoryCacheConfig::default());
499498

500-
let gas_cap = provider.chain_spec().max_gas_limit();
501499
EthApi::new(
502500
provider.clone(),
503501
testing_pool(),
504502
NoopNetwork::default(),
505503
cache.clone(),
506504
GasPriceOracle::new(provider, Default::default(), cache),
507-
gas_cap,
505+
GasCap::default(),
508506
DEFAULT_MAX_SIMULATE_BLOCKS,
509507
DEFAULT_ETH_PROOF_WINDOW,
510508
BlockingTaskPool::build().expect("failed to build tracing pool"),

crates/transaction-pool/src/validate/eth.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ use alloy_consensus::{
1818
},
1919
BlockHeader,
2020
};
21-
use alloy_eips::eip4844::{env_settings::EnvKzgSettings, MAX_BLOBS_PER_BLOCK};
21+
use alloy_eips::{
22+
eip1559::ETHEREUM_BLOCK_GAS_LIMIT,
23+
eip4844::{env_settings::EnvKzgSettings, MAX_BLOBS_PER_BLOCK},
24+
};
2225
use reth_chainspec::{ChainSpec, EthereumHardforks};
2326
use reth_primitives::{InvalidTransactionError, SealedBlock};
2427
use reth_primitives_traits::GotExpected;
@@ -530,7 +533,7 @@ impl EthTransactionValidatorBuilder {
530533
/// - EIP-4844
531534
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
532535
Self {
533-
block_gas_limit: chain_spec.max_gas_limit,
536+
block_gas_limit: ETHEREUM_BLOCK_GAS_LIMIT,
534537
chain_spec,
535538
minimum_priority_fee: None,
536539
additional_tasks: 1,

0 commit comments

Comments
 (0)