Skip to content
Open
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
43 changes: 25 additions & 18 deletions cumulus/test/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,24 +102,31 @@ std = [
"substrate-wasm-builder",
"tracing/std",
]

increment-spec-version = []
# A runtime which expects to build behind the relay chain tip.
relay-parent-offset = []
# A runtime with elastic-scaling configuration.
elastic-scaling = []
# A runtime with low slot duration of 500ms for low-latency testing with 12 cores.
elastic-scaling-500ms = []
# A runtime with a slot duration of 6s but parameters that allow multiple blocks per slot.
elastic-scaling-multi-block-slot = []
# A runtime that uses block-bundling.
block-bundling = []
# A runtime with 12s slot duration which only authors one block per slot.

# The default parachain slot duration is 6s. The following features can be used to change this value:
# Change the parachain slot duration to 12s
12s-slot = []
# Change the parachain slot duration to 18s
18s-slot = []

# Configure the runtime to use sync backing. More specifically, this leads to:
# - setting `AllowMultipleBlocksPerSlot` to `false`
# - setting the unincluded segment capacity to 1
sync-backing = []
# A runtime with 6s slot duration which only authors one block per slot.
async-backing = []
# A runtime that uses `CandidateDescriptorV3`.

# The default block processing velocity is 1. The following features can be used to change this value:
# Change the block processing velocity to 3
velocity-3 = []
# Change the block processing velocity to 6
velocity-6 = []
# Change the block processing velocity to 12
velocity-12 = []
Comment on lines +121 to +125
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comments on what they are doing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


# The default relay parent offset is 0. The following features can be used to change this value:
# Change the relay parent offset to 2
relay-parent-offset-2 = []

# Configure the runtiem to use scheduling V3
v3-descriptor = []
# An elastic scaling runtime with 12s slots.
elastic-scaling-12s-slot = []
# A runtime with 18s slot duration with increased spec version for runtime upgrade testing.
slot-duration-18s = ["increment-spec-version"]
82 changes: 31 additions & 51 deletions cumulus/test/runtime/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,99 +18,79 @@
fn main() {
use substrate_wasm_builder::WasmBuilder;

WasmBuilder::init_with_defaults()
.enable_feature("async-backing")
.import_memory()
.build();
// A runtime with 6s slot duration which only authors one block per slot.
WasmBuilder::init_with_defaults().build();

WasmBuilder::init_with_defaults()
.enable_feature("increment-spec-version")
.set_file_name("wasm_binary_spec_version_incremented.rs")
.build();

WasmBuilder::init_with_defaults()
.enable_feature("elastic-scaling")
.import_memory()
.set_file_name("wasm_binary_elastic_scaling_mvp.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("elastic-scaling")
.import_memory()
.enable_feature("velocity-3")
.enable_feature("increment-spec-version")
.set_file_name("wasm_binary_elastic_scaling.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("elastic-scaling-500ms")
.import_memory()
// A runtime with 6s slots and block velocity 12.
// Coupled with 12 cores it can produce a block every 500ms.
WasmBuilder::init_with_defaults()
.enable_feature("velocity-12")
.set_file_name("wasm_binary_elastic_scaling_500ms.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("elastic-scaling-multi-block-slot")
.import_memory()
// A runtime with a slot duration of 6s but parameters that allow multiple blocks per slot.
WasmBuilder::init_with_defaults()
.enable_feature("velocity-6")
.set_file_name("wasm_binary_elastic_scaling_multi_block_slot.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("relay-parent-offset")
.import_memory()
// A runtime that uses a relay parent offset of 2.
WasmBuilder::init_with_defaults()
.enable_feature("relay-parent-offset-2")
.set_file_name("wasm_binary_relay_parent_offset.rs")
.build();

WasmBuilder::new()
.with_current_project()
WasmBuilder::init_with_defaults()
.enable_feature("sync-backing")
.import_memory()
.enable_feature("12s-slot")
.set_file_name("wasm_binary_sync_backing.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("elastic-scaling-12s-slot")
.enable_feature("elastic-scaling")
.import_memory()
// An elastic scaling runtime with 12s slots.
WasmBuilder::init_with_defaults()
.enable_feature("12s-slot")
.enable_feature("velocity-3")
.enable_feature("increment-spec-version")
.set_file_name("wasm_binary_elastic_scaling_12s_slot.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("block-bundling")
.import_memory()
// A runtime that uses block-bundling.
WasmBuilder::init_with_defaults()
.enable_feature("velocity-12")
.set_file_name("wasm_binary_block_bundling.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("async-backing")
WasmBuilder::init_with_defaults()
.enable_feature("v3-descriptor")
.import_memory()
.set_file_name("wasm_binary_async_backing_v3.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("async-backing")
WasmBuilder::init_with_defaults()
.enable_feature("v3-descriptor")
.enable_feature("relay-parent-offset")
.import_memory()
.enable_feature("relay-parent-offset-2")
.set_file_name("wasm_binary_async_backing_v3_rpo.rs")
.build();

WasmBuilder::new()
.with_current_project()
.enable_feature("elastic-scaling")
WasmBuilder::init_with_defaults()
.enable_feature("v3-descriptor")
.import_memory()
.enable_feature("velocity-3")
.set_file_name("wasm_binary_elastic_scaling_v3.rs")
.build();

// A runtime with 18s slot duration with increased spec version for runtime upgrade testing.
WasmBuilder::init_with_defaults()
.enable_feature("slot-duration-18s")
.enable_feature("18s-slot")
.enable_feature("increment-spec-version")
.set_file_name("wasm_binary_slot_duration_18s.rs")
.build();
Expand Down
128 changes: 128 additions & 0 deletions cumulus/test/runtime/src/flavors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// Copyright (C) Parity Technologies (UK) Ltd.
Comment thread
iulianbarbu marked this conversation as resolved.
// This file is part of Cumulus.

// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

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

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

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

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

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

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

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

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

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

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

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

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

pub(crate) const SCHEDULING_V3_ENABLED: bool = cfg!(feature = "v3-descriptor");

pub(crate) const fn relay_parent_offset() -> u32 {
if cfg!(feature = "relay-parent-offset-2") {
return 2;
}

0
}

pub(crate) const fn slot_duration() -> u64 {
if cfg!(feature = "18s-slot") {
return 18000;
}

if cfg!(feature = "12s-slot") {
return 12000;
}

6000
}

pub(crate) const fn block_processing_velocity() -> u32 {
if cfg!(feature = "velocity-12") {
return 12;
}

if cfg!(feature = "velocity-6") {
return 6;
}

if cfg!(feature = "velocity-3") {
return 3;
}

1
}

pub(crate) const fn unincluded_segment_capacity() -> u32 {
if cfg!(feature = "sync-backing") {
return 1;
}

// Without sync backing, the block flow is the following:
//
// - Collator produces the block(s) on relay chain block `X`
// - In the meantime the relay chain is building block `X + 1`
// - The collator sends the collation to the relay chain, and it gets backed on chain in relay
// block `X + 2`
// - The collation then gets included on chain in relay block `X + 3`
block_processing_velocity() * 3
}
Loading
Loading