mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: use new ChainHardforks type on ChainSpec (#9065)
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
|
||||
use reth_beacon_consensus::BeaconEngineMessage;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
|
||||
use reth_engine_primitives::EngineTypes;
|
||||
use reth_execution_errors::{BlockExecutionError, BlockValidationError};
|
||||
|
||||
@ -2492,7 +2492,7 @@ mod tests {
|
||||
use super::*;
|
||||
use alloy_genesis::Genesis;
|
||||
use reth_db::test_utils::create_test_static_files_dir;
|
||||
use reth_primitives::{Hardfork, U256};
|
||||
use reth_primitives::{EthereumHardfork, U256};
|
||||
use reth_provider::{
|
||||
providers::StaticFileProvider, test_utils::blocks::BlockchainTestData,
|
||||
};
|
||||
@ -2721,9 +2721,9 @@ mod tests {
|
||||
async fn payload_pre_merge() {
|
||||
let data = BlockchainTestData::default();
|
||||
let mut block1 = data.blocks[0].0.block.clone();
|
||||
block1
|
||||
.header
|
||||
.set_difficulty(MAINNET.fork(Hardfork::Paris).ttd().unwrap() - U256::from(1));
|
||||
block1.header.set_difficulty(
|
||||
MAINNET.fork(EthereumHardfork::Paris).ttd().unwrap() - U256::from(1),
|
||||
);
|
||||
block1 = block1.unseal().seal_slow();
|
||||
let (block2, exec_result2) = data.blocks[1].clone();
|
||||
let mut block2 = block2.unseal().block;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
use reth_chainspec::{Chain, ChainSpec, Hardfork};
|
||||
use reth_chainspec::{Chain, ChainSpec, EthereumHardfork};
|
||||
use reth_primitives::{constants::ETH_TO_WEI, BlockNumber, U256};
|
||||
|
||||
/// Calculates the base block reward.
|
||||
@ -26,7 +26,7 @@ pub fn base_block_reward(
|
||||
block_difficulty: U256,
|
||||
total_difficulty: U256,
|
||||
) -> Option<u128> {
|
||||
if chain_spec.fork(Hardfork::Paris).active_at_ttd(total_difficulty, block_difficulty) ||
|
||||
if chain_spec.fork(EthereumHardfork::Paris).active_at_ttd(total_difficulty, block_difficulty) ||
|
||||
chain_spec.chain == Chain::goerli()
|
||||
{
|
||||
None
|
||||
@ -39,9 +39,9 @@ pub fn base_block_reward(
|
||||
///
|
||||
/// Caution: The caller must ensure that the block number is before the merge.
|
||||
pub fn base_block_reward_pre_merge(chain_spec: &ChainSpec, block_number: BlockNumber) -> u128 {
|
||||
if chain_spec.fork(Hardfork::Constantinople).active_at_block(block_number) {
|
||||
if chain_spec.fork(EthereumHardfork::Constantinople).active_at_block(block_number) {
|
||||
ETH_TO_WEI * 2
|
||||
} else if chain_spec.fork(Hardfork::Byzantium).active_at_block(block_number) {
|
||||
} else if chain_spec.fork(EthereumHardfork::Byzantium).active_at_block(block_number) {
|
||||
ETH_TO_WEI * 3
|
||||
} else {
|
||||
ETH_TO_WEI * 5
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
//! Collection of methods for block validation.
|
||||
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_consensus::ConsensusError;
|
||||
use reth_primitives::{
|
||||
constants::{
|
||||
@ -8,7 +8,7 @@ use reth_primitives::{
|
||||
MAXIMUM_EXTRA_DATA_SIZE,
|
||||
},
|
||||
eip4844::calculate_excess_blob_gas,
|
||||
GotExpected, Hardfork, Header, SealedBlock, SealedHeader,
|
||||
EthereumHardfork, GotExpected, Header, SealedBlock, SealedHeader,
|
||||
};
|
||||
|
||||
/// Gas used needs to be less than gas limit. Gas used is going to be checked after execution.
|
||||
@ -29,7 +29,7 @@ pub fn validate_header_base_fee(
|
||||
header: &SealedHeader,
|
||||
chain_spec: &ChainSpec,
|
||||
) -> Result<(), ConsensusError> {
|
||||
if chain_spec.fork(Hardfork::London).active_at_block(header.number) &&
|
||||
if chain_spec.fork(EthereumHardfork::London).active_at_block(header.number) &&
|
||||
header.base_fee_per_gas.is_none()
|
||||
{
|
||||
return Err(ConsensusError::BaseFeeMissing)
|
||||
@ -192,11 +192,11 @@ pub fn validate_against_parent_eip1559_base_fee(
|
||||
parent: &SealedHeader,
|
||||
chain_spec: &ChainSpec,
|
||||
) -> Result<(), ConsensusError> {
|
||||
if chain_spec.fork(Hardfork::London).active_at_block(header.number) {
|
||||
if chain_spec.fork(EthereumHardfork::London).active_at_block(header.number) {
|
||||
let base_fee = header.base_fee_per_gas.ok_or(ConsensusError::BaseFeeMissing)?;
|
||||
|
||||
let expected_base_fee =
|
||||
if chain_spec.fork(Hardfork::London).transitions_at_block(header.number) {
|
||||
if chain_spec.fork(EthereumHardfork::London).transitions_at_block(header.number) {
|
||||
reth_primitives::constants::EIP1559_INITIAL_BASE_FEE
|
||||
} else {
|
||||
// This BaseFeeMissing will not happen as previous blocks are checked to have
|
||||
|
||||
Reference in New Issue
Block a user