Skip to content

Commit

Permalink
Westend by default for local setup (#163)
Browse files Browse the repository at this point in the history
* Enable fast runtime by default

* Add genesis config for EthereumSystem

* Enable meta-hash extension

* Fix test to construct extrinsic
  • Loading branch information
yrong authored Aug 5, 2024
1 parent c7cbd99 commit df4bad7
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ serde = { optional = true, features = ["derive"], workspace = true, default-feat
# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -161,6 +162,7 @@ std = [
"cumulus-primitives-utility/std",
"frame-benchmarking/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub type SignedExtra = (
bridge_to_bulletin_config::OnBridgeHubRococoRefundRococoBulletinMessages,
),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ fn construct_extrinsic(
OnBridgeHubRococoRefundRococoBulletinMessages::default(),
),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim::new(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ serde = { optional = true, features = ["derive"], workspace = true, default-feat
# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
Expand Down Expand Up @@ -149,6 +150,7 @@ std = [
"cumulus-primitives-utility/std",
"frame-benchmarking/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ pub type SignedExtra = (
BridgeRejectObsoleteHeadersAndMessages,
(bridge_to_rococo_config::OnBridgeHubWestendRefundBridgeHubRococoMessages,),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
frame_metadata_hash_extension::CheckMetadataHash<Runtime>,
);

/// Unchecked extrinsic type as expected by this runtime.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ fn construct_extrinsic(
BridgeRejectObsoleteHeadersAndMessages::default(),
(bridge_to_rococo_config::OnBridgeHubWestendRefundBridgeHubRococoMessages::default(),),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim::new(),
frame_metadata_hash_extension::CheckMetadataHash::<Runtime>::new(false),
);
let payload = SignedPayload::new(call.clone(), extra.clone()).unwrap();
let signature = payload.using_encoded(|e| sender.sign(e));
Expand Down
1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ try-runtime = [
]
fast-runtime = [
"bridge-hub-rococo-runtime/fast-runtime",
"bridge-hub-westend-runtime/fast-runtime",
"coretime-rococo-runtime/fast-runtime",
"coretime-westend-runtime/fast-runtime",
]
4 changes: 4 additions & 0 deletions cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ pub mod westend {
},
"bridgeRococoMessages": {
"owner": bridges_pallet_owner.clone(),
},
"ethereumSystem": {
"paraId": id,
"assetHubParaId": 1000
}
})
}
Expand Down
1 change: 1 addition & 0 deletions cumulus/polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option<ParaId>) {
let para_prefixes = [
// Penpal
"penpal-rococo-",
"penpal-westend-",
"penpal-kusama-",
"penpal-polkadot-",
// Glutton Kusama
Expand Down
3 changes: 2 additions & 1 deletion polkadot/node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ fn westend_local_testnet_genesis() -> serde_json::Value {
#[cfg(feature = "westend-native")]
pub fn westend_local_testnet_config() -> Result<WestendChainSpec, String> {
Ok(WestendChainSpec::builder(
westend::WASM_BINARY.ok_or("Westend development wasm not available")?,
westend::fast_runtime_binary::WASM_BINARY
.ok_or("Westend development wasm not available")?,
Default::default(),
)
.with_name("Westend Local Testnet")
Expand Down
9 changes: 9 additions & 0 deletions polkadot/runtime/westend/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@
#[cfg(all(not(feature = "metadata-hash"), feature = "std"))]
fn main() {
substrate_wasm_builder::WasmBuilder::build_using_defaults();
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.set_file_name("fast_runtime_binary.rs")
.enable_feature("fast-runtime")
.build();
}

#[cfg(all(feature = "metadata-hash", feature = "std"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("WND", 12)
.build();
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.set_file_name("fast_runtime_binary.rs")
.enable_feature("fast-runtime")
.enable_metadata_hash("WND", 12)
.build();
}

#[cfg(not(feature = "std"))]
Expand Down
8 changes: 7 additions & 1 deletion polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ impl_runtime_weights!(westend_runtime_constants);
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

#[cfg(feature = "std")]
pub mod fast_runtime_binary {
include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
}

/// Runtime version (Westend).
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
Expand Down Expand Up @@ -1103,7 +1108,8 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
matches!(
c,
RuntimeCall::Staking(..) |
RuntimeCall::Session(..) | RuntimeCall::Utility(..) |
RuntimeCall::Session(..) |
RuntimeCall::Utility(..) |
RuntimeCall::FastUnstake(..) |
RuntimeCall::VoterList(..) |
RuntimeCall::NominationPools(..)
Expand Down

0 comments on commit df4bad7

Please sign in to comment.