From 26a66cdd98b4879f2c6631ea0e493bad2d1d49a3 Mon Sep 17 00:00:00 2001 From: stevencartavia Date: Wed, 30 Oct 2024 17:39:54 -0600 Subject: [PATCH 1/5] replace DisplayHardforks with Box --- crates/chainspec/src/api.rs | 9 ++++----- crates/chainspec/src/spec.rs | 9 ++++++--- crates/optimism/chainspec/src/lib.rs | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/crates/chainspec/src/api.rs b/crates/chainspec/src/api.rs index 36640f34b709..95f6b65584a7 100644 --- a/crates/chainspec/src/api.rs +++ b/crates/chainspec/src/api.rs @@ -1,11 +1,10 @@ use crate::{ChainSpec, DepositContract}; -use alloc::vec::Vec; +use alloc::{fmt::Display, vec::Vec}; use alloy_chains::Chain; use alloy_eips::eip1559::BaseFeeParams; use alloy_genesis::Genesis; use alloy_primitives::B256; use core::fmt::Debug; -use reth_ethereum_forks::DisplayHardforks; use reth_network_peers::NodeRecord; use reth_primitives_traits::Header; @@ -39,7 +38,7 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug { fn prune_delete_limit(&self) -> usize; /// Returns a string representation of the hardforks. - fn display_hardforks(&self) -> DisplayHardforks; + fn display_hardforks(&self) -> Box; /// The genesis header. fn genesis_header(&self) -> &Header; @@ -89,8 +88,8 @@ impl EthChainSpec for ChainSpec { self.prune_delete_limit } - fn display_hardforks(&self) -> DisplayHardforks { - self.display_hardforks() + fn display_hardforks(&self) -> Box { + Box::new(self.display_hardforks()) } fn genesis_header(&self) -> &Header { diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index 779eb8a37577..8a506c275632 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -1,6 +1,6 @@ pub use alloy_eips::eip1559::BaseFeeParams; -use alloc::{boxed::Box, sync::Arc, vec::Vec}; +use alloc::{boxed::Box, fmt::Display, sync::Arc, vec::Vec}; use alloy_chains::{Chain, NamedChain}; use alloy_consensus::constants::EMPTY_WITHDRAWALS; use alloy_eips::{ @@ -393,8 +393,11 @@ impl ChainSpec { } /// Returns the hardfork display helper. - pub fn display_hardforks(&self) -> DisplayHardforks { - DisplayHardforks::new(&self, self.paris_block_and_final_difficulty.map(|(block, _)| block)) + pub fn display_hardforks(&self) -> Box { + Box::new(DisplayHardforks::new( + &self, + self.paris_block_and_final_difficulty.map(|(block, _)| block), + )) } /// Get the fork id for the given hardfork. diff --git a/crates/optimism/chainspec/src/lib.rs b/crates/optimism/chainspec/src/lib.rs index 70adf2272cfb..896baea1ce38 100644 --- a/crates/optimism/chainspec/src/lib.rs +++ b/crates/optimism/chainspec/src/lib.rs @@ -30,8 +30,8 @@ pub(crate) use once_cell::sync::Lazy as LazyLock; pub use op::OP_MAINNET; pub use op_sepolia::OP_SEPOLIA; use reth_chainspec::{ - BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, - DisplayHardforks, EthChainSpec, EthereumHardforks, ForkFilter, ForkId, Hardforks, Head, + BaseFeeParams, BaseFeeParamsKind, ChainSpec, ChainSpecBuilder, DepositContract, EthChainSpec, + EthereumHardforks, ForkFilter, ForkId, Hardforks, Head, }; use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition, Hardfork}; use reth_network_peers::NodeRecord; @@ -287,8 +287,8 @@ impl EthChainSpec for OpChainSpec { self.inner.prune_delete_limit() } - fn display_hardforks(&self) -> DisplayHardforks { - self.inner.display_hardforks() + fn display_hardforks(&self) -> Box { + Box::new(self.inner.display_hardforks()) } fn genesis_header(&self) -> &Header { From 5f8fd3f6939419070d8d887df1a622df7c849ee6 Mon Sep 17 00:00:00 2001 From: stevencartavia Date: Wed, 30 Oct 2024 19:18:49 -0600 Subject: [PATCH 2/5] update import --- crates/chainspec/src/api.rs | 4 ++-- crates/chainspec/src/spec.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/chainspec/src/api.rs b/crates/chainspec/src/api.rs index 95f6b65584a7..cd5dbd1c1d5e 100644 --- a/crates/chainspec/src/api.rs +++ b/crates/chainspec/src/api.rs @@ -1,10 +1,10 @@ use crate::{ChainSpec, DepositContract}; -use alloc::{fmt::Display, vec::Vec}; +use alloc::vec::Vec; use alloy_chains::Chain; use alloy_eips::eip1559::BaseFeeParams; use alloy_genesis::Genesis; use alloy_primitives::B256; -use core::fmt::Debug; +use core::fmt::{Debug, Display}; use reth_network_peers::NodeRecord; use reth_primitives_traits::Header; diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index 8a506c275632..b9d3fb004de3 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -1,6 +1,6 @@ pub use alloy_eips::eip1559::BaseFeeParams; -use alloc::{boxed::Box, fmt::Display, sync::Arc, vec::Vec}; +use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_chains::{Chain, NamedChain}; use alloy_consensus::constants::EMPTY_WITHDRAWALS; use alloy_eips::{ @@ -9,6 +9,7 @@ use alloy_eips::{ }; use alloy_genesis::Genesis; use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256}; +use core::fmt::Display; use derive_more::From; use alloy_consensus::constants::{DEV_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH}; From 189d5cca36feb6e90cb7cca8c5dd414cecb858b1 Mon Sep 17 00:00:00 2001 From: stevencartavia Date: Wed, 30 Oct 2024 19:33:38 -0600 Subject: [PATCH 3/5] fix --- crates/chainspec/src/api.rs | 2 +- crates/optimism/chainspec/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/chainspec/src/api.rs b/crates/chainspec/src/api.rs index cd5dbd1c1d5e..01710782599d 100644 --- a/crates/chainspec/src/api.rs +++ b/crates/chainspec/src/api.rs @@ -1,5 +1,5 @@ use crate::{ChainSpec, DepositContract}; -use alloc::vec::Vec; +use alloc::{boxed::Box, vec::Vec}; use alloy_chains::Chain; use alloy_eips::eip1559::BaseFeeParams; use alloy_genesis::Genesis; diff --git a/crates/optimism/chainspec/src/lib.rs b/crates/optimism/chainspec/src/lib.rs index 896baea1ce38..c90715d68425 100644 --- a/crates/optimism/chainspec/src/lib.rs +++ b/crates/optimism/chainspec/src/lib.rs @@ -17,7 +17,7 @@ mod dev; mod op; mod op_sepolia; -use alloc::{vec, vec::Vec}; +use alloc::{boxed::Box, vec, vec::Vec}; use alloy_chains::Chain; use alloy_genesis::Genesis; use alloy_primitives::{Bytes, Parity, Signature, B256, U256}; From 7aaca1c531bd73c16799c5baceb1fa08cfaad98b Mon Sep 17 00:00:00 2001 From: stevencartavia Date: Thu, 31 Oct 2024 11:14:36 -0600 Subject: [PATCH 4/5] update --- crates/chainspec/src/api.rs | 2 +- crates/chainspec/src/spec.rs | 8 ++------ crates/optimism/chainspec/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/crates/chainspec/src/api.rs b/crates/chainspec/src/api.rs index 01710782599d..a2072cc35659 100644 --- a/crates/chainspec/src/api.rs +++ b/crates/chainspec/src/api.rs @@ -89,7 +89,7 @@ impl EthChainSpec for ChainSpec { } fn display_hardforks(&self) -> Box { - Box::new(self.display_hardforks()) + Box::new(ChainSpec::display_hardforks(self)) } fn genesis_header(&self) -> &Header { diff --git a/crates/chainspec/src/spec.rs b/crates/chainspec/src/spec.rs index b9d3fb004de3..779eb8a37577 100644 --- a/crates/chainspec/src/spec.rs +++ b/crates/chainspec/src/spec.rs @@ -9,7 +9,6 @@ use alloy_eips::{ }; use alloy_genesis::Genesis; use alloy_primitives::{address, b256, Address, BlockNumber, B256, U256}; -use core::fmt::Display; use derive_more::From; use alloy_consensus::constants::{DEV_GENESIS_HASH, MAINNET_GENESIS_HASH, SEPOLIA_GENESIS_HASH}; @@ -394,11 +393,8 @@ impl ChainSpec { } /// Returns the hardfork display helper. - pub fn display_hardforks(&self) -> Box { - Box::new(DisplayHardforks::new( - &self, - self.paris_block_and_final_difficulty.map(|(block, _)| block), - )) + pub fn display_hardforks(&self) -> DisplayHardforks { + DisplayHardforks::new(&self, self.paris_block_and_final_difficulty.map(|(block, _)| block)) } /// Get the fork id for the given hardfork. diff --git a/crates/optimism/chainspec/src/lib.rs b/crates/optimism/chainspec/src/lib.rs index c90715d68425..8ad36c66afb0 100644 --- a/crates/optimism/chainspec/src/lib.rs +++ b/crates/optimism/chainspec/src/lib.rs @@ -288,7 +288,7 @@ impl EthChainSpec for OpChainSpec { } fn display_hardforks(&self) -> Box { - Box::new(self.inner.display_hardforks()) + Box::new(ChainSpec::display_hardforks(self)) } fn genesis_header(&self) -> &Header { From cdb67148b23b81e185001c752fd4f4f01fcc58b8 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 31 Oct 2024 20:51:28 +0100 Subject: [PATCH 5/5] Update crates/chainspec/src/api.rs --- crates/chainspec/src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/chainspec/src/api.rs b/crates/chainspec/src/api.rs index a2072cc35659..ee25f72bae8d 100644 --- a/crates/chainspec/src/api.rs +++ b/crates/chainspec/src/api.rs @@ -89,7 +89,7 @@ impl EthChainSpec for ChainSpec { } fn display_hardforks(&self) -> Box { - Box::new(ChainSpec::display_hardforks(self)) + Box::new(Self::display_hardforks(self)) } fn genesis_header(&self) -> &Header {