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

Add development runtime #200

Merged
merged 1 commit into from
Aug 3, 2021
Merged
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
131 changes: 131 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-consensus-manual-seal = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-consensus-epochs = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ make run-benchmarking
make build-all-release
```

## Run local testnet polkadot-launch
## Run development chain

```bash
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev
```

## Run local testnet with polkadot-launch

Install `polkadot-launch`:

Expand Down
3 changes: 3 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ with-asgard-runtime = [
with-bifrost-runtime = [
"node-service/with-bifrost-runtime",
]
with-dev-runtime = [
"node-service/with-dev-runtime"
]
with-all-runtime = [
"with-asgard-runtime",
"with-bifrost-runtime",
Expand Down
50 changes: 42 additions & 8 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ fn load_spec(
#[cfg(feature = "with-asgard-runtime")]
"asgard-genesis" => Box::new(service::chain_spec::asgard::chainspec_config(para_id)),
#[cfg(feature = "with-asgard-runtime")]
"asgard-dev" => Box::new(service::chain_spec::asgard::development_config(para_id)?),
#[cfg(feature = "with-asgard-runtime")]
"asgard-local" => Box::new(service::chain_spec::asgard::local_testnet_config(para_id)?),
#[cfg(feature = "with-bifrost-runtime")]
"bifrost" => Box::new(service::chain_spec::bifrost::ChainSpec::from_json_bytes(
Expand All @@ -74,9 +72,9 @@ fn load_spec(
#[cfg(feature = "with-bifrost-runtime")]
"bifrost-genesis" => Box::new(service::chain_spec::bifrost::chainspec_config(para_id)),
#[cfg(feature = "with-bifrost-runtime")]
"bifrost-dev" => Box::new(service::chain_spec::bifrost::development_config(para_id)?),
#[cfg(feature = "with-bifrost-runtime")]
"bifrost-local" => Box::new(service::chain_spec::bifrost::local_testnet_config(para_id)?),
#[cfg(feature = "with-dev-runtime")]
"dev" => Box::new(service::chain_spec::dev::development_config(para_id)?),
path => {
let path = std::path::PathBuf::from(path);
if path.to_str().map(|s| s.contains("asgard")) == Some(true) {
Expand All @@ -86,13 +84,22 @@ fn load_spec(
}
#[cfg(not(feature = "with-asgard-runtime"))]
return Err("Asgard runtime is not available. Please compile the node with `--features with-asgard-runtime` to enable it.".into());
} else {
} else if path.to_str().map(|s| s.contains("bifrost")) == Some(true) {
#[cfg(feature = "with-bifrost-runtime")]
{
Box::new(service::chain_spec::bifrost::ChainSpec::from_json_file(path)?)
}
#[cfg(not(feature = "with-bifrost-runtime"))]
return Err("Bifrost runtime is not available. Please compile the node with `--features with-bifrost-runtime` to enable it.".into());
} else if path.to_str().map(|s| s.contains("dev")) == Some(true) {
#[cfg(feature = "with-dev-runtime")]
{
Box::new(service::chain_spec::dev::ChainSpec::from_json_file(path)?)
}
#[cfg(not(feature = "with-dev-runtime"))]
return Err("Dev runtime is not available. Please compile the node with `--features with-dev-runtime` to enable it.".into());
} else {
return Err("Unknown runtime is not available.".into());
}
},
})
Expand Down Expand Up @@ -141,13 +148,20 @@ impl SubstrateCli for Cli {
}
#[cfg(not(feature = "with-asgard-runtime"))]
panic!("Asgard runtime is not available. Please compile the node with `--features with-asgard-runtime` to enable it.");
} else {
} else if spec.is_bifrost() {
#[cfg(feature = "with-bifrost-runtime")]
{
&service::collator::bifrost_runtime::VERSION
}
#[cfg(not(feature = "with-bifrost-runtime"))]
panic!("Bifrost runtime is not available. Please compile the node with `--features with-bifrost-runtime` to enable it.");
} else {
#[cfg(feature = "with-dev-runtime")]
{
&service::dev::dev_runtime::VERSION
}
#[cfg(not(feature = "with-dev-runtime"))]
panic!("Asgard dev runtime is not available. Please compile the node with `--features with-dev-runtime` to enable it.");
}
}
}
Expand Down Expand Up @@ -227,6 +241,14 @@ macro_rules! construct_async_run {
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
});
#[cfg(feature = "with-dev-runtime")]
return runner.async_run(|$config| {
let $components = crate::service::dev::new_partial(
&$config,
)?;
let task_manager = $components.task_manager;
{ $( $code )* }.map(|v| (v, task_manager))
});
}}
}

Expand All @@ -239,6 +261,11 @@ pub fn run() -> Result<()> {
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
runner.run_node_until_exit(|config| async move {
if config.chain_spec.is_asgard_dev() {
#[cfg(feature = "with-dev-runtime")]
return service::dev::new_full(config).map_err(Into::into);
}

let para_id =
node_service::chain_spec::RelayExtensions::try_get(&*config.chain_spec)
.map(|e| e.para_id);
Expand Down Expand Up @@ -283,11 +310,16 @@ pub fn run() -> Result<()> {
.run::<service::asgard_runtime::Block, service::asgard_runtime::RuntimeApi, service::AsgardExecutor>(
config,
);
#[cfg(not(feature = "with-asgard-runtime"))]
#[cfg(feature = "with-bifrost-runtime")]
return cmd
.run::<service::bifrost_runtime::Block, service::bifrost_runtime::RuntimeApi, service::BifrostExecutor>(
config,
);
#[cfg(feature = "with-dev-runtime")]
return cmd
.run::<service::dev_runtime::Block, service::dev_runtime::RuntimeApi, service::DevExecutor>(
config,
);
});
},
Some(Subcommand::Benchmark(cmd)) =>
Expand All @@ -298,9 +330,11 @@ pub fn run() -> Result<()> {
#[cfg(feature = "with-asgard-runtime")]
return cmd
.run::<service::asgard_runtime::Block, service::AsgardExecutor>(config);
#[cfg(not(feature = "with-asgard-runtime"))]
#[cfg(feature = "with-bifrost-runtime")]
return cmd
.run::<service::bifrost_runtime::Block, service::BifrostExecutor>(config);
#[cfg(feature = "with-dev-runtime")]
return cmd.run::<service::dev_runtime::Block, service::DevExecutor>(config);
});
} else {
Err("Benchmarking wasn't enabled when building the node. \
Expand Down
18 changes: 16 additions & 2 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,31 @@ sc-telemetry = { version = "3.0.0" }
sc-transaction-pool = { version = "3.0.0" }
sc-tracing = { version = "3.0.0" }
sc-service = { version = "0.9.0", default-features = false }
sc-consensus = { version = "0.9.0" }
sc-consensus-manual-seal = { version = "0.9.0" }
sc-consensus-aura = { version = "0.9.0" }
sc-finality-grandpa = { version = "0.9.0" }
sc-consensus-slots = { version = "0.9.0"}
sc-rpc-api = { version = "0.9.0"}
sc-rpc = { version = "3.0.0" }
sc-keystore = { version = "3.0.0" }
frame-benchmarking = { version = "3.0.0", default-features = false }

# Substrate Primitives
sp-consensus-aura = { version = "0.9.0" }
sp-consensus = { version = "0.9.0" }
grandpa_primitives = { package = "sp-finality-grandpa", version = "3.0.0" }
sp-finality-grandpa = { version = "3.0.0" }
sp-inherents = { version = "3.0.0" }
sp-api = { version = "3.0.0" }
sp-block-builder = { version = "3.0.0" }
sp-blockchain = { version = "3.0.0" }
sp-core = { version = "3.0.0" }
sp-keystore = { version = "0.9.0" }
sp-offchain = { package = "sp-offchain", version = "3.0.0" }
sc-rpc = { version = "3.0.0" }
sp-runtime = { version = "3.0.0" }
sp-session = { version = "3.0.0" }
sp-storage = { version = "3.0.0" }
sp-trie = { version = "3.0.0" }
sp-timestamp = { version = "3.0.0" }
sp-transaction-pool = { version = "3.0.0" }

Expand All @@ -40,6 +49,7 @@ pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0" }
# Substrate Other
frame-system-rpc-runtime-api = { version = "3.0.0" }
substrate-prometheus-endpoint = { version = "0.9.0" }
substrate-frame-rpc-system = { version = "3.0.0" }

# Cumulus dependencies
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.8" }
Expand All @@ -61,6 +71,7 @@ serde_json = "1.0.60"
# Runtimes
asgard-runtime = { path = "../../runtime/asgard", optional = true }
bifrost-runtime = { path = "../../runtime/bifrost", optional = true }
dev-runtime = { path = "../../runtime/dev", optional = true }
node-primitives = { path = "../primitives" }
node-rpc = { path = "../rpc" }

Expand All @@ -86,6 +97,9 @@ with-asgard-runtime = [
with-bifrost-runtime = [
"bifrost-runtime",
]
with-dev-runtime = [
"dev-runtime",
]
with-all-runtime = [
"with-asgard-runtime",
"with-bifrost-runtime",
Expand Down
Loading