Skip to content

chore: cleanup chainspecs - #643

Merged
ntn-x2 merged 30 commits into
developfrom
aa/chainspec-cleanup
May 29, 2024
Merged

chore: cleanup chainspecs#643
ntn-x2 merged 30 commits into
developfrom
aa/chainspec-cleanup

Conversation

@ntn-x2

@ntn-x2ntn-x2 commented May 17, 2024

Copy link
Copy Markdown
Contributor

Fixeshttps://github.com/KILTprotocol/ticket/issues/3404.

Cleaning up the different chainspecs required also the modules to be restructured a bit. To note is the following:

  • Removal of the --runtime flag. Now any possible runtime is parsed solely from the provided --chain (or --dev) parameter (relevant for starting up the node going forward)
  • Removal of the unused chainspecs and renaming of the folder (relevant for starting up the node going forward)
  • Removal of all maintain scripts, which can be re-added if needed
  • Removal of the clone runtime

Of interest is the change from this

match(id, runtime){("clone-dev", _) => Ok(Box::new(chain_spec::clone::get_chain_spec_dev()?)),("clone-new", _) => Ok(Box::new(chain_spec::clone::new_chain_spec()?)),("dev", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),("spiritnet-dev", _) => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),("peregrine-new", _) => Ok(Box::new(chain_spec::peregrine::make_new_spec()?)),("rilt-new", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_rilt()?)),("rilt", _) => Ok(Box::new(chain_spec::peregrine::load_rilt_spec()?)),("spiritnet", _) => Ok(Box::new(chain_spec::spiritnet::load_spiritnet_spec()?)),("","spiritnet") => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),("","peregrine") => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),(path,"spiritnet") => Ok(Box::new(chain_spec::spiritnet::ChainSpec::from_json_file(path.into())?)),(path,"peregrine") => Ok(Box::new(chain_spec::peregrine::ChainSpec::from_json_file(path.into())?)),(path,"clone") => Ok(Box::new(chain_spec::clone::ChainSpec::from_json_file(path.into())?)),
_ => Err("Unknown KILT parachain spec".to_owned()),}

to this

match s {// Peregrine development"dev" => Ok(Self::Peregrine(PeregrineRuntime::Dev)),// New blank Peregrine chainspec"peregrine-new" => Ok(Self::Peregrine(PeregrineRuntime::New)),// Peregrine chainspec"peregrine" => Ok(Self::Peregrine(PeregrineRuntime::Peregrine)),// Peregrine staging chainspec"peregrine-stg" => Ok(Self::Peregrine(PeregrineRuntime::PeregrineStg)),// RILT chainspec"rilt" => Ok(Self::Peregrine(PeregrineRuntime::Rilt)),// Any other Peregrine-based chainspec
s if s.contains("peregrine") => Ok(Self::Peregrine(PeregrineRuntime::Other(s.to_string()))),// Spiritnet development"spiritnet-dev" => Ok(Self::Spiritnet(SpiritnetRuntime::Dev)),// New blank Spiritnet chainspec"spiritnet-new" => Ok(Self::Spiritnet(SpiritnetRuntime::New)),// Spiritnet chainspec"spiritnet" => Ok(Self::Spiritnet(SpiritnetRuntime::Spiritnet)),// Any other Spiritnet-based chainspec
s if s.contains("spiritnet") => Ok(Self::Spiritnet(SpiritnetRuntime::Other(s.to_string()))),
_ => Err(format!("Unknown chainspec id provided: {s}")),}

@ntn-x2ntn-x2 self-assigned this May 17, 2024
@ntn-x2
ntn-x2force-pushed the aa/chainspec-cleanup branch from 373ae86 to ae685d1CompareMay 22, 2024 10:01
@ntn-x2
ntn-x2 marked this pull request as ready for review May 23, 2024 13:11
@ntn-x2
ntn-x2 requested a review from Ad96elMay 23, 2024 13:11

@Ad96elAd96el left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice changes. We got rid of a lot of dead code. I tried running the node, but it results in an error.

Comment threadscripts/run_benches_for_runtime.sh
Comment threadnodes/standalone/src/command.rs Outdated
Comment threadnodes/standalone/src/command.rs
Comment threadnodes/parachain/Cargo.toml Outdated
Comment threadnodes/parachain/src/cli.rs Outdated
Comment threadnodes/parachain/src/cli.rs
Comment threadnodes/parachain/src/chain_spec/mod.rs
Comment threadnodes/parachain/src/chain_spec/mod.rs
Comment threadnodes/parachain/src/chain_spec/utils.rs
Comment threadnodes/parachain/src/chain_spec/utils.rs Outdated
Ad96el
Ad96el previously approved these changes May 28, 2024

@Ad96elAd96el left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. The commands are running

@ntn-x2
ntn-x2 merged commit e547f6b into developMay 29, 2024
@ntn-x2
ntn-x2 deleted the aa/chainspec-cleanup branch May 29, 2024 11:11
Ad96el pushed a commit that referenced this pull request May 31, 2024
Fixeshttps://github.com/KILTprotocol/ticket/issues/3404.
Cleaning up the different chainspecs required also the modules to be
restructured a bit. To note is the following:
* Removal of the `--runtime` flag. Now any possible runtime is parsed
solely from the provided `--chain` (or `--dev`) parameter (relevant for
starting up the node going forward)
* Removal of the unused chainspecs and renaming of the folder (relevant
for starting up the node going forward)
* Removal of all maintain scripts, which can be re-added if needed
* Removal of the clone runtime
Of interest is the change from this
```rust
match (id, runtime) {
("clone-dev", _) => Ok(Box::new(chain_spec::clone::get_chain_spec_dev()?)),
("clone-new", _) => Ok(Box::new(chain_spec::clone::new_chain_spec()?)),
("dev", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),
("spiritnet-dev", _) => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),
("peregrine-new", _) => Ok(Box::new(chain_spec::peregrine::make_new_spec()?)),
("rilt-new", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_rilt()?)),
("rilt", _) => Ok(Box::new(chain_spec::peregrine::load_rilt_spec()?)),
("spiritnet", _) => Ok(Box::new(chain_spec::spiritnet::load_spiritnet_spec()?)),
("", "spiritnet") => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),
("", "peregrine") => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),
(path, "spiritnet") => Ok(Box::new(chain_spec::spiritnet::ChainSpec::from_json_file(path.into())?)),
(path, "peregrine") => Ok(Box::new(chain_spec::peregrine::ChainSpec::from_json_file(path.into())?)),
(path, "clone") => Ok(Box::new(chain_spec::clone::ChainSpec::from_json_file(path.into())?)),
_ => Err("Unknown KILT parachain spec".to_owned()),
}
```
to this
```rust
match s {
// Peregrine development
"dev" => Ok(Self::Peregrine(PeregrineRuntime::Dev)),
// New blank Peregrine chainspec
"peregrine-new" => Ok(Self::Peregrine(PeregrineRuntime::New)),
// Peregrine chainspec
"peregrine" => Ok(Self::Peregrine(PeregrineRuntime::Peregrine)),
// Peregrine staging chainspec
"peregrine-stg" => Ok(Self::Peregrine(PeregrineRuntime::PeregrineStg)),
// RILT chainspec
"rilt" => Ok(Self::Peregrine(PeregrineRuntime::Rilt)),
// Any other Peregrine-based chainspec
s if s.contains("peregrine") => Ok(Self::Peregrine(PeregrineRuntime::Other(s.to_string()))),
// Spiritnet development
"spiritnet-dev" => Ok(Self::Spiritnet(SpiritnetRuntime::Dev)),
// New blank Spiritnet chainspec
"spiritnet-new" => Ok(Self::Spiritnet(SpiritnetRuntime::New)),
// Spiritnet chainspec
"spiritnet" => Ok(Self::Spiritnet(SpiritnetRuntime::Spiritnet)),
// Any other Spiritnet-based chainspec
s if s.contains("spiritnet") => Ok(Self::Spiritnet(SpiritnetRuntime::Other(s.to_string()))),
_ => Err(format!("Unknown chainspec id provided: {s}")),
}
```
Ad96el pushed a commit that referenced this pull request Aug 20, 2024
Fixeshttps://github.com/KILTprotocol/ticket/issues/3404.
Cleaning up the different chainspecs required also the modules to be
restructured a bit. To note is the following:
* Removal of the `--runtime` flag. Now any possible runtime is parsed
solely from the provided `--chain` (or `--dev`) parameter (relevant for
starting up the node going forward)
* Removal of the unused chainspecs and renaming of the folder (relevant
for starting up the node going forward)
* Removal of all maintain scripts, which can be re-added if needed
* Removal of the clone runtime
Of interest is the change from this
```rust
match (id, runtime) {
("clone-dev", _) => Ok(Box::new(chain_spec::clone::get_chain_spec_dev()?)),
("clone-new", _) => Ok(Box::new(chain_spec::clone::new_chain_spec()?)),
("dev", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),
("spiritnet-dev", _) => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),
("peregrine-new", _) => Ok(Box::new(chain_spec::peregrine::make_new_spec()?)),
("rilt-new", _) => Ok(Box::new(chain_spec::peregrine::get_chain_spec_rilt()?)),
("rilt", _) => Ok(Box::new(chain_spec::peregrine::load_rilt_spec()?)),
("spiritnet", _) => Ok(Box::new(chain_spec::spiritnet::load_spiritnet_spec()?)),
("", "spiritnet") => Ok(Box::new(chain_spec::spiritnet::get_chain_spec_dev()?)),
("", "peregrine") => Ok(Box::new(chain_spec::peregrine::get_chain_spec_dev()?)),
(path, "spiritnet") => Ok(Box::new(chain_spec::spiritnet::ChainSpec::from_json_file(path.into())?)),
(path, "peregrine") => Ok(Box::new(chain_spec::peregrine::ChainSpec::from_json_file(path.into())?)),
(path, "clone") => Ok(Box::new(chain_spec::clone::ChainSpec::from_json_file(path.into())?)),
_ => Err("Unknown KILT parachain spec".to_owned()),
}
```
to this
```rust
match s {
// Peregrine development
"dev" => Ok(Self::Peregrine(PeregrineRuntime::Dev)),
// New blank Peregrine chainspec
"peregrine-new" => Ok(Self::Peregrine(PeregrineRuntime::New)),
// Peregrine chainspec
"peregrine" => Ok(Self::Peregrine(PeregrineRuntime::Peregrine)),
// Peregrine staging chainspec
"peregrine-stg" => Ok(Self::Peregrine(PeregrineRuntime::PeregrineStg)),
// RILT chainspec
"rilt" => Ok(Self::Peregrine(PeregrineRuntime::Rilt)),
// Any other Peregrine-based chainspec
s if s.contains("peregrine") => Ok(Self::Peregrine(PeregrineRuntime::Other(s.to_string()))),
// Spiritnet development
"spiritnet-dev" => Ok(Self::Spiritnet(SpiritnetRuntime::Dev)),
// New blank Spiritnet chainspec
"spiritnet-new" => Ok(Self::Spiritnet(SpiritnetRuntime::New)),
// Spiritnet chainspec
"spiritnet" => Ok(Self::Spiritnet(SpiritnetRuntime::Spiritnet)),
// Any other Spiritnet-based chainspec
s if s.contains("spiritnet") => Ok(Self::Spiritnet(SpiritnetRuntime::Other(s.to_string()))),
_ => Err(format!("Unknown chainspec id provided: {s}")),
}
```
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ntn-x2@Ad96el