Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 76c2082

Browse files
committed
sc-cli: Remove SubstrateCli::native_runtime_version function
The native runtime will be removed in the near future and thus this function will not be required anymore. \# Code changes Downstream users just need to remove `native_runtime_version` from their implementation of the `SubstrateCli` trait.
1 parent dfd8286 commit 76c2082

File tree

6 files changed

+9
-45
lines changed

6 files changed

+9
-45
lines changed

bin/node-template/node/src/command.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
};
77
use frame_benchmarking_cli::{BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE};
88
use node_template_runtime::{Block, EXISTENTIAL_DEPOSIT};
9-
use sc_cli::{ChainSpec, RuntimeVersion, SubstrateCli};
9+
use sc_cli::SubstrateCli;
1010
use sc_service::PartialComponents;
1111
use sp_keyring::Sr25519Keyring;
1212

@@ -46,10 +46,6 @@ impl SubstrateCli for Cli {
4646
Box::new(chain_spec::ChainSpec::from_json_file(std::path::PathBuf::from(path))?),
4747
})
4848
}
49-
50-
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
51-
&node_template_runtime::VERSION
52-
}
5349
}
5450

5551
/// Parse and run command line arguments

bin/node/cli/src/command.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use frame_benchmarking_cli::*;
2626
use kitchensink_runtime::{ExistentialDeposit, RuntimeApi};
2727
use node_executor::ExecutorDispatch;
2828
use node_primitives::Block;
29-
use sc_cli::{ChainSpec, Result, RuntimeVersion, SubstrateCli};
29+
use sc_cli::{Result, SubstrateCli};
3030
use sc_service::PartialComponents;
3131
use sp_keyring::Sr25519Keyring;
3232

@@ -79,10 +79,6 @@ impl SubstrateCli for Cli {
7979
};
8080
Ok(spec)
8181
}
82-
83-
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
84-
&kitchensink_runtime::VERSION
85-
}
8682
}
8783

8884
/// Parse command line arguments into service configuration.

bin/node/executor/benches/bench.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use codec::{Decode, Encode};
1919
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
2020
use frame_support::Hashable;
2121
use kitchensink_runtime::{
22-
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, GenesisConfig, Header,
23-
RuntimeCall, UncheckedExtrinsic,
22+
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, Header, RuntimeCall,
23+
RuntimeGenesisConfig, UncheckedExtrinsic,
2424
};
2525
use node_executor::ExecutorDispatch;
2626
use node_primitives::{BlockNumber, Hash};
@@ -67,7 +67,7 @@ fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
6767
node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
6868
}
6969

70-
fn new_test_ext(genesis_config: &GenesisConfig) -> TestExternalities<BlakeTwo256> {
70+
fn new_test_ext(genesis_config: &RuntimeGenesisConfig) -> TestExternalities<BlakeTwo256> {
7171
let mut test_ext = TestExternalities::new_with_code(
7272
compact_code_unwrap(),
7373
genesis_config.build_storage().unwrap(),
@@ -157,7 +157,7 @@ fn construct_block<E: Externalities>(
157157
}
158158

159159
fn test_blocks(
160-
genesis_config: &GenesisConfig,
160+
genesis_config: &RuntimeGenesisConfig,
161161
executor: &NativeElseWasmExecutor<ExecutorDispatch>,
162162
) -> Vec<(Vec<u8>, Hash)> {
163163
let mut test_ext = new_test_ext(genesis_config);

client/cli/src/commands/insert_key.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ mod tests {
125125
"test".into()
126126
}
127127

128-
fn native_runtime_version(_: &Box<dyn ChainSpec>) -> &'static sp_version::RuntimeVersion {
129-
unimplemented!("Not required in tests")
130-
}
131-
132128
fn load_spec(&self, _: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
133129
Ok(Box::new(GenericChainSpec::from_genesis(
134130
"test",

client/cli/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,4 @@ pub trait SubstrateCli: Sized {
248248
command.init(&Self::support_url(), &Self::impl_version(), logger_hook, &config)?;
249249
Runner::new(config, tokio_runtime, signals)
250250
}
251-
/// Native runtime version.
252-
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion;
253251
}

client/cli/src/runner.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,18 @@ pub fn print_node_infos<C: SubstrateCli>(config: &Configuration) {
187187
.path()
188188
.map_or_else(|| "<unknown>".to_owned(), |p| p.display().to_string())
189189
);
190-
info!("⛓ Native runtime: {}", C::native_runtime_version(&config.chain_spec));
191190
}
192191

193192
#[cfg(test)]
194193
mod tests {
194+
use super::*;
195+
use sc_network::config::NetworkConfiguration;
196+
use sc_service::{Arc, ChainType, GenericChainSpec, NoExtension};
195197
use std::{
196198
path::PathBuf,
197199
sync::atomic::{AtomicU64, Ordering},
198200
};
199201

200-
use sc_network::config::NetworkConfiguration;
201-
use sc_service::{Arc, ChainType, GenericChainSpec, NoExtension};
202-
use sp_runtime::create_runtime_str;
203-
use sp_version::create_apis_vec;
204-
205-
use super::*;
206-
207202
struct Cli;
208203

209204
impl SubstrateCli for Cli {
@@ -237,23 +232,6 @@ mod tests {
237232
) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
238233
Err("nope".into())
239234
}
240-
241-
fn native_runtime_version(
242-
_: &Box<dyn sc_service::ChainSpec>,
243-
) -> &'static sp_version::RuntimeVersion {
244-
const VERSION: sp_version::RuntimeVersion = sp_version::RuntimeVersion {
245-
spec_name: create_runtime_str!("spec"),
246-
impl_name: create_runtime_str!("name"),
247-
authoring_version: 0,
248-
spec_version: 0,
249-
impl_version: 0,
250-
apis: create_apis_vec!([]),
251-
transaction_version: 2,
252-
state_version: 0,
253-
};
254-
255-
&VERSION
256-
}
257235
}
258236

259237
fn create_runner() -> Runner<Cli> {

0 commit comments

Comments
 (0)