Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Restore previous version of ext_sandbox_invoke (#236)
Browse files Browse the repository at this point in the history
* Restore previous version of ext_sandbox_invoke.

* Rebuild binaries.
  • Loading branch information
pepyakin authored and gavofyork committed Jun 25, 2018
1 parent a663a8a commit e50bb08
Show file tree
Hide file tree
Showing 13 changed files with 880 additions and 3 deletions.
286 changes: 286 additions & 0 deletions demo/runtime/wasm/Cargo.lock

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
286 changes: 286 additions & 0 deletions polkadot/runtime/wasm/Cargo.lock

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
20 changes: 19 additions & 1 deletion substrate/executor/src/wasm_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,25 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
this.sandbox_store.instance_teardown(instance_idx)?;
Ok(())
},
ext_sandbox_invoke(instance_idx: u32, export_ptr: *const u8, export_len: usize, args_ptr: *const u8, args_len: usize, return_val_ptr: *const u8, return_val_len: usize, state: usize) -> u32 => {
ext_sandbox_invoke(instance_idx: u32, export_ptr: *const u8, export_len: usize, state: usize) -> u32 => {
trace!(target: "runtime-sandbox", "invoke, instance_idx={}", instance_idx);
let export = this.memory.get(export_ptr, export_len as usize)
.map_err(|_| DummyUserError)
.and_then(|b|
String::from_utf8(b)
.map_err(|_| DummyUserError)
)?;

let instance = this.sandbox_store.instance(instance_idx)?;
let result = instance.invoke(&export, &[], this, state);
match result {
Ok(None) => Ok(sandbox_primitives::ERR_OK),
Ok(_) => unimplemented!(),
Err(_) => Ok(sandbox_primitives::ERR_EXECUTION),
}
},
// TODO: Remove the old 'ext_sandbox_invoke' and rename this to it.
ext_sandbox_invoke_poc2(instance_idx: u32, export_ptr: *const u8, export_len: usize, args_ptr: *const u8, args_len: usize, return_val_ptr: *const u8, return_val_len: usize, state: usize) -> u32 => {
use codec::Slicable;

trace!(target: "runtime-sandbox", "invoke, instance_idx={}", instance_idx);
Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 3 additions & 2 deletions substrate/runtime-sandbox/without_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ mod ffi {
imports_len: usize,
state: usize,
) -> u32;
pub fn ext_sandbox_invoke(
// TODO: Rename it back to 'ext_sandbox_invoke'.
pub fn ext_sandbox_invoke_poc2(
instance_idx: u32,
export_ptr: *const u8,
export_len: usize,
Expand Down Expand Up @@ -271,7 +272,7 @@ impl<T> Instance<T> {
let mut return_val = vec![0u8; sandbox_primitives::ReturnValue::ENCODED_MAX_SIZE];

let result = unsafe {
ffi::ext_sandbox_invoke(
ffi::ext_sandbox_invoke_poc2(
self.instance_idx,
name.as_ptr(),
name.len(),
Expand Down
Loading

0 comments on commit e50bb08

Please sign in to comment.