Skip to content

Commit

Permalink
chore: rename from snapshot to static file terminology (#6758)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexey Shekhirin <a.shekhirin@gmail.com>
  • Loading branch information
joshieDo and shekhirin committed Feb 23, 2024
1 parent aeaabfb commit 0a6e95c
Show file tree
Hide file tree
Showing 131 changed files with 2,571 additions and 2,044 deletions.
2 changes: 1 addition & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ crates/metrics @onbjerg
crates/tracing @onbjerg
crates/tasks @mattsse
crates/prune @shekhirin @joshieDo
crates/snapshot @joshieDo
crates/static-file @joshieDo @shekhirin
.github/ @onbjerg @gakonst @DaniPopes
54 changes: 27 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ members = [
"crates/node-optimism/",
"crates/node-core/",
"crates/node-api/",
"crates/snapshot/",
"crates/stages/",
"crates/static-file/",
"crates/storage/codecs/",
"crates/storage/codecs/derive/",
"crates/storage/db/",
Expand Down Expand Up @@ -163,8 +163,8 @@ reth-rpc-builder = { path = "crates/rpc/rpc-builder" }
reth-rpc-engine-api = { path = "crates/rpc/rpc-engine-api" }
reth-rpc-types = { path = "crates/rpc/rpc-types" }
reth-rpc-types-compat = { path = "crates/rpc/rpc-types-compat" }
reth-snapshot = { path = "crates/snapshot" }
reth-stages = { path = "crates/stages" }
reth-static-file = { path = "crates/static-file" }
reth-tasks = { path = "crates/tasks" }
reth-tokio-util = { path = "crates/tokio-util" }
reth-tracing = { path = "crates/tracing" }
Expand Down
2 changes: 1 addition & 1 deletion bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ reth-payload-validator.workspace = true
reth-basic-payload-builder.workspace = true
reth-discv4.workspace = true
reth-prune.workspace = true
reth-snapshot = { workspace = true, features = ["clap"] }
reth-static-file = { workspace = true, features = ["clap"] }
reth-trie.workspace = true
reth-nippy-jar.workspace = true
reth-node-api.workspace = true
Expand Down
24 changes: 12 additions & 12 deletions bin/reth/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use fdlimit::raise_fd_limit;
use futures::{future::Either, stream, stream_select, StreamExt};
use reth_auto_seal_consensus::AutoSealBuilder;
use reth_beacon_consensus::{
hooks::{EngineHooks, PruneHook, SnapshotHook},
hooks::{EngineHooks, PruneHook, StaticFileHook},
BeaconConsensusEngine, MIN_BLOCKS_FOR_PIPELINE_RUN,
};
use reth_blockchain_tree::{config::BlockchainTreeConfig, ShareableBlockchainTree};
Expand Down Expand Up @@ -39,7 +39,7 @@ use reth_payload_builder::PayloadBuilderHandle;
use reth_provider::{providers::BlockchainProvider, ProviderFactory};
use reth_prune::PrunerBuilder;
use reth_rpc_engine_api::EngineApi;
use reth_snapshot::Snapshotter;
use reth_static_file::StaticFileProducer;
use reth_tasks::{TaskExecutor, TaskManager};
use reth_transaction_pool::TransactionPool;
use std::{path::PathBuf, sync::Arc};
Expand Down Expand Up @@ -130,9 +130,9 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
let provider_factory = ProviderFactory::new(
Arc::clone(&self.db),
Arc::clone(&self.config.chain),
self.data_dir.snapshots_path(),
self.data_dir.static_files_path(),
)?
.with_snapshots_metrics();
.with_static_files_metrics();

self.config.start_metrics_endpoint(prometheus_handle, Arc::clone(&self.db)).await?;

Expand Down Expand Up @@ -264,14 +264,14 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit

let mut hooks = EngineHooks::new();

let mut snapshotter = Snapshotter::new(
let mut static_file_producer = StaticFileProducer::new(
provider_factory.clone(),
provider_factory.snapshot_provider(),
provider_factory.static_file_provider(),
prune_config.clone().unwrap_or_default().segments,
);
let snapshotter_events = snapshotter.events();
hooks.add(SnapshotHook::new(snapshotter.clone(), Box::new(executor.clone())));
info!(target: "reth::cli", "Snapshotter initialized");
let static_file_producer_events = static_file_producer.events();
hooks.add(StaticFileHook::new(static_file_producer.clone(), Box::new(executor.clone())));
info!(target: "reth::cli", "StaticFileProducer initialized");

// Configure the pipeline
let (mut pipeline, client) = if self.config.dev.dev {
Expand Down Expand Up @@ -301,7 +301,7 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
sync_metrics_tx,
prune_config.clone(),
max_block,
snapshotter,
static_file_producer,
evm_config,
)
.await?;
Expand All @@ -324,7 +324,7 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
sync_metrics_tx,
prune_config.clone(),
max_block,
snapshotter,
static_file_producer,
evm_config,
)
.await?;
Expand Down Expand Up @@ -377,7 +377,7 @@ impl<DB: Database + DatabaseMetrics + DatabaseMetadata + 'static> NodeBuilderWit
Either::Right(stream::empty())
},
pruner_events.map(Into::into),
snapshotter_events.map(Into::into),
static_file_producer_events.map(Into::into),
);
executor.spawn_critical(
"events task",
Expand Down
20 changes: 10 additions & 10 deletions bin/reth/src/commands/db/clear.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use clap::{Parser, Subcommand};
use reth_db::{
database::Database,
snapshot::iter_snapshots,
static_file::iter_static_files,
table::Table,
transaction::{DbTx, DbTxMut},
TableViewer, Tables,
};
use reth_primitives::{snapshot::find_fixed_range, SnapshotSegment};
use reth_primitives::{static_file::find_fixed_range, StaticFileSegment};
use reth_provider::ProviderFactory;

/// The arguments for the `reth db clear` command
Expand All @@ -23,13 +23,13 @@ impl Command {
Subcommands::Mdbx { table } => {
table.view(&ClearViewer { db: provider_factory.db_ref() })?
}
Subcommands::Snapshot { segment } => {
let snapshot_provider = provider_factory.snapshot_provider();
let snapshots = iter_snapshots(snapshot_provider.directory())?;
Subcommands::StaticFile { segment } => {
let static_file_provider = provider_factory.static_file_provider();
let static_files = iter_static_files(static_file_provider.directory())?;

if let Some(segment_snapshots) = snapshots.get(&segment) {
for (block_range, _) in segment_snapshots {
snapshot_provider
if let Some(segment_static_files) = static_files.get(&segment) {
for (block_range, _) in segment_static_files {
static_file_provider
.delete_jar(segment, find_fixed_range(block_range.start()))?;
}
}
Expand All @@ -44,8 +44,8 @@ impl Command {
enum Subcommands {
/// Deletes all database table entries
Mdbx { table: Tables },
/// Deletes all snapshot segment entries
Snapshot { segment: SnapshotSegment },
/// Deletes all static file segment entries
StaticFile { segment: StaticFileSegment },
}

struct ClearViewer<'a, DB: Database> {
Expand Down
26 changes: 13 additions & 13 deletions bin/reth/src/commands/db/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use crate::utils::DbTool;
use clap::Parser;
use reth_db::{
database::Database,
snapshot::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask, ReceiptMask, TransactionMask},
static_file::{ColumnSelectorOne, ColumnSelectorTwo, HeaderMask, ReceiptMask, TransactionMask},
table::{Decompress, DupSort, Table},
tables, RawKey, RawTable, Receipts, TableViewer, Transactions,
};
use reth_primitives::{BlockHash, Header, SnapshotSegment};
use reth_primitives::{BlockHash, Header, StaticFileSegment};
use tracing::error;

/// The arguments for the `reth db get` command
Expand Down Expand Up @@ -34,9 +34,9 @@ enum Subcommand {
#[clap(long)]
raw: bool,
},
/// Gets the content of a snapshot segment for the given key
Snapshot {
segment: SnapshotSegment,
/// Gets the content of a static file segment for the given key
StaticFile {
segment: StaticFileSegment,

/// The key to get content for
#[arg(value_parser = maybe_json_value_parser)]
Expand All @@ -55,22 +55,22 @@ impl Command {
Subcommand::Mdbx { table, key, subkey, raw } => {
table.view(&GetValueViewer { tool, key, subkey, raw })?
}
Subcommand::Snapshot { segment, key, raw } => {
Subcommand::StaticFile { segment, key, raw } => {
let (key, mask): (u64, _) = match segment {
SnapshotSegment::Headers => {
StaticFileSegment::Headers => {
(table_key::<tables::Headers>(&key)?, <HeaderMask<Header, BlockHash>>::MASK)
}
SnapshotSegment::Transactions => (
StaticFileSegment::Transactions => (
table_key::<tables::Transactions>(&key)?,
<TransactionMask<<Transactions as Table>::Value>>::MASK,
),
SnapshotSegment::Receipts => (
StaticFileSegment::Receipts => (
table_key::<tables::Receipts>(&key)?,
<ReceiptMask<<Receipts as Table>::Value>>::MASK,
),
};

let content = tool.provider_factory.snapshot_provider().find_snapshot(
let content = tool.provider_factory.static_file_provider().find_static_file(
segment,
|provider| {
let mut cursor = provider.cursor()?;
Expand All @@ -88,7 +88,7 @@ impl Command {
println!("{:?}", content);
} else {
match segment {
SnapshotSegment::Headers => {
StaticFileSegment::Headers => {
let header = Header::decompress(content[0].as_slice())?;
let block_hash = BlockHash::decompress(content[1].as_slice())?;
println!(
Expand All @@ -97,13 +97,13 @@ impl Command {
serde_json::to_string_pretty(&block_hash)?
);
}
SnapshotSegment::Transactions => {
StaticFileSegment::Transactions => {
let transaction = <<Transactions as Table>::Value>::decompress(
content[0].as_slice(),
)?;
println!("{}", serde_json::to_string_pretty(&transaction)?);
}
SnapshotSegment::Receipts => {
StaticFileSegment::Receipts => {
let receipt = <<Receipts as Table>::Value>::decompress(
content[0].as_slice(),
)?;
Expand Down
Loading

0 comments on commit 0a6e95c

Please sign in to comment.