Skip to content

Commit

Permalink
Merge pull request #46 from multiversx/rc/v1.7.next1
Browse files Browse the repository at this point in the history
Rc/v1.7.next1 (Spica)
  • Loading branch information
andrei-marinica authored Nov 14, 2024
2 parents 3750dc3 + 009e154 commit b92b7e8
Show file tree
Hide file tree
Showing 12 changed files with 141 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
default: true
toolchain: "1.77"
- name: Run rust tests
run: cargo test
run: cargo +1.77 test
clippy_check:
permissions: write-all
name: Clippy linter check
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

[workspace]
resolver = "2"

members = [
"c-api",
"vm-executor",
Expand Down
2 changes: 1 addition & 1 deletion Docker/arm64.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM arm64v8/rust:1.76.0
FROM arm64v8/rust:1.77.0

RUN apt-get update && apt-get install -y \
wget \
Expand Down
9 changes: 8 additions & 1 deletion c-api/libvmexeccapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ typedef struct {
int32_t (*get_num_esdt_transfers_func_ptr)(void *context);
int32_t (*get_call_value_token_name_func_ptr)(void *context, int32_t call_value_offset, int32_t token_name_offset);
int32_t (*get_call_value_token_name_by_index_func_ptr)(void *context, int32_t call_value_offset, int32_t token_name_offset, int32_t index);
int32_t (*is_reserved_function_name_func_ptr)(void *context, int32_t name_handle);
void (*write_log_func_ptr)(void *context, int32_t data_pointer, int32_t data_length, int32_t topic_ptr, int32_t num_topics);
void (*write_event_log_func_ptr)(void *context, int32_t num_topics, int32_t topic_lengths_offset, int32_t topic_offset, int32_t data_offset, int32_t data_length);
int64_t (*get_block_timestamp_func_ptr)(void *context);
Expand Down Expand Up @@ -121,6 +122,8 @@ typedef struct {
void (*managed_sc_address_func_ptr)(void *context, int32_t destination_handle);
void (*managed_owner_address_func_ptr)(void *context, int32_t destination_handle);
void (*managed_caller_func_ptr)(void *context, int32_t destination_handle);
void (*managed_get_original_caller_addr_func_ptr)(void *context, int32_t destination_handle);
void (*managed_get_relayer_addr_func_ptr)(void *context, int32_t destination_handle);
void (*managed_signal_error_func_ptr)(void *context, int32_t err_handle);
void (*managed_write_log_func_ptr)(void *context, int32_t topics_handle, int32_t data_handle);
void (*managed_get_original_tx_hash_func_ptr)(void *context, int32_t result_handle);
Expand All @@ -129,7 +132,7 @@ typedef struct {
void (*managed_get_prev_block_random_seed_func_ptr)(void *context, int32_t result_handle);
void (*managed_get_return_data_func_ptr)(void *context, int32_t result_id, int32_t result_handle);
void (*managed_get_multi_esdt_call_value_func_ptr)(void *context, int32_t multi_call_value_handle);
void (*managed_get_back_transfers_func_ptr)(void *context, int32_t esdt_transfers_value_handle, int32_t call_value_handle);
void (*managed_get_back_transfers_func_ptr)(void *context, int32_t esdt_transfers_value_handle, int32_t egld_value_handle);
void (*managed_get_esdt_balance_func_ptr)(void *context, int32_t address_handle, int32_t token_id_handle, int64_t nonce, int32_t value_handle);
void (*managed_get_esdt_token_data_func_ptr)(void *context, int32_t address_handle, int32_t token_id_handle, int64_t nonce, int32_t value_handle, int32_t properties_handle, int32_t hash_handle, int32_t name_handle, int32_t attributes_handle, int32_t creator_handle, int32_t royalties_handle, int32_t uris_handle);
void (*managed_async_call_func_ptr)(void *context, int32_t dest_handle, int32_t value_handle, int32_t function_handle, int32_t arguments_handle);
Expand All @@ -144,6 +147,7 @@ typedef struct {
int32_t (*managed_execute_on_same_context_func_ptr)(void *context, int64_t gas, int32_t address_handle, int32_t value_handle, int32_t function_handle, int32_t arguments_handle, int32_t result_handle);
int32_t (*managed_execute_on_dest_context_func_ptr)(void *context, int64_t gas, int32_t address_handle, int32_t value_handle, int32_t function_handle, int32_t arguments_handle, int32_t result_handle);
int32_t (*managed_multi_transfer_esdt_nft_execute_func_ptr)(void *context, int32_t dst_handle, int32_t token_transfers_handle, int64_t gas_limit, int32_t function_handle, int32_t arguments_handle);
int32_t (*managed_multi_transfer_esdt_nft_execute_by_user_func_ptr)(void *context, int32_t user_handle, int32_t dst_handle, int32_t token_transfers_handle, int64_t gas_limit, int32_t function_handle, int32_t arguments_handle);
int32_t (*managed_transfer_value_execute_func_ptr)(void *context, int32_t dst_handle, int32_t value_handle, int64_t gas_limit, int32_t function_handle, int32_t arguments_handle);
int32_t (*managed_is_esdt_frozen_func_ptr)(void *context, int32_t address_handle, int32_t token_id_handle, int64_t nonce);
int32_t (*managed_is_esdt_limited_transfer_func_ptr)(void *context, int32_t token_id_handle);
Expand Down Expand Up @@ -293,6 +297,9 @@ typedef struct {
int32_t (*get_curve_length_ec_func_ptr)(void *context, int32_t ec_handle);
int32_t (*get_priv_key_byte_length_ec_func_ptr)(void *context, int32_t ec_handle);
int32_t (*elliptic_curve_get_values_func_ptr)(void *context, int32_t ec_handle, int32_t field_order_handle, int32_t base_point_order_handle, int32_t eq_constant_handle, int32_t x_base_point_handle, int32_t y_base_point_handle);
int32_t (*managed_verify_secp256r1_func_ptr)(void *context, int32_t key_handle, int32_t message_handle, int32_t sig_handle);
int32_t (*managed_verify_blssignature_share_func_ptr)(void *context, int32_t key_handle, int32_t message_handle, int32_t sig_handle);
int32_t (*managed_verify_blsaggregated_signature_func_ptr)(void *context, int32_t key_handle, int32_t message_handle, int32_t sig_handle);
} vm_exec_vm_hook_c_func_pointers;

typedef struct {
Expand Down
9 changes: 8 additions & 1 deletion c-api/src/capi_vm_hook_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub get_num_esdt_transfers_func_ptr: extern "C" fn(context: *mut c_void) -> i32,
pub get_call_value_token_name_func_ptr: extern "C" fn(context: *mut c_void, call_value_offset: i32, token_name_offset: i32) -> i32,
pub get_call_value_token_name_by_index_func_ptr: extern "C" fn(context: *mut c_void, call_value_offset: i32, token_name_offset: i32, index: i32) -> i32,
pub is_reserved_function_name_func_ptr: extern "C" fn(context: *mut c_void, name_handle: i32) -> i32,
pub write_log_func_ptr: extern "C" fn(context: *mut c_void, data_pointer: i32, data_length: i32, topic_ptr: i32, num_topics: i32),
pub write_event_log_func_ptr: extern "C" fn(context: *mut c_void, num_topics: i32, topic_lengths_offset: i32, topic_offset: i32, data_offset: i32, data_length: i32),
pub get_block_timestamp_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
Expand Down Expand Up @@ -93,6 +94,8 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub managed_sc_address_func_ptr: extern "C" fn(context: *mut c_void, destination_handle: i32),
pub managed_owner_address_func_ptr: extern "C" fn(context: *mut c_void, destination_handle: i32),
pub managed_caller_func_ptr: extern "C" fn(context: *mut c_void, destination_handle: i32),
pub managed_get_original_caller_addr_func_ptr: extern "C" fn(context: *mut c_void, destination_handle: i32),
pub managed_get_relayer_addr_func_ptr: extern "C" fn(context: *mut c_void, destination_handle: i32),
pub managed_signal_error_func_ptr: extern "C" fn(context: *mut c_void, err_handle: i32),
pub managed_write_log_func_ptr: extern "C" fn(context: *mut c_void, topics_handle: i32, data_handle: i32),
pub managed_get_original_tx_hash_func_ptr: extern "C" fn(context: *mut c_void, result_handle: i32),
Expand All @@ -101,7 +104,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub managed_get_prev_block_random_seed_func_ptr: extern "C" fn(context: *mut c_void, result_handle: i32),
pub managed_get_return_data_func_ptr: extern "C" fn(context: *mut c_void, result_id: i32, result_handle: i32),
pub managed_get_multi_esdt_call_value_func_ptr: extern "C" fn(context: *mut c_void, multi_call_value_handle: i32),
pub managed_get_back_transfers_func_ptr: extern "C" fn(context: *mut c_void, esdt_transfers_value_handle: i32, call_value_handle: i32),
pub managed_get_back_transfers_func_ptr: extern "C" fn(context: *mut c_void, esdt_transfers_value_handle: i32, egld_value_handle: i32),
pub managed_get_esdt_balance_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32),
pub managed_get_esdt_token_data_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32, properties_handle: i32, hash_handle: i32, name_handle: i32, attributes_handle: i32, creator_handle: i32, royalties_handle: i32, uris_handle: i32),
pub managed_async_call_func_ptr: extern "C" fn(context: *mut c_void, dest_handle: i32, value_handle: i32, function_handle: i32, arguments_handle: i32),
Expand All @@ -116,6 +119,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub managed_execute_on_same_context_func_ptr: extern "C" fn(context: *mut c_void, gas: i64, address_handle: i32, value_handle: i32, function_handle: i32, arguments_handle: i32, result_handle: i32) -> i32,
pub managed_execute_on_dest_context_func_ptr: extern "C" fn(context: *mut c_void, gas: i64, address_handle: i32, value_handle: i32, function_handle: i32, arguments_handle: i32, result_handle: i32) -> i32,
pub managed_multi_transfer_esdt_nft_execute_func_ptr: extern "C" fn(context: *mut c_void, dst_handle: i32, token_transfers_handle: i32, gas_limit: i64, function_handle: i32, arguments_handle: i32) -> i32,
pub managed_multi_transfer_esdt_nft_execute_by_user_func_ptr: extern "C" fn(context: *mut c_void, user_handle: i32, dst_handle: i32, token_transfers_handle: i32, gas_limit: i64, function_handle: i32, arguments_handle: i32) -> i32,
pub managed_transfer_value_execute_func_ptr: extern "C" fn(context: *mut c_void, dst_handle: i32, value_handle: i32, gas_limit: i64, function_handle: i32, arguments_handle: i32) -> i32,
pub managed_is_esdt_frozen_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, token_id_handle: i32, nonce: i64) -> i32,
pub managed_is_esdt_limited_transfer_func_ptr: extern "C" fn(context: *mut c_void, token_id_handle: i32) -> i32,
Expand Down Expand Up @@ -265,6 +269,9 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub get_curve_length_ec_func_ptr: extern "C" fn(context: *mut c_void, ec_handle: i32) -> i32,
pub get_priv_key_byte_length_ec_func_ptr: extern "C" fn(context: *mut c_void, ec_handle: i32) -> i32,
pub elliptic_curve_get_values_func_ptr: extern "C" fn(context: *mut c_void, ec_handle: i32, field_order_handle: i32, base_point_order_handle: i32, eq_constant_handle: i32, x_base_point_handle: i32, y_base_point_handle: i32) -> i32,
pub managed_verify_secp256r1_func_ptr: extern "C" fn(context: *mut c_void, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32,
pub managed_verify_blssignature_share_func_ptr: extern "C" fn(context: *mut c_void, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32,
pub managed_verify_blsaggregated_signature_func_ptr: extern "C" fn(context: *mut c_void, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32,
}

impl std::fmt::Debug for vm_exec_vm_hook_c_func_pointers {
Expand Down
32 changes: 30 additions & 2 deletions c-api/src/capi_vm_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ impl multiversx_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.get_call_value_token_name_by_index_func_ptr)(self.vm_hooks_ptr, self.convert_mem_ptr(call_value_offset), self.convert_mem_ptr(token_name_offset), index)
}

fn is_reserved_function_name(&self, name_handle: i32) -> i32 {
(self.c_func_pointers_ptr.is_reserved_function_name_func_ptr)(self.vm_hooks_ptr, name_handle)
}

fn write_log(&self, data_pointer: MemPtr, data_length: MemLength, topic_ptr: MemPtr, num_topics: i32) {
(self.c_func_pointers_ptr.write_log_func_ptr)(self.vm_hooks_ptr, self.convert_mem_ptr(data_pointer), self.convert_mem_length(data_length), self.convert_mem_ptr(topic_ptr), num_topics)
}
Expand Down Expand Up @@ -371,6 +375,14 @@ impl multiversx_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.managed_caller_func_ptr)(self.vm_hooks_ptr, destination_handle)
}

fn managed_get_original_caller_addr(&self, destination_handle: i32) {
(self.c_func_pointers_ptr.managed_get_original_caller_addr_func_ptr)(self.vm_hooks_ptr, destination_handle)
}

fn managed_get_relayer_addr(&self, destination_handle: i32) {
(self.c_func_pointers_ptr.managed_get_relayer_addr_func_ptr)(self.vm_hooks_ptr, destination_handle)
}

fn managed_signal_error(&self, err_handle: i32) {
(self.c_func_pointers_ptr.managed_signal_error_func_ptr)(self.vm_hooks_ptr, err_handle)
}
Expand Down Expand Up @@ -403,8 +415,8 @@ impl multiversx_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.managed_get_multi_esdt_call_value_func_ptr)(self.vm_hooks_ptr, multi_call_value_handle)
}

fn managed_get_back_transfers(&self, esdt_transfers_value_handle: i32, call_value_handle: i32) {
(self.c_func_pointers_ptr.managed_get_back_transfers_func_ptr)(self.vm_hooks_ptr, esdt_transfers_value_handle, call_value_handle)
fn managed_get_back_transfers(&self, esdt_transfers_value_handle: i32, egld_value_handle: i32) {
(self.c_func_pointers_ptr.managed_get_back_transfers_func_ptr)(self.vm_hooks_ptr, esdt_transfers_value_handle, egld_value_handle)
}

fn managed_get_esdt_balance(&self, address_handle: i32, token_id_handle: i32, nonce: i64, value_handle: i32) {
Expand Down Expand Up @@ -463,6 +475,10 @@ impl multiversx_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.managed_multi_transfer_esdt_nft_execute_func_ptr)(self.vm_hooks_ptr, dst_handle, token_transfers_handle, gas_limit, function_handle, arguments_handle)
}

fn managed_multi_transfer_esdt_nft_execute_by_user(&self, user_handle: i32, dst_handle: i32, token_transfers_handle: i32, gas_limit: i64, function_handle: i32, arguments_handle: i32) -> i32 {
(self.c_func_pointers_ptr.managed_multi_transfer_esdt_nft_execute_by_user_func_ptr)(self.vm_hooks_ptr, user_handle, dst_handle, token_transfers_handle, gas_limit, function_handle, arguments_handle)
}

fn managed_transfer_value_execute(&self, dst_handle: i32, value_handle: i32, gas_limit: i64, function_handle: i32, arguments_handle: i32) -> i32 {
(self.c_func_pointers_ptr.managed_transfer_value_execute_func_ptr)(self.vm_hooks_ptr, dst_handle, value_handle, gas_limit, function_handle, arguments_handle)
}
Expand Down Expand Up @@ -1058,4 +1074,16 @@ impl multiversx_chain_vm_executor::VMHooks for CapiVMHooks {
fn elliptic_curve_get_values(&self, ec_handle: i32, field_order_handle: i32, base_point_order_handle: i32, eq_constant_handle: i32, x_base_point_handle: i32, y_base_point_handle: i32) -> i32 {
(self.c_func_pointers_ptr.elliptic_curve_get_values_func_ptr)(self.vm_hooks_ptr, ec_handle, field_order_handle, base_point_order_handle, eq_constant_handle, x_base_point_handle, y_base_point_handle)
}

fn managed_verify_secp256r1(&self, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32 {
(self.c_func_pointers_ptr.managed_verify_secp256r1_func_ptr)(self.vm_hooks_ptr, key_handle, message_handle, sig_handle)
}

fn managed_verify_blssignature_share(&self, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32 {
(self.c_func_pointers_ptr.managed_verify_blssignature_share_func_ptr)(self.vm_hooks_ptr, key_handle, message_handle, sig_handle)
}

fn managed_verify_blsaggregated_signature(&self, key_handle: i32, message_handle: i32, sig_handle: i32) -> i32 {
(self.c_func_pointers_ptr.managed_verify_blsaggregated_signature_func_ptr)(self.vm_hooks_ptr, key_handle, message_handle, sig_handle)
}
}
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "stable"
2 changes: 1 addition & 1 deletion vm-executor-wasmer/src/wasmer_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use wasmer::{ExportIndex, GlobalInit, GlobalType, Mutability, Type, wasmparser::Operator};
use wasmer::{wasmparser::Operator, ExportIndex, GlobalInit, GlobalType, Mutability, Type};
use wasmer_types::{GlobalIndex, ModuleInfo};

pub trait MiddlewareWithProtectedGlobals {
Expand Down
Loading

0 comments on commit b92b7e8

Please sign in to comment.