mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
Rococo: Build two versions of the wasm binary (#2229)
One for local networks with `fast-runtime` feature activated (1 minute sessions) and one without the feature activated that will be the default that runs with 1 hour long sessions.
This commit is contained in:
@@ -1068,7 +1068,7 @@ fn rococo_local_testnet_genesis() -> serde_json::Value {
|
|||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
|
||||||
Ok(RococoChainSpec::builder(
|
Ok(RococoChainSpec::builder(
|
||||||
rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?,
|
rococo::fast_runtime_binary::WASM_BINARY.ok_or("Rococo development wasm not available")?,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
)
|
)
|
||||||
.with_name("Rococo Local Testnet")
|
.with_name("Rococo Local Testnet")
|
||||||
|
|||||||
@@ -16,16 +16,19 @@
|
|||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn main() {
|
fn main() {
|
||||||
// note: needs to be synced with rococo-runtime-constants::time hard-coded string literal
|
|
||||||
const ROCOCO_EPOCH_DURATION_ENV: &str = "ROCOCO_EPOCH_DURATION";
|
|
||||||
|
|
||||||
substrate_wasm_builder::WasmBuilder::new()
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
.with_current_project()
|
.with_current_project()
|
||||||
.import_memory()
|
.import_memory()
|
||||||
.export_heap_base()
|
.export_heap_base()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
println!("cargo:rerun-if-env-changed={}", ROCOCO_EPOCH_DURATION_ENV);
|
substrate_wasm_builder::WasmBuilder::new()
|
||||||
|
.with_current_project()
|
||||||
|
.set_file_name("fast_runtime_binary.rs")
|
||||||
|
.enable_feature("fast-runtime")
|
||||||
|
.import_memory()
|
||||||
|
.export_heap_base()
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
|
|||||||
@@ -37,14 +37,15 @@ pub mod currency {
|
|||||||
|
|
||||||
/// Time and blocks.
|
/// Time and blocks.
|
||||||
pub mod time {
|
pub mod time {
|
||||||
|
use runtime_common::prod_or_fast;
|
||||||
|
|
||||||
use primitives::{BlockNumber, Moment};
|
use primitives::{BlockNumber, Moment};
|
||||||
pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
||||||
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
|
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
|
||||||
|
|
||||||
frame_support::parameter_types! {
|
frame_support::parameter_types! {
|
||||||
pub storage EpochDurationInBlocks: BlockNumber = option_env!("ROCOCO_EPOCH_DURATION")
|
pub EpochDurationInBlocks: BlockNumber =
|
||||||
.map(|s| s.parse().expect("`ROCOCO_EPOCH_DURATION` is not a valid `BlockNumber`"))
|
prod_or_fast!(1 * HOURS, 1 * MINUTES, "ROCOCO_EPOCH_DURATION");
|
||||||
.unwrap_or(1 * MINUTES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// These time units are defined in number of blocks.
|
// These time units are defined in number of blocks.
|
||||||
|
|||||||
@@ -131,6 +131,14 @@ impl_runtime_weights!(rococo_runtime_constants);
|
|||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||||
|
|
||||||
|
/// Provides the `WASM_BINARY` build with `fast-runtime` feature enabled.
|
||||||
|
///
|
||||||
|
/// This is for example useful for local test chains.
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub mod fast_runtime_binary {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
/// Runtime version (Rococo).
|
/// Runtime version (Rococo).
|
||||||
#[sp_version::runtime_version]
|
#[sp_version::runtime_version]
|
||||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||||
|
|||||||
Reference in New Issue
Block a user