Skip to content

Commit 08434db

Browse files
committed
Revert "Remove sandboxing host function interface (paritytech#12852)"
This reverts commit 5722ece.
1 parent 2a0eeff commit 08434db

File tree

29 files changed

+3850
-8
lines changed

29 files changed

+3850
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ members = [
208208
"primitives/runtime-interface/test",
209209
"primitives/runtime-interface/test-wasm",
210210
"primitives/runtime-interface/test-wasm-deprecated",
211+
"primitives/sandbox",
211212
"primitives/serializer",
212213
"primitives/session",
213214
"primitives/staking",

bin/node/runtime/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sp-session = { version = "4.0.0-dev", default-features = false, path = "../../..
4040
sp-transaction-pool = { version = "4.0.0-dev", default-features = false, path = "../../../primitives/transaction-pool" }
4141
sp-version = { version = "5.0.0", default-features = false, path = "../../../primitives/version" }
4242
sp-io = { version = "7.0.0", default-features = false, path = "../../../primitives/io" }
43+
sp-sandbox = { version = "0.10.0-dev", default-features = false, path = "../../../primitives/sandbox" }
4344

4445
# frame dependencies
4546
frame-executive = { version = "4.0.0-dev", default-features = false, path = "../../../frame/executive" }
@@ -118,6 +119,7 @@ substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-bu
118119
default = ["std"]
119120
with-tracing = ["frame-executive/with-tracing"]
120121
std = [
122+
"sp-sandbox/std",
121123
"pallet-whitelist/std",
122124
"pallet-offences-benchmarking?/std",
123125
"pallet-election-provider-support-benchmarking?/std",
@@ -315,3 +317,8 @@ try-runtime = [
315317
"pallet-vesting/try-runtime",
316318
"pallet-whitelist/try-runtime",
317319
]
320+
# Force `sp-sandbox` to call into the host resident executor. One still need to make sure
321+
# that `sc-executor` gets the `wasmer-sandbox` feature which happens automatically when
322+
# specified on the command line.
323+
# Don't use that on a production chain.
324+
wasmer-sandbox = ["sp-sandbox/wasmer-sandbox"]

client/executor/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ readme = "README.md"
1414
targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
17+
lazy_static = "1.4.0"
1718
lru = "0.8.1"
1819
parking_lot = "0.12.1"
1920
tracing = "0.1.29"
@@ -25,6 +26,7 @@ sc-executor-wasmi = { version = "0.10.0-dev", path = "wasmi" }
2526
sc-executor-wasmtime = { version = "0.10.0-dev", path = "wasmtime" }
2627
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
2728
sp-core = { version = "7.0.0", path = "../../primitives/core" }
29+
sp-core-hashing-proc-macro = { version = "5.0.0", path = "../../primitives/core/hashing/proc-macro" }
2830
sp-externalities = { version = "0.13.0", path = "../../primitives/externalities" }
2931
sp-io = { version = "7.0.0", path = "../../primitives/io" }
3032
sp-panic-handler = { version = "5.0.0", path = "../../primitives/panic-handler" }
@@ -59,3 +61,4 @@ default = ["std"]
5961
# This crate does not have `no_std` support, we just require this for tests
6062
std = []
6163
wasm-extern-trace = []
64+
wasmer-sandbox = ["sc-executor-common/wasmer-sandbox"]

client/executor/common/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ readme = "README.md"
1414
targets = ["x86_64-unknown-linux-gnu"]
1515

1616
[dependencies]
17+
codec = { package = "parity-scale-codec", version = "3.0.0" }
18+
environmental = "1.1.3"
1719
thiserror = "1.0.30"
1820
wasm-instrument = "0.3"
21+
wasmer = { version = "2.2", features = ["singlepass"], optional = true }
1922
wasmi = "0.13"
2023
sc-allocator = { version = "4.1.0-dev", path = "../../allocator" }
2124
sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../../primitives/maybe-compressed-blob" }
25+
sp-sandbox = { version = "0.10.0-dev", path = "../../../primitives/sandbox" }
2226
sp-wasm-interface = { version = "7.0.0", path = "../../../primitives/wasm-interface" }
2327

2428
[features]
2529
default = []
30+
wasmer-sandbox = [
31+
"wasmer",
32+
]

client/executor/common/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ pub enum Error {
3030
#[error(transparent)]
3131
Wasmi(#[from] wasmi::Error),
3232

33+
#[error("Sandbox error: {0}")]
34+
Sandbox(String),
35+
3336
#[error("Error calling api function: {0}")]
3437
ApiError(Box<dyn std::error::Error + Send + Sync>),
3538

client/executor/common/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323

2424
pub mod error;
2525
pub mod runtime_blob;
26+
pub mod sandbox;
2627
pub mod util;
2728
pub mod wasm_runtime;

0 commit comments

Comments
 (0)