Skip to content

fix(runtime): Rollback Wasmer to older version #2533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
88 changes: 49 additions & 39 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ skip = [
# crypto-mac 0.7.0 still uses it: https://github.com/RustCrypto/traits/issues/43
{ name = "subtle", version = "=1.0.0" },

# wasmer-runtime-core v0.16.2 still uses it
# wasmer-runtime-core v0.13.1 still uses it
{ name = "smallvec", version = "=0.6.13" },
{ name = "parking_lot", version = "=0.9.0" },
{ name = "parking_lot_core", version = "=0.6.2" },
{ name = "hex", version = "=0.3.2" },

# wabt 0.9.0 (dev dependency) still uses it
{ name = "glob", version = "=0.2.11" },
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.16.2", features = ["default-backend-singlepass"], default-features = false }
wasmer-runtime-core = { version = "0.16.2" }
wasmer-runtime = { version = "0.13.1", features = ["default-backend-singlepass"], default-features = false }
wasmer-runtime-core = { version = "0.13.1" }
pwasm-utils = "0.12"
parity-wasm = "0.41"

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

pub trait IntoVMError {
Expand Down Expand Up @@ -64,51 +65,29 @@ impl IntoVMError for wasmer_runtime::error::ResolveError {

impl IntoVMError for wasmer_runtime::error::RuntimeError {
fn into_vm_error(self) -> VMError {
use wasmer_runtime::ExceptionCode;
let data = &*self.0;

if let Some(err) = data.downcast_ref::<VMLogicError>() {
match err {
VMLogicError::HostError(h) => {
VMError::FunctionCallError(FunctionCallError::HostError(h.clone()))
}
VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()),
VMLogicError::InconsistentStateError(e) => {
VMError::InconsistentStateError(e.clone())
}
}
} else if let Some(err) = data.downcast_ref::<ExceptionCode>() {
use wasmer_runtime::ExceptionCode::*;
match err {
Unreachable => {
VMError::FunctionCallError(FunctionCallError::WasmTrap(WasmTrap::Unreachable))
use wasmer_runtime::error::RuntimeError;
match &self {
RuntimeError::Trap { msg: _ } => VMError::FunctionCallError(WasmUnknownError),
RuntimeError::Error { data } => {
if let Some(err) = data.downcast_ref::<VMLogicError>() {
match err {
VMLogicError::HostError(h) => {
VMError::FunctionCallError(FunctionCallError::HostError(h.clone()))
}
VMLogicError::ExternalError(s) => VMError::ExternalError(s.clone()),
VMLogicError::InconsistentStateError(e) => {
VMError::InconsistentStateError(e.clone())
}
}
} else {
eprintln!(
"Bad error case! Output is non-deterministic {:?} {:?}",
data.type_id(),
self.to_string()
);
VMError::FunctionCallError(WasmUnknownError)
}
IncorrectCallIndirectSignature => VMError::FunctionCallError(
FunctionCallError::WasmTrap(WasmTrap::IncorrectCallIndirectSignature),
),
MemoryOutOfBounds => VMError::FunctionCallError(FunctionCallError::WasmTrap(
WasmTrap::MemoryOutOfBounds,
)),
CallIndirectOOB => VMError::FunctionCallError(FunctionCallError::WasmTrap(
WasmTrap::CallIndirectOOB,
)),
IllegalArithmetic => VMError::FunctionCallError(FunctionCallError::WasmTrap(
WasmTrap::IllegalArithmetic,
)),
MisalignedAtomicAccess => VMError::FunctionCallError(FunctionCallError::WasmTrap(
WasmTrap::MisalignedAtomicAccess,
)),
}
} else {
// TODO: Wasmer provides no way to distingush runtime Internal Wasmer errors or host panics
// (at least for a single-pass backend)
// https://github.com/wasmerio/wasmer/issues/1338
eprintln!(
"Bad error case! Output might be non-deterministic {:?} {:?}",
data.type_id(),
self.to_string()
);
VMError::FunctionCallError(FunctionCallError::WasmUnknownError)
}
}
}