Skip to content

Commit 24bd45f

Browse files
Clean up genesis config presets for all runtimes (#450)
This PR does three things related to chain-specs and genesis config presets: - Refactor `preset_names` to `genesis_config_presets` in all runtimes as suggested for the Polkadot Coretime runtime in #410. - Make the chain-spec generator use the preset from the WASM directly for each runtime. - Propagate the `on_chain_release_build` feature to the chain-spec generator. Without this we cannot generate live/genesis chain-specs with the chain-spec generator without having to post-process it to replace the WASM compiled with this flag. --------- Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
1 parent cd529ba commit 24bd45f

28 files changed

Lines changed: 115 additions & 75 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010

1111
- Allow signed origins to send arbitrary XCMs from some system chains ([polkadot-fellows/runtimes#407](https://github.com/polkadot-fellows/runtimes/pull/407))
1212

13+
### Fixed
14+
15+
- Chain-spec generator: propagate the `on_chain_release_build` feature to the chain-spec generator. Without this the live/genesis chain-specs contain a wrongly-configured WASM blob ([polkadot-fellows/runtimes#450](https://github.com/polkadot-fellows/runtimes/pull/450)).
16+
1317
## [1.3.2] 27.08.2024
1418

1519
### Fixed

chain-spec-generator/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,19 @@ runtime-benchmarks = [
4646
"people-polkadot-runtime/runtime-benchmarks",
4747
"polkadot-runtime/runtime-benchmarks",
4848
]
49+
50+
on-chain-release-build = [
51+
"asset-hub-kusama-runtime/on-chain-release-build",
52+
"asset-hub-polkadot-runtime/on-chain-release-build",
53+
"bridge-hub-kusama-runtime/on-chain-release-build",
54+
"bridge-hub-polkadot-runtime/on-chain-release-build",
55+
"collectives-polkadot-runtime/on-chain-release-build",
56+
"coretime-kusama-runtime/on-chain-release-build",
57+
"coretime-polkadot-runtime/on-chain-release-build",
58+
"encointer-kusama-runtime/on-chain-release-build",
59+
"glutton-kusama-runtime/on-chain-release-build",
60+
"kusama-runtime/on-chain-release-build",
61+
"people-kusama-runtime/on-chain-release-build",
62+
"people-polkadot-runtime/on-chain-release-build",
63+
"polkadot-runtime/on-chain-release-build",
64+
]

chain-spec-generator/src/system_parachains_specs.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn asset_hub_polkadot_local_testnet_config() -> Result<Box<dyn ChainSpec>, S
6666
.with_name("Polkadot Asset Hub Local")
6767
.with_id("asset-hub-polkadot-local")
6868
.with_chain_type(ChainType::Local)
69-
.with_genesis_config_patch(asset_hub_polkadot_runtime::genesis_config_presets::asset_hub_polkadot_local_testnet_genesis(1000.into()))
69+
.with_genesis_config_preset_name("local_testnet")
7070
.with_properties(properties)
7171
.build(),
7272
))
@@ -86,7 +86,7 @@ pub fn asset_hub_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Str
8686
.with_name("Kusama Asset Hub Local")
8787
.with_id("asset-hub-kusama-local")
8888
.with_chain_type(ChainType::Local)
89-
.with_genesis_config_patch(asset_hub_kusama_runtime::genesis_config_presets::asset_hub_kusama_local_testnet_genesis(1000.into()))
89+
.with_genesis_config_preset_name("local_testnet")
9090
.with_properties(properties)
9191
.build(),
9292
))
@@ -107,7 +107,7 @@ pub fn collectives_polkadot_local_testnet_config() -> Result<Box<dyn ChainSpec>,
107107
.with_name("Polkadot Collectives Local")
108108
.with_id("collectives-polkadot-local")
109109
.with_chain_type(ChainType::Local)
110-
.with_genesis_config_patch(collectives_polkadot_runtime::genesis_config_presets::collectives_polkadot_local_testnet_genesis(1001.into()))
110+
.with_genesis_config_preset_name("local_testnet")
111111
.with_properties(properties)
112112
.build(),
113113
))
@@ -128,7 +128,7 @@ pub fn bridge_hub_polkadot_local_testnet_config() -> Result<Box<dyn ChainSpec>,
128128
.with_name("Polkadot Bridge Hub Local")
129129
.with_id("bridge-hub-polkadot-local")
130130
.with_chain_type(ChainType::Local)
131-
.with_genesis_config_patch(bridge_hub_polkadot_runtime::genesis_config_presets::bridge_hub_polkadot_local_testnet_genesis(1002.into()))
131+
.with_genesis_config_preset_name("local_testnet")
132132
.with_properties(properties)
133133
.build(),
134134
))
@@ -148,7 +148,7 @@ pub fn bridge_hub_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, St
148148
.with_name("Kusama Bridge Hub Local")
149149
.with_id("bridge-hub-kusama-local")
150150
.with_chain_type(ChainType::Local)
151-
.with_genesis_config_patch(bridge_hub_kusama_runtime::genesis_config_presets::bridge_hub_kusama_local_testnet_genesis(1002.into()))
151+
.with_genesis_config_preset_name("local_testnet")
152152
.with_properties(properties)
153153
.build(),
154154
))
@@ -166,11 +166,7 @@ pub fn glutton_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Strin
166166
.with_name("Kusama Glutton Local")
167167
.with_id("glutton-kusama-local")
168168
.with_chain_type(ChainType::Local)
169-
.with_genesis_config_patch(
170-
glutton_kusama_runtime::genesis_config_presets::glutton_kusama_local_testnet_genesis(
171-
1300.into(),
172-
),
173-
)
169+
.with_genesis_config_preset_name("local_testnet")
174170
.with_properties(properties)
175171
.build(),
176172
))
@@ -190,7 +186,7 @@ pub fn encointer_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Str
190186
.with_name("Kusama Encointer Local")
191187
.with_id("encointer-kusama-local")
192188
.with_chain_type(ChainType::Local)
193-
.with_genesis_config_patch(encointer_kusama_runtime::genesis_config_presets::encointer_kusama_local_testnet_genesis(1001.into()))
189+
.with_genesis_config_preset_name("local_testnet")
194190
.with_properties(properties)
195191
.build(),
196192
))
@@ -210,11 +206,7 @@ pub fn coretime_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, Stri
210206
.with_name("Kusama Coretime Local")
211207
.with_id("coretime-kusama-local")
212208
.with_chain_type(ChainType::Local)
213-
.with_genesis_config_patch(
214-
coretime_kusama_runtime::genesis_config_presets::coretime_kusama_local_testnet_genesis(
215-
1005.into(),
216-
),
217-
)
209+
.with_genesis_config_preset_name("local_testnet")
218210
.with_properties(properties)
219211
.build(),
220212
))
@@ -327,11 +319,7 @@ pub fn people_kusama_local_testnet_config() -> Result<Box<dyn ChainSpec>, String
327319
.with_name("Kusama People Local")
328320
.with_id("people-kusama-local")
329321
.with_chain_type(ChainType::Local)
330-
.with_genesis_config_patch(
331-
people_kusama_runtime::genesis_config_presets::people_kusama_local_testnet_genesis(
332-
1004.into(),
333-
),
334-
)
322+
.with_genesis_config_preset_name("local_testnet")
335323
.with_properties(properties)
336324
.build(),
337325
))
@@ -351,11 +339,7 @@ pub fn people_polkadot_local_testnet_config() -> Result<Box<dyn ChainSpec>, Stri
351339
.with_name("Polkadot People Local")
352340
.with_id("people-polkadot-local")
353341
.with_chain_type(ChainType::Local)
354-
.with_genesis_config_patch(
355-
people_polkadot_runtime::genesis_config_presets::people_polkadot_local_testnet_genesis(
356-
1004.into(),
357-
),
358-
)
342+
.with_genesis_config_preset_name("local_testnet")
359343
.with_properties(properties)
360344
.build(),
361345
))

relay/kusama/src/genesis_config_presets.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use pallet_staking::{Forcing, StakerStatus};
2323
use polkadot_primitives::{AccountPublic, AssignmentId, AsyncBackingParams};
2424
use runtime_parachains::configuration::HostConfiguration;
2525
use sp_core::{sr25519, Pair, Public};
26+
use sp_genesis_builder::PresetId;
2627
use sp_runtime::{traits::IdentifyAccount, Perbill};
2728
#[cfg(not(feature = "std"))]
2829
use sp_std::alloc::format;
@@ -224,6 +225,11 @@ pub fn kusama_development_config_genesis() -> serde_json::Value {
224225
)
225226
}
226227

228+
/// Provides the names of the predefined genesis configs for this runtime.
229+
pub fn preset_names() -> Vec<PresetId> {
230+
vec![PresetId::from("development"), PresetId::from("local_testnet")]
231+
}
232+
227233
/// Provides the JSON representation of predefined genesis config for given `id`.
228234
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
229235
let patch = match id.try_into() {

relay/kusama/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,10 +2523,7 @@ sp_api::impl_runtime_apis! {
25232523
}
25242524

25252525
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
2526-
vec![
2527-
sp_genesis_builder::PresetId::from("local_testnet"),
2528-
sp_genesis_builder::PresetId::from("development"),
2529-
]
2526+
genesis_config_presets::preset_names()
25302527
}
25312528
}
25322529

relay/polkadot/src/genesis_config_presets.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use polkadot_primitives::{AccountPublic, AssignmentId, AsyncBackingParams};
2323
use polkadot_runtime_constants::currency::UNITS as DOT;
2424
use runtime_parachains::configuration::HostConfiguration;
2525
use sp_core::{sr25519, Pair, Public};
26+
use sp_genesis_builder::PresetId;
2627
use sp_runtime::{traits::IdentifyAccount, Perbill};
2728
#[cfg(not(feature = "std"))]
2829
use sp_std::alloc::format;
@@ -224,6 +225,11 @@ pub fn polkadot_development_config_genesis() -> serde_json::Value {
224225
)
225226
}
226227

228+
/// Provides the names of the predefined genesis configs for this runtime.
229+
pub fn preset_names() -> Vec<PresetId> {
230+
vec![PresetId::from("development"), PresetId::from("local_testnet")]
231+
}
232+
227233
/// Provides the JSON representation of predefined genesis config for given `id`.
228234
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
229235
let patch = match id.try_into() {

relay/polkadot/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,10 +2694,7 @@ sp_api::impl_runtime_apis! {
26942694
}
26952695

26962696
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
2697-
vec![
2698-
sp_genesis_builder::PresetId::from("local_testnet"),
2699-
sp_genesis_builder::PresetId::from("development"),
2700-
]
2697+
genesis_config_presets::preset_names()
27012698
}
27022699
}
27032700

system-parachains/asset-hubs/asset-hub-kusama/src/genesis_config_presets.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//! Genesis configs presets for the AssetHubKusama runtime
1818
1919
use crate::*;
20+
use sp_genesis_builder::PresetId;
2021
use sp_std::vec::Vec;
2122
use system_parachains_constants::genesis_presets::*;
2223

@@ -72,6 +73,11 @@ fn asset_hub_kusama_development_genesis(para_id: ParaId) -> serde_json::Value {
7273
asset_hub_kusama_local_testnet_genesis(para_id)
7374
}
7475

76+
/// Provides the names of the predefined genesis configs for this runtime.
77+
pub fn preset_names() -> Vec<PresetId> {
78+
vec![PresetId::from("development"), PresetId::from("local_testnet")]
79+
}
80+
7581
/// Provides the JSON representation of predefined genesis config for given `id`.
7682
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
7783
let patch = match id.try_into() {

system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,10 +1372,7 @@ impl_runtime_apis! {
13721372
}
13731373

13741374
fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
1375-
vec![
1376-
sp_genesis_builder::PresetId::from("local_testnet"),
1377-
sp_genesis_builder::PresetId::from("development"),
1378-
]
1375+
genesis_config_presets::preset_names()
13791376
}
13801377
}
13811378

system-parachains/asset-hubs/asset-hub-polkadot/src/genesis_config_presets.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use crate::*;
2020
use parachains_common::AssetHubPolkadotAuraId;
2121
use sp_core::sr25519;
22+
use sp_genesis_builder::PresetId;
2223
use sp_std::vec::Vec;
2324
use system_parachains_constants::genesis_presets::*;
2425

@@ -88,6 +89,11 @@ fn asset_hub_polkadot_development_genesis(para_id: ParaId) -> serde_json::Value
8889
asset_hub_polkadot_local_testnet_genesis(para_id)
8990
}
9091

92+
/// Provides the names of the predefined genesis configs for this runtime.
93+
pub fn preset_names() -> Vec<PresetId> {
94+
vec![PresetId::from("development"), PresetId::from("local_testnet")]
95+
}
96+
9197
/// Provides the JSON representation of predefined genesis config for given `id`.
9298
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<sp_std::vec::Vec<u8>> {
9399
let patch = match id.try_into() {

0 commit comments

Comments
 (0)