Skip to content
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
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Disable debug assertions to prevent unsafe precondition check failures
# from older wasmer versions that don't meet newer Rust safety requirements.
# These checks are optional and the code works correctly despite triggering them.
[build]
rustflags = ["-C", "debug-assertions=no"]
6 changes: 3 additions & 3 deletions .github/workflows/libvmexeccapi-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ jobs:
- os: ubuntu-22.04
artifact_name: libvmexeccapi.so
make_target: capi-linux-amd64
- os: macos-13
- os: macos-15-intel
artifact_name: libvmexeccapi.dylib
make_target: capi-osx-amd64
- os: macos-13-xlarge
- os: macos-latest
artifact_name: libvmexeccapi_arm
make_target: capi-osx-arm
steps:
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.83"
toolchain: "1.92"

- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
default: true
toolchain: "1.83"
toolchain: "1.92"
- name: Run rust tests
run: cargo +1.83 test --release
run: cargo +1.92 test --release
clippy_check:
permissions: write-all
name: Clippy linter check
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This file contains a centralizes a trace of all published crate versions, with their changes in short.

## [multiversx-chain-vm-executor 0.5.1] - 2026-01-20
- Upgraded to Wasmer v6.1.0.
- Fixed linker issue on Linux for Wasmer 2 (unreleased).
- Upgraded to edition 2024.
- Upgraded dependencies.

## [multiversx-chain-vm-executor 0.5.0] - 2025-07-03
- Barnard VM hooks.

Expand Down
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ members = [
"vm-executor-experimental",
"vm-executor-wasmer",
]

[patch.crates-io]
# Overrides the `multiversx-chain-vm-executor` dependency to use the local path,
# for local builds and CI. Required by multiversx-chain-vm-executor-wasmer, which
# cannot set the path directly without breaking external consumers.
multiversx-chain-vm-executor = { path = "vm-executor" }
9 changes: 5 additions & 4 deletions c-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "multiversx-chain-vm-executor-c-api"
version = "0.0.0"
edition = "2021"
edition = "2024"
publish = false

[lib]
Expand All @@ -15,8 +15,9 @@ multiversx-chain-vm-executor-wasmer = { path = "../vm-executor-wasmer" }
lazy_static = "1.4"
libc = { version = "^0.2", default-features = false }

env_logger = "0.8.4"
log = "0.4.14"
chrono = "0.4.23"
env_logger = "0.11"
log = "0.4"

[build-dependencies]
cbindgen = "0.9"
cbindgen = "0.29"
1,226 changes: 932 additions & 294 deletions c-api/libvmexeccapi.h

Large diffs are not rendered by default.

34 changes: 18 additions & 16 deletions c-api/src/basic_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) unsafe fn get_slice_checked<'a, T>(ptr: *const T, len: usize) -> &'a
if ptr.is_null() {
&[]
} else {
std::slice::from_raw_parts(ptr, len)
unsafe { std::slice::from_raw_parts(ptr, len) }
}
}

Expand All @@ -52,27 +52,29 @@ pub(crate) unsafe fn string_copy(
dest_buffer: *mut c_char,
dest_buffer_len: c_int,
) -> c_int {
if dest_buffer.is_null() {
// buffer pointer is null
return -1;
}
unsafe {
if dest_buffer.is_null() {
// buffer pointer is null
return -1;
}

let dest_buffer_len = dest_buffer_len as usize;
let dest_buffer_len = dest_buffer_len as usize;

if s.len() >= dest_buffer_len {
// buffer is too small to hold the error message
return -1;
}
if s.len() >= dest_buffer_len {
// buffer is too small to hold the error message
return -1;
}

let dest_buffer = slice::from_raw_parts_mut(dest_buffer as *mut u8, dest_buffer_len);
let dest_buffer = slice::from_raw_parts_mut(dest_buffer as *mut u8, dest_buffer_len);

ptr::copy_nonoverlapping(s.as_ptr(), dest_buffer.as_mut_ptr(), s.len());
ptr::copy_nonoverlapping(s.as_ptr(), dest_buffer.as_mut_ptr(), s.len());

// Add a trailing null so people using the string as a `char *` don't
// accidentally read into garbage.
dest_buffer[s.len()] = 0;
// Add a trailing null so people using the string as a `char *` don't
// accidentally read into garbage.
dest_buffer[s.len()] = 0;

s.len() as c_int + 1
s.len() as c_int + 1
}
}

#[allow(non_camel_case_types)]
Expand Down
6 changes: 3 additions & 3 deletions c-api/src/capi_breakpoints.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use meta::capi_safe_unwind;
use multiversx_chain_vm_executor::InstanceLegacy;

use crate::capi_instance::{vm_exec_instance_t, CapiInstance};
use crate::capi_instance::{CapiInstance, vm_exec_instance_t};
use crate::service_singleton::with_service;
use crate::vm_exec_result_t;

Expand All @@ -15,7 +15,7 @@ use crate::vm_exec_result_t;
///
/// C API function, works with raw object pointers.
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
#[unsafe(no_mangle)]
#[capi_safe_unwind(vm_exec_result_t::VM_EXEC_ERROR)]
pub unsafe extern "C" fn vm_exec_instance_set_breakpoint_value(
instance_ptr: *const vm_exec_instance_t,
Expand All @@ -38,7 +38,7 @@ pub unsafe extern "C" fn vm_exec_instance_set_breakpoint_value(
///
/// C API function, works with raw object pointers.
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
#[unsafe(no_mangle)]
#[capi_safe_unwind(0)]
pub unsafe extern "C" fn vm_exec_instance_get_breakpoint_value(
instance_ptr: *const vm_exec_instance_t,
Expand Down
6 changes: 3 additions & 3 deletions c-api/src/capi_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{service_singleton::with_service, string_copy, string_length};
///
/// This can be used to dynamically allocate a buffer with the correct number of
/// bytes needed to store a message.
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn vm_exec_last_error_length() -> c_int {
string_length(get_last_error_string())
}
Expand All @@ -32,12 +32,12 @@ pub extern "C" fn vm_exec_last_error_length() -> c_int {
/// # Safety
///
/// C API function, works with raw object pointers.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vm_exec_last_error_message(
dest_buffer: *mut c_char,
dest_buffer_len: c_int,
) -> c_int {
string_copy(get_last_error_string(), dest_buffer, dest_buffer_len)
unsafe { string_copy(get_last_error_string(), dest_buffer, dest_buffer_len) }
}

fn get_last_error_string() -> String {
Expand Down
18 changes: 10 additions & 8 deletions c-api/src/capi_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct CapiExecutor {
///
/// C API function, works with raw object pointers.
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
#[unsafe(no_mangle)]
#[capi_safe_unwind(vm_exec_result_t::VM_EXEC_ERROR)]
pub unsafe extern "C" fn vm_exec_new_executor(
executor: *mut *mut vm_exec_executor_t,
Expand All @@ -32,8 +32,8 @@ pub unsafe extern "C" fn vm_exec_new_executor(
return_if_ptr_null!(vm_hook_pointers_ptr_ptr, "VM hooks ptr is null");

// unpacking the vm hooks object pointer
let vm_hook_pointers_ptr = *vm_hook_pointers_ptr_ptr;
let vm_hook_pointers = (*vm_hook_pointers_ptr).clone();
let vm_hook_pointers_ptr = unsafe { *vm_hook_pointers_ptr_ptr };
let vm_hook_pointers = unsafe { (*vm_hook_pointers_ptr).clone() };

// create executor
let executor_result =
Expand All @@ -43,7 +43,9 @@ pub unsafe extern "C" fn vm_exec_new_executor(
let capi_executor = CapiExecutor {
content: executor_box,
};
*executor = Box::into_raw(Box::new(capi_executor)) as *mut vm_exec_executor_t;
unsafe {
*executor = Box::into_raw(Box::new(capi_executor)) as *mut vm_exec_executor_t;
}
vm_exec_result_t::VM_EXEC_OK
}
Err(message) => {
Expand All @@ -58,7 +60,7 @@ pub unsafe extern "C" fn vm_exec_new_executor(
/// # Safety
///
/// C API function, works with raw object pointers.
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vm_force_sighandler_reinstall() {
force_sighandler_reinstall();
}
Expand All @@ -76,7 +78,7 @@ pub unsafe extern "C" fn vm_force_sighandler_reinstall() {
///
/// C API function, works with raw object pointers.
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
#[unsafe(no_mangle)]
#[capi_safe_unwind(vm_exec_result_t::VM_EXEC_ERROR)]
pub unsafe extern "C" fn vm_exec_executor_set_vm_hooks_ptr(
executor_ptr: *mut vm_exec_executor_t,
Expand Down Expand Up @@ -107,10 +109,10 @@ pub unsafe extern "C" fn vm_exec_executor_set_vm_hooks_ptr(
///
/// C API function, works with raw object pointers.
#[allow(clippy::cast_ptr_alignment)]
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn vm_exec_executor_destroy(executor_ptr: *mut vm_exec_executor_t) {
if !executor_ptr.is_null() {
let executor = Box::from_raw(executor_ptr as *mut CapiExecutor);
let executor = unsafe { Box::from_raw(executor_ptr as *mut CapiExecutor) };
drop(executor)
}
}
Loading
Loading