diff --git a/crates/cli/commands/src/db/checksum.rs b/crates/cli/commands/src/db/checksum.rs index e5ed9d909c..b1c6c6c557 100644 --- a/crates/cli/commands/src/db/checksum.rs +++ b/crates/cli/commands/src/db/checksum.rs @@ -4,15 +4,17 @@ use crate::{ }; use alloy_primitives::map::foldhash::fast::FixedState; use clap::Parser; +use itertools::Itertools; use reth_chainspec::EthereumHardforks; -use reth_db::DatabaseEnv; +use reth_db::{static_file::iter_static_files, DatabaseEnv}; use reth_db_api::{ cursor::DbCursorRO, table::Table, transaction::DbTx, RawKey, RawTable, RawValue, TableViewer, Tables, }; use reth_db_common::DbTool; use reth_node_builder::{NodeTypesWithDB, NodeTypesWithDBAdapter}; -use reth_provider::{providers::ProviderNodeTypes, DBProvider}; +use reth_provider::{providers::ProviderNodeTypes, DBProvider, StaticFileProviderFactory}; +use reth_static_file_types::StaticFileSegment; use std::{ hash::{BuildHasher, Hasher}, sync::Arc, @@ -20,24 +22,54 @@ use std::{ }; use tracing::{info, warn}; +/// Interval for logging progress during checksum computation. +const PROGRESS_LOG_INTERVAL: usize = 100_000; + #[derive(Parser, Debug)] /// The arguments for the `reth db checksum` command pub struct Command { - /// The table name - table: Tables, + #[command(subcommand)] + subcommand: Subcommand, +} - /// The start of the range to checksum. - #[arg(long, value_parser = maybe_json_value_parser)] - start_key: Option, +#[derive(clap::Subcommand, Debug)] +enum Subcommand { + /// Calculates the checksum of a database table + Mdbx { + /// The table name + table: Tables, - /// The end of the range to checksum. - #[arg(long, value_parser = maybe_json_value_parser)] - end_key: Option, + /// The start of the range to checksum. + #[arg(long, value_parser = maybe_json_value_parser)] + start_key: Option, - /// The maximum number of records that are queried and used to compute the - /// checksum. - #[arg(long)] - limit: Option, + /// The end of the range to checksum. + #[arg(long, value_parser = maybe_json_value_parser)] + end_key: Option, + + /// The maximum number of records that are queried and used to compute the + /// checksum. + #[arg(long)] + limit: Option, + }, + /// Calculates the checksum of a static file segment + StaticFile { + /// The static file segment + #[arg(value_enum)] + segment: StaticFileSegment, + + /// The block number to start from (inclusive). + #[arg(long)] + start_block: Option, + + /// The block number to end at (inclusive). + #[arg(long)] + end_block: Option, + + /// The maximum number of rows to checksum. + #[arg(long)] + limit: Option, + }, } impl Command { @@ -47,16 +79,109 @@ impl Command { tool: &DbTool>>, ) -> eyre::Result<()> { warn!("This command should be run without the node running!"); - self.table.view(&ChecksumViewer { - tool, - start_key: self.start_key, - end_key: self.end_key, - limit: self.limit, - })?; + + match self.subcommand { + Subcommand::Mdbx { table, start_key, end_key, limit } => { + table.view(&ChecksumViewer { tool, start_key, end_key, limit })?; + } + Subcommand::StaticFile { segment, start_block, end_block, limit } => { + checksum_static_file(tool, segment, start_block, end_block, limit)?; + } + } + Ok(()) } } +/// Creates a new hasher with the standard seed used for checksum computation. +fn checksum_hasher() -> impl Hasher { + FixedState::with_seed(u64::from_be_bytes(*b"RETHRETH")).build_hasher() +} + +fn checksum_static_file>( + tool: &DbTool>>, + segment: StaticFileSegment, + start_block: Option, + end_block: Option, + limit: Option, +) -> eyre::Result<()> { + let static_file_provider = tool.provider_factory.static_file_provider(); + if let Err(err) = static_file_provider.check_consistency(&tool.provider_factory.provider()?) { + warn!("Error checking consistency of static files: {err}"); + } + + let static_files = iter_static_files(static_file_provider.directory())?; + + let ranges = static_files + .get(segment) + .ok_or_else(|| eyre::eyre!("No static files found for segment: {}", segment))?; + + let start_time = Instant::now(); + let mut hasher = checksum_hasher(); + let mut total = 0usize; + let limit = limit.unwrap_or(usize::MAX); + + let start_block = start_block.unwrap_or(0); + let end_block = end_block.unwrap_or(u64::MAX); + + info!( + "Computing checksum for {} static files, start_block={}, end_block={}, limit={:?}", + segment, + start_block, + end_block, + if limit == usize::MAX { None } else { Some(limit) } + ); + + 'outer: for (block_range, _header) in ranges.iter().sorted_by_key(|(range, _)| range.start()) { + if block_range.end() < start_block || block_range.start() > end_block { + continue; + } + + let fixed_block_range = static_file_provider.find_fixed_range(segment, block_range.start()); + let jar_provider = static_file_provider + .get_segment_provider_for_range(segment, || Some(fixed_block_range), None)? + .ok_or_else(|| { + eyre::eyre!( + "Failed to get segment provider for segment {} at range {}", + segment, + block_range + ) + })?; + + let mut cursor = jar_provider.cursor()?; + + while let Ok(Some(row)) = cursor.next_row() { + for col_data in row.iter() { + hasher.write(col_data); + } + + total += 1; + + if total.is_multiple_of(PROGRESS_LOG_INTERVAL) { + info!("Hashed {total} entries."); + } + + if total >= limit { + break 'outer; + } + } + + // Explicitly drop provider before removing from cache to avoid deadlock + drop(jar_provider); + static_file_provider.remove_cached_provider(segment, fixed_block_range.end()); + } + + let checksum = hasher.finish(); + let elapsed = start_time.elapsed(); + + info!( + "Checksum for static file segment `{}`: {:#x} ({} entries, elapsed: {:?})", + segment, checksum, total, elapsed + ); + + Ok(()) +} + pub(crate) struct ChecksumViewer<'a, N: NodeTypesWithDB> { tool: &'a DbTool, start_key: Option, @@ -102,7 +227,7 @@ impl TableViewer<(u64, Duration)> for ChecksumViewer<'_, N }; let start_time = Instant::now(); - let mut hasher = FixedState::with_seed(u64::from_be_bytes(*b"RETHRETH")).build_hasher(); + let mut hasher = checksum_hasher(); let mut total = 0; let limit = self.limit.unwrap_or(usize::MAX); @@ -111,7 +236,7 @@ impl TableViewer<(u64, Duration)> for ChecksumViewer<'_, N for (index, entry) in walker.enumerate() { let (k, v): (RawKey, RawValue) = entry?; - if index.is_multiple_of(100_000) { + if index.is_multiple_of(PROGRESS_LOG_INTERVAL) { info!("Hashed {index} entries."); } diff --git a/crates/cli/commands/src/db/mod.rs b/crates/cli/commands/src/db/mod.rs index 189bf3d72e..f813924efb 100644 --- a/crates/cli/commands/src/db/mod.rs +++ b/crates/cli/commands/src/db/mod.rs @@ -39,7 +39,7 @@ pub enum Subcommands { Stats(stats::Command), /// Lists the contents of a table List(list::Command), - /// Calculates the content checksum of a table + /// Calculates the content checksum of a table or static file segment Checksum(checksum::Command), /// Create a diff between two database tables or two entire databases. Diff(diff::Command), diff --git a/docs/vocs/docs/pages/cli/SUMMARY.mdx b/docs/vocs/docs/pages/cli/SUMMARY.mdx index 4381ed7842..89a390f3f7 100644 --- a/docs/vocs/docs/pages/cli/SUMMARY.mdx +++ b/docs/vocs/docs/pages/cli/SUMMARY.mdx @@ -10,6 +10,8 @@ - [`reth db stats`](./reth/db/stats.mdx) - [`reth db list`](./reth/db/list.mdx) - [`reth db checksum`](./reth/db/checksum.mdx) + - [`reth db checksum mdbx`](./reth/db/checksum/mdbx.mdx) + - [`reth db checksum static-file`](./reth/db/checksum/static-file.mdx) - [`reth db diff`](./reth/db/diff.mdx) - [`reth db get`](./reth/db/get.mdx) - [`reth db get mdbx`](./reth/db/get/mdbx.mdx) @@ -66,6 +68,8 @@ - [`op-reth db stats`](./op-reth/db/stats.mdx) - [`op-reth db list`](./op-reth/db/list.mdx) - [`op-reth db checksum`](./op-reth/db/checksum.mdx) + - [`op-reth db checksum mdbx`](./op-reth/db/checksum/mdbx.mdx) + - [`op-reth db checksum static-file`](./op-reth/db/checksum/static-file.mdx) - [`op-reth db diff`](./op-reth/db/diff.mdx) - [`op-reth db get`](./op-reth/db/get.mdx) - [`op-reth db get mdbx`](./op-reth/db/get/mdbx.mdx) diff --git a/docs/vocs/docs/pages/cli/op-reth/db.mdx b/docs/vocs/docs/pages/cli/op-reth/db.mdx index d6c8ef5669..335b54cba6 100644 --- a/docs/vocs/docs/pages/cli/op-reth/db.mdx +++ b/docs/vocs/docs/pages/cli/op-reth/db.mdx @@ -11,7 +11,7 @@ Usage: op-reth db [OPTIONS] Commands: stats Lists all the tables, their entry count and their size list Lists the contents of a table - checksum Calculates the content checksum of a table + checksum Calculates the content checksum of a table or static file segment diff Create a diff between two database tables or two entire databases get Gets the content of a table for the given key drop Deletes all database entries diff --git a/docs/vocs/docs/pages/cli/op-reth/db/checksum.mdx b/docs/vocs/docs/pages/cli/op-reth/db/checksum.mdx index 4587020941..8027558cfb 100644 --- a/docs/vocs/docs/pages/cli/op-reth/db/checksum.mdx +++ b/docs/vocs/docs/pages/cli/op-reth/db/checksum.mdx @@ -1,27 +1,19 @@ # op-reth db checksum -Calculates the content checksum of a table +Calculates the content checksum of a table or static file segment ```bash $ op-reth db checksum --help ``` ```txt -Usage: op-reth db checksum [OPTIONS] +Usage: op-reth db checksum [OPTIONS] -Arguments: -
- The table name +Commands: + mdbx Calculates the checksum of a database table + static-file Calculates the checksum of a static file segment + help Print this message or the help of the given subcommand(s) Options: - --start-key - The start of the range to checksum - - --end-key - The end of the range to checksum - - --limit - The maximum number of records that are queried and used to compute the checksum - -h, --help Print help (see a summary with '-h') diff --git a/docs/vocs/docs/pages/cli/op-reth/db/checksum/mdbx.mdx b/docs/vocs/docs/pages/cli/op-reth/db/checksum/mdbx.mdx new file mode 100644 index 0000000000..aa34fef694 --- /dev/null +++ b/docs/vocs/docs/pages/cli/op-reth/db/checksum/mdbx.mdx @@ -0,0 +1,179 @@ +# op-reth db checksum mdbx + +Calculates the checksum of a database table + +```bash +$ op-reth db checksum mdbx --help +``` +```txt +Usage: op-reth db checksum mdbx [OPTIONS]
+ +Arguments: +
+ The table name + +Options: + --start-key + The start of the range to checksum + + --end-key + The end of the range to checksum + + --limit + The maximum number of records that are queried and used to compute the checksum + + -h, --help + Print help (see a summary with '-h') + +Datadir: + --chain + The chain this node is running. + Possible values are either a built-in chain or the path to a chain specification file. + + Built-in chains: + optimism, optimism_sepolia, optimism-sepolia, base, base_sepolia, base-sepolia, arena-z, arena-z-sepolia, automata, base-devnet-0-sepolia-dev-0, bob, boba-sepolia, boba, camp-sepolia, celo, creator-chain-testnet-sepolia, cyber, cyber-sepolia, ethernity, ethernity-sepolia, fraxtal, funki, funki-sepolia, hashkeychain, ink, ink-sepolia, lisk, lisk-sepolia, lyra, metal, metal-sepolia, mint, mode, mode-sepolia, oplabs-devnet-0-sepolia-dev-0, orderly, ozean-sepolia, pivotal-sepolia, polynomial, race, race-sepolia, radius_testnet-sepolia, redstone, rehearsal-0-bn-0-rehearsal-0-bn, rehearsal-0-bn-1-rehearsal-0-bn, settlus-mainnet, settlus-sepolia-sepolia, shape, shape-sepolia, silent-data-mainnet, snax, soneium, soneium-minato-sepolia, sseed, swan, swell, tbn, tbn-sepolia, unichain, unichain-sepolia, worldchain, worldchain-sepolia, xterio-eth, zora, zora-sepolia, dev + + [default: optimism] + +Logging: + --log.stdout.format + The format to use for logs written to stdout + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.stdout.filter + The filter to use for logs written to stdout + + [default: ] + + --log.file.format + The format to use for logs written to the log file + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.file.filter + The filter to use for logs written to the log file + + [default: debug] + + --log.file.directory + The path to put log files in + + [default: /logs] + + --log.file.name + The prefix name of the log files + + [default: reth.log] + + --log.file.max-size + The maximum size (in MB) of one log file + + [default: 200] + + --log.file.max-files + The maximum amount of log files that will be stored. If set to 0, background file logging is disabled + + [default: 5] + + --log.journald + Write logs to journald + + --log.journald.filter + The filter to use for logs written to journald + + [default: error] + + --color + Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting + + Possible values: + - always: Colors on + - auto: Auto-detect + - never: Colors off + + [default: always] + + --logs-otlp[=] + Enable `Opentelemetry` logs export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/logs` - gRPC: `http://localhost:4317` + + Example: --logs-otlp=http://collector:4318/v1/logs + + [env: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=] + + --logs-otlp.filter + Set a filter directive for the OTLP logs exporter. This controls the verbosity of logs sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --logs-otlp.filter=info,reth=debug + + Defaults to INFO if not specified. + + [default: info] + +Display: + -v, --verbosity... + Set the minimum log level. + + -v Errors + -vv Warnings + -vvv Info + -vvvv Debug + -vvvvv Traces (warning: very verbose!) + + -q, --quiet + Silence all log output + +Tracing: + --tracing-otlp[=] + Enable `Opentelemetry` tracing export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/traces` - gRPC: `http://localhost:4317` + + Example: --tracing-otlp=http://collector:4318/v1/traces + + [env: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=] + + --tracing-otlp-protocol + OTLP transport protocol to use for exporting traces and logs. + + - `http`: expects endpoint path to end with `/v1/traces` or `/v1/logs` - `grpc`: expects endpoint without a path + + Defaults to HTTP if not specified. + + Possible values: + - http: HTTP/Protobuf transport, port 4318, requires `/v1/traces` path + - grpc: gRPC transport, port 4317 + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + + --tracing-otlp.filter + Set a filter directive for the OTLP tracer. This controls the verbosity of spans and events sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --tracing-otlp.filter=info,reth=debug,hyper_util=off + + Defaults to TRACE if not specified. + + [default: debug] + + --tracing-otlp.sample-ratio + Trace sampling ratio to control the percentage of traces to export. + + Valid range: 0.0 to 1.0 - 1.0, default: Sample all traces - 0.01: Sample 1% of traces - 0.0: Disable sampling + + Example: --tracing-otlp.sample-ratio=0.0. + + [env: OTEL_TRACES_SAMPLER_ARG=] +``` \ No newline at end of file diff --git a/docs/vocs/docs/pages/cli/op-reth/db/checksum/static-file.mdx b/docs/vocs/docs/pages/cli/op-reth/db/checksum/static-file.mdx new file mode 100644 index 0000000000..0515b99883 --- /dev/null +++ b/docs/vocs/docs/pages/cli/op-reth/db/checksum/static-file.mdx @@ -0,0 +1,186 @@ +# op-reth db checksum static-file + +Calculates the checksum of a static file segment + +```bash +$ op-reth db checksum static-file --help +``` +```txt +Usage: op-reth db checksum static-file [OPTIONS] + +Arguments: + + The static file segment + + Possible values: + - headers: Static File segment responsible for the `CanonicalHeaders`, `Headers`, `HeaderTerminalDifficulties` tables + - transactions: Static File segment responsible for the `Transactions` table + - receipts: Static File segment responsible for the `Receipts` table + - transaction-senders: Static File segment responsible for the `TransactionSenders` table + - account-change-sets: Static File segment responsible for the `AccountChangeSets` table + +Options: + --start-block + The block number to start from (inclusive) + + --end-block + The block number to end at (inclusive) + + --limit + The maximum number of rows to checksum + + -h, --help + Print help (see a summary with '-h') + +Datadir: + --chain + The chain this node is running. + Possible values are either a built-in chain or the path to a chain specification file. + + Built-in chains: + optimism, optimism_sepolia, optimism-sepolia, base, base_sepolia, base-sepolia, arena-z, arena-z-sepolia, automata, base-devnet-0-sepolia-dev-0, bob, boba-sepolia, boba, camp-sepolia, celo, creator-chain-testnet-sepolia, cyber, cyber-sepolia, ethernity, ethernity-sepolia, fraxtal, funki, funki-sepolia, hashkeychain, ink, ink-sepolia, lisk, lisk-sepolia, lyra, metal, metal-sepolia, mint, mode, mode-sepolia, oplabs-devnet-0-sepolia-dev-0, orderly, ozean-sepolia, pivotal-sepolia, polynomial, race, race-sepolia, radius_testnet-sepolia, redstone, rehearsal-0-bn-0-rehearsal-0-bn, rehearsal-0-bn-1-rehearsal-0-bn, settlus-mainnet, settlus-sepolia-sepolia, shape, shape-sepolia, silent-data-mainnet, snax, soneium, soneium-minato-sepolia, sseed, swan, swell, tbn, tbn-sepolia, unichain, unichain-sepolia, worldchain, worldchain-sepolia, xterio-eth, zora, zora-sepolia, dev + + [default: optimism] + +Logging: + --log.stdout.format + The format to use for logs written to stdout + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.stdout.filter + The filter to use for logs written to stdout + + [default: ] + + --log.file.format + The format to use for logs written to the log file + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.file.filter + The filter to use for logs written to the log file + + [default: debug] + + --log.file.directory + The path to put log files in + + [default: /logs] + + --log.file.name + The prefix name of the log files + + [default: reth.log] + + --log.file.max-size + The maximum size (in MB) of one log file + + [default: 200] + + --log.file.max-files + The maximum amount of log files that will be stored. If set to 0, background file logging is disabled + + [default: 5] + + --log.journald + Write logs to journald + + --log.journald.filter + The filter to use for logs written to journald + + [default: error] + + --color + Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting + + Possible values: + - always: Colors on + - auto: Auto-detect + - never: Colors off + + [default: always] + + --logs-otlp[=] + Enable `Opentelemetry` logs export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/logs` - gRPC: `http://localhost:4317` + + Example: --logs-otlp=http://collector:4318/v1/logs + + [env: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=] + + --logs-otlp.filter + Set a filter directive for the OTLP logs exporter. This controls the verbosity of logs sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --logs-otlp.filter=info,reth=debug + + Defaults to INFO if not specified. + + [default: info] + +Display: + -v, --verbosity... + Set the minimum log level. + + -v Errors + -vv Warnings + -vvv Info + -vvvv Debug + -vvvvv Traces (warning: very verbose!) + + -q, --quiet + Silence all log output + +Tracing: + --tracing-otlp[=] + Enable `Opentelemetry` tracing export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/traces` - gRPC: `http://localhost:4317` + + Example: --tracing-otlp=http://collector:4318/v1/traces + + [env: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=] + + --tracing-otlp-protocol + OTLP transport protocol to use for exporting traces and logs. + + - `http`: expects endpoint path to end with `/v1/traces` or `/v1/logs` - `grpc`: expects endpoint without a path + + Defaults to HTTP if not specified. + + Possible values: + - http: HTTP/Protobuf transport, port 4318, requires `/v1/traces` path + - grpc: gRPC transport, port 4317 + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + + --tracing-otlp.filter + Set a filter directive for the OTLP tracer. This controls the verbosity of spans and events sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --tracing-otlp.filter=info,reth=debug,hyper_util=off + + Defaults to TRACE if not specified. + + [default: debug] + + --tracing-otlp.sample-ratio + Trace sampling ratio to control the percentage of traces to export. + + Valid range: 0.0 to 1.0 - 1.0, default: Sample all traces - 0.01: Sample 1% of traces - 0.0: Disable sampling + + Example: --tracing-otlp.sample-ratio=0.0. + + [env: OTEL_TRACES_SAMPLER_ARG=] +``` \ No newline at end of file diff --git a/docs/vocs/docs/pages/cli/reth/db.mdx b/docs/vocs/docs/pages/cli/reth/db.mdx index 4fda4538d1..ef1793696b 100644 --- a/docs/vocs/docs/pages/cli/reth/db.mdx +++ b/docs/vocs/docs/pages/cli/reth/db.mdx @@ -11,7 +11,7 @@ Usage: reth db [OPTIONS] Commands: stats Lists all the tables, their entry count and their size list Lists the contents of a table - checksum Calculates the content checksum of a table + checksum Calculates the content checksum of a table or static file segment diff Create a diff between two database tables or two entire databases get Gets the content of a table for the given key drop Deletes all database entries diff --git a/docs/vocs/docs/pages/cli/reth/db/checksum.mdx b/docs/vocs/docs/pages/cli/reth/db/checksum.mdx index 067737df48..31030442a3 100644 --- a/docs/vocs/docs/pages/cli/reth/db/checksum.mdx +++ b/docs/vocs/docs/pages/cli/reth/db/checksum.mdx @@ -1,27 +1,19 @@ # reth db checksum -Calculates the content checksum of a table +Calculates the content checksum of a table or static file segment ```bash $ reth db checksum --help ``` ```txt -Usage: reth db checksum [OPTIONS]
+Usage: reth db checksum [OPTIONS] -Arguments: -
- The table name +Commands: + mdbx Calculates the checksum of a database table + static-file Calculates the checksum of a static file segment + help Print this message or the help of the given subcommand(s) Options: - --start-key - The start of the range to checksum - - --end-key - The end of the range to checksum - - --limit - The maximum number of records that are queried and used to compute the checksum - -h, --help Print help (see a summary with '-h') diff --git a/docs/vocs/docs/pages/cli/reth/db/checksum/mdbx.mdx b/docs/vocs/docs/pages/cli/reth/db/checksum/mdbx.mdx new file mode 100644 index 0000000000..4608d1c282 --- /dev/null +++ b/docs/vocs/docs/pages/cli/reth/db/checksum/mdbx.mdx @@ -0,0 +1,179 @@ +# reth db checksum mdbx + +Calculates the checksum of a database table + +```bash +$ reth db checksum mdbx --help +``` +```txt +Usage: reth db checksum mdbx [OPTIONS]
+ +Arguments: +
+ The table name + +Options: + --start-key + The start of the range to checksum + + --end-key + The end of the range to checksum + + --limit + The maximum number of records that are queried and used to compute the checksum + + -h, --help + Print help (see a summary with '-h') + +Datadir: + --chain + The chain this node is running. + Possible values are either a built-in chain or the path to a chain specification file. + + Built-in chains: + mainnet, sepolia, holesky, hoodi, dev + + [default: mainnet] + +Logging: + --log.stdout.format + The format to use for logs written to stdout + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.stdout.filter + The filter to use for logs written to stdout + + [default: ] + + --log.file.format + The format to use for logs written to the log file + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.file.filter + The filter to use for logs written to the log file + + [default: debug] + + --log.file.directory + The path to put log files in + + [default: /logs] + + --log.file.name + The prefix name of the log files + + [default: reth.log] + + --log.file.max-size + The maximum size (in MB) of one log file + + [default: 200] + + --log.file.max-files + The maximum amount of log files that will be stored. If set to 0, background file logging is disabled + + [default: 5] + + --log.journald + Write logs to journald + + --log.journald.filter + The filter to use for logs written to journald + + [default: error] + + --color + Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting + + Possible values: + - always: Colors on + - auto: Auto-detect + - never: Colors off + + [default: always] + + --logs-otlp[=] + Enable `Opentelemetry` logs export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/logs` - gRPC: `http://localhost:4317` + + Example: --logs-otlp=http://collector:4318/v1/logs + + [env: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=] + + --logs-otlp.filter + Set a filter directive for the OTLP logs exporter. This controls the verbosity of logs sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --logs-otlp.filter=info,reth=debug + + Defaults to INFO if not specified. + + [default: info] + +Display: + -v, --verbosity... + Set the minimum log level. + + -v Errors + -vv Warnings + -vvv Info + -vvvv Debug + -vvvvv Traces (warning: very verbose!) + + -q, --quiet + Silence all log output + +Tracing: + --tracing-otlp[=] + Enable `Opentelemetry` tracing export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/traces` - gRPC: `http://localhost:4317` + + Example: --tracing-otlp=http://collector:4318/v1/traces + + [env: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=] + + --tracing-otlp-protocol + OTLP transport protocol to use for exporting traces and logs. + + - `http`: expects endpoint path to end with `/v1/traces` or `/v1/logs` - `grpc`: expects endpoint without a path + + Defaults to HTTP if not specified. + + Possible values: + - http: HTTP/Protobuf transport, port 4318, requires `/v1/traces` path + - grpc: gRPC transport, port 4317 + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + + --tracing-otlp.filter + Set a filter directive for the OTLP tracer. This controls the verbosity of spans and events sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --tracing-otlp.filter=info,reth=debug,hyper_util=off + + Defaults to TRACE if not specified. + + [default: debug] + + --tracing-otlp.sample-ratio + Trace sampling ratio to control the percentage of traces to export. + + Valid range: 0.0 to 1.0 - 1.0, default: Sample all traces - 0.01: Sample 1% of traces - 0.0: Disable sampling + + Example: --tracing-otlp.sample-ratio=0.0. + + [env: OTEL_TRACES_SAMPLER_ARG=] +``` \ No newline at end of file diff --git a/docs/vocs/docs/pages/cli/reth/db/checksum/static-file.mdx b/docs/vocs/docs/pages/cli/reth/db/checksum/static-file.mdx new file mode 100644 index 0000000000..04bd067b27 --- /dev/null +++ b/docs/vocs/docs/pages/cli/reth/db/checksum/static-file.mdx @@ -0,0 +1,186 @@ +# reth db checksum static-file + +Calculates the checksum of a static file segment + +```bash +$ reth db checksum static-file --help +``` +```txt +Usage: reth db checksum static-file [OPTIONS] + +Arguments: + + The static file segment + + Possible values: + - headers: Static File segment responsible for the `CanonicalHeaders`, `Headers`, `HeaderTerminalDifficulties` tables + - transactions: Static File segment responsible for the `Transactions` table + - receipts: Static File segment responsible for the `Receipts` table + - transaction-senders: Static File segment responsible for the `TransactionSenders` table + - account-change-sets: Static File segment responsible for the `AccountChangeSets` table + +Options: + --start-block + The block number to start from (inclusive) + + --end-block + The block number to end at (inclusive) + + --limit + The maximum number of rows to checksum + + -h, --help + Print help (see a summary with '-h') + +Datadir: + --chain + The chain this node is running. + Possible values are either a built-in chain or the path to a chain specification file. + + Built-in chains: + mainnet, sepolia, holesky, hoodi, dev + + [default: mainnet] + +Logging: + --log.stdout.format + The format to use for logs written to stdout + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.stdout.filter + The filter to use for logs written to stdout + + [default: ] + + --log.file.format + The format to use for logs written to the log file + + Possible values: + - json: Represents JSON formatting for logs. This format outputs log records as JSON objects, making it suitable for structured logging + - log-fmt: Represents logfmt (key=value) formatting for logs. This format is concise and human-readable, typically used in command-line applications + - terminal: Represents terminal-friendly formatting for logs + + [default: terminal] + + --log.file.filter + The filter to use for logs written to the log file + + [default: debug] + + --log.file.directory + The path to put log files in + + [default: /logs] + + --log.file.name + The prefix name of the log files + + [default: reth.log] + + --log.file.max-size + The maximum size (in MB) of one log file + + [default: 200] + + --log.file.max-files + The maximum amount of log files that will be stored. If set to 0, background file logging is disabled + + [default: 5] + + --log.journald + Write logs to journald + + --log.journald.filter + The filter to use for logs written to journald + + [default: error] + + --color + Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting + + Possible values: + - always: Colors on + - auto: Auto-detect + - never: Colors off + + [default: always] + + --logs-otlp[=] + Enable `Opentelemetry` logs export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/logs` - gRPC: `http://localhost:4317` + + Example: --logs-otlp=http://collector:4318/v1/logs + + [env: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=] + + --logs-otlp.filter + Set a filter directive for the OTLP logs exporter. This controls the verbosity of logs sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --logs-otlp.filter=info,reth=debug + + Defaults to INFO if not specified. + + [default: info] + +Display: + -v, --verbosity... + Set the minimum log level. + + -v Errors + -vv Warnings + -vvv Info + -vvvv Debug + -vvvvv Traces (warning: very verbose!) + + -q, --quiet + Silence all log output + +Tracing: + --tracing-otlp[=] + Enable `Opentelemetry` tracing export to an OTLP endpoint. + + If no value provided, defaults based on protocol: - HTTP: `http://localhost:4318/v1/traces` - gRPC: `http://localhost:4317` + + Example: --tracing-otlp=http://collector:4318/v1/traces + + [env: OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=] + + --tracing-otlp-protocol + OTLP transport protocol to use for exporting traces and logs. + + - `http`: expects endpoint path to end with `/v1/traces` or `/v1/logs` - `grpc`: expects endpoint without a path + + Defaults to HTTP if not specified. + + Possible values: + - http: HTTP/Protobuf transport, port 4318, requires `/v1/traces` path + - grpc: gRPC transport, port 4317 + + [env: OTEL_EXPORTER_OTLP_PROTOCOL=] + [default: http] + + --tracing-otlp.filter + Set a filter directive for the OTLP tracer. This controls the verbosity of spans and events sent to the OTLP endpoint. It follows the same syntax as the `RUST_LOG` environment variable. + + Example: --tracing-otlp.filter=info,reth=debug,hyper_util=off + + Defaults to TRACE if not specified. + + [default: debug] + + --tracing-otlp.sample-ratio + Trace sampling ratio to control the percentage of traces to export. + + Valid range: 0.0 to 1.0 - 1.0, default: Sample all traces - 0.01: Sample 1% of traces - 0.0: Disable sampling + + Example: --tracing-otlp.sample-ratio=0.0. + + [env: OTEL_TRACES_SAMPLER_ARG=] +``` \ No newline at end of file diff --git a/docs/vocs/sidebar-cli-op-reth.ts b/docs/vocs/sidebar-cli-op-reth.ts index ad2c6be69c..58d814f0e3 100644 --- a/docs/vocs/sidebar-cli-op-reth.ts +++ b/docs/vocs/sidebar-cli-op-reth.ts @@ -44,7 +44,18 @@ export const opRethCliSidebar: SidebarItem = { }, { text: "op-reth db checksum", - link: "/cli/op-reth/db/checksum" + link: "/cli/op-reth/db/checksum", + collapsed: true, + items: [ + { + text: "op-reth db checksum mdbx", + link: "/cli/op-reth/db/checksum/mdbx" + }, + { + text: "op-reth db checksum static-file", + link: "/cli/op-reth/db/checksum/static-file" + } + ] }, { text: "op-reth db diff", diff --git a/docs/vocs/sidebar-cli-reth.ts b/docs/vocs/sidebar-cli-reth.ts index 1b0f88b403..91c39eabb6 100644 --- a/docs/vocs/sidebar-cli-reth.ts +++ b/docs/vocs/sidebar-cli-reth.ts @@ -48,7 +48,18 @@ export const rethCliSidebar: SidebarItem = { }, { text: "reth db checksum", - link: "/cli/reth/db/checksum" + link: "/cli/reth/db/checksum", + collapsed: true, + items: [ + { + text: "reth db checksum mdbx", + link: "/cli/reth/db/checksum/mdbx" + }, + { + text: "reth db checksum static-file", + link: "/cli/reth/db/checksum/static-file" + } + ] }, { text: "reth db diff",