Skip to content

Commit

Permalink
Merge branch 'paradigmxyz:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
allnil authored Jun 3, 2024
2 parents e642ede + 99c951a commit ea9daf8
Show file tree
Hide file tree
Showing 73 changed files with 1,778 additions and 740 deletions.
308 changes: 137 additions & 171 deletions Cargo.lock

Large diffs are not rendered by default.

33 changes: 16 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ unused_rounding = "warn"
useless_let_if_seq = "warn"
use_self = "warn"
missing_const_for_fn = "warn"
empty_line_after_doc_comments = "warn"
iter_on_single_items = "warn"

# These are nursery lints which have findings. Allow them for now. Some are not
# quite mature enough for use in our codebase and some we don't really want.
Expand All @@ -162,13 +164,10 @@ as_ptr_cast_mut = "allow"
cognitive_complexity = "allow"
collection_is_never_read = "allow"
debug_assert_with_mut_call = "allow"
empty_line_after_doc_comments = "allow"
fallible_impl_from = "allow"
future_not_send = "allow"
iter_on_single_items = "allow"
needless_collect = "allow"
non_send_fields_in_send_ty = "allow"
option_if_let_else = "allow"
redundant_pub_crate = "allow"
significant_drop_in_scrutinee = "allow"
significant_drop_tightening = "allow"
Expand Down Expand Up @@ -310,7 +309,7 @@ revm = { version = "9.0.0", features = [
revm-primitives = { version = "4.0.0", features = [
"std",
], default-features = false }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "0f43cf5" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "2b6fff1" }

# eth
alloy-chains = "0.1.15"
Expand All @@ -319,21 +318,21 @@ alloy-dyn-abi = "0.7.2"
alloy-sol-types = "0.7.2"
alloy-rlp = "0.3.4"
alloy-trie = "0.4"
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c", default-features = false, features = [
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec", default-features = false, features = [
"reqwest",
] }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "7320d4c" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "7320d4c" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "61140ec" }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "61140ec" }

# misc
auto_impl = "1"
Expand Down
19 changes: 13 additions & 6 deletions bin/reth/src/commands/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use reth_db::{
version::{get_db_version, DatabaseVersionError, DB_VERSION},
};
use reth_primitives::ChainSpec;
use reth_provider::ProviderFactory;
use reth_provider::{providers::StaticFileProvider, ProviderFactory};
use std::{
io::{self, Write},
sync::Arc,
Expand Down Expand Up @@ -96,7 +96,8 @@ pub enum Subcommands {
macro_rules! db_ro_exec {
($chain:expr, $db_path:expr, $db_args:ident, $sfp:ident, $tool:ident, $command:block) => {
let db = open_db_read_only($db_path, $db_args)?;
let provider_factory = ProviderFactory::new(db, $chain.clone(), $sfp)?;
let provider_factory =
ProviderFactory::new(db, $chain.clone(), StaticFileProvider::read_only($sfp)?);

let $tool = DbTool::new(provider_factory, $chain.clone())?;
$command;
Expand Down Expand Up @@ -156,16 +157,22 @@ impl Command {
}

let db = open_db(&db_path, db_args)?;
let provider_factory =
ProviderFactory::new(db, self.chain.clone(), static_files_path.clone())?;
let provider_factory = ProviderFactory::new(
db,
self.chain.clone(),
StaticFileProvider::read_write(&static_files_path)?,
);

let tool = DbTool::new(provider_factory, self.chain.clone())?;
tool.drop(db_path, static_files_path)?;
}
Subcommands::Clear(command) => {
let db = open_db(&db_path, db_args)?;
let provider_factory =
ProviderFactory::new(db, self.chain.clone(), static_files_path)?;
let provider_factory = ProviderFactory::new(
db,
self.chain.clone(),
StaticFileProvider::read_write(static_files_path)?,
);

command.execute(provider_factory)?;
}
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/static_files/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Command {
let path: PathBuf = StaticFileSegment::Headers
.filename_with_configuration(filters, compression, &block_range)
.into();
let provider = StaticFileProvider::new(PathBuf::default())?;
let provider = StaticFileProvider::read_only(PathBuf::default())?;
let jar_provider = provider.get_segment_provider_from_block(
StaticFileSegment::Headers,
self.from,
Expand Down
8 changes: 6 additions & 2 deletions bin/reth/src/commands/db/static_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use reth_primitives::{
},
BlockNumber, ChainSpec, StaticFileSegment,
};
use reth_provider::{BlockNumReader, ProviderFactory};
use reth_provider::{providers::StaticFileProvider, BlockNumReader, ProviderFactory};
use reth_static_file::{segments as static_file_segments, segments::Segment};
use std::{
path::{Path, PathBuf},
Expand Down Expand Up @@ -99,7 +99,11 @@ impl Command {
data_dir.db().as_path(),
db_args.with_max_read_transaction_duration(Some(MaxReadTransactionDuration::Unbounded)),
)?;
let provider_factory = Arc::new(ProviderFactory::new(db, chain, data_dir.static_files())?);
let provider_factory = Arc::new(ProviderFactory::new(
db,
chain,
StaticFileProvider::read_only(data_dir.static_files())?,
));

{
if !self.only_bench {
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/static_files/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl Command {
.filename_with_configuration(filters, compression, &block_range)
.into();

let provider = StaticFileProvider::new(PathBuf::default())?;
let provider = StaticFileProvider::read_only(PathBuf::default())?;
let jar_provider = provider.get_segment_provider_from_block(
StaticFileSegment::Receipts,
self.from,
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/static_files/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Command {
let path: PathBuf = StaticFileSegment::Transactions
.filename_with_configuration(filters, compression, &block_range)
.into();
let provider = StaticFileProvider::new(PathBuf::default())?;
let provider = StaticFileProvider::read_only(PathBuf::default())?;
let jar_provider = provider.get_segment_provider_from_block(
StaticFileSegment::Transactions,
self.from,
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ impl Command {
}

let static_files = iter_static_files(data_dir.static_files())?;
let static_file_provider = StaticFileProvider::new(data_dir.static_files())?;
let static_file_provider = StaticFileProvider::read_only(data_dir.static_files())?;

let mut total_data_size = 0;
let mut total_index_size = 0;
Expand Down
15 changes: 9 additions & 6 deletions bin/reth/src/commands/debug_cmd/build_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ use reth_primitives::{
U256,
};
use reth_provider::{
providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter,
BundleStateWithReceipts, ProviderFactory, StageCheckpointReader, StateProviderFactory,
providers::{BlockchainProvider, StaticFileProvider},
BlockHashReader, BlockReader, BlockWriter, BundleStateWithReceipts, ProviderFactory,
StageCheckpointReader, StateProviderFactory,
};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_types::engine::{BlobsBundleV1, PayloadAttributes};
Expand Down Expand Up @@ -113,8 +114,10 @@ impl Command {
let factory = ProviderFactory::new(
db,
self.chain.clone(),
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?;
StaticFileProvider::read_only(
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?,
);
let provider = factory.provider()?;

let best_number =
Expand Down Expand Up @@ -155,8 +158,8 @@ impl Command {
let provider_factory = ProviderFactory::new(
Arc::clone(&db),
Arc::clone(&self.chain),
data_dir.static_files(),
)?;
StaticFileProvider::read_only(data_dir.static_files())?,
);

let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
Expand Down
20 changes: 11 additions & 9 deletions bin/reth/src/commands/debug_cmd/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use reth_primitives::{
stage::StageId, BlockHashOrNumber, BlockNumber, ChainSpec, PruneModes, B256,
};
use reth_provider::{
BlockExecutionWriter, HeaderSyncMode, ProviderFactory, StageCheckpointReader,
StaticFileProviderFactory,
providers::StaticFileProvider, BlockExecutionWriter, HeaderSyncMode, ProviderFactory,
StageCheckpointReader, StaticFileProviderFactory,
};
use reth_stages::{
sets::DefaultStages,
Expand Down Expand Up @@ -156,6 +156,9 @@ impl Command {
default_peers_path: PathBuf,
) -> eyre::Result<NetworkHandle> {
let secret_key = get_secret_key(&network_secret_path)?;
let static_files = StaticFileProvider::read_only(
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?;
let network = self
.network
.network_config(config, self.chain.clone(), secret_key, default_peers_path)
Expand All @@ -165,11 +168,7 @@ impl Command {
self.network.discovery.addr,
self.network.discovery.port,
))
.build(ProviderFactory::new(
db,
self.chain.clone(),
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?)
.build(ProviderFactory::new(db, self.chain.clone(), static_files))
.start_network()
.await?;
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
Expand Down Expand Up @@ -210,8 +209,11 @@ impl Command {

fs::create_dir_all(&db_path)?;
let db = Arc::new(init_db(db_path, self.db.database_args())?);
let provider_factory =
ProviderFactory::new(db.clone(), self.chain.clone(), data_dir.static_files())?;
let provider_factory = ProviderFactory::new(
db.clone(),
self.chain.clone(),
StaticFileProvider::read_write(data_dir.static_files())?,
);

debug!(target: "reth::cli", chain=%self.chain.chain, genesis=?self.chain.genesis_hash(), "Initializing genesis");
init_genesis(provider_factory.clone())?;
Expand Down
18 changes: 12 additions & 6 deletions bin/reth/src/commands/debug_cmd/in_memory_merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use reth_network::NetworkHandle;
use reth_network_api::NetworkInfo;
use reth_primitives::{stage::StageId, BlockHashOrNumber, ChainSpec, Receipts};
use reth_provider::{
AccountExtReader, BundleStateWithReceipts, HashingWriter, HeaderProvider,
LatestStateProviderRef, OriginalValuesKnown, ProviderFactory, StageCheckpointReader,
StateWriter, StaticFileProviderFactory, StorageReader,
providers::StaticFileProvider, AccountExtReader, BundleStateWithReceipts, HashingWriter,
HeaderProvider, LatestStateProviderRef, OriginalValuesKnown, ProviderFactory,
StageCheckpointReader, StateWriter, StaticFileProviderFactory, StorageReader,
};
use reth_revm::database::StateProviderDatabase;
use reth_tasks::TaskExecutor;
Expand Down Expand Up @@ -97,8 +97,10 @@ impl Command {
.build(ProviderFactory::new(
db,
self.chain.clone(),
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?)
StaticFileProvider::read_only(
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?,
))
.start_network()
.await?;
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
Expand All @@ -117,7 +119,11 @@ impl Command {

// initialize the database
let db = Arc::new(init_db(db_path, self.db.database_args())?);
let factory = ProviderFactory::new(&db, self.chain.clone(), data_dir.static_files())?;
let factory = ProviderFactory::new(
&db,
self.chain.clone(),
StaticFileProvider::read_only(data_dir.static_files())?,
);
let provider = factory.provider()?;

// Look up merkle checkpoint
Expand Down
17 changes: 12 additions & 5 deletions bin/reth/src/commands/debug_cmd/merkle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ use reth_network_api::NetworkInfo;
use reth_network_p2p::full_block::FullBlockClient;
use reth_primitives::{stage::StageCheckpoint, BlockHashOrNumber, ChainSpec, PruneModes};
use reth_provider::{
BlockNumReader, BlockWriter, BundleStateWithReceipts, HeaderProvider, LatestStateProviderRef,
OriginalValuesKnown, ProviderError, ProviderFactory, StateWriter,
providers::StaticFileProvider, BlockNumReader, BlockWriter, BundleStateWithReceipts,
HeaderProvider, LatestStateProviderRef, OriginalValuesKnown, ProviderError, ProviderFactory,
StateWriter,
};
use reth_revm::database::StateProviderDatabase;
use reth_stages::{
Expand Down Expand Up @@ -102,8 +103,10 @@ impl Command {
.build(ProviderFactory::new(
db,
self.chain.clone(),
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?)
StaticFileProvider::read_only(
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?,
))
.start_network()
.await?;
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
Expand All @@ -122,7 +125,11 @@ impl Command {

// initialize the database
let db = Arc::new(init_db(db_path, self.db.database_args())?);
let factory = ProviderFactory::new(&db, self.chain.clone(), data_dir.static_files())?;
let factory = ProviderFactory::new(
&db,
self.chain.clone(),
StaticFileProvider::read_only(data_dir.static_files())?,
);
let provider_rw = factory.provider_rw()?;

// Configure and build network
Expand Down
17 changes: 11 additions & 6 deletions bin/reth/src/commands/debug_cmd/replay_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use reth_node_core::engine::engine_store::{EngineMessageStore, StoredEngineApiMe
use reth_payload_builder::{PayloadBuilderHandle, PayloadBuilderService};
use reth_primitives::{ChainSpec, PruneModes};
use reth_provider::{
providers::BlockchainProvider, CanonStateSubscriptions, ProviderFactory,
StaticFileProviderFactory,
providers::{BlockchainProvider, StaticFileProvider},
CanonStateSubscriptions, ProviderFactory, StaticFileProviderFactory,
};
use reth_stages::Pipeline;
use reth_static_file::StaticFileProducer;
Expand Down Expand Up @@ -100,8 +100,10 @@ impl Command {
.build(ProviderFactory::new(
db,
self.chain.clone(),
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?)
StaticFileProvider::read_only(
self.datadir.unwrap_or_chain_default(self.chain.chain).static_files(),
)?,
))
.start_network()
.await?;
info!(target: "reth::cli", peer_id = %network.peer_id(), local_addr = %network.local_addr(), "Connected to P2P network");
Expand All @@ -120,8 +122,11 @@ impl Command {

// Initialize the database
let db = Arc::new(init_db(db_path, self.db.database_args())?);
let provider_factory =
ProviderFactory::new(db.clone(), self.chain.clone(), data_dir.static_files())?;
let provider_factory = ProviderFactory::new(
db.clone(),
self.chain.clone(),
StaticFileProvider::read_only(data_dir.static_files())?,
);

let consensus: Arc<dyn Consensus> =
Arc::new(EthBeaconConsensus::new(Arc::clone(&self.chain)));
Expand Down
12 changes: 8 additions & 4 deletions bin/reth/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ use reth_network_p2p::{
use reth_node_events::node::NodeEvent;
use reth_primitives::{stage::StageId, ChainSpec, PruneModes, B256};
use reth_provider::{
BlockNumReader, ChainSpecProvider, HeaderProvider, HeaderSyncMode, ProviderError,
ProviderFactory, StageCheckpointReader, StaticFileProviderFactory,
providers::StaticFileProvider, BlockNumReader, ChainSpecProvider, HeaderProvider,
HeaderSyncMode, ProviderError, ProviderFactory, StageCheckpointReader,
StaticFileProviderFactory,
};
use reth_stages::{prelude::*, Pipeline, StageSet};
use reth_static_file::StaticFileProducer;
Expand Down Expand Up @@ -117,8 +118,11 @@ impl ImportCommand {
info!(target: "reth::cli", path = ?db_path, "Opening database");
let db = Arc::new(init_db(db_path, self.db.database_args())?);
info!(target: "reth::cli", "Database opened");
let provider_factory =
ProviderFactory::new(db.clone(), self.chain.clone(), data_dir.static_files())?;
let provider_factory = ProviderFactory::new(
db.clone(),
self.chain.clone(),
StaticFileProvider::read_write(data_dir.static_files())?,
);

debug!(target: "reth::cli", chain=%self.chain.chain, genesis=?self.chain.genesis_hash(), "Initializing genesis");

Expand Down
Loading

0 comments on commit ea9daf8

Please sign in to comment.