Skip to content
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

New VM hooks for rc/v1.7.next1 #38

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
7 changes: 6 additions & 1 deletion .github/workflows/libvmexeccapi-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ jobs:
- os: ubuntu-20.04
artifact_name: libvmexeccapi.so
make_target: capi-linux-amd64
- os: macos-11
- os: macos-13
artifact_name: libvmexeccapi.dylib
make_target: capi-osx-amd64
- os: macos-13-xlarge
artifact_name: libvmexeccapi_arm
make_target: capi-osx-arm
steps:
- name: Install rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: "1.77"

- 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: stable
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
13 changes: 12 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 All @@ -104,6 +105,10 @@ typedef struct {
int64_t (*get_prev_block_round_func_ptr)(void *context);
int64_t (*get_prev_block_epoch_func_ptr)(void *context);
void (*get_prev_block_random_seed_func_ptr)(void *context, int32_t pointer);
int64_t (*get_round_time_func_ptr)(void *context);
int64_t (*epoch_start_block_time_stamp_func_ptr)(void *context);
int64_t (*epoch_start_block_nonce_func_ptr)(void *context);
int64_t (*epoch_start_block_round_func_ptr)(void *context);
void (*finish_func_ptr)(void *context, int32_t pointer, int32_t length);
int32_t (*execute_on_same_context_func_ptr)(void *context, int64_t gas_limit, int32_t address_offset, int32_t value_offset, int32_t function_offset, int32_t function_length, int32_t num_arguments, int32_t arguments_length_offset, int32_t data_offset);
int32_t (*execute_on_dest_context_func_ptr)(void *context, int64_t gas_limit, int32_t address_offset, int32_t value_offset, int32_t function_offset, int32_t function_length, int32_t num_arguments, int32_t arguments_length_offset, int32_t data_offset);
Expand All @@ -121,6 +126,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 +136,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 +151,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 +301,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
17 changes: 16 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 All @@ -76,6 +77,10 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub get_prev_block_round_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub get_prev_block_epoch_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub get_prev_block_random_seed_func_ptr: extern "C" fn(context: *mut c_void, pointer: i32),
pub get_round_time_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub epoch_start_block_time_stamp_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub epoch_start_block_nonce_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub epoch_start_block_round_func_ptr: extern "C" fn(context: *mut c_void) -> i64,
pub finish_func_ptr: extern "C" fn(context: *mut c_void, pointer: i32, length: i32),
pub execute_on_same_context_func_ptr: extern "C" fn(context: *mut c_void, gas_limit: i64, address_offset: i32, value_offset: i32, function_offset: i32, function_length: i32, num_arguments: i32, arguments_length_offset: i32, data_offset: i32) -> i32,
pub execute_on_dest_context_func_ptr: extern "C" fn(context: *mut c_void, gas_limit: i64, address_offset: i32, value_offset: i32, function_offset: i32, function_length: i32, num_arguments: i32, arguments_length_offset: i32, data_offset: i32) -> i32,
Expand All @@ -93,6 +98,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 +108,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 +123,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 @@ -202,6 +210,10 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub mbuffer_to_big_int_signed_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, big_int_handle: i32) -> i32,
pub mbuffer_from_big_int_unsigned_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, big_int_handle: i32) -> i32,
pub mbuffer_from_big_int_signed_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, big_int_handle: i32) -> i32,
pub mbuffer_to_small_int_unsigned_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32) -> i64,
pub mbuffer_to_small_int_signed_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32) -> i64,
pub mbuffer_from_small_int_unsigned_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, value: i64),
pub mbuffer_from_small_int_signed_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, value: i64),
pub mbuffer_to_big_float_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, big_float_handle: i32) -> i32,
pub mbuffer_from_big_float_func_ptr: extern "C" fn(context: *mut c_void, m_buffer_handle: i32, big_float_handle: i32) -> i32,
pub mbuffer_storage_store_func_ptr: extern "C" fn(context: *mut c_void, key_handle: i32, source_handle: i32) -> i32,
Expand Down Expand Up @@ -265,6 +277,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
Loading
Loading