mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-10 07:48:19 -05:00
fix the issue of network is not known to be merged (#6649)
Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
@@ -36,7 +36,6 @@ use reth_node_ethereum::{EthEngineTypes, EthEvmConfig};
|
||||
#[cfg(feature = "optimism")]
|
||||
use reth_node_optimism::{OptimismEngineTypes, OptimismEvmConfig};
|
||||
use reth_payload_builder::PayloadBuilderHandle;
|
||||
use reth_primitives::DisplayHardforks;
|
||||
use reth_provider::{providers::BlockchainProvider, ProviderFactory};
|
||||
use reth_prune::PrunerBuilder;
|
||||
use reth_rpc_engine_api::EngineApi;
|
||||
@@ -148,7 +147,7 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
|
||||
|
||||
let genesis_hash = init_genesis(Arc::clone(&self.db), self.config.chain.clone())?;
|
||||
|
||||
info!(target: "reth::cli", "{}", DisplayHardforks::new(self.config.chain.hardforks()));
|
||||
info!(target: "reth::cli", "{}", self.config.chain.display_hardforks());
|
||||
|
||||
let consensus = self.config.consensus();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ use reth_node_core::{
|
||||
};
|
||||
use reth_primitives::{
|
||||
constants::eip4844::{LoadKzgSettingsError, MAINNET_KZG_TRUSTED_SETUP},
|
||||
ChainSpec, DisplayHardforks,
|
||||
ChainSpec,
|
||||
};
|
||||
use reth_provider::{providers::BlockchainProvider, ChainSpecProvider, ProviderFactory};
|
||||
use reth_prune::{PrunerBuilder, PrunerEvent};
|
||||
@@ -367,7 +367,7 @@ where
|
||||
|
||||
let genesis_hash = init_genesis(database.clone(), config.chain.clone())?;
|
||||
|
||||
info!(target: "reth::cli", "{}", DisplayHardforks::new(config.chain.hardforks()));
|
||||
info!(target: "reth::cli", "{}", config.chain.display_hardforks());
|
||||
|
||||
let consensus = config.consensus();
|
||||
|
||||
|
||||
@@ -797,6 +797,14 @@ impl ChainSpec {
|
||||
&self.hardforks
|
||||
}
|
||||
|
||||
/// Returns the hardfork display helper.
|
||||
pub fn display_hardforks(&self) -> DisplayHardforks {
|
||||
DisplayHardforks::new(
|
||||
self.hardforks(),
|
||||
self.paris_block_and_final_difficulty.map(|(block, _)| block),
|
||||
)
|
||||
}
|
||||
|
||||
/// Get the fork id for the given hardfork.
|
||||
#[inline]
|
||||
pub fn hardfork_fork_id(&self, fork: Hardfork) -> Option<ForkId> {
|
||||
@@ -1542,8 +1550,7 @@ impl Display for DisplayFork {
|
||||
///
|
||||
/// ```
|
||||
/// # use reth_primitives::MAINNET;
|
||||
/// # use reth_primitives::DisplayHardforks;
|
||||
/// println!("{}", DisplayHardforks::new(MAINNET.hardforks()));
|
||||
/// println!("{}", MAINNET.display_hardforks());
|
||||
/// ```
|
||||
///
|
||||
/// An example of the output:
|
||||
@@ -1565,7 +1572,7 @@ impl Display for DisplayFork {
|
||||
// - ArrowGlacier @13773000
|
||||
// - GrayGlacier @15050000
|
||||
// Merge hard forks:
|
||||
// - Paris @58750000000000000000000 (network is not known to be merged)
|
||||
// - Paris @58750000000000000000000 (network is known to be merged)
|
||||
//
|
||||
// Post-merge hard forks (timestamp based):
|
||||
// - Shanghai @1681338455
|
||||
@@ -1607,26 +1614,27 @@ impl Display for DisplayHardforks {
|
||||
|
||||
impl DisplayHardforks {
|
||||
/// Creates a new [`DisplayHardforks`] from an iterator of hardforks.
|
||||
pub fn new(hardforks: &BTreeMap<Hardfork, ForkCondition>) -> Self {
|
||||
Self::from_iter(hardforks.iter())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> FromIterator<(&'a Hardfork, &'b ForkCondition)> for DisplayHardforks {
|
||||
fn from_iter<T: IntoIterator<Item = (&'a Hardfork, &'b ForkCondition)>>(iter: T) -> Self {
|
||||
pub fn new(
|
||||
hardforks: &BTreeMap<Hardfork, ForkCondition>,
|
||||
known_paris_block: Option<u64>,
|
||||
) -> Self {
|
||||
let mut pre_merge = Vec::new();
|
||||
let mut with_merge = Vec::new();
|
||||
let mut post_merge = Vec::new();
|
||||
|
||||
for (fork, condition) in iter {
|
||||
let display_fork =
|
||||
for (fork, condition) in hardforks {
|
||||
let mut display_fork =
|
||||
DisplayFork { name: fork.to_string(), activated_at: *condition, eip: None };
|
||||
|
||||
match condition {
|
||||
ForkCondition::Block(_) => {
|
||||
pre_merge.push(display_fork);
|
||||
}
|
||||
ForkCondition::TTD { .. } => {
|
||||
ForkCondition::TTD { total_difficulty, .. } => {
|
||||
display_fork.activated_at = ForkCondition::TTD {
|
||||
fork_block: known_paris_block,
|
||||
total_difficulty: *total_difficulty,
|
||||
};
|
||||
with_merge.push(display_fork);
|
||||
}
|
||||
ForkCondition::Timestamp(_) => {
|
||||
@@ -1702,7 +1710,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_hardfork_list_display_mainnet() {
|
||||
assert_eq!(
|
||||
DisplayHardforks::new(MAINNET.hardforks()).to_string(),
|
||||
MAINNET.display_hardforks().to_string(),
|
||||
"Pre-merge hard forks (block based):
|
||||
- Frontier @0
|
||||
- Homestead @1150000
|
||||
@@ -1719,7 +1727,7 @@ mod tests {
|
||||
- ArrowGlacier @13773000
|
||||
- GrayGlacier @15050000
|
||||
Merge hard forks:
|
||||
- Paris @58750000000000000000000 (network is not known to be merged)
|
||||
- Paris @58750000000000000000000 (network is known to be merged)
|
||||
|
||||
Post-merge hard forks (timestamp based):
|
||||
- Shanghai @1681338455
|
||||
@@ -1737,7 +1745,7 @@ Post-merge hard forks (timestamp based):
|
||||
.with_fork(Hardfork::Shanghai, ForkCondition::Never)
|
||||
.build();
|
||||
assert_eq!(
|
||||
DisplayHardforks::new(spec.hardforks()).to_string(),
|
||||
spec.display_hardforks().to_string(),
|
||||
"Pre-merge hard forks (block based):
|
||||
- Frontier @0
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user