Skip to content

Commit

Permalink
introduce VMKind::NearVm (#8873)
Browse files Browse the repository at this point in the history
* introduce VMKind::NearVm

* fix build
  • Loading branch information
Ekleog-NEAR authored and nikurt committed Apr 28, 2023
1 parent 07a529d commit 79353d4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions runtime/near-vm-runner/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/near-vm-runner/src/near_vm_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/near-vm-runner/src/tests/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions runtime/near-vm-runner/src/tests/rs_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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!(),
}
Expand Down
4 changes: 3 additions & 1 deletion runtime/near-vm-runner/src/vm_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ pub enum VMKind {
Wasmer0,
/// Wasmtime VM.
Wasmtime,
// Wasmer 2.x VM,
/// Wasmer 2.x VM.
Wasmer2,
/// NearVM.
NearVm,
}

impl VMKind {
Expand Down

0 comments on commit 79353d4

Please sign in to comment.