diff --git a/runtime/near-vm-runner/src/cache.rs b/runtime/near-vm-runner/src/cache.rs index 4a4732d9fa3..dfcf7e9eda1 100644 --- a/runtime/near-vm-runner/src/cache.rs +++ b/runtime/near-vm-runner/src/cache.rs @@ -37,6 +37,10 @@ fn vm_hash(vm_kind: VMKind) -> u64 { VMKind::Wasmtime => crate::wasmtime_runner::wasmtime_vm_hash(), #[cfg(not(feature = "wasmtime_vm"))] VMKind::Wasmtime => panic!("Wasmtime is not enabled"), + #[cfg(all(feature = "near_vm", target_arch = "x86_64"))] + VMKind::NearVm => crate::near_vm_runner::near_vm_vm_hash(), + #[cfg(not(all(feature = "near_vm", target_arch = "x86_64")))] + VMKind::NearVm => panic!("NearVM is not enabled"), } } diff --git a/runtime/near-vm-runner/src/near_vm_runner.rs b/runtime/near-vm-runner/src/near_vm_runner.rs index 14cdb6aefad..01c08f1f7bc 100644 --- a/runtime/near-vm-runner/src/near_vm_runner.rs +++ b/runtime/near-vm-runner/src/near_vm_runner.rs @@ -238,7 +238,7 @@ const WASMER2_CONFIG: Wasmer2Config = Wasmer2Config { compiler: WasmerCompiler::Singlepass, }; -pub(crate) fn wasmer2_vm_hash() -> u64 { +pub(crate) fn near_vm_vm_hash() -> u64 { WASMER2_CONFIG.config_hash() } diff --git a/runtime/near-vm-runner/src/tests/cache.rs b/runtime/near-vm-runner/src/tests/cache.rs index ed7da23f313..db2754eb1a1 100644 --- a/runtime/near-vm-runner/src/tests/cache.rs +++ b/runtime/near-vm-runner/src/tests/cache.rs @@ -25,7 +25,7 @@ use wasmer_engine::Executable; fn test_caches_compilation_error() { with_vm_variants(|vm_kind: VMKind| { match vm_kind { - VMKind::Wasmer0 | VMKind::Wasmer2 => {} + VMKind::Wasmer0 | VMKind::Wasmer2 | VMKind::NearVm => {} VMKind::Wasmtime => return, } let cache = MockCompiledContractCache::default(); @@ -48,7 +48,7 @@ fn test_caches_compilation_error() { fn test_does_not_cache_io_error() { with_vm_variants(|vm_kind: VMKind| { match vm_kind { - VMKind::Wasmer0 | VMKind::Wasmer2 => {} + VMKind::Wasmer0 | VMKind::Wasmer2 | VMKind::NearVm => {} VMKind::Wasmtime => return, } diff --git a/runtime/near-vm-runner/src/tests/rs_contract.rs b/runtime/near-vm-runner/src/tests/rs_contract.rs index 6755503ccd1..84fd0002723 100644 --- a/runtime/near-vm-runner/src/tests/rs_contract.rs +++ b/runtime/near-vm-runner/src/tests/rs_contract.rs @@ -126,7 +126,7 @@ fn run_test_ext( if let ReturnData::Value(value) = outcome.return_data { assert_eq!(&value, &expected); } else { - panic!("Value was not returned"); + panic!("Value was not returned, got outcome {:?}", outcome); } } @@ -225,7 +225,7 @@ pub fn test_out_of_memory() { assert_eq!( result.aborted, match vm_kind { - VMKind::Wasmer0 | VMKind::Wasmer2 => + VMKind::Wasmer0 | VMKind::Wasmer2 | VMKind::NearVm => Some(FunctionCallError::WasmTrap(WasmTrap::Unreachable)), VMKind::Wasmtime => unreachable!(), } diff --git a/runtime/near-vm-runner/src/vm_kind.rs b/runtime/near-vm-runner/src/vm_kind.rs index b28da18826a..1f6de45b244 100644 --- a/runtime/near-vm-runner/src/vm_kind.rs +++ b/runtime/near-vm-runner/src/vm_kind.rs @@ -14,8 +14,10 @@ pub enum VMKind { Wasmer0, /// Wasmtime VM. Wasmtime, - // Wasmer 2.x VM, + /// Wasmer 2.x VM. Wasmer2, + /// NearVM. + NearVm, } impl VMKind {