From d6dc6b255dbda44dd8acff21cf61442bb961d769 Mon Sep 17 00:00:00 2001 From: jouzo Date: Thu, 7 Sep 2023 17:15:33 +0100 Subject: [PATCH] Clippy cleanup --- lib/ain-contracts/src/lib.rs | 2 +- lib/ain-evm/src/contract.rs | 6 ++--- lib/ain-evm/src/core.rs | 8 +++--- lib/ain-evm/src/evm.rs | 16 +++++------ lib/ain-evm/src/executor.rs | 2 +- lib/ain-evm/src/log.rs | 4 +-- lib/ain-evm/src/precompiles/simple.rs | 2 +- lib/ain-evm/src/transaction/mod.rs | 12 ++++----- lib/ain-evm/src/transaction/system.rs | 9 ++++--- lib/ain-evm/src/txqueue.rs | 29 ++++++++++---------- lib/ain-grpc/src/receipt.rs | 2 +- lib/ain-grpc/src/rpc/debug.rs | 6 ++--- lib/ain-grpc/src/rpc/eth.rs | 18 ++++++------- lib/ain-grpc/src/transaction.rs | 4 +-- lib/ain-rs-exports/src/core.rs | 6 ++--- lib/ain-rs-exports/src/evm.rs | 38 ++++++++++++++------------- lib/ain-rs-exports/src/prelude.rs | 2 +- 17 files changed, 83 insertions(+), 83 deletions(-) diff --git a/lib/ain-contracts/src/lib.rs b/lib/ain-contracts/src/lib.rs index 45242deaf7..050414d70e 100644 --- a/lib/ain-contracts/src/lib.rs +++ b/lib/ain-contracts/src/lib.rs @@ -64,7 +64,7 @@ pub fn get_dst20_deploy_input(init_bytecode: Vec, name: &str, symbol: &str) } pub fn dst20_address_from_token_id(token_id: u64) -> Result { - let number_str = format!("{:x}", token_id); + let number_str = format!("{token_id:x}"); let padded_number_str = format!("{number_str:0>38}"); let final_str = format!("ff{padded_number_str}"); diff --git a/lib/ain-evm/src/contract.rs b/lib/ain-evm/src/contract.rs index 8e42327c49..21be7827d9 100644 --- a/lib/ain-evm/src/contract.rs +++ b/lib/ain-evm/src/contract.rs @@ -84,17 +84,17 @@ pub fn intrinsics_contract( } /// Returns transfer domain address, bytecode and null storage -pub fn transfer_domain_contract() -> Result { +pub fn transfer_domain_contract() -> DeployContractInfo { let FixedContract { contract, fixed_address, } = get_transferdomain_contract(); - Ok(DeployContractInfo { + DeployContractInfo { address: fixed_address, bytecode: Bytes::from(contract.runtime_bytecode), storage: Vec::new(), - }) + } } pub fn dst20_contract( diff --git a/lib/ain-evm/src/core.rs b/lib/ain-evm/src/core.rs index bcc3128095..80e0f794bc 100644 --- a/lib/ain-evm/src/core.rs +++ b/lib/ain-evm/src/core.rs @@ -337,7 +337,7 @@ impl EVMCoreService { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn create_queue(&self) -> Result { @@ -352,7 +352,7 @@ impl EVMCoreService { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn remove_queue(&self, queue_id: u64) { @@ -362,7 +362,7 @@ impl EVMCoreService { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn remove_txs_above_hash_in( @@ -379,7 +379,7 @@ impl EVMCoreService { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn get_target_block_in(&self, queue_id: u64) -> Result { diff --git a/lib/ain-evm/src/evm.rs b/lib/ain-evm/src/evm.rs index aa4ddeaf86..306e1c8eff 100644 --- a/lib/ain-evm/src/evm.rs +++ b/lib/ain-evm/src/evm.rs @@ -69,7 +69,7 @@ impl EVMServices { let datadir = ain_cpp_imports::get_datadir(); let path = PathBuf::from(datadir).join("evm"); if !path.exists() { - std::fs::create_dir(&path)? + std::fs::create_dir(&path)?; } if let Some(state_input_path) = ain_cpp_imports::get_state_input_json() { @@ -108,7 +108,7 @@ impl EVMServices { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn construct_block_in_queue( @@ -200,7 +200,7 @@ impl EVMServices { address, storage, bytecode, - } = transfer_domain_contract()?; + } = transfer_domain_contract(); debug!("deploying {:x?} bytecode {:#?}", address, bytecode); executor.deploy_contract(address, bytecode, storage)?; @@ -246,7 +246,7 @@ impl EVMServices { total_priority_fees ); - let extra_data = format!("DFI: {}", dvm_block_number).into_bytes(); + let extra_data = format!("DFI: {dvm_block_number}").into_bytes(); let gas_limit = self.storage.get_attributes_or_default()?.block_gas_limit; let block = Block::new( PartialHeader { @@ -348,7 +348,7 @@ impl EVMServices { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn push_tx_in_queue(&self, queue_id: u64, tx: QueueTx, hash: XHash) -> Result<()> { @@ -387,7 +387,7 @@ impl EVMServices { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn is_dst20_deployed_or_queued( @@ -422,7 +422,7 @@ impl EVMServices { address, })); - let is_queued = self.core.tx_queues.get(queue_id)?.is_queued(deploy_tx); + let is_queued = self.core.tx_queues.get(queue_id)?.is_queued(&deploy_tx); Ok(is_queued) } @@ -540,7 +540,7 @@ fn get_dst20_migration_txs(mnview_ptr: usize) -> Result> { })); txs.push(QueueTxItem { tx, - tx_hash: Default::default(), + tx_hash: String::default(), gas_used: U256::zero(), state_root: H256::default(), }); diff --git a/lib/ain-evm/src/executor.rs b/lib/ain-evm/src/executor.rs index 1d4505ae2e..d652673815 100644 --- a/lib/ain-evm/src/executor.rs +++ b/lib/ain-evm/src/executor.rs @@ -357,7 +357,7 @@ impl<'backend> AinExecutor<'backend> { storage, } = dst20_contract(self.backend, address, &name, &symbol)?; - self.deploy_contract(address, bytecode.clone(), storage)?; + self.deploy_contract(address, bytecode, storage)?; let (tx, receipt) = dst20_deploy_contract_tx(token_id, &base_fee, &name, &symbol)?; Ok(ApplyTxResult { diff --git a/lib/ain-evm/src/log.rs b/lib/ain-evm/src/log.rs index 05fd586029..0ba92b30eb 100644 --- a/lib/ain-evm/src/log.rs +++ b/lib/ain-evm/src/log.rs @@ -117,8 +117,8 @@ impl LogService { pub fn get_logs_from_filter( &self, - filter: LogsFilter, - filter_type: FilterType, + filter: &LogsFilter, + filter_type: &FilterType, ) -> Result> { let block_number = match filter_type { FilterType::GetFilterChanges => filter.last_block_height, diff --git a/lib/ain-evm/src/precompiles/simple.rs b/lib/ain-evm/src/precompiles/simple.rs index 888e0f4c2d..c6e94f75ad 100644 --- a/lib/ain-evm/src/precompiles/simple.rs +++ b/lib/ain-evm/src/precompiles/simple.rs @@ -101,7 +101,7 @@ impl LinearCostPrecompile for Sha256 { } /// The ECRecoverPublicKey precompile. -/// Similar to ECRecover, but returns the pubkey (not the corresponding Ethereum address) +/// Similar to `ECRecover`, but returns the pubkey (not the corresponding Ethereum address) pub struct ECRecoverPublicKey; impl LinearCostPrecompile for ECRecoverPublicKey { diff --git a/lib/ain-evm/src/transaction/mod.rs b/lib/ain-evm/src/transaction/mod.rs index a0b8ea8e78..4e94b312ff 100644 --- a/lib/ain-evm/src/transaction/mod.rs +++ b/lib/ain-evm/src/transaction/mod.rs @@ -65,7 +65,7 @@ impl LegacyUnsignedTransaction { let sig = s.0.serialize(); let sig = TransactionSignature::new( - s.1.serialize() as u64 % 2 + chain_id * 2 + 35, + u64::from(s.1.serialize()) % 2 + chain_id * 2 + 35, H256::from_slice(&sig[0..32]), H256::from_slice(&sig[32..64]), ) @@ -266,8 +266,8 @@ impl SignedTx { pub fn v(&self) -> u64 { match &self.transaction { TransactionV2::Legacy(tx) => tx.signature.v(), - TransactionV2::EIP2930(tx) => tx.odd_y_parity as u64, - TransactionV2::EIP1559(tx) => tx.odd_y_parity as u64, + TransactionV2::EIP2930(tx) => u64::from(tx.odd_y_parity), + TransactionV2::EIP1559(tx) => u64::from(tx.odd_y_parity), } } @@ -289,16 +289,14 @@ impl SignedTx { pub fn max_fee_per_gas(&self) -> Option { match &self.transaction { - TransactionV2::Legacy(_) => None, - TransactionV2::EIP2930(_) => None, + TransactionV2::Legacy(_) | TransactionV2::EIP2930(_) => None, TransactionV2::EIP1559(tx) => Some(tx.max_fee_per_gas), } } pub fn max_priority_fee_per_gas(&self) -> Option { match &self.transaction { - TransactionV2::Legacy(_) => None, - TransactionV2::EIP2930(_) => None, + TransactionV2::Legacy(_) | TransactionV2::EIP2930(_) => None, TransactionV2::EIP1559(tx) => Some(tx.max_priority_fee_per_gas), } } diff --git a/lib/ain-evm/src/transaction/system.rs b/lib/ain-evm/src/transaction/system.rs index b054aad3f7..13740d8302 100644 --- a/lib/ain-evm/src/transaction/system.rs +++ b/lib/ain-evm/src/transaction/system.rs @@ -35,7 +35,7 @@ impl SystemTx { match self { SystemTx::TransferDomain(data) => Some(data.signed_tx.sender), SystemTx::DST20Bridge(data) => Some(data.signed_tx.sender), - _ => None, + SystemTx::DeployContract(_) => None, } } } @@ -48,9 +48,10 @@ pub enum TransferDirection { impl From for TransferDirection { fn from(direction: bool) -> TransferDirection { - match direction { - true => TransferDirection::EvmIn, - false => TransferDirection::EvmOut, + if direction { + TransferDirection::EvmIn + } else { + TransferDirection::EvmOut } } } diff --git a/lib/ain-evm/src/txqueue.rs b/lib/ain-evm/src/txqueue.rs index 44f19e0a59..f30638799f 100644 --- a/lib/ain-evm/src/txqueue.rs +++ b/lib/ain-evm/src/txqueue.rs @@ -44,7 +44,7 @@ impl TransactionQueueMap { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn create(&self, target_block: U256, state_root: H256) -> u64 { @@ -69,7 +69,7 @@ impl TransactionQueueMap { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn remove(&self, queue_id: u64) -> Option> { @@ -115,7 +115,7 @@ impl TransactionQueueMap { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn push_in( @@ -139,7 +139,7 @@ impl TransactionQueueMap { /// /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn remove_txs_above_hash_in( @@ -163,29 +163,29 @@ impl TransactionQueueMap { /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn get_total_gas_used_in(&self, queue_id: u64) -> Result { - self.with_transaction_queue(queue_id, |queue| queue.get_total_gas_used()) + self.with_transaction_queue(queue_id, TransactionQueue::get_total_gas_used) } /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn get_target_block_in(&self, queue_id: u64) -> Result { - self.with_transaction_queue(queue_id, |queue| queue.get_target_block()) + self.with_transaction_queue(queue_id, TransactionQueue::get_target_block) } /// # Safety /// - /// Result cannot be used safety unless cs_main lock is taken on C++ side + /// Result cannot be used safety unless `cs_main` lock is taken on C++ side /// across all usages. Note: To be replaced with a proper lock flow later. /// pub unsafe fn get_latest_state_root_in(&self, queue_id: u64) -> Result { - self.with_transaction_queue(queue_id, |queue| queue.get_latest_state_root()) + self.with_transaction_queue(queue_id, TransactionQueue::get_latest_state_root) } /// Apply the closure to the queue associated with the queue ID. @@ -288,7 +288,7 @@ impl TransactionQueue { .insert(signed_tx.sender, signed_tx.nonce()); data.total_gas_used += gas_used; } - _ => (), + QueueTx::SystemTx(_) => (), } data.transactions.push(QueueTxItem { tx, @@ -361,17 +361,16 @@ impl TransactionQueue { let data = self.data.lock().unwrap(); data.transactions .last() - .map(|tx_item| tx_item.state_root) - .unwrap_or(data.initial_state_root) + .map_or(data.initial_state_root, |tx_item| tx_item.state_root) } - pub fn is_queued(&self, tx: QueueTx) -> bool { + pub fn is_queued(&self, tx: &QueueTx) -> bool { self.data .lock() .unwrap() .transactions .iter() - .any(|queued| queued.tx == tx) + .any(|queued| &queued.tx == tx) } } diff --git a/lib/ain-grpc/src/receipt.rs b/lib/ain-grpc/src/receipt.rs index 2a58496cfa..a9d19ccfe7 100644 --- a/lib/ain-grpc/src/receipt.rs +++ b/lib/ain-grpc/src/receipt.rs @@ -43,7 +43,7 @@ impl From for ReceiptResult { block_number: b.block_number, contract_address: b.contract_address, cumulative_gas_used: b.cumulative_gas, - effective_gas_price: Default::default(), + effective_gas_price: U256::default(), from: b.from, gas_used: data.used_gas, logs: { diff --git a/lib/ain-grpc/src/rpc/debug.rs b/lib/ain-grpc/src/rpc/debug.rs index 9bf7b55367..a427105841 100644 --- a/lib/ain-grpc/src/rpc/debug.rs +++ b/lib/ain-grpc/src/rpc/debug.rs @@ -76,13 +76,13 @@ impl MetachainDebugRPCServer for MetachainDebugRPCModule { ro_handle.iter().for_each(|el| match el { Ok((_, v)) => { if let Ok(account) = Account::decode(&Rlp::new(&v)) { - debug!("[log_account_states] account {:?}", account) + debug!("[log_account_states] account {:?}", account); } else { - debug!("[log_account_states] Error decoding account {:?}", v) + debug!("[log_account_states] Error decoding account {:?}", v); } } Err(e) => { - debug!("[log_account_states] Error on iter element {e}") + debug!("[log_account_states] Error on iter element {e}"); } }); diff --git a/lib/ain-grpc/src/rpc/eth.rs b/lib/ain-grpc/src/rpc/eth.rs index f93a134e69..a4d881b7ec 100644 --- a/lib/ain-grpc/src/rpc/eth.rs +++ b/lib/ain-grpc/src/rpc/eth.rs @@ -871,19 +871,19 @@ impl MetachainRPCServer for MetachainRPCModule { } } fn get_uncle_count_by_block_number(&self) -> RpcResult { - Ok(Default::default()) + Ok(U256::default()) } fn get_uncle_count_by_block_hash(&self) -> RpcResult { - Ok(Default::default()) + Ok(U256::default()) } fn get_uncle_by_block_number(&self) -> RpcResult> { - Ok(Default::default()) + Ok(None) } fn get_uncle_by_block_hash(&self) -> RpcResult> { - Ok(Default::default()) + Ok(None) } fn get_logs(&self, input: GetLogsRequest) -> RpcResult> { @@ -1005,7 +1005,7 @@ impl MetachainRPCServer for MetachainRPCModule { let logs = self .handler .logs - .get_logs_from_filter(filter, FilterType::GetFilterChanges) + .get_logs_from_filter(&filter, &FilterType::GetFilterChanges) .map_err(to_jsonrpsee_custom_error)? .into_iter() .map(LogResult::from) @@ -1051,7 +1051,7 @@ impl MetachainRPCServer for MetachainRPCModule { let logs = self .handler .logs - .get_logs_from_filter(filter, FilterType::GetFilterLogs) + .get_logs_from_filter(&filter, &FilterType::GetFilterLogs) .map_err(to_jsonrpsee_custom_error)? .into_iter() .map(LogResult::from) @@ -1072,7 +1072,7 @@ fn sign( message: TransactionMessage, ) -> Result> { debug!("sign address {:#x}", address); - let key = format!("{:?}", address); + let key = format!("{address:?}"); let priv_key = get_eth_priv_key(key).unwrap(); let secret_key = SecretKey::parse(&priv_key).unwrap(); @@ -1082,8 +1082,8 @@ fn sign( .map_err(|_| Error::Custom(String::from("invalid signing message")))?; let (signature, recid) = libsecp256k1::sign(&signing_message, &secret_key); let v = match m.chain_id { - None => 27 + recid.serialize() as u64, - Some(chain_id) => 2 * chain_id + 35 + recid.serialize() as u64, + None => 27 + u64::from(recid.serialize()), + Some(chain_id) => 2 * chain_id + 35 + u64::from(recid.serialize()), }; let rs = signature.serialize(); let r = H256::from_slice(&rs[0..32]); diff --git a/lib/ain-grpc/src/transaction.rs b/lib/ain-grpc/src/transaction.rs index 02bc9c9f23..3565cdde4e 100644 --- a/lib/ain-grpc/src/transaction.rs +++ b/lib/ain-grpc/src/transaction.rs @@ -21,13 +21,13 @@ impl From for EthTransactionInfo { .access_list .clone() .into_iter() - .map(|list| list.into()) + .map(std::convert::Into::into) .collect(), TransactionV2::EIP1559(tx) => tx .access_list .clone() .into_iter() - .map(|list| list.into()) + .map(std::convert::Into::into) .collect(), }; diff --git a/lib/ain-rs-exports/src/core.rs b/lib/ain-rs-exports/src/core.rs index 727ae0d008..346444232a 100644 --- a/lib/ain-rs-exports/src/core.rs +++ b/lib/ain-rs-exports/src/core.rs @@ -26,21 +26,21 @@ pub fn ain_rs_init_network_services( grpc_addr: &str, ) { match ain_grpc::init_network_services(json_addr, grpc_addr) { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } pub fn ain_rs_stop_network_services(result: &mut CrossBoundaryResult) { match ain_grpc::stop_network_services() { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } pub fn ain_rs_wipe_evm_folder(result: &mut CrossBoundaryResult) { match ain_grpc::wipe_evm_folder() { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } diff --git a/lib/ain-rs-exports/src/evm.rs b/lib/ain-rs-exports/src/evm.rs index 624157d88b..649a8b7401 100644 --- a/lib/ain-rs-exports/src/evm.rs +++ b/lib/ain-rs-exports/src/evm.rs @@ -17,8 +17,10 @@ use ethereum_types::{H160, U256}; use log::debug; use transaction::{LegacyUnsignedTransaction, TransactionError, LOWER_H256}; -use crate::ffi::{self, TxSenderInfo}; -use crate::prelude::*; +use crate::{ + ffi::{self, TxSenderInfo}, + prelude::*, +}; /// Creates and signs a transaction. /// @@ -223,14 +225,14 @@ pub fn evm_try_create_and_sign_transfer_domain_tx( let Ok(nonce) = SERVICES.evm.get_nonce(from_address) else { return cross_boundary_error_return( result, - format!("Could not get nonce for {:x?}", from_address), + format!("Could not get nonce for {from_address:x?}"), ); }; let t = LegacyUnsignedTransaction { nonce, gas_price: base_fee, - gas_limit: U256::from(100000), + gas_limit: U256::from(100_000), action, value: U256::zero(), input, @@ -275,7 +277,7 @@ pub fn evm_try_get_balance(result: &mut ffi::CrossBoundaryResult, address: &str) } } -/// Removes all transactions in the queue whose sender matches the provided sender address in a specific queue_id +/// Removes all transactions in the queue whose sender matches the provided sender address in a specific `queue_id` /// /// # Arguments /// @@ -299,7 +301,7 @@ pub fn evm_unsafe_try_remove_txs_above_hash_in_q( } } -/// EvmIn. Send DFI to an EVM account. +/// `EvmIn`. Send DFI to an EVM account. /// /// # Arguments /// @@ -328,13 +330,13 @@ pub fn evm_unsafe_try_add_balance_in_q( .evm .push_tx_in_queue(queue_id, queue_tx, native_hash) { - Ok(_) => cross_boundary_success_return(result, ()), + Ok(()) => cross_boundary_success_return(result, ()), Err(e) => cross_boundary_error_return(result, e.to_string()), } } } -/// EvmOut. Send DFI from an EVM account. +/// `EvmOut`. Send DFI from an EVM account. /// /// # Arguments /// @@ -346,7 +348,7 @@ pub fn evm_unsafe_try_add_balance_in_q( /// # Errors /// /// Returns an Error if: -/// - the queue_id does not match any existing queue +/// - the `queue_id` does not match any existing queue /// - the address is not a valid EVM address /// - the account has insufficient balance. /// @@ -374,7 +376,7 @@ pub fn evm_unsafe_try_sub_balance_in_q( .evm .push_tx_in_queue(queue_id, queue_tx, native_hash) { - Ok(_) => cross_boundary_success_return(result, true), + Ok(()) => cross_boundary_success_return(result, true), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -411,7 +413,7 @@ pub fn evm_unsafe_try_validate_raw_tx_in_q( ) -> ffi::ValidateTxMiner { debug!("[evm_unsafe_try_validate_raw_tx_in_q]"); match SERVICES.evm.verify_tx_fees(raw_tx) { - Ok(_) => (), + Ok(()) => (), Err(e) => { debug!("evm_try_validate_raw_tx failed with error: {e}"); return cross_boundary_error_return(result, e.to_string()); @@ -506,7 +508,7 @@ pub fn evm_unsafe_try_push_tx_in_q( .evm .push_tx_in_queue(queue_id, signed_tx.into(), native_hash) { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -583,7 +585,7 @@ pub fn evm_unsafe_try_construct_block_in_q( pub fn evm_unsafe_try_commit_queue(result: &mut ffi::CrossBoundaryResult, queue_id: u64) { unsafe { match SERVICES.evm.commit_queue(queue_id) { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -591,7 +593,7 @@ pub fn evm_unsafe_try_commit_queue(result: &mut ffi::CrossBoundaryResult, queue_ pub fn evm_try_disconnect_latest_block(result: &mut ffi::CrossBoundaryResult) { match SERVICES.evm.storage.disconnect_latest_block() { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -815,7 +817,7 @@ pub fn evm_try_get_tx_by_hash( TransactionAction::Create => true, }, to: match tx.to() { - Some(to) => format!("{:?}", to), + Some(to) => format!("{to:?}"), None => XHash::new(), }, value, @@ -855,7 +857,7 @@ pub fn evm_try_create_dst20( .evm .push_tx_in_queue(queue_id, system_tx, native_hash) { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -888,7 +890,7 @@ pub fn evm_try_bridge_dst20( .evm .push_tx_in_queue(queue_id, system_tx, native_hash) { - Ok(_) => cross_boundary_success(result), + Ok(()) => cross_boundary_success(result), Err(e) => cross_boundary_error_return(result, e.to_string()), } } @@ -902,7 +904,7 @@ pub fn evm_try_bridge_dst20( /// /// # Returns /// -/// Returns the target block for a specific queue_id as a `u64` +/// Returns the target block for a specific `queue_id` as a `u64` pub fn evm_unsafe_try_get_target_block_in_q( result: &mut ffi::CrossBoundaryResult, queue_id: u64, diff --git a/lib/ain-rs-exports/src/prelude.rs b/lib/ain-rs-exports/src/prelude.rs index 6cbb01fb18..f5f0467377 100644 --- a/lib/ain-rs-exports/src/prelude.rs +++ b/lib/ain-rs-exports/src/prelude.rs @@ -2,7 +2,7 @@ use crate::ffi; pub fn cross_boundary_success(result: &mut ffi::CrossBoundaryResult) { result.ok = true; - result.reason = Default::default(); + result.reason = String::default(); } pub fn cross_boundary_error>(result: &mut ffi::CrossBoundaryResult, message: S) {