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

feat: create managed method to get sft meta #2

Merged
merged 4 commits into from
Apr 8, 2024
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@

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

## [klever-chain-vm-executor 0.2.1] - 2024-04-04

- New VM hook: `managedGetSftMetadata`.
- Memory fix.

## [klever-chain-vm-executor 0.2.0] - 2023-10-12

- New VM hook: `managedGetBackTransfers`.
- Memory fix.

## [klever-chain-vm-executor 0.1.0] - 2023-06-15

This is the initial official release of the VM executor interface. The purpose is for it to be used in the new smart contract debugger architecture.

It targets VM 1.5 and integrates the Wasmer 2.2 implementation.
1 change: 1 addition & 0 deletions c-api/libvmexeccapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ typedef struct {
void (*managed_buffer_to_hex_func_ptr)(void *context, int32_t source_handle, int32_t dest_handle);
void (*managed_get_code_metadata_func_ptr)(void *context, int32_t address_handle, int32_t response_handle);
int32_t (*managed_is_builtin_function_func_ptr)(void *context, int32_t function_name_handle);
void (*managed_get_sft_metadata_func_ptr)(void *context, int32_t ticker_handle, int64_t nonce, int32_t data_handle);
int32_t (*big_float_new_from_parts_func_ptr)(void *context, int32_t integral_part, int32_t fractional_part, int32_t exponent);
int32_t (*big_float_new_from_frac_func_ptr)(void *context, int64_t numerator, int64_t denominator);
int32_t (*big_float_new_from_sci_func_ptr)(void *context, int64_t significand, int64_t exponent);
Expand Down
1 change: 1 addition & 0 deletions c-api/src/capi_vm_hook_pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ pub struct vm_exec_vm_hook_c_func_pointers {
pub managed_buffer_to_hex_func_ptr: extern "C" fn(context: *mut c_void, source_handle: i32, dest_handle: i32),
pub managed_get_code_metadata_func_ptr: extern "C" fn(context: *mut c_void, address_handle: i32, response_handle: i32),
pub managed_is_builtin_function_func_ptr: extern "C" fn(context: *mut c_void, function_name_handle: i32) -> i32,
pub managed_get_sft_metadata_func_ptr: extern "C" fn(context: *mut c_void, ticker_handle: i32, nonce: i64, data_handle: i32),
pub big_float_new_from_parts_func_ptr: extern "C" fn(context: *mut c_void, integral_part: i32, fractional_part: i32, exponent: i32) -> i32,
pub big_float_new_from_frac_func_ptr: extern "C" fn(context: *mut c_void, numerator: i64, denominator: i64) -> i32,
pub big_float_new_from_sci_func_ptr: extern "C" fn(context: *mut c_void, significand: i64, exponent: i64) -> i32,
Expand Down
4 changes: 4 additions & 0 deletions c-api/src/capi_vm_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ impl klever_chain_vm_executor::VMHooks for CapiVMHooks {
(self.c_func_pointers_ptr.managed_is_builtin_function_func_ptr)(self.vm_hooks_ptr, function_name_handle)
}

fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) {
(self.c_func_pointers_ptr.managed_get_sft_metadata_func_ptr)(self.vm_hooks_ptr, ticker_handle, nonce, data_handle)
}

fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
(self.c_func_pointers_ptr.big_float_new_from_parts_func_ptr)(self.vm_hooks_ptr, integral_part, fractional_part, exponent)
}
Expand Down
4 changes: 2 additions & 2 deletions vm-executor-wasmer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "klever-chain-vm-executor-wasmer"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
publish = false # will also be published, but it is not yet ready for that

[lib]

[dependencies.klever-chain-vm-executor]
version = "0.2.0"
version = "0.2.1"
path = "../vm-executor"

[dependencies]
Expand Down
6 changes: 6 additions & 0 deletions vm-executor-wasmer/src/wasmer_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,11 @@ fn wasmer_import_managed_is_builtin_function(env: &VMHooksWrapper, function_name
env.vm_hooks.managed_is_builtin_function(function_name_handle)
}

#[rustfmt::skip]
fn wasmer_import_managed_get_sft_metadata(env: &VMHooksWrapper, ticker_handle: i32, nonce: i64, data_handle: i32) {
env.vm_hooks.managed_get_sft_metadata(ticker_handle, nonce, data_handle)
}

#[rustfmt::skip]
fn wasmer_import_big_float_new_from_parts(env: &VMHooksWrapper, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
env.vm_hooks.big_float_new_from_parts(integral_part, fractional_part, exponent)
Expand Down Expand Up @@ -1311,6 +1316,7 @@ pub fn generate_import_object(store: &Store, env: &VMHooksWrapper) -> ImportObje
"managedBufferToHex" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_buffer_to_hex),
"managedGetCodeMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_code_metadata),
"managedIsBuiltinFunction" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_is_builtin_function),
"managedGetSftMetadata" => Function::new_native_with_env(store, env.clone(), wasmer_import_managed_get_sft_metadata),
"bigFloatNewFromParts" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_parts),
"bigFloatNewFromFrac" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_frac),
"bigFloatNewFromSci" => Function::new_native_with_env(store, env.clone(), wasmer_import_big_float_new_from_sci),
Expand Down
2 changes: 1 addition & 1 deletion vm-executor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "klever-chain-vm-executor"
version = "0.2.0"
version = "0.2.1"
edition = "2021"

authors = []
Expand Down
5 changes: 5 additions & 0 deletions vm-executor/src/vm_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub trait VMHooks: core::fmt::Debug + 'static {
fn managed_buffer_to_hex(&self, source_handle: i32, dest_handle: i32);
fn managed_get_code_metadata(&self, address_handle: i32, response_handle: i32);
fn managed_is_builtin_function(&self, function_name_handle: i32) -> i32;
fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32);
fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32;
fn big_float_new_from_frac(&self, numerator: i64, denominator: i64) -> i32;
fn big_float_new_from_sci(&self, significand: i64, exponent: i64) -> i32;
Expand Down Expand Up @@ -713,6 +714,10 @@ impl VMHooks for VMHooksDefault {
0
}

fn managed_get_sft_metadata(&self, ticker_handle: i32, nonce: i64, data_handle: i32) {
println!("Called: managed_get_sft_metadata");
}

fn big_float_new_from_parts(&self, integral_part: i32, fractional_part: i32, exponent: i32) -> i32 {
println!("Called: big_float_new_from_parts");
0
Expand Down
Loading