Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clap = { workspace = true, features = ["derive"] }
futures = { workspace = true, features = ["thread-pool"] }
serde = { workspace = true, features = ["derive"] }
hex.workspace = true
tokio = { workspace = true, features = ["time"] }
tokio = { workspace = true, features = ["time", "rt", "net"] }

# Storage import
memmap2.workspace = true
Expand Down Expand Up @@ -68,6 +68,7 @@ sp-offchain.workspace = true
sp-session.workspace = true
frame-metadata-hash-extension.workspace = true
frame-system.workspace = true
frame-support.workspace = true
pallet-transaction-payment.workspace = true
pallet-commitments.workspace = true
pallet-drand.workspace = true
Expand All @@ -80,7 +81,7 @@ polkadot-sdk = { workspace = true, features = [
] }

# These dependencies are used for the subtensor's RPCs
jsonrpsee = { workspace = true, features = ["server"] }
jsonrpsee = { workspace = true, features = ["server", "http-client"] }
sc-rpc.workspace = true
sp-api.workspace = true
sc-rpc-api.workspace = true
Expand Down Expand Up @@ -156,6 +157,7 @@ runtime-benchmarks = [
"node-subtensor-runtime/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-benchmarking-cli/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sc-service/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
Expand All @@ -174,6 +176,7 @@ pow-faucet = []
# in the near future.
try-runtime = [
"node-subtensor-runtime/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-transaction-payment/try-runtime",
"sp-runtime/try-runtime",
Expand Down
92 changes: 92 additions & 0 deletions node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use node_subtensor_runtime::opaque::Block;
use sc_cli::RunCmd;
use sc_consensus::BasicQueue;
use sc_service::{Configuration, TaskManager};
use std::fmt;
use std::path::PathBuf;
use std::sync::Arc;

#[derive(Debug, clap::Parser)]
Expand All @@ -33,6 +35,14 @@ pub struct Cli {

#[command(flatten)]
pub eth: EthConfiguration,

/// Control historical gap-backfill during initial/catch-up sync.
///
/// `keep` preserves complete history (default for normal node runs).
/// `skip` is faster/lighter but historical block data may be incomplete.
/// For `build-test-clone`, the implicit default is `skip` unless this flag is explicitly set.
#[arg(long, value_enum, default_value_t = HistoryBackfill::Keep)]
pub history_backfill: HistoryBackfill,
}

#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -70,6 +80,88 @@ pub enum Subcommand {

// Db meta columns information.
ChainInfo(sc_cli::ChainInfoCmd),

// Build a patched test clone chainspec from synced network state.
#[command(name = "build-test-clone")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the name reflect what the code is doing because what it is really doing is building a chainspec, right?

Maybe something like build-clone-spec ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i was thinking about it a lot. initially it was clone-state and i also considered the one you're suggesting. i don't know, actually reflecting name would be something like clone-into-patched-spec, build-patched-clone and then build-test-clone or something like that. i'm not happy with any of these variants.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at least it should have spec in the name because it produces a spec?

Maybe something like build-patched-spec?

CloneState(CloneStateCmd),
}

/// Build a patched clone chainspec by syncing state, exporting raw state, and applying test patch.
#[derive(Debug, Clone, clap::Args)]
pub struct CloneStateCmd {
/// Chain spec identifier or path (same semantics as `--chain`).
#[arg(long, value_name = "CHAIN")]
pub chain: String,

/// Base path used for syncing and state export.
#[arg(long, value_name = "PATH")]
pub base_path: PathBuf,
Comment on lines +92 to +98
Copy link
Collaborator

@l0r1s l0r1s Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can have a default for those? We will use it for mainnet most of the time and using target/mainnet-clone seems like a good default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good default if we consider it a source code/cargo environment, but node is a binary though and can be ran everywhere. i would keep it explicit, because even if we use something like tmp, it's easy to miss and clutter up your storage.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes you are right, could error if not passed when used as binary


/// Output file path for the final patched chainspec JSON.
#[arg(long, value_name = "FILE")]
pub output: PathBuf,

/// Sync mode for the temporary sync node.
#[arg(long, value_enum, default_value_t = sc_cli::SyncMode::Warp)]
pub sync: sc_cli::SyncMode,

/// Database backend for the temporary sync/export node.
#[arg(long, value_enum, default_value_t = sc_cli::Database::ParityDb)]
pub database: sc_cli::Database,

/// RPC port used by the temporary sync node.
#[arg(long, default_value_t = 9966)]
pub rpc_port: u16,

/// P2P port used by the temporary sync node.
#[arg(long, default_value_t = 30466)]
pub port: u16,

/// Maximum time to wait for sync completion.
#[arg(long, default_value_t = 7200)]
pub sync_timeout_sec: u64,

/// Accept sync completion when current is within this many blocks of highest.
#[arg(long, default_value_t = 8)]
pub sync_lag_blocks: u64,

/// Optional bootnodes for the sync step. Repeatable.
#[arg(long, value_name = "BOOTNODE")]
pub bootnodes: Vec<String>,

/// Include Alice in patched validator authorities (default if no validator flags are passed; Sudo is assigned to the first selected validator in Alice->Bob->Charlie order).
#[arg(long, default_value_t = false)]
pub alice: bool,

/// Include Bob in patched validator authorities (if any validator flag is set, only selected validators are used; Sudo is assigned to the first selected validator in Alice->Bob->Charlie order).
#[arg(long, default_value_t = false)]
pub bob: bool,

/// Include Charlie in patched validator authorities (if any validator flag is set, only selected validators are used; Sudo is assigned to the first selected validator in Alice->Bob->Charlie order).
#[arg(long, default_value_t = false)]
pub charlie: bool,
Comment on lines +133 to +142
Copy link
Collaborator

@l0r1s l0r1s Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What could be nice is to have an "authorities" vector arg so we can add more than 3 authorities if needed and not fixed ones (alice/bob/charlie), else we have to repatch the chainspec after creating it. Maybe it can be done later if we need it though!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd keep alice, bob and charlie as flags as we have with node and use when we run node for testing, but having additional flag to specify other authorities would be useful though.

}

#[derive(Debug, Clone, Copy, clap::ValueEnum, Default)]
pub enum HistoryBackfill {
#[default]
Keep,
Skip,
}

impl AsRef<str> for HistoryBackfill {
fn as_ref(&self) -> &str {
match self {
HistoryBackfill::Keep => "keep",
HistoryBackfill::Skip => "skip",
}
}
}

impl fmt::Display for HistoryBackfill {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_ref())
}
}

/// Available Sealing methods.
Expand Down
Loading
Loading