Skip to content
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
1 change: 0 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ jobs:
- name: Test All
run: |
make test-all
make test-benchmarking
- name: Inform buddies online
uses: 8398a7/action-slack@v3
if: always() && (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ yarn.lock
*.log
output
deploy
snapshot.bin
*.wasm
7 changes: 7 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 @@ -90,6 +90,8 @@ incremental = true
node-inspect = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-executive = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-metadata = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8" }
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,11 @@ build-bifrost-wasm:
.PHONY: build-asgard-wasm
build-asgard-wasm:
.maintain/build-wasm.sh asgard

.PHONY: try-bifrost-runtime-upgrade
try-bifrost-runtime-upgrade:
./scripts/try-runtime.sh bifrost

.PHONY: try-asgard-runtime-upgrade
try-asgard-runtime-upgrade:
./scripts/try-runtime.sh asgard
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ curl https://sh.rustup.rs -sSf | sh
make init
```

## Build binary

```bash
make build-all-release
```

## Testing

```bash
Expand All @@ -49,10 +55,12 @@ if runtime logic change we may do the benchmarking to regenerate WeightInfo for
make run-benchmarking
```

## Build binary
## Testing runtime migration

If modify the storage, should test the data migration before production upgrade.

```bash
make build-all-release
make try-bifrost-runtime-upgrade
```

## Run development chain
Expand Down
7 changes: 7 additions & 0 deletions node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ node-primitives = { path = "../primitives" }

# CLI-specific dependencies
sc-cli = { version = "0.9.0", optional = true }
try-runtime-cli = { version = "0.9.0", optional = true }
frame-try-runtime = { version = "0.9.0", optional = true }
frame-benchmarking-cli = { version = "3.0.0", optional = true }
node-inspect = { version = "0.8.0", optional = true }

Expand All @@ -58,6 +60,7 @@ cli = [
"node-inspect",
"sc-cli",
"frame-benchmarking-cli",
'try-runtime-cli',
"sc-service",
"structopt",
"substrate-build-script-utils",
Expand All @@ -76,3 +79,7 @@ with-all-runtime = [
"with-asgard-runtime",
"with-bifrost-runtime",
]
try-runtime = [
"node-service/try-runtime",
"try-runtime-cli",
]
5 changes: 5 additions & 0 deletions node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub enum Subcommand {
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),

/// Try some experimental command on the runtime. This includes migration and runtime-upgrade
/// testing.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),

/// Verify a signature for a message, provided on STDIN, with a given (public or secret) key.
Verify(VerifyCmd),

Expand Down
126 changes: 91 additions & 35 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ fn load_spec(
Box::new(service::chain_spec::asgard::ChainSpec::from_json_file(path)?)
}
#[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());
return Err(service::ASGARD_RUNTIME_NOT_AVAILABLE.into());
} 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) {
return Err(service::BIFROST_RUNTIME_NOT_AVAILABLE.into());
} else if path.to_str().map(|s| s.contains("asgard-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());
#[cfg(not(feature = "with-dev-runtime"))]
return Err(service::DEV_RUNTIME_NOT_AVAILABLE.into());
} else {
return Err("Unknown runtime is not available.".into());
}
Expand Down Expand Up @@ -147,21 +147,21 @@ impl SubstrateCli for Cli {
&service::collator::asgard_runtime::VERSION
}
#[cfg(not(feature = "with-asgard-runtime"))]
panic!("Asgard runtime is not available. Please compile the node with `--features with-asgard-runtime` to enable it.");
panic!("{}", service::ASGARD_RUNTIME_NOT_AVAILABLE);
} 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.");
panic!("{}", service::BIFROST_RUNTIME_NOT_AVAILABLE);
} 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.");
panic!("{}", service::DEV_RUNTIME_NOT_AVAILABLE);
}
}
}
Expand Down Expand Up @@ -252,6 +252,60 @@ macro_rules! construct_async_run {
}}
}

macro_rules! with_runtime_or_err {
($chain_spec:expr, { $( $code:tt )* }) => {
if $chain_spec.is_bifrost() {
#[cfg(feature = "with-bifrost-runtime")]
#[allow(unused_imports)]
use bifrost_runtime::{Block, RuntimeApi};
#[cfg(feature = "with-bifrost-runtime")]
#[allow(unused_imports)]
use BifrostExecutor as Executor;
#[cfg(feature = "with-bifrost-runtime")]
$( $code )*

#[cfg(not(feature = "with-bifrost-runtime"))]
return Err(service::BIFROST_RUNTIME_NOT_AVAILABLE.into());
} else if $chain_spec.is_asgard() {
#[cfg(feature = "with-asgard-runtime")]
#[allow(unused_imports)]
use asgard_runtime::{Block, RuntimeApi};
#[cfg(feature = "with-asgard-runtime")]
#[allow(unused_imports)]
use AsgardExecutor as Executor;
#[cfg(feature = "with-asgard-runtime")]
$( $code )*

#[cfg(not(feature = "with-asgard-runtime"))]
return Err(service::ASGARD_RUNTIME_NOT_AVAILABLE.into());
} else {
#[cfg(feature = "with-dev-runtime")]
#[allow(unused_imports)]
use service::dev::dev_runtime::{Block, RuntimeApi};
#[cfg(feature = "with-dev-runtime")]
#[allow(unused_imports)]
use service::dev::DevExecutor as Executor;
#[cfg(feature = "with-dev-runtime")]
$( $code )*

#[cfg(not(feature = "with-dev-runtime"))]
return Err(service::DEV_RUNTIME_NOT_AVAILABLE.into());
}
}
}

fn set_default_ss58_version(spec: &Box<dyn ChainSpec>) {
use sp_core::crypto::Ss58AddressFormat;

let ss58_version = if spec.is_bifrost() {
Ss58AddressFormat::BifrostAccount
} else {
Ss58AddressFormat::SubstrateAccount
};

sp_core::crypto::set_default_ss58_version(ss58_version);
}

/// Parse command line arguments into service configuration.
#[allow(unreachable_code)]
pub fn run() -> Result<()> {
Expand Down Expand Up @@ -309,39 +363,22 @@ pub fn run() -> Result<()> {
},
Some(Subcommand::Inspect(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);

return runner.sync_run(|config| {
#[cfg(feature = "with-asgard-runtime")]
return cmd
.run::<service::asgard_runtime::Block, service::asgard_runtime::RuntimeApi, service::AsgardExecutor>(
config,
);
#[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,
);
});
with_runtime_or_err!(chain_spec, {
return runner.sync_run(|config| cmd.run::<Block, RuntimeApi, Executor>(config));
})
},
Some(Subcommand::Benchmark(cmd)) =>
if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);

return runner.sync_run(|config| {
#[cfg(feature = "with-asgard-runtime")]
return cmd
.run::<service::asgard_runtime::Block, service::AsgardExecutor>(config);
#[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);
});
with_runtime_or_err!(chain_spec, {
return runner.sync_run(|config| cmd.run::<Block, Executor>(config));
})
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
Expand Down Expand Up @@ -446,6 +483,25 @@ pub fn run() -> Result<()> {

Ok(())
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;

set_default_ss58_version(chain_spec);

with_runtime_or_err!(chain_spec, {
return runner.async_run(|config| {
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
sc_service::TaskManager::new(config.task_executor.clone(), registry)
.map_err(|e| {
sc_cli::Error::Service(sc_service::Error::Prometheus(e))
})?;
Ok((cmd.run::<Block, Executor>(config), task_manager))
});
})
},
}
}

Expand Down
6 changes: 5 additions & 1 deletion node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0" }
frame-system-rpc-runtime-api = { version = "3.0.0" }
substrate-prometheus-endpoint = { version = "0.9.0" }
substrate-frame-rpc-system = { version = "3.0.0" }

try-runtime-cli = { version = "0.9.0", optional = true }
# Cumulus dependencies
cumulus-client-consensus-aura = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.8" }
cumulus-client-consensus-common = { git = "https://github.com/paritytech/cumulus", branch = "polkadot-v0.9.8" }
Expand Down Expand Up @@ -108,4 +108,8 @@ with-all-runtime = [
"with-asgard-runtime",
"with-bifrost-runtime",
]
try-runtime = [
"asgard-runtime/try-runtime",
"bifrost-runtime/try-runtime",
]

7 changes: 7 additions & 0 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,10 @@ impl IdentifyVariant for Box<dyn sc_service::ChainSpec> {
self.id().starts_with("asgard-dev") || self.id().starts_with("dev")
}
}

pub const BIFROST_RUNTIME_NOT_AVAILABLE: &str =
"Bifrost runtime is not available. Please compile the node with `--features with-bifrost-runtime` to enable it.";
pub const ASGARD_RUNTIME_NOT_AVAILABLE: &str =
"Asgard runtime is not available. Please compile the node with `--features with-asgard-runtime` to enable it.";
pub const DEV_RUNTIME_NOT_AVAILABLE: &str =
"Dev runtime is not available. Please compile the node with `--features with-dev-runtime` to enable it.";
6 changes: 6 additions & 0 deletions pallets/salp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
// Ensure we're `no_std` when compiling for Wasm.
#![cfg_attr(not(feature = "std"), no_std)]

pub mod migration {
pub fn migrate() {
log::info!("salp migration...");
}
}

#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
#[cfg(test)]
Expand Down
Loading