Skip to content

Commit

Permalink
feat(sp-wasm-interface): Gear sandbox (#35)
Browse files Browse the repository at this point in the history
* move allocator to primitives
* move HostState to sp-wasm-interface
* move StoreData to sp-wasm-interface
* caller method
* move MemoryWrapper to sp-wasm-interface
* add sp-wasm-interface util module
* refactor with_caller_mut method
  • Loading branch information
ukint-vs committed Nov 28, 2023
1 parent ca32c48 commit 90d03f0
Show file tree
Hide file tree
Showing 31 changed files with 1,451 additions and 530 deletions.
48 changes: 37 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ members = [
"client/network/sync",
"client/network/test",
"client/offchain",
"client/allocator",
"client/proposer-metrics",
"client/rpc",
"client/rpc-api",
Expand Down Expand Up @@ -183,6 +182,7 @@ members = [
"frame/vesting",
"frame/glutton",
"frame/whitelist",
"primitives/allocator",
"primitives/api",
"primitives/api/proc-macro",
"primitives/api/test",
Expand Down
20 changes: 0 additions & 20 deletions client/allocator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,20 +0,0 @@
[package]
name = "sc-allocator"
version = "4.1.0-dev"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
homepage = "https://substrate.io"
repository = "https://github.com/paritytech/substrate/"
description = "Collection of allocator implementations."
documentation = "https://docs.rs/sc-allocator"
readme = "README.md"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
log = "0.4.17"
thiserror = "1.0.30"
sp-core = { version = "21.0.0", path = "../../primitives/core" }
sp-wasm-interface = { version = "14.0.0", path = "../../primitives/wasm-interface" }
2 changes: 1 addition & 1 deletion client/executor/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
thiserror = "1.0.30"
wasm-instrument = "0.3"
wasmi = { git = "https://github.com/gear-tech/wasmi", branch = "v0.13.2-sign-ext", features = ["virtual_memory"] }
sc-allocator = { version = "4.1.0-dev", path = "../../allocator" }
sp-allocator = { version = "4.1.0-dev", path = "../../../primitives/allocator" }
sp-maybe-compressed-blob = { version = "4.1.0-dev", path = "../../../primitives/maybe-compressed-blob" }
sp-wasm-interface = { version = "14.0.0", path = "../../../primitives/wasm-interface" }

Expand Down
2 changes: 1 addition & 1 deletion client/executor/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub enum Error {
Other(String),

#[error(transparent)]
Allocator(#[from] sc_allocator::Error),
Allocator(#[from] sp_allocator::Error),

#[error("Host function {0} execution failed with: {1}")]
FunctionExecution(String, String),
Expand Down
8 changes: 0 additions & 8 deletions client/executor/common/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
use crate::error::Result;
use sp_wasm_interface::Pointer;
use std::ops::Range;

/// Construct a range from an offset to a data length after the offset.
/// Returns None if the end of the range would exceed some maximum offset.
pub fn checked_range(offset: usize, len: usize, max: usize) -> Option<Range<usize>> {
let end = offset.checked_add(len)?;
(end <= max).then(|| offset..end)
}

/// Provides safe memory access interface using an external buffer
pub trait MemoryTransfer {
Expand Down
2 changes: 1 addition & 1 deletion client/executor/common/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use crate::error::Error;
use sp_wasm_interface::Value;

pub use sc_allocator::AllocationStats;
pub use sp_allocator::AllocationStats;

/// Default heap allocation strategy.
pub const DEFAULT_HEAP_ALLOC_STRATEGY: HeapAllocStrategy =
Expand Down
2 changes: 1 addition & 1 deletion client/executor/wasmi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
log = "0.4.17"
wasmi = { git = "https://github.com/gear-tech/wasmi", branch = "v0.13.2-sign-ext", features = ["virtual_memory"] }
sc-allocator = { version = "4.1.0-dev", path = "../../allocator" }
sc-executor-common = { version = "0.10.0-dev", path = "../common" }
sp-allocator = { version = "4.1.0-dev", path = "../../../primitives/allocator" }
sp-runtime-interface = { version = "7.0.0", path = "../../../primitives/runtime-interface" }
sp-wasm-interface = { version = "7.0.0", path = "../../../primitives/wasm-interface" }
Loading

0 comments on commit 90d03f0

Please sign in to comment.