Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add command download to download public node snapshots #13598

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1cb2f46
feat: add v1 for execute fn with url necessary and decompression not …
lean-apple Dec 30, 2024
3c45e96
feat: add v1 for execute fn with url necessary
lean-apple Dec 30, 2024
d82392e
feat: add decompression file option to cli
lean-apple Jan 3, 2025
9a134cc
docs: add command documentation
lean-apple Jan 3, 2025
f27faf4
docs: improve code doc + cli displayed
lean-apple Jan 6, 2025
fd8f9f2
fix: typo
lean-apple Jan 6, 2025
8b05e7c
fix: complete doc
lean-apple Jan 6, 2025
01f2206
fix: complete doc
lean-apple Jan 6, 2025
337e819
fix: fix doc fmt
lean-apple Jan 6, 2025
48ac0a8
fix: fix doc fmt
lean-apple Jan 6, 2025
d7ad3ee
docs: add download cli ref to global summary
lean-apple Jan 6, 2025
74950e9
Merge branch 'main' into cli-download-public-node-snapshots
lean-apple Jan 9, 2025
c7e263d
refactor: update most of println with tracing::info except one
lean-apple Jan 9, 2025
3c9e7b4
refactor: remove decompress option
lean-apple Jan 10, 2025
4f0c5c7
chore: fmt
lean-apple Jan 10, 2025
bc6fde2
refactor: replace tokyo::fs by std::fs
lean-apple Jan 10, 2025
b4a894a
refactor: draft working version with both command threads
lean-apple Jan 10, 2025
7b68991
refactor: refactor stream and extract fn
lean-apple Jan 13, 2025
8fe0ed3
refactor: make --url option with default mainnet archive snapshot url
lean-apple Jan 13, 2025
0fe6e3e
docs: complete url long help documentation
lean-apple Jan 13, 2025
b2b146a
docs: update book help
lean-apple Jan 13, 2025
b1dd028
Merge branch 'main' into cli-download-public-node-snapshots
lean-apple Jan 13, 2025
145f6c0
docs: remove --decompress
lean-apple Jan 13, 2025
cba7ae2
docs: update command description
lean-apple Jan 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 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 bin/reth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ futures.workspace = true

# misc
aquamarine.workspace = true
eyre.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
backon.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
eyre.workspace = true
similar-asserts.workspace = true

[dev-dependencies]
Expand Down
8 changes: 7 additions & 1 deletion bin/reth/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use clap::{value_parser, Parser, Subcommand};
use reth_chainspec::ChainSpec;
use reth_cli::chainspec::ChainSpecParser;
use reth_cli_commands::{
config_cmd, db, dump_genesis, import, init_cmd, init_state,
config_cmd, db, download, dump_genesis, import, init_cmd, init_state,
node::{self, NoArgs},
p2p, prune, recover, stage,
};
Expand Down Expand Up @@ -169,6 +169,9 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>, Ext: clap::Args + fmt::Debug> Cl
Commands::Db(command) => {
runner.run_blocking_until_ctrl_c(command.execute::<EthereumNode>())
}
Commands::Download(command) => {
runner.run_blocking_until_ctrl_c(command.execute::<EthereumNode>())
}
Commands::Stage(command) => runner.run_command_until_exit(|ctx| {
command.execute::<EthereumNode, _, _, EthNetworkPrimitives>(
ctx,
Expand Down Expand Up @@ -221,6 +224,9 @@ pub enum Commands<C: ChainSpecParser, Ext: clap::Args + fmt::Debug> {
/// Database debugging utilities
#[command(name = "db")]
Db(db::Command<C>),
/// Downloads and extracts node snapshots
#[command(name = "download")]
Download(download::Command<C>),
/// Manipulate individual stages.
#[command(name = "stage")]
Stage(stage::Command<C>),
Expand Down
1 change: 1 addition & 0 deletions book/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [`reth db clear static-file`](./cli/reth/db/clear/static-file.md)
- [`reth db version`](./cli/reth/db/version.md)
- [`reth db path`](./cli/reth/db/path.md)
- [`reth download`](./cli/reth/download.md)
- [`reth stage`](./cli/reth/stage.md)
- [`reth stage run`](./cli/reth/stage/run.md)
- [`reth stage drop`](./cli/reth/stage/drop.md)
Expand Down
1 change: 1 addition & 0 deletions book/cli/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [`reth db clear static-file`](./reth/db/clear/static-file.md)
- [`reth db version`](./reth/db/version.md)
- [`reth db path`](./reth/db/path.md)
- [`reth download`](./reth/download.md)
- [`reth stage`](./reth/stage.md)
- [`reth stage run`](./reth/stage/run.md)
- [`reth stage drop`](./reth/stage/drop.md)
Expand Down
1 change: 1 addition & 0 deletions book/cli/reth.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Commands:
import This syncs RLP encoded blocks from a file
dump-genesis Dumps genesis block JSON configuration to stdout
db Database debugging utilities
download Downloads and extracts node snapshots
stage Manipulate individual stages
p2p P2P Debugging utilities
config Write config to stdout
Expand Down
136 changes: 136 additions & 0 deletions book/cli/reth/download.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# reth download

Downloads and extracts node snapshots

```bash
$ reth download --help
```
```txt
Usage: reth download [OPTIONS]

Options:
--chain <CHAIN_OR_PATH>
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, dev

[default: mainnet]

--instance <INSTANCE>
Add a new instance of a node.

Configures the ports of the node to avoid conflicts with the defaults. This is useful for running multiple nodes on the same machine.

Max number of instances is 200. It is chosen in a way so that it's not possible to have port numbers that conflict with each other.

Changes to the following port numbers: - `DISCOVERY_PORT`: default + `instance` - 1 - `AUTH_PORT`: default + `instance` * 100 - 100 - `HTTP_RPC_PORT`: default - `instance` + 1 - `WS_RPC_PORT`: default + `instance` * 2 - 2

[default: 1]

-h, --help
Print help (see a summary with '-h')

Datadir:
--datadir <DATA_DIR>
The path to the data dir for all reth files and subdirectories.

Defaults to the OS-specific data directory:

- Linux: `$XDG_DATA_HOME/reth/` or `$HOME/.local/share/reth/`
- Windows: `{FOLDERID_RoamingAppData}/reth/`
- macOS: `$HOME/Library/Application Support/reth/`

[default: default]

--datadir.static-files <PATH>
The absolute path to store static files in.

-u, --url <URL>
Specify a snapshot URL or let the command propose a default one.

Available snapshot sources:
- https://downloads.merkle.io (default, mainnet archive)
- https://publicnode.com/snapshots (full nodes & testnets)

If no URL is provided, the latest mainnet archive snapshot
will be proposed for download from merkle.io

Logging:
--log.stdout.format <FORMAT>
The format to use for logs written to stdout

[default: terminal]

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

--log.stdout.filter <FILTER>
The filter to use for logs written to stdout

[default: ]

--log.file.format <FORMAT>
The format to use for logs written to the log file

[default: terminal]

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

--log.file.filter <FILTER>
The filter to use for logs written to the log file

[default: debug]

--log.file.directory <PATH>
The path to put log files in

[default: <CACHE_DIR>/logs]

--log.file.max-size <SIZE>
The maximum size (in MB) of one log file

[default: 200]

--log.file.max-files <COUNT>
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 <FILTER>
The filter to use for logs written to journald

[default: error]

--color <COLOR>
Sets whether or not the formatter emits ANSI terminal escape codes for colors and other text formatting

[default: always]

Possible values:
- always: Colors on
- auto: Colors on
- never: Colors off

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
```
9 changes: 5 additions & 4 deletions crates/cli/commands/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,19 @@ tokio.workspace = true

# misc
ahash = "0.8"
human_bytes = "0.4.1"
eyre.workspace = true
backon.workspace = true
clap = { workspace = true, features = ["derive", "env"] }
eyre.workspace = true
human_bytes = "0.4.1"
reqwest.workspace = true
serde.workspace = true
serde_json.workspace = true
tracing.workspace = true
backon.workspace = true
secp256k1 = { workspace = true, features = [
"global-context",
"rand-std",
"recovery",
] }
tracing.workspace = true

# io
fdlimit.workspace = true
Expand Down
Loading
Loading