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

Commit 0899527

Browse files
authored
Companion PR for #6569 (#1394)
* Update wasm-builder version to 2.0.0 * Fix all crate compile * Update cargo lock * Bump runtime impl_version
1 parent f50db05 commit 0899527

File tree

21 files changed

+209
-142
lines changed

21 files changed

+209
-142
lines changed

cli/src/command.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ impl SubstrateCli for Cli {
5353
.unwrap_or("polkadot")
5454
} else { id };
5555
Ok(match id {
56-
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()),
57-
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()),
58-
"polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()),
59-
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()),
60-
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()),
61-
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()),
56+
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
57+
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?),
58+
"polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()?),
59+
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()?),
60+
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()?),
61+
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?),
6262
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
6363
"westend" => Box::new(service::chain_spec::westend_config()?),
6464
"kusama" => Box::new(service::chain_spec::kusama_config()?),
65-
"westend-dev" => Box::new(service::chain_spec::westend_development_config()),
66-
"westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()),
67-
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()),
65+
"westend-dev" => Box::new(service::chain_spec::westend_development_config()?),
66+
"westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()?),
67+
"westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?),
6868
path if self.run.force_kusama => {
6969
Box::new(service::KusamaChainSpec::from_json_file(std::path::PathBuf::from(path))?)
7070
},

node/service/src/chain_spec.rs

+78-51
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn westend_session_keys(
113113
westend::SessionKeys { babe, grandpa, im_online, parachain_validator, authority_discovery }
114114
}
115115

116-
fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {
116+
fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
117117
// subkey inspect "$SECRET"
118118
let endowed_accounts = vec![];
119119

@@ -132,7 +132,7 @@ fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {
132132

133133
polkadot::GenesisConfig {
134134
system: Some(polkadot::SystemConfig {
135-
code: polkadot::WASM_BINARY.to_vec(),
135+
code: wasm_binary.to_vec(),
136136
changes_trie_config: Default::default(),
137137
}),
138138
balances: Some(polkadot::BalancesConfig {
@@ -197,7 +197,7 @@ fn polkadot_staging_testnet_config_genesis() -> polkadot::GenesisConfig {
197197
}
198198
}
199199

200-
fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {
200+
fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
201201
// subkey inspect "$SECRET"
202202
let endowed_accounts = vec![
203203
// 5ENpP27BrVdJTdUfY6djmcw3d3xEJ6NzSUU52CCPmGpMrdEY
@@ -284,7 +284,7 @@ fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {
284284

285285
westend::GenesisConfig {
286286
system: Some(westend::SystemConfig {
287-
code: westend::WASM_BINARY.to_vec(),
287+
code: wasm_binary.to_vec(),
288288
changes_trie_config: Default::default(),
289289
}),
290290
balances: Some(westend::BalancesConfig {
@@ -337,7 +337,7 @@ fn westend_staging_testnet_config_genesis() -> westend::GenesisConfig {
337337
}
338338
}
339339

340-
fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {
340+
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
341341
// subkey inspect "$SECRET"
342342
let endowed_accounts = vec![
343343
// 5CVFESwfkk7NmhQ6FwHCM9roBvr9BGa4vJHFYU8DnGQxrXvz
@@ -424,7 +424,7 @@ fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {
424424

425425
kusama::GenesisConfig {
426426
system: Some(kusama::SystemConfig {
427-
code: kusama::WASM_BINARY.to_vec(),
427+
code: wasm_binary.to_vec(),
428428
changes_trie_config: Default::default(),
429429
}),
430430
balances: Some(kusama::BalancesConfig {
@@ -490,54 +490,60 @@ fn kusama_staging_testnet_config_genesis() -> kusama::GenesisConfig {
490490
}
491491

492492
/// Polkadot staging testnet config.
493-
pub fn polkadot_staging_testnet_config() -> PolkadotChainSpec {
493+
pub fn polkadot_staging_testnet_config() -> Result<PolkadotChainSpec, String> {
494+
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
494495
let boot_nodes = vec![];
495-
PolkadotChainSpec::from_genesis(
496+
497+
Ok(PolkadotChainSpec::from_genesis(
496498
"Polkadot Staging Testnet",
497499
"polkadot_staging_testnet",
498500
ChainType::Live,
499-
polkadot_staging_testnet_config_genesis,
501+
move || polkadot_staging_testnet_config_genesis(wasm_binary),
500502
boot_nodes,
501503
Some(TelemetryEndpoints::new(vec![(POLKADOT_STAGING_TELEMETRY_URL.to_string(), 0)])
502504
.expect("Polkadot Staging telemetry url is valid; qed")),
503505
Some(DEFAULT_PROTOCOL_ID),
504506
None,
505507
Default::default(),
506-
)
508+
))
507509
}
508510

509511
/// Staging testnet config.
510-
pub fn kusama_staging_testnet_config() -> KusamaChainSpec {
512+
pub fn kusama_staging_testnet_config() -> Result<KusamaChainSpec, String> {
513+
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
511514
let boot_nodes = vec![];
512-
KusamaChainSpec::from_genesis(
515+
516+
Ok(KusamaChainSpec::from_genesis(
513517
"Kusama Staging Testnet",
514518
"kusama_staging_testnet",
515519
ChainType::Live,
516-
kusama_staging_testnet_config_genesis,
520+
move || kusama_staging_testnet_config_genesis(wasm_binary),
517521
boot_nodes,
518522
Some(TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])
519523
.expect("Kusama Staging telemetry url is valid; qed")),
520524
Some(DEFAULT_PROTOCOL_ID),
521525
None,
522526
Default::default(),
523-
)
527+
))
524528
}
525529

526530
/// Westend staging testnet config.
527-
pub fn westend_staging_testnet_config() -> WestendChainSpec {
531+
pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
532+
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
528533
let boot_nodes = vec![];
529-
WestendChainSpec::from_genesis(
534+
535+
Ok(WestendChainSpec::from_genesis(
530536
"Westend Staging Testnet",
531537
"westend_staging_testnet",
532538
ChainType::Live,
533-
westend_staging_testnet_config_genesis,
539+
move || westend_staging_testnet_config_genesis(wasm_binary),
534540
boot_nodes,
535541
Some(TelemetryEndpoints::new(vec![(WESTEND_STAGING_TELEMETRY_URL.to_string(), 0)])
536542
.expect("Westend Staging telemetry url is valid; qed")),
537543
Some(DEFAULT_PROTOCOL_ID),
538544
None,
539545
Default::default(),
540-
)
546+
))
541547
}
542548

543549
/// Helper function to generate a crypto pair from seed
@@ -595,6 +601,7 @@ fn testnet_accounts() -> Vec<AccountId> {
595601

596602
/// Helper function to create polkadot GenesisConfig for testing
597603
pub fn polkadot_testnet_genesis(
604+
wasm_binary: &[u8],
598605
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
599606
_root_key: AccountId,
600607
endowed_accounts: Option<Vec<AccountId>>,
@@ -606,7 +613,7 @@ pub fn polkadot_testnet_genesis(
606613

607614
polkadot::GenesisConfig {
608615
system: Some(polkadot::SystemConfig {
609-
code: polkadot::WASM_BINARY.to_vec(),
616+
code: wasm_binary.to_vec(),
610617
changes_trie_config: Default::default(),
611618
}),
612619
indices: Some(polkadot::IndicesConfig {
@@ -669,6 +676,7 @@ pub fn polkadot_testnet_genesis(
669676

670677
/// Helper function to create kusama GenesisConfig for testing
671678
pub fn kusama_testnet_genesis(
679+
wasm_binary: &[u8],
672680
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
673681
_root_key: AccountId,
674682
endowed_accounts: Option<Vec<AccountId>>,
@@ -680,7 +688,7 @@ pub fn kusama_testnet_genesis(
680688

681689
kusama::GenesisConfig {
682690
system: Some(kusama::SystemConfig {
683-
code: kusama::WASM_BINARY.to_vec(),
691+
code: wasm_binary.to_vec(),
684692
changes_trie_config: Default::default(),
685693
}),
686694
indices: Some(kusama::IndicesConfig {
@@ -743,6 +751,7 @@ pub fn kusama_testnet_genesis(
743751

744752
/// Helper function to create polkadot GenesisConfig for testing
745753
pub fn westend_testnet_genesis(
754+
wasm_binary: &[u8],
746755
initial_authorities: Vec<(AccountId, AccountId, BabeId, GrandpaId, ImOnlineId, ValidatorId, AuthorityDiscoveryId)>,
747756
root_key: AccountId,
748757
endowed_accounts: Option<Vec<AccountId>>,
@@ -754,7 +763,7 @@ pub fn westend_testnet_genesis(
754763

755764
westend::GenesisConfig {
756765
system: Some(westend::SystemConfig {
757-
code: westend::WASM_BINARY.to_vec(),
766+
code: wasm_binary.to_vec(),
758767
changes_trie_config: Default::default(),
759768
}),
760769
indices: Some(westend::IndicesConfig {
@@ -803,8 +812,9 @@ pub fn westend_testnet_genesis(
803812
}
804813
}
805814

806-
fn polkadot_development_config_genesis() -> polkadot::GenesisConfig {
815+
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
807816
polkadot_testnet_genesis(
817+
wasm_binary,
808818
vec![
809819
get_authority_keys_from_seed("Alice"),
810820
],
@@ -813,8 +823,9 @@ fn polkadot_development_config_genesis() -> polkadot::GenesisConfig {
813823
)
814824
}
815825

816-
fn kusama_development_config_genesis() -> kusama::GenesisConfig {
826+
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
817827
kusama_testnet_genesis(
828+
wasm_binary,
818829
vec![
819830
get_authority_keys_from_seed("Alice"),
820831
],
@@ -823,8 +834,9 @@ fn kusama_development_config_genesis() -> kusama::GenesisConfig {
823834
)
824835
}
825836

826-
fn westend_development_config_genesis() -> westend::GenesisConfig {
837+
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
827838
westend_testnet_genesis(
839+
wasm_binary,
828840
vec![
829841
get_authority_keys_from_seed("Alice"),
830842
],
@@ -834,52 +846,59 @@ fn westend_development_config_genesis() -> westend::GenesisConfig {
834846
}
835847

836848
/// Polkadot development config (single validator Alice)
837-
pub fn polkadot_development_config() -> PolkadotChainSpec {
838-
PolkadotChainSpec::from_genesis(
849+
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
850+
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
851+
852+
Ok(PolkadotChainSpec::from_genesis(
839853
"Development",
840854
"dev",
841855
ChainType::Development,
842-
polkadot_development_config_genesis,
856+
move || polkadot_development_config_genesis(wasm_binary),
843857
vec![],
844858
None,
845859
Some(DEFAULT_PROTOCOL_ID),
846860
None,
847861
Default::default(),
848-
)
862+
))
849863
}
850864

851865
/// Kusama development config (single validator Alice)
852-
pub fn kusama_development_config() -> KusamaChainSpec {
853-
KusamaChainSpec::from_genesis(
866+
pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
867+
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
868+
869+
Ok(KusamaChainSpec::from_genesis(
854870
"Development",
855871
"kusama_dev",
856872
ChainType::Development,
857-
kusama_development_config_genesis,
873+
move || kusama_development_config_genesis(wasm_binary),
858874
vec![],
859875
None,
860876
Some(DEFAULT_PROTOCOL_ID),
861877
None,
862878
Default::default(),
863-
)
879+
))
864880
}
865881

866882
/// Westend development config (single validator Alice)
867-
pub fn westend_development_config() -> WestendChainSpec {
868-
WestendChainSpec::from_genesis(
883+
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
884+
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
885+
886+
Ok(WestendChainSpec::from_genesis(
869887
"Development",
870888
"westend_dev",
871889
ChainType::Development,
872-
westend_development_config_genesis,
890+
move || westend_development_config_genesis(wasm_binary),
873891
vec![],
874892
None,
875893
Some(DEFAULT_PROTOCOL_ID),
876894
None,
877895
Default::default(),
878-
)
896+
))
879897
}
880898

881-
fn polkadot_local_testnet_genesis() -> polkadot::GenesisConfig {
899+
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
882900
polkadot_testnet_genesis(
901+
wasm_binary,
883902
vec![
884903
get_authority_keys_from_seed("Alice"),
885904
get_authority_keys_from_seed("Bob"),
@@ -890,22 +909,25 @@ fn polkadot_local_testnet_genesis() -> polkadot::GenesisConfig {
890909
}
891910

892911
/// Polkadot local testnet config (multivalidator Alice + Bob)
893-
pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
894-
PolkadotChainSpec::from_genesis(
912+
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
913+
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
914+
915+
Ok(PolkadotChainSpec::from_genesis(
895916
"Local Testnet",
896917
"local_testnet",
897918
ChainType::Local,
898-
polkadot_local_testnet_genesis,
919+
move || polkadot_local_testnet_genesis(wasm_binary),
899920
vec![],
900921
None,
901922
Some(DEFAULT_PROTOCOL_ID),
902923
None,
903924
Default::default(),
904-
)
925+
))
905926
}
906927

907-
fn kusama_local_testnet_genesis() -> kusama::GenesisConfig {
928+
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::GenesisConfig {
908929
kusama_testnet_genesis(
930+
wasm_binary,
909931
vec![
910932
get_authority_keys_from_seed("Alice"),
911933
get_authority_keys_from_seed("Bob"),
@@ -916,22 +938,25 @@ fn kusama_local_testnet_genesis() -> kusama::GenesisConfig {
916938
}
917939

918940
/// Kusama local testnet config (multivalidator Alice + Bob)
919-
pub fn kusama_local_testnet_config() -> KusamaChainSpec {
920-
KusamaChainSpec::from_genesis(
941+
pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
942+
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
943+
944+
Ok(KusamaChainSpec::from_genesis(
921945
"Kusama Local Testnet",
922946
"kusama_local_testnet",
923947
ChainType::Local,
924-
kusama_local_testnet_genesis,
948+
move || kusama_local_testnet_genesis(wasm_binary),
925949
vec![],
926950
None,
927951
Some(DEFAULT_PROTOCOL_ID),
928952
None,
929953
Default::default(),
930-
)
954+
))
931955
}
932956

933-
fn westend_local_testnet_genesis() -> westend::GenesisConfig {
957+
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::GenesisConfig {
934958
westend_testnet_genesis(
959+
wasm_binary,
935960
vec![
936961
get_authority_keys_from_seed("Alice"),
937962
get_authority_keys_from_seed("Bob"),
@@ -942,16 +967,18 @@ fn westend_local_testnet_genesis() -> westend::GenesisConfig {
942967
}
943968

944969
/// Westend local testnet config (multivalidator Alice + Bob)
945-
pub fn westend_local_testnet_config() -> WestendChainSpec {
946-
WestendChainSpec::from_genesis(
970+
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
971+
let wasm_binary = westend::WASM_BINARY.ok_or("Westend development wasm not available")?;
972+
973+
Ok(WestendChainSpec::from_genesis(
947974
"Westend Local Testnet",
948975
"westend_local_testnet",
949976
ChainType::Local,
950-
westend_local_testnet_genesis,
977+
move || westend_local_testnet_genesis(wasm_binary),
951978
vec![],
952979
None,
953980
Some(DEFAULT_PROTOCOL_ID),
954981
None,
955982
Default::default(),
956-
)
983+
))
957984
}

0 commit comments

Comments
 (0)