Skip to content

Commit

Permalink
Merge pull request #145 from Phala-Network/rustc-2022-7-11
Browse files Browse the repository at this point in the history
Upgrade Rust to nightly-2022-07-11
  • Loading branch information
jasl authored Jul 15, 2022
2 parents 5472cf7 + 7a10d11 commit 096a44b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 29 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,30 @@ env:
CARGO_TERM_COLOR: always

jobs:
cargo-tests:
test:
name: Cargo test
runs-on: ubuntu-20.04
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master # https://github.com/easimon/maximize-build-space
with:
root-reserve-mb: 4096
temp-reserve-mb: 4096
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-04-01
toolchain: nightly-2022-07-11
override: true
target: wasm32-unknown-unknown
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: 'true'
- name: Run cargo tests
submodules: "true"
- name: Build for Cargo test
run: cargo test --no-run --verbose --workspace
- name: Show disk usage
run: df -h
- name: Run Cargo test
run: cargo test --verbose --workspace
2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name = "khala-node"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
tracing-core = "=0.1.26" # TODO: Higher version will break log format, stick to this version until upstream upgrade.
tracing-core = "=0.1.26" # TODO: https://github.com/paritytech/substrate/issues/11691

async-trait = "0.1.42"
clap = { version = "3.1", features = ["derive"] }
Expand Down
70 changes: 48 additions & 22 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,15 @@ impl SubstrateCli for Cli {

fn native_runtime_version(chain_spec: &Box<dyn sc_service::ChainSpec>) -> &'static RuntimeVersion {
match chain_spec.runtime_name().as_str() {
#[cfg(feature = "phala-native")]
"phala" => &phala_parachain_runtime::VERSION,
#[cfg(feature = "khala-native")]
"khala" => &khala_parachain_runtime::VERSION,
#[cfg(feature = "rhala-native")]
"rhala" => &rhala_parachain_runtime::VERSION,
#[cfg(feature = "thala-native")]
"thala" => &thala_parachain_runtime::VERSION,
#[cfg(feature = "shell-native")]
"shell" => &shell_parachain_runtime::VERSION,
_ => panic!("Can not determine runtime"),
}
Expand Down Expand Up @@ -479,35 +484,45 @@ macro_rules! construct_async_run {

/// Creates partial components for the runtimes that are supported by the benchmarks.
macro_rules! construct_benchmark_partials {
($config:expr, |$partials:ident| $code:expr) => {
($config:expr, |$partials:ident| $code:expr) => {{
#[cfg(feature = "phala-native")]
if $config.chain_spec.is_phala() {
let $partials = new_partial::<phala_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::phala::parachain_build_import_queue,
)?;
$code
} else if $config.chain_spec.is_khala() {
return $code
}

#[cfg(feature = "khala-native")]
if $config.chain_spec.is_khala() {
let $partials = new_partial::<khala_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::khala::parachain_build_import_queue,
)?;
$code
} else if $config.chain_spec.is_rhala() {
return $code
}

#[cfg(feature = "rhala-native")]
if $config.chain_spec.is_rhala() {
let $partials = new_partial::<rhala_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::rhala::parachain_build_import_queue,
)?;
$code
} else if $config.chain_spec.is_thala() {
return $code
}

#[cfg(feature = "thala-native")]
if $config.chain_spec.is_thala() {
let $partials = new_partial::<thala_parachain_runtime::RuntimeApi, _>(
&$config,
crate::service::thala::parachain_build_import_queue,
)?;
$code
} else {
Err("The chain is not supported".into())
return $code
}
};

Err("The chain is not supported".into())
}};
}

/// Parse command line arguments into service configuration.
Expand Down Expand Up @@ -612,26 +627,37 @@ pub fn run() -> Result<()> {

// Switch on the concrete benchmark sub-commands
match cmd {
BenchmarkCmd::Pallet(cmd) =>
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| {
#[cfg(feature = "phala-native")]
if config.chain_spec.is_phala() {
cmd.run::<Block, crate::service::phala::RuntimeExecutor>(config)
} else if config.chain_spec.is_khala() {
cmd.run::<Block, crate::service::khala::RuntimeExecutor>(config)
} else if config.chain_spec.is_rhala() {
cmd.run::<Block, crate::service::rhala::RuntimeExecutor>(config)
} else if config.chain_spec.is_thala() {
cmd.run::<Block, crate::service::thala::RuntimeExecutor>(config)
} else {
Err("Chain doesn't support benchmarking".into())
return cmd.run::<Block, crate::service::phala::RuntimeExecutor>(config)
}

#[cfg(feature = "khala-native")]
if config.chain_spec.is_khala() {
return cmd.run::<Block, crate::service::khala::RuntimeExecutor>(config)
}

#[cfg(feature = "rhala-native")]
if config.chain_spec.is_rhala() {
return cmd.run::<Block, crate::service::rhala::RuntimeExecutor>(config)
}

#[cfg(feature = "thala-native")]
if config.chain_spec.is_thala() {
return cmd.run::<Block, crate::service::thala::RuntimeExecutor>(config)
}

Err("Chain doesn't support benchmarking".into())
})
} else {
Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
},
}
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
construct_benchmark_partials!(config, |partials| cmd.run(partials.client))
}),
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2022-04-01"
channel = "nightly-2022-07-11"
components = ["rustfmt"]
targets = ["wasm32-unknown-unknown"]

0 comments on commit 096a44b

Please sign in to comment.