mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: use OpChainSpec in OptimismNode and its components (#11304)
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -7970,6 +7970,7 @@ dependencies = [
|
||||
"op-alloy-rpc-types",
|
||||
"reth-chainspec",
|
||||
"reth-ethereum-forks",
|
||||
"reth-network-peers",
|
||||
"reth-optimism-forks",
|
||||
"reth-primitives-traits",
|
||||
"serde_json",
|
||||
@ -8133,6 +8134,7 @@ dependencies = [
|
||||
"reth-chainspec",
|
||||
"reth-evm",
|
||||
"reth-execution-types",
|
||||
"reth-optimism-chainspec",
|
||||
"reth-optimism-consensus",
|
||||
"reth-optimism-evm",
|
||||
"reth-optimism-forks",
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
use crate::{ChainSpec, DepositContract};
|
||||
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, Display};
|
||||
use reth_network_peers::NodeRecord;
|
||||
use reth_primitives_traits::Header;
|
||||
|
||||
/// Trait representing type configuring a chain spec.
|
||||
@ -41,6 +43,9 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
|
||||
|
||||
/// The block gas limit.
|
||||
fn max_gas_limit(&self) -> u64;
|
||||
|
||||
/// The bootnodes for the chain, if any.
|
||||
fn bootnodes(&self) -> Option<Vec<NodeRecord>>;
|
||||
}
|
||||
|
||||
impl EthChainSpec for ChainSpec {
|
||||
@ -83,4 +88,8 @@ impl EthChainSpec for ChainSpec {
|
||||
fn max_gas_limit(&self) -> u64 {
|
||||
self.max_gas_limit
|
||||
}
|
||||
|
||||
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
|
||||
self.bootnodes()
|
||||
}
|
||||
}
|
||||
|
||||
@ -825,13 +825,13 @@ fn into_optimism_chain_spec(genesis: Genesis) -> ChainSpec {
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait for reading the current [`ChainSpec`].
|
||||
/// A trait for reading the current chainspec.
|
||||
#[auto_impl::auto_impl(&, Arc)]
|
||||
pub trait ChainSpecProvider: Send + Sync {
|
||||
/// The chain spec type.
|
||||
type ChainSpec: EthChainSpec + 'static;
|
||||
|
||||
/// Get an [`Arc`] to the [`ChainSpec`].
|
||||
/// Get an [`Arc`] to the chainspec.
|
||||
fn chain_spec(&self) -> Arc<Self::ChainSpec>;
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use alloy_primitives::B256;
|
||||
use clap::Parser;
|
||||
use reth_beacon_consensus::EthBeaconConsensus;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_config::{config::EtlConfig, Config};
|
||||
use reth_db::{init_db, open_db_read_only, DatabaseEnv};
|
||||
@ -50,14 +50,14 @@ pub struct EnvironmentArgs<C: ChainSpecParser> {
|
||||
pub db: DatabaseArgs,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> EnvironmentArgs<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> EnvironmentArgs<C> {
|
||||
/// Initializes environment according to [`AccessRights`] and returns an instance of
|
||||
/// [`Environment`].
|
||||
pub fn init<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
&self,
|
||||
access: AccessRights,
|
||||
) -> eyre::Result<Environment<N>> {
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain());
|
||||
let db_path = data_dir.db();
|
||||
let sf_path = data_dir.static_files();
|
||||
|
||||
@ -93,7 +93,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> EnvironmentArgs<C> {
|
||||
|
||||
let provider_factory = self.create_provider_factory(&config, db, sfp)?;
|
||||
if access.is_read_write() {
|
||||
debug!(target: "reth::cli", chain=%self.chain.chain, genesis=?self.chain.genesis_hash(), "Initializing genesis");
|
||||
debug!(target: "reth::cli", chain=%self.chain.chain(), genesis=?self.chain.genesis_hash(), "Initializing genesis");
|
||||
init_genesis(&provider_factory)?;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
use crate::db::get::{maybe_json_value_parser, table_key};
|
||||
use ahash::RandomState;
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_db::{DatabaseEnv, RawKey, RawTable, RawValue, TableViewer, Tables};
|
||||
use reth_db_api::{cursor::DbCursorRO, table::Table, transaction::DbTx};
|
||||
use reth_db_common::DbTool;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter, NodeTypesWithEngine};
|
||||
use reth_provider::providers::ProviderNodeTypes;
|
||||
use std::{
|
||||
hash::{BuildHasher, Hasher},
|
||||
sync::Arc,
|
||||
@ -35,7 +36,7 @@ pub struct Command {
|
||||
|
||||
impl Command {
|
||||
/// Execute `db checksum` command
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec = ChainSpec>>(
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec: EthereumHardforks>>(
|
||||
self,
|
||||
tool: &DbTool<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>>,
|
||||
) -> eyre::Result<()> {
|
||||
@ -63,9 +64,7 @@ impl<N: NodeTypesWithDB> ChecksumViewer<'_, N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB<ChainSpec = ChainSpec>> TableViewer<(u64, Duration)>
|
||||
for ChecksumViewer<'_, N>
|
||||
{
|
||||
impl<N: ProviderNodeTypes> TableViewer<(u64, Duration)> for ChecksumViewer<'_, N> {
|
||||
type Error = eyre::Report;
|
||||
|
||||
fn view<T: Table>(&self) -> Result<(u64, Duration), Self::Error> {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use alloy_primitives::BlockHash;
|
||||
use alloy_primitives::{hex, BlockHash};
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_db::{
|
||||
static_file::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask, ReceiptMask, TransactionMask},
|
||||
tables, RawKey, RawTable, Receipts, TableViewer, Transactions,
|
||||
@ -8,8 +7,8 @@ use reth_db::{
|
||||
use reth_db_api::table::{Decompress, DupSort, Table};
|
||||
use reth_db_common::DbTool;
|
||||
use reth_node_builder::NodeTypesWithDB;
|
||||
use reth_primitives::{hex, Header};
|
||||
use reth_provider::StaticFileProviderFactory;
|
||||
use reth_primitives::Header;
|
||||
use reth_provider::{providers::ProviderNodeTypes, StaticFileProviderFactory};
|
||||
use reth_static_file_types::StaticFileSegment;
|
||||
use tracing::error;
|
||||
|
||||
@ -54,10 +53,7 @@ enum Subcommand {
|
||||
|
||||
impl Command {
|
||||
/// Execute `db get` command
|
||||
pub fn execute<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
self,
|
||||
tool: &DbTool<N>,
|
||||
) -> eyre::Result<()> {
|
||||
pub fn execute<N: ProviderNodeTypes>(self, tool: &DbTool<N>) -> eyre::Result<()> {
|
||||
match self.subcommand {
|
||||
Subcommand::Mdbx { table, key, subkey, raw } => {
|
||||
table.view(&GetValueViewer { tool, key, subkey, raw })?
|
||||
@ -148,7 +144,7 @@ struct GetValueViewer<'a, N: NodeTypesWithDB> {
|
||||
raw: bool,
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB<ChainSpec = ChainSpec>> TableViewer<()> for GetValueViewer<'_, N> {
|
||||
impl<N: ProviderNodeTypes> TableViewer<()> for GetValueViewer<'_, N> {
|
||||
type Error = eyre::Report;
|
||||
|
||||
fn view<T: Table>(&self) -> Result<(), Self::Error> {
|
||||
|
||||
@ -2,7 +2,7 @@ use super::tui::DbListTUI;
|
||||
use alloy_primitives::hex;
|
||||
use clap::Parser;
|
||||
use eyre::WrapErr;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_db::{DatabaseEnv, RawValue, TableViewer, Tables};
|
||||
use reth_db_api::{database::Database, table::Table};
|
||||
use reth_db_common::{DbTool, ListFilter};
|
||||
@ -53,7 +53,7 @@ pub struct Command {
|
||||
|
||||
impl Command {
|
||||
/// Execute `db list` command
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec = ChainSpec>>(
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec: EthereumHardforks>>(
|
||||
self,
|
||||
tool: &DbTool<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>>,
|
||||
) -> eyre::Result<()> {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::{Parser, Subcommand};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_db::version::{get_db_version, DatabaseVersionError, DB_VERSION};
|
||||
use reth_db_common::DbTool;
|
||||
@ -63,12 +63,12 @@ macro_rules! db_ro_exec {
|
||||
};
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `db` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
) -> eyre::Result<()> {
|
||||
let data_dir = self.env.datadir.clone().resolve_datadir(self.env.chain.chain);
|
||||
let data_dir = self.env.datadir.clone().resolve_datadir(self.env.chain.chain());
|
||||
let db_path = data_dir.db();
|
||||
let static_files_path = data_dir.static_files();
|
||||
|
||||
|
||||
@ -4,14 +4,14 @@ use comfy_table::{Cell, Row, Table as ComfyTable};
|
||||
use eyre::WrapErr;
|
||||
use human_bytes::human_bytes;
|
||||
use itertools::Itertools;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_db::{mdbx, static_file::iter_static_files, DatabaseEnv, TableViewer, Tables};
|
||||
use reth_db_api::database::Database;
|
||||
use reth_db_common::DbTool;
|
||||
use reth_fs_util as fs;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter, NodeTypesWithEngine};
|
||||
use reth_node_core::dirs::{ChainPath, DataDirPath};
|
||||
use reth_provider::providers::StaticFileProvider;
|
||||
use reth_provider::providers::{ProviderNodeTypes, StaticFileProvider};
|
||||
use reth_static_file_types::SegmentRangeInclusive;
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
@ -38,7 +38,7 @@ pub struct Command {
|
||||
|
||||
impl Command {
|
||||
/// Execute `db stats` command
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec = ChainSpec>>(
|
||||
pub fn execute<N: NodeTypesWithEngine<ChainSpec: EthereumHardforks>>(
|
||||
self,
|
||||
data_dir: ChainPath<DataDirPath>,
|
||||
tool: &DbTool<NodeTypesWithDBAdapter<N, Arc<DatabaseEnv>>>,
|
||||
@ -325,10 +325,7 @@ impl Command {
|
||||
Ok(table)
|
||||
}
|
||||
|
||||
fn checksum_report<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
&self,
|
||||
tool: &DbTool<N>,
|
||||
) -> eyre::Result<ComfyTable> {
|
||||
fn checksum_report<N: ProviderNodeTypes>(&self, tool: &DbTool<N>) -> eyre::Result<ComfyTable> {
|
||||
let mut table = ComfyTable::new();
|
||||
table.load_preset(comfy_table::presets::ASCII_MARKDOWN);
|
||||
table.set_header(vec![Cell::new("Table"), Cell::new("Checksum"), Cell::new("Elapsed")]);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
|
||||
/// Dumps genesis block JSON configuration to stdout
|
||||
@ -21,7 +21,7 @@ pub struct DumpGenesisCommand<C: ChainSpecParser> {
|
||||
chain: Arc<C::ChainSpec>,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> DumpGenesisCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec>> DumpGenesisCommand<C> {
|
||||
/// Execute the `dump-genesis` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
println!("{}", serde_json::to_string_pretty(self.chain.genesis())?);
|
||||
|
||||
@ -4,7 +4,7 @@ use alloy_primitives::B256;
|
||||
use clap::Parser;
|
||||
use futures::{Stream, StreamExt};
|
||||
use reth_beacon_consensus::EthBeaconConsensus;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_config::Config;
|
||||
use reth_consensus::Consensus;
|
||||
@ -20,12 +20,12 @@ use reth_network_p2p::{
|
||||
bodies::downloader::BodyDownloader,
|
||||
headers::downloader::{HeaderDownloader, SyncTarget},
|
||||
};
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithEngine};
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_node_core::version::SHORT_VERSION;
|
||||
use reth_node_events::node::NodeEvent;
|
||||
use reth_provider::{
|
||||
BlockNumReader, ChainSpecProvider, HeaderProvider, ProviderError, ProviderFactory,
|
||||
StageCheckpointReader,
|
||||
providers::ProviderNodeTypes, BlockNumReader, ChainSpecProvider, HeaderProvider, ProviderError,
|
||||
ProviderFactory, StageCheckpointReader,
|
||||
};
|
||||
use reth_prune::PruneModes;
|
||||
use reth_stages::{prelude::*, Pipeline, StageId, StageSet};
|
||||
@ -56,7 +56,7 @@ pub struct ImportCommand<C: ChainSpecParser> {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> ImportCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> ImportCommand<C> {
|
||||
/// Execute `import` command
|
||||
pub async fn execute<N, E, F>(self, executor: F) -> eyre::Result<()>
|
||||
where
|
||||
@ -168,7 +168,7 @@ pub fn build_import_pipeline<N, C, E>(
|
||||
executor: E,
|
||||
) -> eyre::Result<(Pipeline<N>, impl Stream<Item = NodeEvent>)>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: ProviderNodeTypes,
|
||||
C: Consensus + 'static,
|
||||
E: BlockExecutorProvider,
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_provider::BlockHashReader;
|
||||
@ -15,7 +15,7 @@ pub struct InitCommand<C: ChainSpecParser> {
|
||||
env: EnvironmentArgs<C>,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> InitCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> InitCommand<C> {
|
||||
/// Execute the `init` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use alloy_primitives::B256;
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_config::config::EtlConfig;
|
||||
use reth_db_common::init::init_from_state_dump;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithEngine};
|
||||
use reth_provider::ProviderFactory;
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_provider::{providers::ProviderNodeTypes, ProviderFactory};
|
||||
|
||||
use std::{fs::File, io::BufReader, path::PathBuf};
|
||||
use tracing::info;
|
||||
@ -40,7 +40,7 @@ pub struct InitStateCommand<C: ChainSpecParser> {
|
||||
pub state: PathBuf,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> InitStateCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> InitStateCommand<C> {
|
||||
/// Execute the `init` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
@ -59,7 +59,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> InitStateCommand<C> {
|
||||
}
|
||||
|
||||
/// Initialize chain with state at specific block, from a file with state dump.
|
||||
pub fn init_at_state<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
pub fn init_at_state<N: ProviderNodeTypes>(
|
||||
state_dump_path: PathBuf,
|
||||
factory: ProviderFactory<N>,
|
||||
etl_config: EtlConfig,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Main node command for launching a node
|
||||
|
||||
use clap::{value_parser, Args, Parser};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_cli_util::parse_socket_address;
|
||||
@ -112,7 +112,7 @@ pub struct NodeCommand<
|
||||
pub ext: Ext,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> NodeCommand<C> {
|
||||
impl<C: ChainSpecParser> NodeCommand<C> {
|
||||
/// Parsers only the default CLI arguments
|
||||
pub fn parse_args() -> Self {
|
||||
Self::parse()
|
||||
@ -128,7 +128,11 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> NodeCommand<C> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>, Ext: clap::Args + fmt::Debug> NodeCommand<C, Ext> {
|
||||
impl<
|
||||
C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>,
|
||||
Ext: clap::Args + fmt::Debug,
|
||||
> NodeCommand<C, Ext>
|
||||
{
|
||||
/// Launches the node
|
||||
///
|
||||
/// This transforms the node command into a node config and launches the node using the given
|
||||
|
||||
@ -5,7 +5,7 @@ use std::{path::PathBuf, sync::Arc};
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use backon::{ConstantBuilder, Retryable};
|
||||
use clap::{Parser, Subcommand};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_util::{get_secret_key, hash_or_num_value_parser};
|
||||
use reth_config::Config;
|
||||
@ -73,10 +73,10 @@ pub enum Subcommands {
|
||||
Rlpx(rlpx::Command),
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `p2p` command
|
||||
pub async fn execute(self) -> eyre::Result<()> {
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain);
|
||||
let data_dir = self.datadir.clone().resolve_datadir(self.chain.chain());
|
||||
let config_path = self.config.clone().unwrap_or_else(|| data_dir.config());
|
||||
|
||||
// Load configuration
|
||||
@ -100,7 +100,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
let net = NetworkConfigBuilder::new(p2p_secret_key)
|
||||
.peer_config(config.peers_config_with_basic_nodes_from_file(None))
|
||||
.external_ip_resolver(self.network.nat)
|
||||
.disable_discv4_discovery_if(self.chain.chain.is_optimism())
|
||||
.disable_discv4_discovery_if(self.chain.chain().is_optimism())
|
||||
.boot_nodes(boot_nodes.clone())
|
||||
.apply(|builder| {
|
||||
self.network.discovery.apply_to_builder(builder, rlpx_socket, boot_nodes)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Command that runs pruning without any limits.
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_prune::PrunerBuilder;
|
||||
@ -15,7 +15,7 @@ pub struct PruneCommand<C: ChainSpecParser> {
|
||||
env: EnvironmentArgs<C>,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> PruneCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> PruneCommand<C> {
|
||||
/// Execute the `prune` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! `reth recover` command.
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
@ -22,7 +22,7 @@ pub enum Subcommands<C: ChainSpecParser> {
|
||||
StorageTries(storage_tries::Command<C>),
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `recover` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_db::tables;
|
||||
@ -21,7 +21,7 @@ pub struct Command<C: ChainSpecParser> {
|
||||
env: EnvironmentArgs<C>,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `storage-tries` recovery command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::Parser;
|
||||
use itertools::Itertools;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_db::{static_file::iter_static_files, tables};
|
||||
use reth_db_api::transaction::DbTxMut;
|
||||
@ -25,7 +25,7 @@ pub struct Command<C: ChainSpecParser> {
|
||||
stage: StageEnum,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `db` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
@ -164,7 +164,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
StageId::IndexStorageHistory.to_string(),
|
||||
Default::default(),
|
||||
)?;
|
||||
insert_genesis_history(&provider_rw.0, self.env.chain.genesis.alloc.iter())?;
|
||||
insert_genesis_history(&provider_rw.0, self.env.chain.genesis().alloc.iter())?;
|
||||
}
|
||||
StageEnum::TxLookup => {
|
||||
tx.clear::<tables::TransactionHashNumbers>()?;
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::setup;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_db::{tables, DatabaseEnv};
|
||||
use reth_db_api::{
|
||||
cursor::DbCursorRO, database::Database, table::TableImporter, transaction::DbTx,
|
||||
@ -10,7 +9,10 @@ use reth_db_common::DbTool;
|
||||
use reth_evm::{execute::BlockExecutorProvider, noop::NoopBlockExecutorProvider};
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter};
|
||||
use reth_node_core::dirs::{ChainPath, DataDirPath};
|
||||
use reth_provider::{providers::StaticFileProvider, DatabaseProviderFactory, ProviderFactory};
|
||||
use reth_provider::{
|
||||
providers::{ProviderNodeTypes, StaticFileProvider},
|
||||
DatabaseProviderFactory, ProviderFactory,
|
||||
};
|
||||
use reth_stages::{stages::ExecutionStage, Stage, StageCheckpoint, UnwindInput};
|
||||
use tracing::info;
|
||||
|
||||
@ -23,7 +25,7 @@ pub(crate) async fn dump_execution_stage<N, E>(
|
||||
executor: E,
|
||||
) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: ProviderNodeTypes,
|
||||
E: BlockExecutorProvider,
|
||||
{
|
||||
let (output_db, tip_block_number) = setup(from, to, &output_datadir.db(), db_tool)?;
|
||||
@ -129,7 +131,7 @@ fn import_tables_with_range<N: NodeTypesWithDB>(
|
||||
/// Dry-run an unwind to FROM block, so we can get the `PlainStorageState` and
|
||||
/// `PlainAccountState` safely. There might be some state dependency from an address
|
||||
/// which hasn't been changed in the given range.
|
||||
fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn unwind_and_copy<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: u64,
|
||||
tip_block_number: u64,
|
||||
@ -166,7 +168,7 @@ fn dry_run<N, E>(
|
||||
executor: E,
|
||||
) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: ProviderNodeTypes,
|
||||
E: BlockExecutorProvider,
|
||||
{
|
||||
info!(target: "reth::cli", "Executing stage. [dry-run]");
|
||||
|
||||
@ -3,17 +3,19 @@ use std::sync::Arc;
|
||||
use super::setup;
|
||||
use alloy_primitives::BlockNumber;
|
||||
use eyre::Result;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_db::{tables, DatabaseEnv};
|
||||
use reth_db_api::{database::Database, table::TableImporter};
|
||||
use reth_db_common::DbTool;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter};
|
||||
use reth_node_builder::NodeTypesWithDBAdapter;
|
||||
use reth_node_core::dirs::{ChainPath, DataDirPath};
|
||||
use reth_provider::{providers::StaticFileProvider, DatabaseProviderFactory, ProviderFactory};
|
||||
use reth_provider::{
|
||||
providers::{ProviderNodeTypes, StaticFileProvider},
|
||||
DatabaseProviderFactory, ProviderFactory,
|
||||
};
|
||||
use reth_stages::{stages::AccountHashingStage, Stage, StageCheckpoint, UnwindInput};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn dump_hashing_account_stage<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
pub(crate) async fn dump_hashing_account_stage<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: BlockNumber,
|
||||
to: BlockNumber,
|
||||
@ -49,7 +51,7 @@ pub(crate) async fn dump_hashing_account_stage<N: NodeTypesWithDB<ChainSpec = Ch
|
||||
}
|
||||
|
||||
/// Dry-run an unwind to FROM block and copy the necessary table data to the new database.
|
||||
fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn unwind_and_copy<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: u64,
|
||||
tip_block_number: u64,
|
||||
@ -74,7 +76,7 @@ fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
}
|
||||
|
||||
/// Try to re-execute the stage straight away
|
||||
fn dry_run<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn dry_run<N: ProviderNodeTypes>(
|
||||
output_provider_factory: ProviderFactory<N>,
|
||||
to: u64,
|
||||
from: u64,
|
||||
|
||||
@ -2,17 +2,19 @@ use std::sync::Arc;
|
||||
|
||||
use super::setup;
|
||||
use eyre::Result;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_db::{tables, DatabaseEnv};
|
||||
use reth_db_api::{database::Database, table::TableImporter};
|
||||
use reth_db_common::DbTool;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter};
|
||||
use reth_node_builder::NodeTypesWithDBAdapter;
|
||||
use reth_node_core::dirs::{ChainPath, DataDirPath};
|
||||
use reth_provider::{providers::StaticFileProvider, DatabaseProviderFactory, ProviderFactory};
|
||||
use reth_provider::{
|
||||
providers::{ProviderNodeTypes, StaticFileProvider},
|
||||
DatabaseProviderFactory, ProviderFactory,
|
||||
};
|
||||
use reth_stages::{stages::StorageHashingStage, Stage, StageCheckpoint, UnwindInput};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn dump_hashing_storage_stage<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
pub(crate) async fn dump_hashing_storage_stage<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: u64,
|
||||
to: u64,
|
||||
@ -39,7 +41,7 @@ pub(crate) async fn dump_hashing_storage_stage<N: NodeTypesWithDB<ChainSpec = Ch
|
||||
}
|
||||
|
||||
/// Dry-run an unwind to FROM block and copy the necessary table data to the new database.
|
||||
fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn unwind_and_copy<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: u64,
|
||||
tip_block_number: u64,
|
||||
@ -69,7 +71,7 @@ fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
}
|
||||
|
||||
/// Try to re-execute the stage straight away
|
||||
fn dry_run<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn dry_run<N: ProviderNodeTypes>(
|
||||
output_provider_factory: ProviderFactory<N>,
|
||||
to: u64,
|
||||
from: u64,
|
||||
|
||||
@ -3,16 +3,18 @@ use std::sync::Arc;
|
||||
use super::setup;
|
||||
use alloy_primitives::BlockNumber;
|
||||
use eyre::Result;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_config::config::EtlConfig;
|
||||
use reth_db::{tables, DatabaseEnv};
|
||||
use reth_db_api::{database::Database, table::TableImporter};
|
||||
use reth_db_common::DbTool;
|
||||
use reth_evm::noop::NoopBlockExecutorProvider;
|
||||
use reth_exex::ExExManagerHandle;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter};
|
||||
use reth_node_builder::NodeTypesWithDBAdapter;
|
||||
use reth_node_core::dirs::{ChainPath, DataDirPath};
|
||||
use reth_provider::{providers::StaticFileProvider, DatabaseProviderFactory, ProviderFactory};
|
||||
use reth_provider::{
|
||||
providers::{ProviderNodeTypes, StaticFileProvider},
|
||||
DatabaseProviderFactory, ProviderFactory,
|
||||
};
|
||||
use reth_prune::PruneModes;
|
||||
use reth_stages::{
|
||||
stages::{
|
||||
@ -23,7 +25,7 @@ use reth_stages::{
|
||||
};
|
||||
use tracing::info;
|
||||
|
||||
pub(crate) async fn dump_merkle_stage<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
pub(crate) async fn dump_merkle_stage<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
from: BlockNumber,
|
||||
to: BlockNumber,
|
||||
@ -66,7 +68,7 @@ pub(crate) async fn dump_merkle_stage<N: NodeTypesWithDB<ChainSpec = ChainSpec>>
|
||||
}
|
||||
|
||||
/// Dry-run an unwind to FROM block and copy the necessary table data to the new database.
|
||||
fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn unwind_and_copy<N: ProviderNodeTypes>(
|
||||
db_tool: &DbTool<N>,
|
||||
range: (u64, u64),
|
||||
tip_block_number: u64,
|
||||
@ -144,7 +146,7 @@ fn unwind_and_copy<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
}
|
||||
|
||||
/// Try to re-execute the stage straight away
|
||||
fn dry_run<N: NodeTypesWithDB<ChainSpec = ChainSpec>>(
|
||||
fn dry_run<N: ProviderNodeTypes>(
|
||||
output_provider_factory: ProviderFactory<N>,
|
||||
to: u64,
|
||||
from: u64,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Database debugging tool
|
||||
use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_db::{init_db, mdbx::DatabaseArguments, tables, DatabaseEnv};
|
||||
use reth_db_api::{
|
||||
@ -75,24 +75,26 @@ pub struct StageCommand {
|
||||
macro_rules! handle_stage {
|
||||
($stage_fn:ident, $tool:expr, $command:expr) => {{
|
||||
let StageCommand { output_datadir, from, to, dry_run, .. } = $command;
|
||||
let output_datadir = output_datadir.with_chain($tool.chain().chain, DatadirArgs::default());
|
||||
let output_datadir =
|
||||
output_datadir.with_chain($tool.chain().chain(), DatadirArgs::default());
|
||||
$stage_fn($tool, *from, *to, output_datadir, *dry_run).await?
|
||||
}};
|
||||
|
||||
($stage_fn:ident, $tool:expr, $command:expr, $executor:expr) => {{
|
||||
let StageCommand { output_datadir, from, to, dry_run, .. } = $command;
|
||||
let output_datadir = output_datadir.with_chain($tool.chain().chain, DatadirArgs::default());
|
||||
let output_datadir =
|
||||
output_datadir.with_chain($tool.chain().chain(), DatadirArgs::default());
|
||||
$stage_fn($tool, *from, *to, output_datadir, *dry_run, $executor).await?
|
||||
}};
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `dump-stage` command
|
||||
pub async fn execute<N, E, F>(self, executor: F) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>,
|
||||
E: BlockExecutorProvider,
|
||||
F: FnOnce(Arc<ChainSpec>) -> E,
|
||||
F: FnOnce(Arc<C::ChainSpec>) -> E,
|
||||
{
|
||||
let Environment { provider_factory, .. } = self.env.init::<N>(AccessRights::RO)?;
|
||||
let tool = DbTool::new(provider_factory)?;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_evm::execute::BlockExecutorProvider;
|
||||
@ -39,13 +39,13 @@ pub enum Subcommands<C: ChainSpecParser> {
|
||||
Unwind(unwind::Command<C>),
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `stage` command
|
||||
pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>,
|
||||
E: BlockExecutorProvider,
|
||||
F: FnOnce(Arc<ChainSpec>) -> E,
|
||||
F: FnOnce(Arc<C::ChainSpec>) -> E,
|
||||
{
|
||||
match self.command {
|
||||
Subcommands::Run(command) => command.execute::<N, _, _>(ctx, executor).await,
|
||||
|
||||
@ -6,7 +6,7 @@ use crate::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use alloy_eips::BlockHashOrNumber;
|
||||
use clap::Parser;
|
||||
use reth_beacon_consensus::EthBeaconConsensus;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_runner::CliContext;
|
||||
use reth_cli_util::get_secret_key;
|
||||
@ -102,13 +102,13 @@ pub struct Command<C: ChainSpecParser> {
|
||||
network: NetworkArgs,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `stage` command
|
||||
pub async fn execute<N, E, F>(self, ctx: CliContext, executor: F) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>,
|
||||
E: BlockExecutorProvider,
|
||||
F: FnOnce(Arc<ChainSpec>) -> E,
|
||||
F: FnOnce(Arc<C::ChainSpec>) -> E,
|
||||
{
|
||||
// Raise the fd limit of the process.
|
||||
// Does not do anything on windows.
|
||||
@ -131,7 +131,7 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
target_triple: VERGEN_CARGO_TARGET_TRIPLE,
|
||||
build_profile: BUILD_PROFILE_NAME,
|
||||
},
|
||||
ChainSpecInfo { name: provider_factory.chain_spec().chain.to_string() },
|
||||
ChainSpecInfo { name: provider_factory.chain_spec().chain().to_string() },
|
||||
ctx.task_executor,
|
||||
Hooks::new(
|
||||
provider_factory.db_ref().clone(),
|
||||
|
||||
@ -5,7 +5,7 @@ use alloy_eips::BlockHashOrNumber;
|
||||
use alloy_primitives::{BlockNumber, B256};
|
||||
use clap::{Parser, Subcommand};
|
||||
use reth_beacon_consensus::EthBeaconConsensus;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_config::Config;
|
||||
use reth_consensus::Consensus;
|
||||
@ -16,8 +16,8 @@ use reth_exex::ExExManagerHandle;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithEngine};
|
||||
use reth_node_core::args::NetworkArgs;
|
||||
use reth_provider::{
|
||||
BlockExecutionWriter, BlockNumReader, ChainSpecProvider, FinalizedBlockReader,
|
||||
FinalizedBlockWriter, ProviderFactory, StaticFileProviderFactory,
|
||||
providers::ProviderNodeTypes, BlockExecutionWriter, BlockNumReader, ChainSpecProvider,
|
||||
FinalizedBlockReader, FinalizedBlockWriter, ProviderFactory, StaticFileProviderFactory,
|
||||
};
|
||||
use reth_prune::PruneModes;
|
||||
use reth_stages::{
|
||||
@ -48,7 +48,7 @@ pub struct Command<C: ChainSpecParser> {
|
||||
offline: bool,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec: EthChainSpec + EthereumHardforks>> Command<C> {
|
||||
/// Execute `db stage unwind` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
@ -189,7 +189,7 @@ impl Subcommands {
|
||||
/// Returns the block range to unwind.
|
||||
///
|
||||
/// This returns an inclusive range: [target..=latest]
|
||||
fn unwind_range<N: NodeTypesWithDB<ChainSpec = ChainSpec, DB = Arc<DatabaseEnv>>>(
|
||||
fn unwind_range<N: ProviderNodeTypes<DB = Arc<DatabaseEnv>>>(
|
||||
&self,
|
||||
factory: ProviderFactory<N>,
|
||||
) -> eyre::Result<RangeInclusive<u64>> {
|
||||
|
||||
@ -10,7 +10,7 @@ use reth::{
|
||||
rpc::api::eth::{helpers::AddDevSigners, FullEthApiServer},
|
||||
tasks::TaskManager,
|
||||
};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_db::{test_utils::TempDatabase, DatabaseEnv};
|
||||
use reth_node_builder::{
|
||||
components::NodeComponentsBuilder, rpc::EthApiBuilderProvider, FullNodeTypesAdapter, Node,
|
||||
@ -47,11 +47,11 @@ mod traits;
|
||||
/// Creates the initial setup with `num_nodes` started and interconnected.
|
||||
pub async fn setup<N>(
|
||||
num_nodes: usize,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<N::ChainSpec>,
|
||||
is_dev: bool,
|
||||
) -> eyre::Result<(Vec<NodeHelperType<N, N::AddOns>>, TaskManager, Wallet)>
|
||||
where
|
||||
N: Default + Node<TmpNodeAdapter<N>> + NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
N: Default + Node<TmpNodeAdapter<N>> + NodeTypesWithEngine<ChainSpec: EthereumHardforks>,
|
||||
N::ComponentsBuilder: NodeComponentsBuilder<
|
||||
TmpNodeAdapter<N>,
|
||||
Components: NodeComponents<TmpNodeAdapter<N>, Network: PeersHandleProvider>,
|
||||
@ -73,8 +73,7 @@ where
|
||||
let mut nodes: Vec<NodeTestContext<_, _>> = Vec::with_capacity(num_nodes);
|
||||
|
||||
for idx in 0..num_nodes {
|
||||
let node_config = NodeConfig::test()
|
||||
.with_chain(chain_spec.clone())
|
||||
let node_config = NodeConfig::new(chain_spec.clone())
|
||||
.with_network(network_config.clone())
|
||||
.with_unused_ports()
|
||||
.with_rpc(RpcServerArgs::default().with_unused_ports().with_http())
|
||||
|
||||
@ -17,7 +17,7 @@ use reth::{
|
||||
types::engine::PayloadStatusEnum,
|
||||
},
|
||||
};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_node_builder::{NodeAddOns, NodeTypesWithEngine};
|
||||
use reth_stages_types::StageId;
|
||||
use tokio_stream::StreamExt;
|
||||
@ -50,7 +50,7 @@ impl<Node, Engine, AddOns> NodeTestContext<Node, AddOns>
|
||||
where
|
||||
Engine: EngineTypes,
|
||||
Node: FullNodeComponents,
|
||||
Node::Types: NodeTypesWithEngine<ChainSpec = ChainSpec, Engine = Engine>,
|
||||
Node::Types: NodeTypesWithEngine<ChainSpec: EthereumHardforks, Engine = Engine>,
|
||||
Node::Network: PeersHandleProvider,
|
||||
AddOns: NodeAddOns<Node>,
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@ use reth::{
|
||||
DebugApiServer,
|
||||
},
|
||||
};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_node_builder::{EthApiTypes, NodeTypes};
|
||||
|
||||
#[allow(missing_debug_implementations)]
|
||||
@ -18,7 +18,7 @@ pub struct RpcTestContext<Node: FullNodeComponents, EthApi: EthApiTypes> {
|
||||
|
||||
impl<Node, EthApi> RpcTestContext<Node, EthApi>
|
||||
where
|
||||
Node: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeComponents<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
|
||||
EthApi: EthApiSpec + EthTransactions + TraceExt,
|
||||
{
|
||||
/// Injects a raw transaction into the node tx pool via RPC server
|
||||
|
||||
@ -4,7 +4,7 @@ use alloy_primitives::{keccak256, B256, U256};
|
||||
use alloy_rpc_types_debug::ExecutionWitness;
|
||||
use eyre::OptionExt;
|
||||
use pretty_assertions::Comparison;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks};
|
||||
use reth_engine_primitives::InvalidBlockHook;
|
||||
use reth_evm::{
|
||||
system_calls::{apply_beacon_root_contract_call, apply_blockhashes_contract_call},
|
||||
@ -52,7 +52,11 @@ impl<P, EvmConfig> InvalidBlockWitnessHook<P, EvmConfig> {
|
||||
|
||||
impl<P, EvmConfig> InvalidBlockWitnessHook<P, EvmConfig>
|
||||
where
|
||||
P: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec> + Send + Sync + 'static,
|
||||
P: StateProviderFactory
|
||||
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
{
|
||||
fn on_invalid_block(
|
||||
@ -295,7 +299,11 @@ where
|
||||
|
||||
impl<P, EvmConfig> InvalidBlockHook for InvalidBlockWitnessHook<P, EvmConfig>
|
||||
where
|
||||
P: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec> + Send + Sync + 'static,
|
||||
P: StateProviderFactory
|
||||
+ ChainSpecProvider<ChainSpec: EthChainSpec + EthereumHardforks>
|
||||
+ Send
|
||||
+ Sync
|
||||
+ 'static,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
{
|
||||
fn on_invalid_block(
|
||||
|
||||
@ -10,7 +10,7 @@ pub use states::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::Future;
|
||||
use reth_chainspec::{ChainSpec, EthChainSpec, EthereumHardforks, Hardforks};
|
||||
use reth_chainspec::{EthChainSpec, EthereumHardforks, Hardforks};
|
||||
use reth_cli_util::get_secret_key;
|
||||
use reth_db_api::{
|
||||
database::Database,
|
||||
@ -641,7 +641,7 @@ impl<Node: FullNodeTypes> BuilderContext<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>> BuilderContext<Node> {
|
||||
impl<Node: FullNodeTypes<Types: NodeTypes<ChainSpec: Hardforks>>> BuilderContext<Node> {
|
||||
/// Creates the [`NetworkBuilder`] for the node.
|
||||
pub async fn network_builder(&self) -> eyre::Result<NetworkBuilder<(), ()>> {
|
||||
let network_config = self.network_config()?;
|
||||
|
||||
@ -10,7 +10,7 @@ use reth_beacon_consensus::EthBeaconConsensus;
|
||||
use reth_blockchain_tree::{
|
||||
BlockchainTree, BlockchainTreeConfig, ShareableBlockchainTree, TreeExternals,
|
||||
};
|
||||
use reth_chainspec::{Chain, ChainSpec, EthChainSpec, EthereumHardforks};
|
||||
use reth_chainspec::{Chain, EthChainSpec, EthereumHardforks};
|
||||
use reth_config::{config::EtlConfig, PruneConfig};
|
||||
use reth_consensus::Consensus;
|
||||
use reth_db_api::database::Database;
|
||||
@ -879,8 +879,8 @@ impl<T, CB>
|
||||
>
|
||||
where
|
||||
T: FullNodeTypes<
|
||||
Provider: WithTree + StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypes<ChainSpec = ChainSpec>,
|
||||
Provider: WithTree + StateProviderFactory + ChainSpecProvider,
|
||||
Types: NodeTypes<ChainSpec: EthereumHardforks>,
|
||||
>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
{
|
||||
|
||||
@ -7,7 +7,7 @@ use reth_beacon_consensus::{
|
||||
BeaconConsensusEngineHandle,
|
||||
};
|
||||
use reth_blockchain_tree::BlockchainTreeConfig;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthChainSpec;
|
||||
use reth_consensus_debug_client::{DebugConsensusClient, EtherscanBlockProvider};
|
||||
use reth_engine_service::service::{ChainEvent, EngineService};
|
||||
use reth_engine_tree::{
|
||||
@ -18,9 +18,7 @@ use reth_engine_util::EngineMessageStreamExt;
|
||||
use reth_exex::ExExManagerHandle;
|
||||
use reth_network::{NetworkSyncUpdater, SyncState};
|
||||
use reth_network_api::{BlockDownloaderProvider, NetworkEventListenerProvider};
|
||||
use reth_node_api::{
|
||||
BuiltPayload, FullNodeTypes, NodeAddOns, NodeTypesWithDB, NodeTypesWithEngine,
|
||||
};
|
||||
use reth_node_api::{BuiltPayload, FullNodeTypes, NodeAddOns, NodeTypesWithEngine};
|
||||
use reth_node_core::{
|
||||
dirs::{ChainPath, DataDirPath},
|
||||
exit::NodeExitFuture,
|
||||
@ -30,7 +28,8 @@ use reth_node_core::{
|
||||
};
|
||||
use reth_node_events::{cl::ConsensusLayerHealthEvents, node};
|
||||
use reth_payload_primitives::PayloadBuilder;
|
||||
use reth_provider::providers::BlockchainProvider2;
|
||||
use reth_primitives::EthereumHardforks;
|
||||
use reth_provider::providers::{BlockchainProvider2, ProviderNodeTypes};
|
||||
use reth_rpc_engine_api::{capabilities::EngineCapabilities, EngineApi};
|
||||
use reth_tasks::TaskExecutor;
|
||||
use reth_tokio_util::EventSender;
|
||||
@ -72,7 +71,7 @@ impl EngineNodeLauncher {
|
||||
|
||||
impl<Types, T, CB, AO> LaunchNode<NodeBuilderWithComponents<T, CB, AO>> for EngineNodeLauncher
|
||||
where
|
||||
Types: NodeTypesWithDB<ChainSpec = ChainSpec> + NodeTypesWithEngine,
|
||||
Types: ProviderNodeTypes + NodeTypesWithEngine,
|
||||
T: FullNodeTypes<Types = Types, Provider = BlockchainProvider2<Types>>,
|
||||
CB: NodeComponentsBuilder<T>,
|
||||
AO: NodeAddOns<
|
||||
@ -127,7 +126,7 @@ where
|
||||
debug!(target: "reth::cli", chain=%this.chain_id(), genesis=?this.genesis_hash(), "Initializing genesis");
|
||||
})
|
||||
.with_genesis()?
|
||||
.inspect(|this: &LaunchContextWith<Attached<WithConfigs<ChainSpec>, _>>| {
|
||||
.inspect(|this: &LaunchContextWith<Attached<WithConfigs<Types::ChainSpec>, _>>| {
|
||||
info!(target: "reth::cli", "\n{}", this.chain_spec().display_hardforks());
|
||||
})
|
||||
.with_metrics_task()
|
||||
@ -296,7 +295,7 @@ where
|
||||
if let Some(maybe_custom_etherscan_url) = ctx.node_config().debug.etherscan.clone() {
|
||||
info!(target: "reth::cli", "Using etherscan as consensus client");
|
||||
|
||||
let chain = ctx.node_config().chain.chain;
|
||||
let chain = ctx.node_config().chain.chain();
|
||||
let etherscan_url = maybe_custom_etherscan_url.map(Ok).unwrap_or_else(|| {
|
||||
// If URL isn't provided, use default Etherscan URL for the chain if it is known
|
||||
chain
|
||||
|
||||
@ -4,11 +4,10 @@ use std::{
|
||||
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6},
|
||||
ops::Not,
|
||||
path::PathBuf,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use clap::Args;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthChainSpec;
|
||||
use reth_config::Config;
|
||||
use reth_discv4::{NodeRecord, DEFAULT_DISCOVERY_ADDR, DEFAULT_DISCOVERY_PORT};
|
||||
use reth_discv5::{
|
||||
@ -186,8 +185,8 @@ impl NetworkArgs {
|
||||
})
|
||||
}
|
||||
|
||||
/// Build a [`NetworkConfigBuilder`] from a [`Config`] and a [`ChainSpec`], in addition to the
|
||||
/// values in this option struct.
|
||||
/// Build a [`NetworkConfigBuilder`] from a [`Config`] and a [`EthChainSpec`], in addition to
|
||||
/// the values in this option struct.
|
||||
///
|
||||
/// The `default_peers_file` will be used as the default location to store the persistent peers
|
||||
/// file if `no_persist_peers` is false, and there is no provided `peers_file`.
|
||||
@ -200,7 +199,7 @@ impl NetworkArgs {
|
||||
pub fn network_config(
|
||||
&self,
|
||||
config: &Config,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: impl EthChainSpec,
|
||||
secret_key: SecretKey,
|
||||
default_peers_file: PathBuf,
|
||||
) -> NetworkConfigBuilder {
|
||||
|
||||
@ -139,6 +139,25 @@ impl NodeConfig<ChainSpec> {
|
||||
}
|
||||
|
||||
impl<ChainSpec> NodeConfig<ChainSpec> {
|
||||
/// Creates a new config with given chain spec, setting all fields to default values.
|
||||
pub fn new(chain: Arc<ChainSpec>) -> Self {
|
||||
Self {
|
||||
config: None,
|
||||
chain,
|
||||
metrics: None,
|
||||
instance: 1,
|
||||
network: NetworkArgs::default(),
|
||||
rpc: RpcServerArgs::default(),
|
||||
txpool: TxPoolArgs::default(),
|
||||
builder: PayloadBuilderArgs::default(),
|
||||
debug: DebugArgs::default(),
|
||||
db: DatabaseArgs::default(),
|
||||
dev: DevArgs::default(),
|
||||
pruning: PruningArgs::default(),
|
||||
datadir: DatadirArgs::default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets --dev mode for the node.
|
||||
///
|
||||
/// In addition to setting the `--dev` flag, this also:
|
||||
@ -407,21 +426,7 @@ impl<ChainSpec> NodeConfig<ChainSpec> {
|
||||
|
||||
impl Default for NodeConfig<ChainSpec> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
config: None,
|
||||
chain: MAINNET.clone(),
|
||||
metrics: None,
|
||||
instance: 1,
|
||||
network: NetworkArgs::default(),
|
||||
rpc: RpcServerArgs::default(),
|
||||
txpool: TxPoolArgs::default(),
|
||||
builder: PayloadBuilderArgs::default(),
|
||||
debug: DebugArgs::default(),
|
||||
db: DatabaseArgs::default(),
|
||||
dev: DevArgs::default(),
|
||||
pruning: PruningArgs::default(),
|
||||
datadir: DatadirArgs::default(),
|
||||
}
|
||||
Self::new(MAINNET.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -16,12 +16,14 @@ workspace = true
|
||||
reth-chainspec = { workspace = true, features = ["optimism"] }
|
||||
reth-ethereum-forks.workspace = true
|
||||
reth-primitives-traits.workspace = true
|
||||
reth-network-peers.workspace = true
|
||||
|
||||
# op-reth
|
||||
reth-optimism-forks.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-chains.workspace = true
|
||||
alloy-genesis.workspace = true
|
||||
alloy-primitives.workspace = true
|
||||
|
||||
# io
|
||||
|
||||
@ -16,7 +16,10 @@ mod dev;
|
||||
mod op;
|
||||
mod op_sepolia;
|
||||
|
||||
use alloy_primitives::{Parity, Signature, U256};
|
||||
use std::fmt::Display;
|
||||
|
||||
use alloy_genesis::Genesis;
|
||||
use alloy_primitives::{Parity, Signature, B256, U256};
|
||||
pub use base::BASE_MAINNET;
|
||||
pub use base_sepolia::BASE_SEPOLIA;
|
||||
pub use dev::OP_DEV;
|
||||
@ -24,10 +27,15 @@ pub use op::OP_MAINNET;
|
||||
pub use op_sepolia::OP_SEPOLIA;
|
||||
|
||||
use derive_more::{Constructor, Deref, Into};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::{
|
||||
BaseFeeParams, ChainSpec, DepositContract, EthChainSpec, EthereumHardforks, ForkFilter, ForkId,
|
||||
Hardforks, Head,
|
||||
};
|
||||
use reth_network_peers::NodeRecord;
|
||||
use reth_primitives_traits::Header;
|
||||
|
||||
/// OP stack chain spec type.
|
||||
#[derive(Debug, Clone, Deref, Into, Constructor)]
|
||||
#[derive(Debug, Clone, Deref, Into, Constructor, PartialEq, Eq)]
|
||||
pub struct OpChainSpec {
|
||||
/// [`ChainSpec`].
|
||||
pub inner: ChainSpec,
|
||||
@ -39,6 +47,86 @@ pub fn optimism_deposit_tx_signature() -> Signature {
|
||||
Signature::new(U256::ZERO, U256::ZERO, Parity::Parity(false))
|
||||
}
|
||||
|
||||
impl EthChainSpec for OpChainSpec {
|
||||
fn chain(&self) -> alloy_chains::Chain {
|
||||
self.inner.chain()
|
||||
}
|
||||
|
||||
fn base_fee_params_at_timestamp(&self, timestamp: u64) -> BaseFeeParams {
|
||||
self.inner.base_fee_params_at_timestamp(timestamp)
|
||||
}
|
||||
|
||||
fn base_fee_params_at_block(&self, block_number: u64) -> BaseFeeParams {
|
||||
self.inner.base_fee_params_at_block(block_number)
|
||||
}
|
||||
|
||||
fn deposit_contract(&self) -> Option<&DepositContract> {
|
||||
self.inner.deposit_contract()
|
||||
}
|
||||
|
||||
fn genesis_hash(&self) -> B256 {
|
||||
self.inner.genesis_hash()
|
||||
}
|
||||
|
||||
fn prune_delete_limit(&self) -> usize {
|
||||
self.inner.prune_delete_limit()
|
||||
}
|
||||
|
||||
fn display_hardforks(&self) -> impl Display {
|
||||
self.inner.display_hardforks()
|
||||
}
|
||||
|
||||
fn genesis_header(&self) -> &Header {
|
||||
self.inner.genesis_header()
|
||||
}
|
||||
|
||||
fn genesis(&self) -> &Genesis {
|
||||
self.inner.genesis()
|
||||
}
|
||||
|
||||
fn max_gas_limit(&self) -> u64 {
|
||||
self.inner.max_gas_limit()
|
||||
}
|
||||
|
||||
fn bootnodes(&self) -> Option<Vec<NodeRecord>> {
|
||||
self.inner.bootnodes()
|
||||
}
|
||||
}
|
||||
|
||||
impl Hardforks for OpChainSpec {
|
||||
fn fork<H: reth_chainspec::Hardfork>(&self, fork: H) -> reth_chainspec::ForkCondition {
|
||||
self.inner.fork(fork)
|
||||
}
|
||||
|
||||
fn forks_iter(
|
||||
&self,
|
||||
) -> impl Iterator<Item = (&dyn reth_chainspec::Hardfork, reth_chainspec::ForkCondition)> {
|
||||
self.inner.forks_iter()
|
||||
}
|
||||
|
||||
fn fork_id(&self, head: &Head) -> ForkId {
|
||||
self.inner.fork_id(head)
|
||||
}
|
||||
|
||||
fn latest_fork_id(&self) -> ForkId {
|
||||
self.inner.latest_fork_id()
|
||||
}
|
||||
|
||||
fn fork_filter(&self, head: Head) -> ForkFilter {
|
||||
self.inner.fork_filter(head)
|
||||
}
|
||||
}
|
||||
|
||||
impl EthereumHardforks for OpChainSpec {
|
||||
fn final_paris_total_difficulty(&self, block_number: u64) -> Option<U256> {
|
||||
self.inner.final_paris_total_difficulty(block_number)
|
||||
}
|
||||
|
||||
fn get_final_paris_total_difficulty(&self) -> Option<U256> {
|
||||
self.inner.get_final_paris_total_difficulty()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use alloy_genesis::Genesis;
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_node_core::args::utils::parse_custom_chain_spec;
|
||||
use reth_optimism_chainspec::{
|
||||
@ -27,7 +26,7 @@ fn chain_value_parser(s: &str) -> eyre::Result<Arc<OpChainSpec>, eyre::Error> {
|
||||
pub struct OpChainSpecParser;
|
||||
|
||||
impl ChainSpecParser for OpChainSpecParser {
|
||||
type ChainSpec = ChainSpec;
|
||||
type ChainSpec = OpChainSpec;
|
||||
|
||||
const SUPPORTED_CHAINS: &'static [&'static str] = &[
|
||||
"dev",
|
||||
@ -40,7 +39,7 @@ impl ChainSpecParser for OpChainSpecParser {
|
||||
];
|
||||
|
||||
fn parse(s: &str) -> eyre::Result<Arc<Self::ChainSpec>> {
|
||||
chain_value_parser(s).map(|s| Arc::new(Arc::unwrap_or_clone(s).inner))
|
||||
chain_value_parser(s)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use alloy_primitives::B256;
|
||||
use futures_util::{Stream, StreamExt};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_config::Config;
|
||||
use reth_consensus::Consensus;
|
||||
use reth_downloaders::{
|
||||
@ -14,6 +13,7 @@ use reth_network_p2p::{
|
||||
};
|
||||
use reth_node_builder::NodeTypesWithDB;
|
||||
use reth_node_events::node::NodeEvent;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_evm::OpExecutorProvider;
|
||||
use reth_provider::{BlockNumReader, ChainSpecProvider, HeaderProvider, ProviderFactory};
|
||||
use reth_prune::PruneModes;
|
||||
@ -36,7 +36,7 @@ pub(crate) async fn build_import_pipeline<N, C>(
|
||||
disable_exec: bool,
|
||||
) -> eyre::Result<(Pipeline<N>, impl Stream<Item = NodeEvent>)>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: NodeTypesWithDB<ChainSpec = OpChainSpec>,
|
||||
C: Consensus + 'static,
|
||||
{
|
||||
if !file_client.has_canonical_blocks() {
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
//! Command that initializes the node by importing OP Mainnet chain segment below Bedrock, from a
|
||||
//! file.
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use reth_consensus::noop::NoopConsensus;
|
||||
@ -12,6 +11,7 @@ use reth_downloaders::file_client::{
|
||||
};
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_node_core::version::SHORT_VERSION;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_primitives::bedrock::is_dup_tx;
|
||||
use reth_provider::StageCheckpointReader;
|
||||
use reth_prune::PruneModes;
|
||||
@ -40,7 +40,7 @@ pub struct ImportOpCommand<C: ChainSpecParser> {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> ImportOpCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> ImportOpCommand<C> {
|
||||
/// Execute `import` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_commands::common::{AccessRights, Environment, EnvironmentArgs};
|
||||
use reth_db::tables;
|
||||
@ -15,12 +14,13 @@ use reth_downloaders::{
|
||||
use reth_execution_types::ExecutionOutcome;
|
||||
use reth_node_builder::{NodeTypesWithDB, NodeTypesWithEngine};
|
||||
use reth_node_core::version::SHORT_VERSION;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_primitives::bedrock::is_dup_tx;
|
||||
use reth_primitives::Receipts;
|
||||
use reth_provider::{
|
||||
writer::UnifiedStorageWriter, DatabaseProviderFactory, OriginalValuesKnown, ProviderFactory,
|
||||
StageCheckpointReader, StageCheckpointWriter, StateWriter, StaticFileProviderFactory,
|
||||
StaticFileWriter, StatsReader,
|
||||
providers::ProviderNodeTypes, writer::UnifiedStorageWriter, DatabaseProviderFactory,
|
||||
OriginalValuesKnown, ProviderFactory, StageCheckpointReader, StageCheckpointWriter,
|
||||
StateWriter, StaticFileProviderFactory, StaticFileWriter, StatsReader,
|
||||
};
|
||||
use reth_stages::{StageCheckpoint, StageId};
|
||||
use reth_static_file_types::StaticFileSegment;
|
||||
@ -46,7 +46,7 @@ pub struct ImportReceiptsOpCommand<C: ChainSpecParser> {
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> ImportReceiptsOpCommand<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> ImportReceiptsOpCommand<C> {
|
||||
/// Execute `import` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
@ -88,7 +88,7 @@ pub async fn import_receipts_from_file<N, P, F>(
|
||||
filter: F,
|
||||
) -> eyre::Result<()>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: NodeTypesWithDB<ChainSpec = OpChainSpec>,
|
||||
P: AsRef<Path>,
|
||||
F: FnMut(u64, &mut Receipts) -> usize,
|
||||
{
|
||||
@ -126,7 +126,7 @@ pub async fn import_receipts_from_reader<N, F>(
|
||||
mut filter: F,
|
||||
) -> eyre::Result<ImportReceiptsResult>
|
||||
where
|
||||
N: NodeTypesWithDB<ChainSpec = ChainSpec>,
|
||||
N: ProviderNodeTypes,
|
||||
F: FnMut(u64, &mut Receipts) -> usize,
|
||||
{
|
||||
let static_file_provider = provider_factory.static_file_provider();
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
//! Command that initializes the node from a genesis file.
|
||||
|
||||
use clap::Parser;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_commands::common::{AccessRights, Environment};
|
||||
use reth_db_common::init::init_from_state_dump;
|
||||
use reth_node_builder::NodeTypesWithEngine;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_primitives::bedrock::BEDROCK_HEADER;
|
||||
use reth_provider::{
|
||||
BlockNumReader, ChainSpecProvider, DatabaseProviderFactory, StaticFileProviderFactory,
|
||||
@ -35,7 +35,7 @@ pub struct InitStateCommandOp<C: ChainSpecParser> {
|
||||
without_ovm: bool,
|
||||
}
|
||||
|
||||
impl<C: ChainSpecParser<ChainSpec = ChainSpec>> InitStateCommandOp<C> {
|
||||
impl<C: ChainSpecParser<ChainSpec = OpChainSpec>> InitStateCommandOp<C> {
|
||||
/// Execute the `init` command
|
||||
pub async fn execute<N: NodeTypesWithEngine<ChainSpec = C::ChainSpec>>(
|
||||
self,
|
||||
|
||||
@ -2,7 +2,6 @@ use crate::chainspec::OpChainSpecParser;
|
||||
use clap::Subcommand;
|
||||
use import::ImportOpCommand;
|
||||
use import_receipts::ImportReceiptsOpCommand;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_commands::{
|
||||
config_cmd, db, dump_genesis, init_cmd,
|
||||
@ -19,10 +18,8 @@ pub mod init_state;
|
||||
|
||||
/// Commands to be executed
|
||||
#[derive(Debug, Subcommand)]
|
||||
pub enum Commands<
|
||||
Spec: ChainSpecParser<ChainSpec = ChainSpec> = OpChainSpecParser,
|
||||
Ext: clap::Args + fmt::Debug = NoArgs,
|
||||
> {
|
||||
pub enum Commands<Spec: ChainSpecParser = OpChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs>
|
||||
{
|
||||
/// Start the node
|
||||
#[command(name = "node")]
|
||||
Node(Box<node::NodeCommand<Spec, Ext>>),
|
||||
|
||||
@ -28,6 +28,7 @@ pub mod commands;
|
||||
pub mod receipt_file_codec;
|
||||
|
||||
pub use commands::{import::ImportOpCommand, import_receipts::ImportReceiptsOpCommand};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
|
||||
use std::{ffi::OsString, fmt, sync::Arc};
|
||||
|
||||
@ -35,7 +36,7 @@ use chainspec::OpChainSpecParser;
|
||||
use clap::{command, value_parser, Parser};
|
||||
use commands::Commands;
|
||||
use futures_util::Future;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthChainSpec;
|
||||
use reth_cli::chainspec::ChainSpecParser;
|
||||
use reth_cli_commands::node::NoArgs;
|
||||
use reth_cli_runner::CliRunner;
|
||||
@ -55,10 +56,7 @@ use tracing::info;
|
||||
/// This is the entrypoint to the executable.
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(author, version = SHORT_VERSION, long_version = LONG_VERSION, about = "Reth", long_about = None)]
|
||||
pub struct Cli<
|
||||
Spec: ChainSpecParser<ChainSpec = ChainSpec> = OpChainSpecParser,
|
||||
Ext: clap::Args + fmt::Debug = NoArgs,
|
||||
> {
|
||||
pub struct Cli<Spec: ChainSpecParser = OpChainSpecParser, Ext: clap::Args + fmt::Debug = NoArgs> {
|
||||
/// The command to run
|
||||
#[command(subcommand)]
|
||||
command: Commands<Spec, Ext>,
|
||||
@ -112,9 +110,9 @@ impl Cli {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Spec, Ext> Cli<Spec, Ext>
|
||||
impl<C, Ext> Cli<C, Ext>
|
||||
where
|
||||
Spec: ChainSpecParser<ChainSpec = ChainSpec>,
|
||||
C: ChainSpecParser<ChainSpec = OpChainSpec>,
|
||||
Ext: clap::Args + fmt::Debug,
|
||||
{
|
||||
/// Execute the configured cli command.
|
||||
@ -123,12 +121,12 @@ where
|
||||
/// [`NodeCommand`](reth_cli_commands::node::NodeCommand).
|
||||
pub fn run<L, Fut>(mut self, launcher: L) -> eyre::Result<()>
|
||||
where
|
||||
L: FnOnce(WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, ChainSpec>>, Ext) -> Fut,
|
||||
L: FnOnce(WithLaunchContext<NodeBuilder<Arc<DatabaseEnv>, C::ChainSpec>>, Ext) -> Fut,
|
||||
Fut: Future<Output = eyre::Result<()>>,
|
||||
{
|
||||
// add network name to logs dir
|
||||
self.logs.log_file_directory =
|
||||
self.logs.log_file_directory.join(self.chain.chain.to_string());
|
||||
self.logs.log_file_directory.join(self.chain.chain().to_string());
|
||||
|
||||
let _guard = self.init_tracing()?;
|
||||
info!(target: "reth::cli", "Initialized tracing, debug log directory: {}", self.logs.log_file_directory);
|
||||
|
||||
@ -21,6 +21,7 @@ reth-trie-common.workspace = true
|
||||
|
||||
# op-reth
|
||||
reth-optimism-forks.workspace = true
|
||||
reth-optimism-chainspec.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-primitives.workspace = true
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#![cfg(feature = "optimism")]
|
||||
|
||||
use alloy_primitives::{B64, U256};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
|
||||
use reth_consensus_common::validation::{
|
||||
validate_against_parent_4844, validate_against_parent_eip1559_base_fee,
|
||||
@ -18,6 +18,7 @@ use reth_consensus_common::validation::{
|
||||
validate_header_base_fee, validate_header_extradata, validate_header_gas,
|
||||
validate_shanghai_withdrawals,
|
||||
};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_forks::OptimismHardforks;
|
||||
use reth_primitives::{
|
||||
BlockWithSenders, GotExpected, Header, SealedBlock, SealedHeader, EMPTY_OMMER_ROOT_HASH,
|
||||
@ -36,17 +37,12 @@ pub use validation::validate_block_post_execution;
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct OptimismBeaconConsensus {
|
||||
/// Configuration
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
}
|
||||
|
||||
impl OptimismBeaconConsensus {
|
||||
/// Create a new instance of [`OptimismBeaconConsensus`]
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// If given chain spec is not optimism [`ChainSpec::is_optimism`]
|
||||
pub fn new(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
assert!(chain_spec.is_optimism(), "optimism consensus only valid for optimism chains");
|
||||
pub const fn new(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||
Self { chain_spec }
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,23 +32,20 @@ use tracing::trace;
|
||||
/// Provides executors to execute regular optimism blocks
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OpExecutorProvider<EvmConfig = OptimismEvmConfig> {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
evm_config: EvmConfig,
|
||||
}
|
||||
|
||||
impl OpExecutorProvider {
|
||||
/// Creates a new default optimism executor provider.
|
||||
pub fn optimism(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
Self::new(
|
||||
chain_spec.clone(),
|
||||
OptimismEvmConfig::new(Arc::new(OpChainSpec { inner: (*chain_spec).clone() })),
|
||||
)
|
||||
pub fn optimism(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||
Self::new(chain_spec.clone(), OptimismEvmConfig::new(chain_spec))
|
||||
}
|
||||
}
|
||||
|
||||
impl<EvmConfig> OpExecutorProvider<EvmConfig> {
|
||||
/// Creates a new executor provider.
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>, evm_config: EvmConfig) -> Self {
|
||||
pub const fn new(chain_spec: Arc<OpChainSpec>, evm_config: EvmConfig) -> Self {
|
||||
Self { chain_spec, evm_config }
|
||||
}
|
||||
}
|
||||
@ -98,7 +95,7 @@ where
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OpEvmExecutor<EvmConfig> {
|
||||
/// The chainspec
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
/// How to create an EVM.
|
||||
evm_config: EvmConfig,
|
||||
}
|
||||
@ -240,7 +237,11 @@ pub struct OpBlockExecutor<EvmConfig, DB> {
|
||||
|
||||
impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB> {
|
||||
/// Creates a new Optimism block executor.
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>, evm_config: EvmConfig, state: State<DB>) -> Self {
|
||||
pub const fn new(
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
evm_config: EvmConfig,
|
||||
state: State<DB>,
|
||||
) -> Self {
|
||||
Self { executor: OpEvmExecutor { chain_spec, evm_config }, state }
|
||||
}
|
||||
|
||||
@ -504,12 +505,8 @@ mod tests {
|
||||
}
|
||||
|
||||
fn executor_provider(chain_spec: Arc<ChainSpec>) -> OpExecutorProvider<OptimismEvmConfig> {
|
||||
OpExecutorProvider {
|
||||
evm_config: OptimismEvmConfig::new(Arc::new(OpChainSpec {
|
||||
inner: (*chain_spec).clone(),
|
||||
})),
|
||||
chain_spec,
|
||||
}
|
||||
let chain_spec = Arc::new(OpChainSpec::new(Arc::unwrap_or_clone(chain_spec)));
|
||||
OpExecutorProvider { evm_config: OptimismEvmConfig::new(chain_spec.clone()), chain_spec }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -4,6 +4,7 @@ use crate::OptimismBlockExecutionError;
|
||||
use alloy_primitives::{address, b256, hex, Address, Bytes, B256, U256};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_execution_errors::BlockExecutionError;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_forks::OptimismHardfork;
|
||||
use reth_primitives::Block;
|
||||
use revm::{
|
||||
@ -260,7 +261,7 @@ impl RethL1BlockInfo for L1BlockInfo {
|
||||
/// deployer contract. This is done by directly setting the code of the create2 deployer account
|
||||
/// prior to executing any transactions on the timestamp activation of the fork.
|
||||
pub fn ensure_create2_deployer<DB>(
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
timestamp: u64,
|
||||
db: &mut revm::State<DB>,
|
||||
) -> Result<(), DB::Error>
|
||||
|
||||
@ -14,6 +14,7 @@ use reth_node_api::{
|
||||
},
|
||||
validate_version_specific_fields, EngineTypes, EngineValidator,
|
||||
};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_forks::OptimismHardfork;
|
||||
use reth_optimism_payload_builder::{OptimismBuiltPayload, OptimismPayloadBuilderAttributes};
|
||||
|
||||
@ -25,12 +26,12 @@ pub struct OptimismEngineTypes;
|
||||
/// Validator for Optimism engine API.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OptimismEngineValidator {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
}
|
||||
|
||||
impl OptimismEngineValidator {
|
||||
/// Instantiates a new validator.
|
||||
pub const fn new(chain_spec: Arc<ChainSpec>) -> Self {
|
||||
pub const fn new(chain_spec: Arc<OpChainSpec>) -> Self {
|
||||
Self { chain_spec }
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use reth_basic_payload_builder::{BasicPayloadJobGenerator, BasicPayloadJobGeneratorConfig};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_network::{NetworkHandle, NetworkManager};
|
||||
use reth_node_api::{EngineValidator, FullNodeComponents, NodeAddOns};
|
||||
@ -63,7 +62,7 @@ impl OptimismNode {
|
||||
>
|
||||
where
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = OpChainSpec>,
|
||||
>,
|
||||
{
|
||||
let RollupArgs { disable_txpool_gossip, compute_pending_block, discovery_v4, .. } = args;
|
||||
@ -84,7 +83,7 @@ impl OptimismNode {
|
||||
impl<N> Node<N> for OptimismNode
|
||||
where
|
||||
N: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = OpChainSpec>,
|
||||
>,
|
||||
{
|
||||
type ComponentsBuilder = ComponentsBuilder<
|
||||
@ -107,7 +106,7 @@ where
|
||||
|
||||
impl NodeTypes for OptimismNode {
|
||||
type Primitives = ();
|
||||
type ChainSpec = ChainSpec;
|
||||
type ChainSpec = OpChainSpec;
|
||||
}
|
||||
|
||||
impl NodeTypesWithEngine for OptimismNode {
|
||||
@ -129,7 +128,7 @@ pub struct OptimismExecutorBuilder;
|
||||
|
||||
impl<Node> ExecutorBuilder<Node> for OptimismExecutorBuilder
|
||||
where
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
{
|
||||
type EVM = OptimismEvmConfig;
|
||||
type Executor = OpExecutorProvider<Self::EVM>;
|
||||
@ -138,10 +137,8 @@ where
|
||||
self,
|
||||
ctx: &BuilderContext<Node>,
|
||||
) -> eyre::Result<(Self::EVM, Self::Executor)> {
|
||||
let chain_spec = ctx.chain_spec();
|
||||
let evm_config =
|
||||
OptimismEvmConfig::new(Arc::new(OpChainSpec { inner: (*chain_spec).clone() }));
|
||||
let executor = OpExecutorProvider::new(chain_spec, evm_config.clone());
|
||||
let evm_config = OptimismEvmConfig::new(ctx.chain_spec());
|
||||
let executor = OpExecutorProvider::new(ctx.chain_spec(), evm_config.clone());
|
||||
|
||||
Ok((evm_config, executor))
|
||||
}
|
||||
@ -157,7 +154,7 @@ pub struct OptimismPoolBuilder;
|
||||
|
||||
impl<Node> PoolBuilder<Node> for OptimismPoolBuilder
|
||||
where
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
{
|
||||
type Pool = OpTransactionPool<Node::Provider, DiskFileBlobStore>;
|
||||
|
||||
@ -165,21 +162,19 @@ where
|
||||
let data_dir = ctx.config().datadir();
|
||||
let blob_store = DiskFileBlobStore::open(data_dir.blobstore(), Default::default())?;
|
||||
|
||||
let validator = TransactionValidationTaskExecutor::eth_builder(ctx.chain_spec())
|
||||
.with_head_timestamp(ctx.head().timestamp)
|
||||
.kzg_settings(ctx.kzg_settings()?)
|
||||
.with_additional_tasks(ctx.config().txpool.additional_validation_tasks)
|
||||
.build_with_tasks(
|
||||
ctx.provider().clone(),
|
||||
ctx.task_executor().clone(),
|
||||
blob_store.clone(),
|
||||
)
|
||||
.map(|validator| {
|
||||
OpTransactionValidator::new(validator)
|
||||
// In --dev mode we can't require gas fees because we're unable to decode the L1
|
||||
// block info
|
||||
.require_l1_data_gas_fee(!ctx.config().dev.dev)
|
||||
});
|
||||
let validator = TransactionValidationTaskExecutor::eth_builder(Arc::new(
|
||||
ctx.chain_spec().inner.clone(),
|
||||
))
|
||||
.with_head_timestamp(ctx.head().timestamp)
|
||||
.kzg_settings(ctx.kzg_settings()?)
|
||||
.with_additional_tasks(ctx.config().txpool.additional_validation_tasks)
|
||||
.build_with_tasks(ctx.provider().clone(), ctx.task_executor().clone(), blob_store.clone())
|
||||
.map(|validator| {
|
||||
OpTransactionValidator::new(validator)
|
||||
// In --dev mode we can't require gas fees because we're unable to decode
|
||||
// the L1 block info
|
||||
.require_l1_data_gas_fee(!ctx.config().dev.dev)
|
||||
});
|
||||
|
||||
let transaction_pool = reth_transaction_pool::Pool::new(
|
||||
validator,
|
||||
@ -256,7 +251,7 @@ impl OptimismPayloadBuilder {
|
||||
) -> eyre::Result<PayloadBuilderHandle<OptimismEngineTypes>>
|
||||
where
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = OpChainSpec>,
|
||||
>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
Evm: ConfigureEvm<Header = Header>,
|
||||
@ -292,7 +287,7 @@ impl OptimismPayloadBuilder {
|
||||
impl<Node, Pool> PayloadServiceBuilder<Node, Pool> for OptimismPayloadBuilder
|
||||
where
|
||||
Node: FullNodeTypes<
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<Engine = OptimismEngineTypes, ChainSpec = OpChainSpec>,
|
||||
>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
{
|
||||
@ -301,11 +296,7 @@ where
|
||||
ctx: &BuilderContext<Node>,
|
||||
pool: Pool,
|
||||
) -> eyre::Result<PayloadBuilderHandle<OptimismEngineTypes>> {
|
||||
self.spawn(
|
||||
OptimismEvmConfig::new(Arc::new(OpChainSpec { inner: (*ctx.chain_spec()).clone() })),
|
||||
ctx,
|
||||
pool,
|
||||
)
|
||||
self.spawn(OptimismEvmConfig::new(ctx.chain_spec()), ctx, pool)
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +311,7 @@ pub struct OptimismNetworkBuilder {
|
||||
|
||||
impl<Node, Pool> NetworkBuilder<Node, Pool> for OptimismNetworkBuilder
|
||||
where
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
Pool: TransactionPool + Unpin + 'static,
|
||||
{
|
||||
async fn build_network(
|
||||
@ -377,7 +368,7 @@ pub struct OptimismConsensusBuilder;
|
||||
|
||||
impl<Node> ConsensusBuilder<Node> for OptimismConsensusBuilder
|
||||
where
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
Node: FullNodeTypes<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
{
|
||||
type Consensus = Arc<dyn reth_consensus::Consensus>;
|
||||
|
||||
@ -397,7 +388,7 @@ pub struct OptimismEngineValidatorBuilder;
|
||||
|
||||
impl<Node, Types> EngineValidatorBuilder<Node> for OptimismEngineValidatorBuilder
|
||||
where
|
||||
Types: NodeTypesWithEngine<ChainSpec = ChainSpec>,
|
||||
Types: NodeTypesWithEngine<ChainSpec = OpChainSpec>,
|
||||
Node: FullNodeTypes<Types = Types>,
|
||||
OptimismEngineValidator: EngineValidator<Types::Engine>,
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ use alloy_primitives::{Address, B256};
|
||||
use reth::{rpc::types::engine::PayloadAttributes, tasks::TaskManager};
|
||||
use reth_chainspec::ChainSpecBuilder;
|
||||
use reth_e2e_test_utils::{transaction::TransactionTestContext, wallet::Wallet, NodeHelperType};
|
||||
use reth_optimism_chainspec::BASE_MAINNET;
|
||||
use reth_optimism_chainspec::{OpChainSpec, BASE_MAINNET};
|
||||
use reth_optimism_node::{
|
||||
node::OptimismAddOns, OptimismBuiltPayload, OptimismNode, OptimismPayloadBuilderAttributes,
|
||||
};
|
||||
@ -19,13 +19,13 @@ pub(crate) async fn setup(num_nodes: usize) -> eyre::Result<(Vec<OpNode>, TaskMa
|
||||
let genesis: Genesis = serde_json::from_str(include_str!("../assets/genesis.json")).unwrap();
|
||||
reth_e2e_test_utils::setup(
|
||||
num_nodes,
|
||||
Arc::new(
|
||||
Arc::new(OpChainSpec::new(
|
||||
ChainSpecBuilder::default()
|
||||
.chain(BASE_MAINNET.chain)
|
||||
.genesis(genesis)
|
||||
.ecotone_activated()
|
||||
.build(),
|
||||
),
|
||||
)),
|
||||
false,
|
||||
)
|
||||
.await
|
||||
|
||||
@ -3,12 +3,13 @@
|
||||
use reth_db::test_utils::create_test_rw_db;
|
||||
use reth_node_api::FullNodeComponents;
|
||||
use reth_node_builder::{NodeBuilder, NodeConfig};
|
||||
use reth_optimism_node::node::{OptimismAddOns, OptimismNode};
|
||||
use reth_optimism_node::{node::OptimismAddOns, OptimismNode};
|
||||
use reth_primitives::BASE_MAINNET;
|
||||
|
||||
#[test]
|
||||
fn test_basic_setup() {
|
||||
// parse CLI -> config
|
||||
let config = NodeConfig::test();
|
||||
let config = NodeConfig::new(BASE_MAINNET.clone());
|
||||
let db = create_test_rw_db();
|
||||
let _builder = NodeBuilder::new(config)
|
||||
.with_database(db)
|
||||
|
||||
@ -28,6 +28,7 @@ reth-trie.workspace = true
|
||||
reth-chain-state.workspace = true
|
||||
|
||||
# op-reth
|
||||
reth-optimism-chainspec.workspace = true
|
||||
reth-optimism-consensus.workspace = true
|
||||
reth-optimism-evm.workspace = true
|
||||
reth-optimism-forks.workspace = true
|
||||
|
||||
@ -5,12 +5,13 @@ use std::sync::Arc;
|
||||
use alloy_primitives::U256;
|
||||
use reth_basic_payload_builder::*;
|
||||
use reth_chain_state::ExecutedBlock;
|
||||
use reth_chainspec::{ChainSpec, ChainSpecProvider, EthereumHardforks};
|
||||
use reth_chainspec::{ChainSpecProvider, EthereumHardforks};
|
||||
use reth_evm::{
|
||||
system_calls::pre_block_beacon_root_contract_call, ConfigureEvm, ConfigureEvmEnv,
|
||||
NextBlockEnvAttributes,
|
||||
};
|
||||
use reth_execution_types::ExecutionOutcome;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_consensus::calculate_receipt_root_no_memo_optimism;
|
||||
use reth_optimism_forks::OptimismHardfork;
|
||||
use reth_payload_primitives::{PayloadBuilderAttributes, PayloadBuilderError};
|
||||
@ -94,7 +95,7 @@ where
|
||||
/// Implementation of the [`PayloadBuilder`] trait for [`OptimismPayloadBuilder`].
|
||||
impl<Pool, Client, EvmConfig> PayloadBuilder<Pool, Client> for OptimismPayloadBuilder<EvmConfig>
|
||||
where
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = OpChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
{
|
||||
@ -165,7 +166,7 @@ pub(crate) fn optimism_payload<EvmConfig, Pool, Client>(
|
||||
) -> Result<BuildOutcome<OptimismBuiltPayload>, PayloadBuilderError>
|
||||
where
|
||||
EvmConfig: ConfigureEvm<Header = Header>,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = ChainSpec>,
|
||||
Client: StateProviderFactory + ChainSpecProvider<ChainSpec = OpChainSpec>,
|
||||
Pool: TransactionPool,
|
||||
{
|
||||
let BuildArguments { client, pool, mut cached_reads, config, cancel, best_payload } = args;
|
||||
|
||||
@ -11,7 +11,8 @@ use op_alloy_rpc_types_engine::{
|
||||
OptimismExecutionPayloadEnvelopeV3, OptimismExecutionPayloadEnvelopeV4,
|
||||
};
|
||||
use reth_chain_state::ExecutedBlock;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_payload_builder::EthPayloadBuilderAttributes;
|
||||
use reth_payload_primitives::{BuiltPayload, PayloadBuilderAttributes};
|
||||
use reth_primitives::{
|
||||
@ -119,7 +120,7 @@ pub struct OptimismBuiltPayload {
|
||||
/// empty.
|
||||
pub(crate) sidecars: Vec<BlobTransactionSidecar>,
|
||||
/// The rollup's chainspec.
|
||||
pub(crate) chain_spec: Arc<ChainSpec>,
|
||||
pub(crate) chain_spec: Arc<OpChainSpec>,
|
||||
/// The payload attributes.
|
||||
pub(crate) attributes: OptimismPayloadBuilderAttributes,
|
||||
}
|
||||
@ -132,7 +133,7 @@ impl OptimismBuiltPayload {
|
||||
id: PayloadId,
|
||||
block: SealedBlock,
|
||||
fees: U256,
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
chain_spec: Arc<OpChainSpec>,
|
||||
attributes: OptimismPayloadBuilderAttributes,
|
||||
executed_block: Option<ExecutedBlock>,
|
||||
) -> Self {
|
||||
|
||||
@ -28,6 +28,7 @@ reth-node-builder.workspace = true
|
||||
reth-chainspec.workspace = true
|
||||
|
||||
# op-reth
|
||||
reth-optimism-chainspec.workspace = true
|
||||
reth-optimism-consensus.workspace = true
|
||||
reth-optimism-evm.workspace = true
|
||||
reth-optimism-forks.workspace = true
|
||||
|
||||
@ -3,8 +3,9 @@
|
||||
use alloy_rpc_types::BlockId;
|
||||
use op_alloy_network::Network;
|
||||
use op_alloy_rpc_types::OpTransactionReceipt;
|
||||
use reth_chainspec::{ChainSpec, ChainSpecProvider};
|
||||
use reth_chainspec::ChainSpecProvider;
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_primitives::TransactionMeta;
|
||||
use reth_provider::{BlockReaderIdExt, HeaderProvider};
|
||||
use reth_rpc_eth_api::{
|
||||
@ -21,7 +22,7 @@ where
|
||||
Error = OpEthApiError,
|
||||
NetworkTypes: Network<ReceiptResponse = OpTransactionReceipt>,
|
||||
>,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
{
|
||||
#[inline]
|
||||
fn provider(&self) -> impl HeaderProvider {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use alloy_primitives::{Bytes, TxKind, U256};
|
||||
use alloy_rpc_types_eth::transaction::TransactionRequest;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes};
|
||||
use reth_primitives::{
|
||||
@ -18,7 +18,7 @@ use crate::{OpEthApi, OpEthApiError};
|
||||
impl<N> EthCall for OpEthApi<N>
|
||||
where
|
||||
Self: Call,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ use std::{fmt, sync::Arc};
|
||||
use alloy_primitives::U256;
|
||||
use derive_more::Deref;
|
||||
use op_alloy_network::Optimism;
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_evm::ConfigureEvm;
|
||||
use reth_network_api::NetworkInfo;
|
||||
use reth_node_api::{BuilderProvider, FullNodeComponents, FullNodeTypes, NodeTypes};
|
||||
@ -239,7 +239,7 @@ where
|
||||
|
||||
impl<N> AddDevSigners for OpEthApi<N>
|
||||
where
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
|
||||
{
|
||||
fn with_dev_accounts(&self) {
|
||||
*self.signers().write() = DevSigner::random_signers(20)
|
||||
|
||||
@ -7,6 +7,7 @@ use op_alloy_rpc_types::{
|
||||
};
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_node_api::{FullNodeComponents, NodeTypes};
|
||||
use reth_optimism_chainspec::OpChainSpec;
|
||||
use reth_optimism_evm::RethL1BlockInfo;
|
||||
use reth_optimism_forks::OptimismHardforks;
|
||||
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned, TxType};
|
||||
@ -19,7 +20,7 @@ use crate::{OpEthApi, OpEthApiError};
|
||||
impl<N> LoadReceipt for OpEthApi<N>
|
||||
where
|
||||
Self: Send + Sync,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = ChainSpec>>,
|
||||
N: FullNodeComponents<Types: NodeTypes<ChainSpec = OpChainSpec>>,
|
||||
{
|
||||
#[inline]
|
||||
fn cache(&self) -> &EthStateCache {
|
||||
@ -205,7 +206,7 @@ pub struct OpReceiptBuilder {
|
||||
impl OpReceiptBuilder {
|
||||
/// Returns a new builder.
|
||||
pub fn new(
|
||||
chain_spec: &ChainSpec,
|
||||
chain_spec: &OpChainSpec,
|
||||
transaction: &TransactionSigned,
|
||||
meta: TransactionMeta,
|
||||
receipt: &Receipt,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use alloy_primitives::{map::HashMap, Address};
|
||||
use reth_chainspec::{ChainSpec, EthereumHardforks};
|
||||
use reth_chainspec::EthereumHardforks;
|
||||
use reth_consensus_common::calc;
|
||||
use reth_primitives::{Block, Withdrawal, Withdrawals, U256};
|
||||
|
||||
@ -8,7 +8,7 @@ use reth_primitives::{Block, Withdrawal, Withdrawals, U256};
|
||||
/// Balance changes might include the block reward, uncle rewards, withdrawals, or irregular
|
||||
/// state changes (DAO fork).
|
||||
#[inline]
|
||||
pub fn post_block_balance_increments(
|
||||
pub fn post_block_balance_increments<ChainSpec: EthereumHardforks>(
|
||||
chain_spec: &ChainSpec,
|
||||
block: &Block,
|
||||
total_difficulty: U256,
|
||||
@ -89,6 +89,7 @@ pub fn insert_post_block_withdrawals_balance_increments<ChainSpec: EthereumHardf
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_ethereum_forks::{ChainHardforks, EthereumHardfork, ForkCondition};
|
||||
use reth_primitives::constants::GWEI_TO_WEI;
|
||||
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
use boyer_moore_magiclen::BMByte;
|
||||
use eyre::Result;
|
||||
use reth_chainspec::ChainSpec;
|
||||
use reth_db::{RawTable, TableRawRow};
|
||||
use reth_db_api::{
|
||||
cursor::{DbCursorRO, DbDupCursorRO},
|
||||
@ -13,7 +12,7 @@ use reth_db_api::{
|
||||
};
|
||||
use reth_fs_util as fs;
|
||||
use reth_node_types::NodeTypesWithDB;
|
||||
use reth_provider::{ChainSpecProvider, ProviderFactory};
|
||||
use reth_provider::{providers::ProviderNodeTypes, ChainSpecProvider, ProviderFactory};
|
||||
use std::{path::Path, rc::Rc, sync::Arc};
|
||||
use tracing::info;
|
||||
|
||||
@ -25,7 +24,7 @@ pub struct DbTool<N: NodeTypesWithDB> {
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB> DbTool<N> {
|
||||
/// Get an [`Arc`] to the [`ChainSpec`].
|
||||
/// Get an [`Arc`] to the underlying chainspec.
|
||||
pub fn chain(&self) -> Arc<N::ChainSpec> {
|
||||
self.provider_factory.chain_spec()
|
||||
}
|
||||
@ -110,7 +109,7 @@ impl<N: NodeTypesWithDB> DbTool<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N: NodeTypesWithDB<ChainSpec = ChainSpec>> DbTool<N> {
|
||||
impl<N: ProviderNodeTypes> DbTool<N> {
|
||||
/// Takes a DB where the tables have already been created.
|
||||
pub fn new(provider_factory: ProviderFactory<N>) -> eyre::Result<Self> {
|
||||
// Disable timeout because we are entering a TUI which might read for a long time. We
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use alloy_genesis::GenesisAccount;
|
||||
use alloy_primitives::{Address, B256, U256};
|
||||
use reth_chainspec::{ChainSpec, EthChainSpec};
|
||||
use reth_chainspec::EthChainSpec;
|
||||
use reth_codecs::Compact;
|
||||
use reth_config::config::EtlConfig;
|
||||
use reth_db::tables;
|
||||
@ -333,7 +333,7 @@ where
|
||||
Provider: DBProvider<Tx: DbTxMut>
|
||||
+ BlockNumReader
|
||||
+ BlockHashReader
|
||||
+ ChainSpecProvider<ChainSpec = ChainSpec>
|
||||
+ ChainSpecProvider
|
||||
+ StageCheckpointWriter
|
||||
+ HistoryWriter
|
||||
+ HeaderProvider
|
||||
@ -366,7 +366,7 @@ where
|
||||
|
||||
debug!(target: "reth::cli",
|
||||
block,
|
||||
chain=%provider_rw.chain_spec().chain,
|
||||
chain=%provider_rw.chain_spec().chain(),
|
||||
"Initializing state at block"
|
||||
);
|
||||
|
||||
@ -582,7 +582,7 @@ struct GenesisAccountWithAddress {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use alloy_genesis::Genesis;
|
||||
use reth_chainspec::{Chain, HOLESKY, MAINNET, SEPOLIA};
|
||||
use reth_chainspec::{Chain, ChainSpec, HOLESKY, MAINNET, SEPOLIA};
|
||||
use reth_db::DatabaseEnv;
|
||||
use reth_db_api::{
|
||||
cursor::DbCursorRO,
|
||||
|
||||
@ -13,7 +13,7 @@ use futures_util::{
|
||||
FutureExt, Stream, StreamExt,
|
||||
};
|
||||
use reth_chain_state::CanonStateNotification;
|
||||
use reth_chainspec::{ChainSpec, ChainSpecProvider};
|
||||
use reth_chainspec::{ChainSpecProvider, EthChainSpec};
|
||||
use reth_execution_types::ChangedAccount;
|
||||
use reth_fs_util::FsPathError;
|
||||
use reth_primitives::{
|
||||
@ -74,12 +74,7 @@ pub fn maintain_transaction_pool_future<Client, P, St, Tasks>(
|
||||
config: MaintainPoolConfig,
|
||||
) -> BoxFuture<'static, ()>
|
||||
where
|
||||
Client: StateProviderFactory
|
||||
+ BlockReaderIdExt
|
||||
+ ChainSpecProvider<ChainSpec = ChainSpec>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ 'static,
|
||||
Client: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider + Clone + Send + 'static,
|
||||
P: TransactionPoolExt + 'static,
|
||||
St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
|
||||
Tasks: TaskSpawner + 'static,
|
||||
@ -100,12 +95,7 @@ pub async fn maintain_transaction_pool<Client, P, St, Tasks>(
|
||||
task_spawner: Tasks,
|
||||
config: MaintainPoolConfig,
|
||||
) where
|
||||
Client: StateProviderFactory
|
||||
+ BlockReaderIdExt
|
||||
+ ChainSpecProvider<ChainSpec = ChainSpec>
|
||||
+ Clone
|
||||
+ Send
|
||||
+ 'static,
|
||||
Client: StateProviderFactory + BlockReaderIdExt + ChainSpecProvider + Clone + Send + 'static,
|
||||
P: TransactionPoolExt + 'static,
|
||||
St: Stream<Item = CanonStateNotification> + Send + Unpin + 'static,
|
||||
Tasks: TaskSpawner + 'static,
|
||||
|
||||
Reference in New Issue
Block a user