Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rococo: Build two versions of the wasm binary #2229

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion polkadot/node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ fn rococo_local_testnet_genesis() -> serde_json::Value {
#[cfg(feature = "rococo-native")]
pub fn rococo_local_testnet_config() -> Result<RococoChainSpec, String> {
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(),
)
.with_name("Rococo Local Testnet")
Expand Down
11 changes: 7 additions & 4 deletions polkadot/runtime/rococo/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@

#[cfg(feature = "std")]
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()
.with_current_project()
.import_memory()
.export_heap_base()
.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"))]
Expand Down
7 changes: 4 additions & 3 deletions polkadot/runtime/rococo/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@ pub mod currency {

/// Time and blocks.
pub mod time {
use runtime_common::prod_or_fast;

use primitives::{BlockNumber, Moment};
pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;

frame_support::parameter_types! {
pub storage EpochDurationInBlocks: BlockNumber = option_env!("ROCOCO_EPOCH_DURATION")
.map(|s| s.parse().expect("`ROCOCO_EPOCH_DURATION` is not a valid `BlockNumber`"))
.unwrap_or(1 * MINUTES);
pub EpochDurationInBlocks: BlockNumber =
prod_or_fast!(1 * HOURS, 1 * MINUTES, "ROCOCO_EPOCH_DURATION");
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
}

// These time units are defined in number of blocks.
Expand Down
8 changes: 8 additions & 0 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ impl_runtime_weights!(rococo_runtime_constants);
#[cfg(feature = "std")]
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).
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
Expand Down
Loading