Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
da665f8
Add RISC-V functionality to pallet-contracts
athei Jan 11, 2024
af8ef2c
fmt
athei Feb 29, 2024
1669b38
clippy
athei Feb 29, 2024
a3c4a6d
Apply suggestions from code review
athei Mar 1, 2024
c3c70b9
Merge branch 'master' into at/virt_host_fn
athei Mar 1, 2024
be58bd0
toml format
athei Mar 1, 2024
4442518
Update substrate/primitives/virtualization/src/native.rs
athei Mar 1, 2024
03e68b5
Add log target and demote potentially spammy logs
athei Mar 1, 2024
aec550b
Move transmute into a From impl
athei Mar 1, 2024
f498567
Add prdoc
athei Mar 1, 2024
a3df06d
Move host functions out of sp-io
athei Mar 1, 2024
6226160
Fix rust doc
athei Mar 1, 2024
055c662
temporary: enable trace logging for polkavm
athei Mar 1, 2024
7187146
temporary: only test virt
athei Mar 1, 2024
63da97f
Create PolkaVM config from env
athei Mar 1, 2024
5858762
temporary: enable polkavm tracing
athei Mar 1, 2024
9ee99a0
Use Sync metering for now (Async is not working, yet)
athei Mar 1, 2024
f1e50a8
temporary: switch to generic sandbox for tests
athei Mar 1, 2024
889b082
Revert CI changes
athei Mar 1, 2024
b78eb76
Allow insecure in order to run the generic sandbox
athei Mar 1, 2024
3876120
Use interpreter for now
athei Mar 2, 2024
96f33b2
Reduce call depth limit to account for new items in host state
athei Mar 2, 2024
ea3e773
Merge branch 'master' into at/virt_host_fn
athei Mar 2, 2024
b67fdad
Added new syscalls used by PolkaVM
athei Mar 2, 2024
3e8a99b
Merge branch 'master' into at/virt_host_fn
athei Mar 4, 2024
1a14d55
Revert "Reduce call depth limit to account for new items in host state"
athei Mar 4, 2024
0750203
Merge branch 'master' into at/virt_host_fn
athei Mar 5, 2024
55617c5
Merge branch 'master' into at/virt_host_fn
athei Mar 6, 2024
48a47bb
Guard building riscv code behind feature
athei Mar 6, 2024
87ad52c
Also guard executor tests
athei Mar 6, 2024
d7f0488
Apply suggestions from code review
athei Mar 7, 2024
d375147
Merge branch 'master' into at/virt_host_fn
athei Mar 7, 2024
19e2e27
Update substrate/primitives/wasm-interface/src/lib.rs
athei Apr 8, 2024
79df157
Merge branch 'master' into at/virt_host_fn
athei Apr 8, 2024
44f3520
Remove sp_std
athei Apr 8, 2024
97d0fd7
Merge branch 'master' into at/virt_host_fn
athei Apr 8, 2024
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
5 changes: 4 additions & 1 deletion .gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ test-linux-stable:
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-Cdebug-assertions=y -Dwarnings"
RUST_LOG: "polkavm=trace"
parallel: 3
script:
# Build all but only execute 'runtime' tests.
Expand All @@ -30,7 +31,9 @@ test-linux-stable:
--release \
--no-fail-fast \
--features try-runtime,experimental,riscv,ci-only-tests \
--partition count:${CI_NODE_INDEX}/${CI_NODE_TOTAL}
--retries 0\
-j 1\
test_virtualization
# Upload tests results to Elasticsearch
- echo "Upload test results to Elasticsearch"
- cat target/nextest/default/junit.xml | xq . > target/nextest/default/junit.json
Expand Down
109 changes: 94 additions & 15 deletions Cargo.lock

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

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ members = [
"substrate/primitives/trie",
"substrate/primitives/version",
"substrate/primitives/version/proc-macro",
"substrate/primitives/virtualization",
"substrate/primitives/virtualization/test-fixture",
"substrate/primitives/wasm-interface",
"substrate/primitives/weights",
"substrate/scripts/ci/node-template-release",
Expand Down Expand Up @@ -537,8 +539,9 @@ extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic
default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic

[workspace.dependencies]
polkavm-linker = "0.8.2"
polkavm-derive = "0.8.0"
polkavm = "0.9.0"
polkavm-linker = "0.9.0"
polkavm-derive = "0.9.1"
log = { version = "0.4.20", default-features = false }
quote = { version = "1.0.33" }
serde = { version = "1.0.197", default-features = false }
Expand Down
12 changes: 12 additions & 0 deletions prdoc/pr_3520.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
title: Add virtualization host functions

doc:
- audience: Node Dev
- audience: Runtime Dev
description: |
Add experimental support for virtualization host functions. Those allow the runtime
to spawn and run PolkaVM instances. Not for production use, yet.

crates:
- name: sp-virtualization
- name: sc-executor-wasmtime
1 change: 1 addition & 0 deletions substrate/bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ sp-io = { path = "../../../primitives/io" }
sp-mixnet = { path = "../../../primitives/mixnet" }
sp-mmr-primitives = { path = "../../../primitives/merkle-mountain-range" }
sp-statement-store = { path = "../../../primitives/statement-store" }
sp-virtualization = { path = "../../../primitives/virtualization" }

# client dependencies
sc-client-api = { path = "../../../client/api" }
Expand Down
10 changes: 8 additions & 2 deletions substrate/bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ use std::{path::Path, sync::Arc};

/// Host functions required for kitchensink runtime and Substrate node.
#[cfg(not(feature = "runtime-benchmarks"))]
pub type HostFunctions =
(sp_io::SubstrateHostFunctions, sp_statement_store::runtime_api::HostFunctions);
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
sp_statement_store::runtime_api::HostFunctions,
// Experimental: Don't activate in your production runtime.
sp_virtualization::host_fn::HostFunctions,
);

/// Host functions required for kitchensink runtime and Substrate node.
#[cfg(feature = "runtime-benchmarks")]
pub type HostFunctions = (
sp_io::SubstrateHostFunctions,
sp_statement_store::runtime_api::HostFunctions,
// Experimental: Don't activate in your production runtime.
sp_virtualization::host_fn::HostFunctions,
frame_benchmarking::benchmarking::HostFunctions,
);

Expand Down
2 changes: 2 additions & 0 deletions substrate/client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ sp-runtime = { path = "../../primitives/runtime" }
sp-maybe-compressed-blob = { path = "../../primitives/maybe-compressed-blob" }
sc-tracing = { path = "../tracing" }
sp-tracing = { path = "../../primitives/tracing" }
sp-virtualization = { path = "../../primitives/virtualization" }
sp-virtualization-test-fixture = { path = "../../primitives/virtualization/test-fixture" }
tracing-subscriber = "0.2.19"
paste = "1.0"
regex = "1.6.0"
Expand Down
2 changes: 2 additions & 0 deletions substrate/client/executor/runtime-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ sp-io = { path = "../../../primitives/io", default-features = false, features =
sp-runtime = { path = "../../../primitives/runtime", default-features = false }
sp-runtime-interface = { path = "../../../primitives/runtime-interface", default-features = false }
sp-std = { path = "../../../primitives/std", default-features = false }
sp-virtualization = { path = "../../../primitives/virtualization", default-features = false }

[build-dependencies]
substrate-wasm-builder = { path = "../../../utils/wasm-builder", optional = true }
Expand All @@ -33,5 +34,6 @@ std = [
"sp-runtime-interface/std",
"sp-runtime/std",
"sp-std/std",
"sp-virtualization/std",
"substrate-wasm-builder",
]
4 changes: 4 additions & 0 deletions substrate/client/executor/runtime-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,10 @@ sp_core::wasm_export_functions! {
// Mainly a test that the macro is working when we have a return statement here.
return 1234;
}

fn test_virtualization(test_fixture: Vec<u8>) {
sp_virtualization::run_tests(test_fixture.as_ref());
}
}

// Tests that check output validity. We explicitly return the ptr and len, so we avoid using the
Expand Down
11 changes: 10 additions & 1 deletion substrate/client/executor/src/integration_tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use tracing_subscriber::layer::SubscriberExt;
use crate::WasmExecutionMethod;

pub type TestExternalities = CoreTestExternalities<BlakeTwo256>;
type HostFunctions = sp_io::SubstrateHostFunctions;
type HostFunctions = (sp_io::SubstrateHostFunctions, sp_virtualization::host_fn::HostFunctions);

/// Simple macro that runs a given method as test with the available wasm execution methods.
#[macro_export]
Expand Down Expand Up @@ -799,3 +799,12 @@ fn return_overflow(wasm_method: WasmExecutionMethod) {
error => panic!("unexpected error: {:?}", error),
}
}

test_wasm_execution!(test_virtualization);
fn test_virtualization(wasm_method: WasmExecutionMethod) {
let mut ext = TestExternalities::default();
let mut ext = ext.ext();
let fixture = sp_virtualization_test_fixture::binary().encode();

call_in_wasm("test_virtualization", fixture.as_ref(), wasm_method, &mut ext).unwrap();
}
1 change: 1 addition & 0 deletions substrate/client/executor/wasmtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ anyhow = "1.0.68"
sc-allocator = { path = "../../allocator" }
sc-executor-common = { path = "../common" }
sp-runtime-interface = { path = "../../../primitives/runtime-interface" }
sp-virtualization = { path = "../../../primitives/virtualization" }
sp-wasm-interface = { path = "../../../primitives/wasm-interface", features = ["wasmtime"] }

# Here we include the rustix crate in the exactly same semver-compatible version as used by
Expand Down
Loading