mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
primitive-traits: use alloy INITIAL_BASE_FEE constant (#12022)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -6741,6 +6741,7 @@ name = "reth-consensus-common"
|
||||
version = "1.1.0"
|
||||
dependencies = [
|
||||
"alloy-consensus",
|
||||
"alloy-eips",
|
||||
"alloy-primitives",
|
||||
"mockall",
|
||||
"rand 0.8.5",
|
||||
|
||||
@ -1375,6 +1375,7 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_consensus::{TxEip1559, EMPTY_ROOT_HASH};
|
||||
use alloy_eips::eip1559::INITIAL_BASE_FEE;
|
||||
use alloy_genesis::{Genesis, GenesisAccount};
|
||||
use alloy_primitives::{keccak256, Address, Sealable, B256};
|
||||
use assert_matches::assert_matches;
|
||||
@ -1386,7 +1387,6 @@ mod tests {
|
||||
use reth_evm::test_utils::MockExecutorProvider;
|
||||
use reth_evm_ethereum::execute::EthExecutorProvider;
|
||||
use reth_primitives::{
|
||||
constants::EIP1559_INITIAL_BASE_FEE,
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root},
|
||||
revm_primitives::AccountInfo,
|
||||
Account, BlockBody, Header, Signature, Transaction, TransactionSigned,
|
||||
@ -1560,7 +1560,7 @@ mod tests {
|
||||
provider_rw.commit().unwrap();
|
||||
}
|
||||
|
||||
let single_tx_cost = U256::from(EIP1559_INITIAL_BASE_FEE * MIN_TRANSACTION_GAS);
|
||||
let single_tx_cost = U256::from(INITIAL_BASE_FEE * MIN_TRANSACTION_GAS);
|
||||
let mock_tx = |nonce: u64| -> TransactionSignedEcRecovered {
|
||||
TransactionSigned::from_transaction_and_signature(
|
||||
Transaction::Eip1559(TxEip1559 {
|
||||
@ -1568,7 +1568,7 @@ mod tests {
|
||||
nonce,
|
||||
gas_limit: MIN_TRANSACTION_GAS,
|
||||
to: Address::ZERO.into(),
|
||||
max_fee_per_gas: EIP1559_INITIAL_BASE_FEE as u128,
|
||||
max_fee_per_gas: INITIAL_BASE_FEE as u128,
|
||||
..Default::default()
|
||||
}),
|
||||
Signature::test_signature(),
|
||||
@ -1605,7 +1605,7 @@ mod tests {
|
||||
gas_used: body.len() as u64 * MIN_TRANSACTION_GAS,
|
||||
gas_limit: chain_spec.max_gas_limit,
|
||||
mix_hash: B256::random(),
|
||||
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE),
|
||||
base_fee_per_gas: Some(INITIAL_BASE_FEE),
|
||||
transactions_root,
|
||||
receipts_root,
|
||||
state_root: state_root_unhashed(HashMap::from([(
|
||||
|
||||
@ -3,7 +3,7 @@ use crate::{
|
||||
CanonStateSubscriptions,
|
||||
};
|
||||
use alloy_consensus::{Transaction as _, TxEip1559, EMPTY_ROOT_HASH};
|
||||
use alloy_eips::eip7685::Requests;
|
||||
use alloy_eips::{eip1559::INITIAL_BASE_FEE, eip7685::Requests};
|
||||
use alloy_primitives::{Address, BlockNumber, Sealable, B256, U256};
|
||||
use alloy_signer::SignerSync;
|
||||
use alloy_signer_local::PrivateKeySigner;
|
||||
@ -11,7 +11,6 @@ use rand::{thread_rng, Rng};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardfork, MIN_TRANSACTION_GAS};
|
||||
use reth_execution_types::{Chain, ExecutionOutcome};
|
||||
use reth_primitives::{
|
||||
constants::EIP1559_INITIAL_BASE_FEE,
|
||||
proofs::{calculate_receipt_root, calculate_transaction_root, calculate_withdrawals_root},
|
||||
BlockBody, Header, Receipt, Receipts, SealedBlock, SealedBlockWithSenders, SealedHeader,
|
||||
Transaction, TransactionSigned, TransactionSignedEcRecovered,
|
||||
@ -75,7 +74,7 @@ impl TestBlockBuilder {
|
||||
|
||||
/// Gas cost of a single transaction generated by the block builder.
|
||||
pub fn single_tx_cost() -> U256 {
|
||||
U256::from(EIP1559_INITIAL_BASE_FEE * MIN_TRANSACTION_GAS)
|
||||
U256::from(INITIAL_BASE_FEE * MIN_TRANSACTION_GAS)
|
||||
}
|
||||
|
||||
/// Generates a random [`SealedBlockWithSenders`].
|
||||
@ -92,7 +91,7 @@ impl TestBlockBuilder {
|
||||
nonce,
|
||||
gas_limit: MIN_TRANSACTION_GAS,
|
||||
to: Address::random().into(),
|
||||
max_fee_per_gas: EIP1559_INITIAL_BASE_FEE as u128,
|
||||
max_fee_per_gas: INITIAL_BASE_FEE as u128,
|
||||
max_priority_fee_per_gas: 1,
|
||||
..Default::default()
|
||||
});
|
||||
@ -136,7 +135,7 @@ impl TestBlockBuilder {
|
||||
gas_used: transactions.len() as u64 * MIN_TRANSACTION_GAS,
|
||||
gas_limit: self.chain_spec.max_gas_limit,
|
||||
mix_hash: B256::random(),
|
||||
base_fee_per_gas: Some(EIP1559_INITIAL_BASE_FEE),
|
||||
base_fee_per_gas: Some(INITIAL_BASE_FEE),
|
||||
transactions_root: calculate_transaction_root(&transactions),
|
||||
receipts_root: calculate_receipt_root(&receipts),
|
||||
beneficiary: Address::random(),
|
||||
|
||||
@ -3,7 +3,7 @@ pub use alloy_eips::eip1559::BaseFeeParams;
|
||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||
use alloy_chains::{Chain, NamedChain};
|
||||
use alloy_consensus::constants::EMPTY_WITHDRAWALS;
|
||||
use alloy_eips::eip7685::EMPTY_REQUESTS_HASH;
|
||||
use alloy_eips::{eip1559::INITIAL_BASE_FEE, eip7685::EMPTY_REQUESTS_HASH};
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256};
|
||||
use derive_more::From;
|
||||
@ -19,7 +19,7 @@ use reth_network_peers::{
|
||||
sepolia_nodes, NodeRecord,
|
||||
};
|
||||
use reth_primitives_traits::{
|
||||
constants::{EIP1559_INITIAL_BASE_FEE, HOLESKY_GENESIS_HASH, SEPOLIA_GENESIS_HASH},
|
||||
constants::{HOLESKY_GENESIS_HASH, SEPOLIA_GENESIS_HASH},
|
||||
Header, SealedHeader,
|
||||
};
|
||||
use reth_trie_common::root::state_root_ref_unhashed;
|
||||
@ -314,7 +314,7 @@ impl ChainSpec {
|
||||
pub fn initial_base_fee(&self) -> Option<u64> {
|
||||
// If the base fee is set in the genesis block, we use that instead of the default.
|
||||
let genesis_base_fee =
|
||||
self.genesis.base_fee_per_gas.map(|fee| fee as u64).unwrap_or(EIP1559_INITIAL_BASE_FEE);
|
||||
self.genesis.base_fee_per_gas.map(|fee| fee as u64).unwrap_or(INITIAL_BASE_FEE);
|
||||
|
||||
// If London is activated at genesis, we set the initial base fee as per EIP-1559.
|
||||
self.hardforks.fork(EthereumHardfork::London).active_at_block(0).then_some(genesis_base_fee)
|
||||
|
||||
@ -20,6 +20,7 @@ reth-consensus.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
revm-primitives.workspace = true
|
||||
alloy-consensus.workspace = true
|
||||
alloy-eips.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
reth-storage-api.workspace = true
|
||||
|
||||
@ -204,7 +204,7 @@ pub fn validate_against_parent_eip1559_base_fee<ChainSpec: EthChainSpec + Ethere
|
||||
|
||||
let expected_base_fee =
|
||||
if chain_spec.fork(EthereumHardfork::London).transitions_at_block(header.number) {
|
||||
reth_primitives::constants::EIP1559_INITIAL_BASE_FEE
|
||||
alloy_eips::eip1559::INITIAL_BASE_FEE
|
||||
} else {
|
||||
// This BaseFeeMissing will not happen as previous blocks are checked to have
|
||||
// them.
|
||||
|
||||
@ -27,9 +27,9 @@ use revm_primitives::{
|
||||
};
|
||||
|
||||
mod config;
|
||||
use alloy_eips::eip1559::INITIAL_BASE_FEE;
|
||||
pub use config::{revm_spec, revm_spec_by_timestamp_after_merge};
|
||||
use reth_ethereum_forks::EthereumHardfork;
|
||||
use reth_primitives::constants::EIP1559_INITIAL_BASE_FEE;
|
||||
|
||||
pub mod execute;
|
||||
|
||||
@ -163,7 +163,7 @@ impl ConfigureEvmEnv for EthEvmConfig {
|
||||
gas_limit *= U256::from(elasticity_multiplier);
|
||||
|
||||
// set the base fee to the initial base fee from the EIP-1559 spec
|
||||
basefee = Some(EIP1559_INITIAL_BASE_FEE)
|
||||
basefee = Some(INITIAL_BASE_FEE)
|
||||
}
|
||||
|
||||
let block_env = BlockEnv {
|
||||
|
||||
@ -26,9 +26,6 @@ pub const MIN_PROTOCOL_BASE_FEE: u64 = 7;
|
||||
/// Same as [`MIN_PROTOCOL_BASE_FEE`] but as a U256.
|
||||
pub const MIN_PROTOCOL_BASE_FEE_U256: U256 = U256::from_limbs([7u64, 0, 0, 0]);
|
||||
|
||||
/// Initial base fee as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
|
||||
pub const EIP1559_INITIAL_BASE_FEE: u64 = 1_000_000_000;
|
||||
|
||||
/// Base fee max change denominator as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
|
||||
pub const EIP1559_DEFAULT_BASE_FEE_MAX_CHANGE_DENOMINATOR: u64 = 8;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user