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

PolkaVM parachain runtimes MVP #6704

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
109 changes: 109 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ members = [
"cumulus/parachains/runtimes/test-utils",
"cumulus/parachains/runtimes/testing/penpal",
"cumulus/parachains/runtimes/testing/rococo-parachain",
"cumulus/parachains/runtimes/testing/westend-parachain",
"cumulus/parachains/runtimes/testing/westend-pvm-parachain",
"cumulus/polkadot-omni-node",
"cumulus/polkadot-omni-node/lib",
"cumulus/polkadot-parachain",
Expand Down Expand Up @@ -1376,6 +1378,8 @@ wasmi = { version = "0.32.3", default-features = false }
wasmtime = { version = "8.0.1", default-features = false }
wat = { version = "1.0.0" }
westend-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/relays/westend", default-features = false }
westend-parachain-runtime = { path = "cumulus/parachains/runtimes/testing/westend-parachain" }
westend-pvm-parachain-runtime = { path = "cumulus/parachains/runtimes/testing/westend-pvm-parachain" }
westend-runtime = { path = "polkadot/runtime/westend" }
westend-runtime-constants = { path = "polkadot/runtime/westend/constants", default-features = false }
westend-system-emulated-network = { path = "cumulus/parachains/integration-tests/emulated/networks/westend-system" }
Expand Down
5 changes: 4 additions & 1 deletion cumulus/pallets/parachain-system/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::To
#[doc(hidden)]
mod parachain_validate_block {
use super::*;
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
use sp_runtime_interface::polkavm::{polkavm_export, self};

#[no_mangle]
unsafe fn validate_block(arguments: *mut u8, arguments_len: usize) -> u64 {
#[cfg_attr(any(target_arch = "riscv32", target_arch = "riscv64"), polkavm_export(abi = sp_runtime_interface::polkavm::polkavm_abi))]
pub unsafe extern "C" fn validate_block(arguments: *mut u8, arguments_len: usize) -> u64 {
// We convert the `arguments` into a boxed slice and then into `Bytes`.
let args = #crate_::validate_block::Box::from_raw(
#crate_::validate_block::slice::from_raw_parts_mut(
Expand Down
142 changes: 142 additions & 0 deletions cumulus/parachains/runtimes/testing/westend-parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
[package]
name = "westend-parachain-runtime"
version = "0.6.0"
authors.workspace = true
edition.workspace = true
description = "Simple runtime used by the westend parachain(s)"
license = "Apache-2.0"

[lints]
workspace = true

[dependencies]
codec = { features = ["derive"], workspace = true }
scale-info = { features = ["derive"], workspace = true }

# Substrate
frame-benchmarking = { optional = true, workspace = true }
frame-executive = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-assets = { workspace = true }
pallet-aura = { workspace = true }
pallet-balances = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-aura = { workspace = true }
sp-core = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-runtime-interface = { workspace = true }
sp-session = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }

# Polkadot
pallet-xcm = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
polkadot-runtime-common = { workspace = true }

# Cumulus
cumulus-pallet-aura-ext = { workspace = true }
pallet-message-queue = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
cumulus-pallet-xcm = { workspace = true }
cumulus-pallet-xcmp-queue = { workspace = true }
cumulus-ping = { workspace = true }
cumulus-primitives-aura = { workspace = true }
cumulus-primitives-core = { workspace = true }
cumulus-primitives-storage-weight-reclaim = { workspace = true }
cumulus-primitives-utility = { workspace = true }
parachains-common = { workspace = true }
testnet-parachains-constants = { features = ["westend"], workspace = true }
parachain-info = { workspace = true }

[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
"cumulus-pallet-xcmp-queue/std",
"cumulus-ping/std",
"cumulus-primitives-aura/std",
"cumulus-primitives-core/std",
"cumulus-primitives-storage-weight-reclaim/std",
"cumulus-primitives-utility/std",
"frame-benchmarking?/std",
"frame-executive/std",
"frame-support/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"pallet-assets/std",
"pallet-aura/std",
"pallet-balances/std",
"pallet-message-queue/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-xcm/std",
"parachain-info/std",
"parachains-common/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"scale-info/std",
"sp-api/std",
"sp-block-builder/std",
"sp-consensus-aura/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"testnet-parachains-constants/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
"cumulus-pallet-parachain-system/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"cumulus-primitives-utility/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"parachains-common/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]

# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = []
22 changes: 22 additions & 0 deletions cumulus/parachains/runtimes/testing/westend-parachain/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#[cfg(feature = "std")]
fn main() {
substrate_wasm_builder::WasmBuilder::build_using_defaults();
}

#[cfg(not(feature = "std"))]
fn main() {}
Loading
Loading