Extend node with build-test-clone subcommand#2489
Extend node with build-test-clone subcommand#2489ales-otf wants to merge 4 commits intodevnet-readyfrom
Conversation
c0340ee to
71346f1
Compare
71346f1 to
b9b0e7a
Compare
| ChainInfo(sc_cli::ChainInfoCmd), | ||
|
|
||
| // Build a patched test clone chainspec from synced network state. | ||
| #[command(name = "build-test-clone")] |
There was a problem hiding this comment.
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.
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.
| /// 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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| "--history-backfill", | ||
| history_backfill.as_ref(), |
There was a problem hiding this comment.
This caused a panics at the end of the sync because it doesn't exists on export-state, need to be kept only for the main command I guess:
2026-03-10 19:28:10 build-test-clone: sync target reached
2026-03-10 19:28:12 Essential task `txpool-background` failed. Shutting down service.
error: unexpected argument '--history-backfill' found
tip: to pass '--history-backfill' as a value, use '-- --history-backfill'
Usage: node-subtensor export-state --chain <CHAIN_SPEC> --base-path <PATH> --database <DB> [HASH or NUMBER]
For more information, try '--help'.
2026-03-10 19:28:13 build-test-clone: exporting raw state
Error: Application("export-state failed with status exit status: 2")
There was a problem hiding this comment.
oh shit, i broke it with my clean up 😄
| #[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). | ||
| #[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). | ||
| #[arg(long, default_value_t = false)] | ||
| pub charlie: bool, |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
| "--no-telemetry".to_string(), | ||
| "--no-prometheus".to_string(), | ||
| "--no-mdns".to_string(), | ||
| "--name".to_string(), |
There was a problem hiding this comment.
Missing something after the --name, or maybe it's not needed?
There was a problem hiding this comment.
the name is on the next line :) it's build-test-clone-sync.
| static VALIDATORS: &[Validator] = &[ | ||
| Validator { | ||
| name: "alice", | ||
| sr25519_hex: "d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d", | ||
| ed25519_hex: "88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee", | ||
| }, | ||
| Validator { | ||
| name: "bob", | ||
| sr25519_hex: "8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48", | ||
| ed25519_hex: "d17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae69", | ||
| }, | ||
| Validator { | ||
| name: "charlie", | ||
| sr25519_hex: "90b5ab205c6974c9ea841be688864633dc9ca8a357843eeacf2314649965fe22", | ||
| ed25519_hex: "439660b36c6c03afafca027b910b4fecf99801834c62a5e6006f27d978de234f", | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
There are 2 functions to derive this from the name in the node/chainspec/mod.rs to avoid hardcoding?
There was a problem hiding this comment.
i'll take a look, thanks!
Description
Introduces
build-test-clonesubcommand, that does next:So basically it produces a patched clone of a given network for testing. So you can test on mainnet clone, for example.
It can be used like this:
Then you normally run a testing node with produced chainspec like this:
The PR introduces a
history_backfillflag to skip the gap feeling phase after the initial sync. That phase is needed for the historical data, but for the testing purposes we can skip it. It'skeepby default, so it doesn't affect current node behavior. It'sskipby default forbuild-test-cloneto speed up the process.Also unlike normal node default to rocksdb,
build-test-cloneis default toparitydb. And unlike the patch,build-test-cloneproduces chainspec with only single authority (alice) by default. This is more convenient and lightweight for local runs. But you can specify other conventional authorities using flags (--alice,--bob,--charlie) - any combination of them are allowed.Related Issue(s)
Type of Change
Breaking Change
If this PR introduces a breaking change, please provide a detailed description of the impact and the migration path for existing applications.
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyScreenshots (if applicable)
Please include any relevant screenshots or GIFs that demonstrate the changes made.
Additional Notes
Please provide any additional information or context that may be helpful for reviewers.