-
Notifications
You must be signed in to change notification settings - Fork 288
Extend node with build-test-clone subcommand #2489
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
base: devnet-ready
Are you sure you want to change the base?
Changes from all commits
f34447f
0652bcc
c14c81d
b9b0e7a
2b78032
902bd71
abf2fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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)] | ||
|
|
@@ -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)] | ||
|
|
@@ -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")] | ||
| 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. | ||
|
|
||
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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-stateand i also considered the one you're suggesting. i don't know, actually reflecting name would be something likeclone-into-patched-spec,build-patched-cloneand thenbuild-test-cloneor something like that. i'm not happy with any of these variants.There was a problem hiding this comment.
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?