Skip to content

Commit

Permalink
feat(runtime): upgrade to Wasmer 0.17 and nightly 2020-05-15
Browse files Browse the repository at this point in the history
Used https://crates.io/crates/rust-latest to find latest suitable nightly.

Fixes #2055

Test plan
---------
cargo test --all
  • Loading branch information
olonho committed May 18, 2020
1 parent 48fa6b4 commit 5aff965
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 70 deletions.
101 changes: 41 additions & 60 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions runtime/near-vm-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub enum WasmTrap {
IllegalArithmetic,
/// Misaligned atomic access trap.
MisalignedAtomicAccess,
/// Breakpoint trap.
BreakpointTrap,
/// Generic trap.
GenericTrap,
}

#[derive(
Expand Down Expand Up @@ -244,6 +248,8 @@ impl fmt::Display for WasmTrap {
write!(f, "An arithmetic exception, e.g. divided by zero.")
}
WasmTrap::MisalignedAtomicAccess => write!(f, "Misaligned atomic access trap."),
WasmTrap::GenericTrap => write!(f, "Generic trap."),
WasmTrap::BreakpointTrap => write!(f, "Breakpoint trap."),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/near-vm-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ This crate implements the specification of the interface that Near blockchain ex

[dependencies]
cached = "0.12"
wasmer-runtime = { version = "0.13.1", features = ["default-backend-singlepass"], default-features = false }
wasmer-runtime-core = { version = "0.13.1" }
wasmer-runtime = { version = "0.17", features = ["default-backend-singlepass"], default-features = false }
wasmer-runtime-core = { version = "0.17" }
pwasm-utils = "0.12"
parity-wasm = "0.41"

Expand Down
30 changes: 25 additions & 5 deletions runtime/near-vm-runner/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use near_vm_errors::FunctionCallError::WasmUnknownError;
use near_vm_errors::FunctionCallError::{WasmTrap, WasmUnknownError};
use near_vm_errors::{CompilationError, FunctionCallError, MethodResolveError, VMError};
use near_vm_logic::VMLogicError;

Expand Down Expand Up @@ -65,10 +65,31 @@ impl IntoVMError for wasmer_runtime::error::ResolveError {

impl IntoVMError for wasmer_runtime::error::RuntimeError {
fn into_vm_error(self) -> VMError {
use near_vm_errors::WasmTrap::{BreakpointTrap, GenericTrap};
use wasmer_runtime::error::InvokeError;
use wasmer_runtime::error::RuntimeError;
match &self {
RuntimeError::Trap { msg: _ } => VMError::FunctionCallError(WasmUnknownError),
RuntimeError::Error { data } => {
RuntimeError::InvokeError(invoke_error) => match invoke_error {
InvokeError::FailedWithNoError => VMError::FunctionCallError(WasmUnknownError),
InvokeError::UnknownTrap { address: _, signal: _ } => {
VMError::FunctionCallError(WasmTrap(GenericTrap))
}
InvokeError::TrapCode { code: _, srcloc: _ } => {
VMError::FunctionCallError(WasmTrap(GenericTrap))
}
InvokeError::UnknownTrapCode { trap_code: _, srcloc: _ } => {
VMError::FunctionCallError(WasmTrap(GenericTrap))
}
InvokeError::EarlyTrap(_) => VMError::FunctionCallError(WasmTrap(GenericTrap)),
InvokeError::Breakpoint(_) => VMError::FunctionCallError(WasmTrap(BreakpointTrap)),
},
RuntimeError::Metering(_x) => {
panic!("Support metering errors properly");
}
RuntimeError::InstanceImage(_x) => {
panic!("Support instance image errors properly");
}
RuntimeError::User(data) => {
if let Some(err) = data.downcast_ref::<VMLogicError>() {
match err {
VMLogicError::HostError(h) => {
Expand All @@ -80,12 +101,11 @@ impl IntoVMError for wasmer_runtime::error::RuntimeError {
}
}
} else {
eprintln!(
panic!(
"Bad error case! Output is non-deterministic {:?} {:?}",
data.type_id(),
self.to_string()
);
VMError::FunctionCallError(WasmUnknownError)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion runtime/runtime-params-estimator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(asm)]
#![feature(llvm_asm)]

// Lists all cases that we want to measure.
pub mod cases;
Expand Down
Loading

0 comments on commit 5aff965

Please sign in to comment.