Skip to content

Commit

Permalink
removed rust vm implementation, moved to a different PR
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Nov 15, 2024
1 parent c62f2f1 commit ad777eb
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 138 deletions.
10 changes: 1 addition & 9 deletions chain/vm/src/vm_hooks/vh_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -910,15 +910,7 @@ impl VMHooks for VMHooksDispatcher {
function_handle: i32,
arguments_handle: i32,
) -> i32 {
self.handler.multi_transfer_esdt_nft_execute_by_user(
user_handle,
dst_handle,
token_transfers_handle,
gas_limit as u64,
function_handle,
arguments_handle,
);
0
panic!("Unavailable: managed_multi_transfer_esdt_nft_execute_by_user")
}

fn managed_transfer_value_execute(
Expand Down
12 changes: 0 additions & 12 deletions chain/vm/src/vm_hooks/vh_handler/vh_blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,18 +244,6 @@ pub trait VMHooksBlockchain: VMHooksHandlerSource {
);
}

fn managed_multi_transfer_esdt_nft_execute_by_user(
&self,
_user_handle: RawHandle,
_dst_handle: RawHandle,
_token_transfer_handle: RawHandle,
_gas_limit: i64,
_function_name_handle: RawHandle,
_arguments_handle: RawHandle,
) -> RawHandle {
todo!()
}

fn check_esdt_frozen(
&self,
address_handle: RawHandle,
Expand Down
26 changes: 0 additions & 26 deletions chain/vm/src/vm_hooks/vh_handler/vh_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,32 +179,6 @@ pub trait VMHooksSend: VMHooksHandlerSource {
}
}

fn multi_transfer_esdt_nft_execute_by_user(
&self,
user_handle: RawHandle,
dst_handle: RawHandle,
token_transfer_handle: RawHandle,
_gas_limit: u64,
function_name_handle: RawHandle,
arguments_handle: RawHandle,
) {
let from = self.m_types_lock().mb_to_address(user_handle);
let to = self.m_types_lock().mb_to_address(dst_handle);
let payments = self
.m_types_lock()
.mb_get_vec_of_esdt_payments(token_transfer_handle);
let endpoint_name = self
.m_types_lock()
.mb_to_function_name(function_name_handle);
let arg_buffer = self.m_types_lock().mb_get_vec_of_bytes(arguments_handle);

let _sender = self.current_address();
if to.is_smart_contract_address() {
// && sender.shard == to.shard ?
self.perform_transfer_execute_by_user(from, to, payments, endpoint_name, arg_buffer);
}
}

fn async_call_raw(
&self,
to_handle: RawHandle,
Expand Down
59 changes: 2 additions & 57 deletions chain/vm/src/vm_hooks/vh_impl/vh_debug_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use multiversx_chain_vm_executor::BreakpointValue;
use crate::{
tx_execution::execute_current_tx_context_input,
tx_mock::{
async_call_tx_input, transfer_by_user_tx_input, AsyncCallTxData, BackTransfers,
BlockchainUpdate, CallType, TranferByUserData, TxCache, TxContext, TxFunctionName, TxInput,
TxManagedTypes, TxPanic, TxResult, TxTokenTransfer,
async_call_tx_input, AsyncCallTxData, BackTransfers, BlockchainUpdate, CallType, TxCache,
TxContext, TxFunctionName, TxInput, TxManagedTypes, TxPanic, TxResult,
},
types::{VMAddress, VMCodeMetadata},
vm_err_msg,
Expand Down Expand Up @@ -209,41 +208,6 @@ impl VMHooksHandlerSource for DebugApiVMHooksHandler {
_ => self.vm_error(vm_err_msg::ERROR_SIGNALLED_BY_SMARTCONTRACT),
}
}

fn perform_transfer_execute_by_user(
&self,
from: VMAddress,
to: VMAddress,
token_transfers: Vec<TxTokenTransfer>,
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
) {
let transfer_by_user_data =
self.create_transfer_by_user_data(from, to, token_transfers, func_name, arguments);
let mut tx_input =
transfer_by_user_tx_input(&transfer_by_user_data, CallType::TransferExecute);

if self.is_back_transfer(&tx_input) {
tx_input.call_type = CallType::BackTransfer;
}

let tx_cache = TxCache::new(self.0.blockchain_cache_arc());
let (tx_result, blockchain_updates) = self.0.vm_ref.execute_builtin_function_or_default(
tx_input,
tx_cache,
execute_current_tx_context_input,
);

match tx_result.result_status {
0 => {
self.0.result_lock().all_calls.push(transfer_by_user_data);

let _ = self.sync_call_post_processing(tx_result, blockchain_updates);
},
10 => self.vm_error(&tx_result.result_message), // TODO: not sure it's the right condition, it catches insufficient funds
_ => self.vm_error(vm_err_msg::ERROR_SIGNALLED_BY_SMARTCONTRACT),
}
}
}

impl DebugApiVMHooksHandler {
Expand All @@ -266,25 +230,6 @@ impl DebugApiVMHooksHandler {
}
}

fn create_transfer_by_user_data(
&self,
from: VMAddress,
to: VMAddress,
token_transfers: Vec<TxTokenTransfer>,
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
) -> TranferByUserData {
let tx_hash = self.tx_hash();
TranferByUserData {
from,
to,
token_transfers,
func_name,
arguments,
tx_hash,
}
}

fn sync_call_post_processing(
&self,
tx_result: TxResult,
Expand Down
11 changes: 0 additions & 11 deletions chain/vm/src/vm_hooks/vh_impl/vh_single_tx_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@ impl VMHooksHandlerSource for SingleTxApiVMHooksHandler {
) {
panic!("cannot launch contract calls in the SingleTxApi")
}

fn perform_transfer_execute_by_user(
&self,
_from: VMAddress,
_to: VMAddress,
_token_transfers: Vec<crate::tx_mock::TxTokenTransfer>,
_func_name: TxFunctionName,
_arguments: Vec<Vec<u8>>,
) {
panic!("cannot launch contract calls in the SingleTxApi")
}
}

impl VMHooksBigInt for SingleTxApiVMHooksHandler {}
Expand Down
11 changes: 0 additions & 11 deletions chain/vm/src/vm_hooks/vh_impl/vh_static_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,6 @@ impl VMHooksHandlerSource for StaticApiVMHooksHandler {
) {
panic!("cannot launch contract calls in the StaticApi")
}

fn perform_transfer_execute_by_user(
&self,
_from: VMAddress,
_to: VMAddress,
_token_transfers: Vec<crate::tx_mock::TxTokenTransfer>,
_func_name: TxFunctionName,
_arguments: Vec<Vec<u8>>,
) {
panic!("cannot launch contract calls in the StaticApi")
}
}

impl VMHooksBigInt for StaticApiVMHooksHandler {}
Expand Down
13 changes: 1 addition & 12 deletions chain/vm/src/vm_hooks/vh_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use std::{fmt::Debug, sync::MutexGuard};
use multiversx_chain_core::types::ReturnCode;

use crate::{
tx_mock::{
BackTransfers, TxFunctionName, TxInput, TxLog, TxManagedTypes, TxResult, TxTokenTransfer,
},
tx_mock::{BackTransfers, TxFunctionName, TxInput, TxLog, TxManagedTypes, TxResult},
types::{VMAddress, VMCodeMetadata, H256},
world_mock::{AccountData, BlockInfo},
};
Expand Down Expand Up @@ -99,13 +97,4 @@ pub trait VMHooksHandlerSource: Debug {
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
);

fn perform_transfer_execute_by_user(
&self,
from: VMAddress,
to: VMAddress,
token_transfers: Vec<TxTokenTransfer>,
func_name: TxFunctionName,
arguments: Vec<Vec<u8>>,
);
}

0 comments on commit ad777eb

Please sign in to comment.