Skip to content

Commit 45a29ba

Browse files
committed
Remove Polkadot & Kusama native runtime
This pull request removes the Polkadot and Kusama native runtime from the polkadot node. This brings some implications with it: 1. There are no more `kusama/polkadot-dev` chain specs available. We will need to write some tooling in the fellowship repo to provide them easily. 2. The `try-runtime` job for polkadot & kusama is not available anymore as we don't have the dev chain specs anymore. 3. Certain benchmarking commands will also not work until we migrate them to use a runtime api. Some crates in `utils` are still depending on the polkadot/kusama native runtime that will also need to be fixed.
1 parent 3f0d28c commit 45a29ba

File tree

12 files changed

+45
-854
lines changed

12 files changed

+45
-854
lines changed

Cargo.lock

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

polkadot/Cargo.toml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ color-eyre = { version = "0.6.1", default-features = false }
2525
tikv-jemallocator = "0.5.0"
2626

2727
# Crates in our workspace, defined as dependencies so we can pass them feature flags.
28-
polkadot-cli = { path = "cli", features = [
29-
"kusama-native",
30-
"westend-native",
31-
"rococo-native",
32-
] }
28+
polkadot-cli = { path = "cli", features = [ "westend-native", "rococo-native" ] }
3329
polkadot-node-core-pvf = { path = "node/core/pvf" }
3430
polkadot-node-core-pvf-prepare-worker = { path = "node/core/pvf/prepare-worker" }
3531
polkadot-overseer = { path = "node/overseer" }

polkadot/cli/Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,9 @@ fast-runtime = [ "service/fast-runtime" ]
6767
pyroscope = [ "pyro", "pyroscope_pprofrs" ]
6868
hostperfcheck = [ "polkadot-performance-test" ]
6969

70-
# Configure the native runtimes to use. Polkadot is enabled by default.
71-
#
72-
# Validators require the native runtime currently
73-
polkadot-native = [ "service/polkadot-native" ]
74-
kusama-native = [ "service/kusama-native" ]
75-
westend-native = [ "service/westend-native" ]
76-
rococo-native = [ "service/rococo-native" ]
70+
# Configure the native runtimes to use.
71+
westend-native = ["service/westend-native"]
72+
rococo-native = ["service/rococo-native"]
7773

7874
malus = [ "full-node", "service/malus" ]
7975
runtime-metrics = [

polkadot/cli/src/command.rs

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ pub use polkadot_performance_test::PerfCheckError;
3434
#[cfg(feature = "pyroscope")]
3535
use pyroscope_pprofrs::{pprof_backend, PprofConfig};
3636

37-
impl From<String> for Error {
38-
fn from(s: String) -> Self {
39-
Self::Other(s)
40-
}
41-
}
42-
4337
type Result<T> = std::result::Result<T, Error>;
4438

39+
/// Millisecs per block is assumed to be the same for every relay chain.
40+
const MILLISECS_PER_BLOCK: u64 = 6000;
41+
4542
fn get_exec_name() -> Option<String> {
4643
std::env::current_exe()
4744
.ok()
@@ -91,20 +88,11 @@ impl SubstrateCli for Cli {
9188
};
9289
Ok(match id {
9390
"kusama" => Box::new(service::chain_spec::kusama_config()?),
94-
#[cfg(feature = "kusama-native")]
95-
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()?),
96-
#[cfg(feature = "kusama-native")]
97-
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()?),
98-
#[cfg(feature = "kusama-native")]
99-
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?),
100-
#[cfg(not(feature = "kusama-native"))]
10191
name if name.starts_with("kusama-") && !name.ends_with(".json") =>
102-
Err(format!("`{}` only supported with `kusama-native` feature enabled.", name))?,
92+
Err(format!("`{name}` is not supported anymore as the kusama native runtime no longer part of the node."))?,
10393
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
104-
#[cfg(feature = "polkadot-native")]
105-
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
106-
#[cfg(feature = "polkadot-native")]
107-
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?),
94+
name if name.starts_with("polkadot-") && !name.ends_with(".json") =>
95+
Err(format!("`{name}` is not supported anymore as the polkadot native runtime no longer part of the node."))?,
10896
"rococo" => Box::new(service::chain_spec::rococo_config()?),
10997
#[cfg(feature = "rococo-native")]
11098
"rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?),
@@ -145,7 +133,7 @@ impl SubstrateCli for Cli {
145133
path => {
146134
let path = std::path::PathBuf::from(path);
147135

148-
let chain_spec = Box::new(service::PolkadotChainSpec::from_json_file(path.clone())?)
136+
let chain_spec = Box::new(service::GenericChainSpec::from_json_file(path.clone())?)
149137
as Box<dyn service::ChainSpec>;
150138

151139
// When `force_*` is given or the file name starts with the name of one of the known
@@ -157,7 +145,7 @@ impl SubstrateCli for Cli {
157145
{
158146
Box::new(service::RococoChainSpec::from_json_file(path)?)
159147
} else if self.run.force_kusama || chain_spec.is_kusama() {
160-
Box::new(service::KusamaChainSpec::from_json_file(path)?)
148+
Box::new(service::GenericChainSpec::from_json_file(path)?)
161149
} else if self.run.force_westend || chain_spec.is_westend() {
162150
Box::new(service::WestendChainSpec::from_json_file(path)?)
163151
} else {
@@ -181,17 +169,6 @@ fn set_default_ss58_version(spec: &Box<dyn service::ChainSpec>) {
181169
sp_core::crypto::set_default_ss58_version(ss58_version);
182170
}
183171

184-
const DEV_ONLY_ERROR_PATTERN: &'static str =
185-
"can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev, rococo-dev, wococo-dev], got ";
186-
187-
fn ensure_dev(spec: &Box<dyn service::ChainSpec>) -> std::result::Result<(), String> {
188-
if spec.is_dev() {
189-
Ok(())
190-
} else {
191-
Err(format!("{}{}", DEV_ONLY_ERROR_PATTERN, spec.id()))
192-
}
193-
}
194-
195172
/// Runs performance checks.
196173
/// Should only be used in release build since the check would take too much time otherwise.
197174
fn host_perf_check() -> Result<()> {
@@ -470,8 +447,7 @@ pub fn run() -> Result<()> {
470447
cmd.run(client.clone()).map_err(Error::SubstrateCli)
471448
}),
472449
// These commands are very similar and can be handled in nearly the same way.
473-
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
474-
ensure_dev(chain_spec).map_err(Error::Other)?;
450+
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) =>
475451
runner.sync_run(|mut config| {
476452
let (client, _, _, _) = service::new_chain_ops(&mut config, None)?;
477453
let header = client.header(client.info().genesis_hash).unwrap().unwrap();
@@ -507,11 +483,9 @@ pub fn run() -> Result<()> {
507483
.map_err(Error::SubstrateCli),
508484
_ => unreachable!("Ensured by the outside match; qed"),
509485
}
510-
})
511-
},
486+
}),
512487
BenchmarkCmd::Pallet(cmd) => {
513488
set_default_ss58_version(chain_spec);
514-
ensure_dev(chain_spec).map_err(Error::Other)?;
515489

516490
if cfg!(feature = "runtime-benchmarks") {
517491
runner.sync_run(|config| {

polkadot/cli/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ pub enum Error {
5858
#[error("This subcommand is only available when compiled with `{feature}`")]
5959
FeatureNotEnabled { feature: &'static str },
6060
}
61+
62+
impl From<String> for Error {
63+
fn from(s: String) -> Self {
64+
Self::Other(s)
65+
}
66+
}

polkadot/node/malus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ path = "../../src/bin/prepare-worker.rs"
2626
doc = false
2727

2828
[dependencies]
29-
polkadot-cli = { path = "../../cli", features = [ "malus", "rococo-native", "kusama-native", "westend-native", "polkadot-native" ] }
29+
polkadot-cli = { path = "../../cli", features = [ "malus", "rococo-native", "westend-native" ] }
3030
polkadot-node-subsystem = { path = "../subsystem" }
3131
polkadot-node-subsystem-util = { path = "../subsystem-util" }
3232
polkadot-node-subsystem-types = { path = "../subsystem-types" }

polkadot/node/service/Cargo.toml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,12 @@ polkadot-node-subsystem-util = { path = "../subsystem-util" }
103103
polkadot-node-subsystem-types = { path = "../subsystem-types" }
104104
polkadot-runtime-parachains = { path = "../../runtime/parachains" }
105105
polkadot-node-network-protocol = { path = "../network/protocol" }
106-
polkadot-runtime-common = { path = "../../runtime/common" }
107106

108107
# Polkadot Runtime Constants
109-
polkadot-runtime-constants = { path = "../../runtime/polkadot/constants", optional = true }
110-
kusama-runtime-constants = { path = "../../runtime/kusama/constants", optional = true }
111108
rococo-runtime-constants = { path = "../../runtime/rococo/constants", optional = true }
112109
westend-runtime-constants = { path = "../../runtime/westend/constants", optional = true }
113110

114111
# Polkadot Runtimes
115-
polkadot-runtime = { path = "../../runtime/polkadot", optional = true }
116-
kusama-runtime = { path = "../../runtime/kusama", optional = true }
117112
westend-runtime = { path = "../../runtime/westend", optional = true }
118113
rococo-runtime = { path = "../../runtime/rococo", optional = true }
119114

@@ -183,11 +178,7 @@ full-node = [
183178
"polkadot-statement-distribution",
184179
]
185180

186-
# Configure the native runtimes to use. Polkadot is enabled by default.
187-
#
188-
# Validators require the native runtime currently
189-
polkadot-native = [ "polkadot-runtime", "polkadot-runtime-constants" ]
190-
kusama-native = [ "kusama-runtime", "kusama-runtime-constants" ]
181+
# Configure the native runtimes to use.
191182
westend-native = [ "westend-runtime", "westend-runtime-constants" ]
192183
rococo-native = [ "rococo-runtime", "rococo-runtime-constants" ]
193184

polkadot/node/service/src/benchmarking.rs

Lines changed: 13 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,8 @@ macro_rules! identify_chain {
3434
$generic_code:expr $(,)*
3535
) => {
3636
match $chain {
37-
Chain::Polkadot => {
38-
#[cfg(feature = "polkadot-native")]
39-
{
40-
use polkadot_runtime as runtime;
41-
42-
let call = $generic_code;
43-
44-
Ok(polkadot_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
45-
}
46-
47-
#[cfg(not(feature = "polkadot-native"))]
48-
{
49-
Err("`polkadot-native` feature not enabled")
50-
}
51-
},
52-
Chain::Kusama => {
53-
#[cfg(feature = "kusama-native")]
54-
{
55-
use kusama_runtime as runtime;
56-
57-
let call = $generic_code;
58-
59-
Ok(kusama_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
60-
}
61-
62-
#[cfg(not(feature = "kusama-native"))]
63-
{
64-
Err("`kusama-native` feature not enabled")
65-
}
66-
},
37+
Chain::Polkadot => Err("Polkadot runtimes are currently not supported"),
38+
Chain::Kusama => Err("Kusama runtimes are currently not supported"),
6739
Chain::Rococo => {
6840
#[cfg(feature = "rococo-native")]
6941
{
@@ -91,16 +63,18 @@ macro_rules! identify_chain {
9163

9264
#[cfg(not(feature = "westend-native"))]
9365
{
94-
let _ = $nonce;
95-
let _ = $current_block;
96-
let _ = $period;
97-
let _ = $genesis;
98-
let _ = $signer;
99-
10066
Err("`westend-native` feature not enabled")
10167
}
10268
},
103-
Chain::Unknown => Err("Unknown chain"),
69+
Chain::Unknown => {
70+
let _ = $nonce;
71+
let _ = $current_block;
72+
let _ = $period;
73+
let _ = $genesis;
74+
let _ = $signer;
75+
76+
Err("Unknown chain")
77+
},
10478
}
10579
};
10680
}
@@ -130,10 +104,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
130104
}
131105

132106
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
133-
let period = polkadot_runtime_common::BlockHashCount::get()
134-
.checked_next_power_of_two()
135-
.map(|c| c / 2)
136-
.unwrap_or(2) as u64;
107+
let period = 128;
137108
let genesis = self.client.usage_info().chain.best_hash;
138109
let signer = Sr25519Keyring::Bob.pair();
139110
let current_block = 0;
@@ -181,10 +152,7 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
181152

182153
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
183154
let signer = Sr25519Keyring::Bob.pair();
184-
let period = polkadot_runtime_common::BlockHashCount::get()
185-
.checked_next_power_of_two()
186-
.map(|c| c / 2)
187-
.unwrap_or(2) as u64;
155+
let period = 128;
188156
let genesis = self.client.usage_info().chain.best_hash;
189157
let current_block = 0;
190158
let _dest = self.dest.clone();
@@ -206,60 +174,6 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
206174
}
207175
}
208176

209-
#[cfg(feature = "polkadot-native")]
210-
fn polkadot_sign_call(
211-
call: polkadot_runtime::RuntimeCall,
212-
nonce: u32,
213-
current_block: u64,
214-
period: u64,
215-
genesis: sp_core::H256,
216-
acc: sp_core::sr25519::Pair,
217-
) -> OpaqueExtrinsic {
218-
use codec::Encode;
219-
use polkadot_runtime as runtime;
220-
use sp_core::Pair;
221-
222-
let extra: runtime::SignedExtra = (
223-
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
224-
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
225-
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
226-
frame_system::CheckGenesis::<runtime::Runtime>::new(),
227-
frame_system::CheckMortality::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
228-
period,
229-
current_block,
230-
)),
231-
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
232-
frame_system::CheckWeight::<runtime::Runtime>::new(),
233-
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
234-
polkadot_runtime_common::claims::PrevalidateAttests::<runtime::Runtime>::new(),
235-
);
236-
237-
let payload = runtime::SignedPayload::from_raw(
238-
call.clone(),
239-
extra.clone(),
240-
(
241-
(),
242-
runtime::VERSION.spec_version,
243-
runtime::VERSION.transaction_version,
244-
genesis,
245-
genesis,
246-
(),
247-
(),
248-
(),
249-
(),
250-
),
251-
);
252-
253-
let signature = payload.using_encoded(|p| acc.sign(p));
254-
runtime::UncheckedExtrinsic::new_signed(
255-
call,
256-
sp_runtime::AccountId32::from(acc.public()).into(),
257-
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
258-
extra,
259-
)
260-
.into()
261-
}
262-
263177
#[cfg(feature = "westend-native")]
264178
fn westend_sign_call(
265179
call: westend_runtime::RuntimeCall,
@@ -312,58 +226,6 @@ fn westend_sign_call(
312226
.into()
313227
}
314228

315-
#[cfg(feature = "kusama-native")]
316-
fn kusama_sign_call(
317-
call: kusama_runtime::RuntimeCall,
318-
nonce: u32,
319-
current_block: u64,
320-
period: u64,
321-
genesis: sp_core::H256,
322-
acc: sp_core::sr25519::Pair,
323-
) -> OpaqueExtrinsic {
324-
use codec::Encode;
325-
use kusama_runtime as runtime;
326-
use sp_core::Pair;
327-
328-
let extra: runtime::SignedExtra = (
329-
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
330-
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
331-
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
332-
frame_system::CheckGenesis::<runtime::Runtime>::new(),
333-
frame_system::CheckMortality::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
334-
period,
335-
current_block,
336-
)),
337-
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
338-
frame_system::CheckWeight::<runtime::Runtime>::new(),
339-
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
340-
);
341-
342-
let payload = runtime::SignedPayload::from_raw(
343-
call.clone(),
344-
extra.clone(),
345-
(
346-
(),
347-
runtime::VERSION.spec_version,
348-
runtime::VERSION.transaction_version,
349-
genesis,
350-
genesis,
351-
(),
352-
(),
353-
(),
354-
),
355-
);
356-
357-
let signature = payload.using_encoded(|p| acc.sign(p));
358-
runtime::UncheckedExtrinsic::new_signed(
359-
call,
360-
sp_runtime::AccountId32::from(acc.public()).into(),
361-
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
362-
extra,
363-
)
364-
.into()
365-
}
366-
367229
#[cfg(feature = "rococo-native")]
368230
fn rococo_sign_call(
369231
call: rococo_runtime::RuntimeCall,

0 commit comments

Comments
 (0)