Skip to content

Commit

Permalink
perf: removed useless code and fixed log level
Browse files Browse the repository at this point in the history
  • Loading branch information
toints committed May 21, 2024
1 parent e9d6f4f commit c2ad635
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
5 changes: 1 addition & 4 deletions pallets/assets-bridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

pub use crate as assets_bridge;
pub use assets_bridge::{Config, Error, Event as AssetsBridgeEvent};

use sp_std::collections::btree_set::BTreeSet;
pub use assets_bridge::{Error, Event as AssetsBridgeEvent};

use frame_support::{
derive_impl,
Expand All @@ -27,7 +25,6 @@ use frame_system::EnsureSigned;

use sp_core::{H160, H256};
pub use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
AccountId32, BuildStorage,
};
Expand Down
18 changes: 8 additions & 10 deletions pallets/evm/precompile/transfer-to-magnet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ where
let target_gas = handle.gas_limit();
let context = handle.context();

log::info!(
log::debug!(
"codeAddress:{:?}, input:{:?}, targetGas:{:?}",
&code_address,
&input,
Expand All @@ -103,9 +103,7 @@ where

let token_addr = solidity::decode_arguments::<Address>(&input[4..36])?;
let amount = solidity::decode_arguments::<u128>(&input[36..68])?;
log::info!("Caller:{:?}, tokenAddr:{:?}, amount:{:?}", &caller, &token_addr, &amount);

log::info!("who bstr data len:{:?}", &input[100..].len());
log::debug!("Caller:{:?}, tokenAddr:{:?}, amount:{:?}", &caller, &token_addr, &amount);

if handle.is_static() {
log::error!("Can't be static call error");
Expand All @@ -123,12 +121,12 @@ where
});
},
};
log::info!("to who ss58:{:?}", &to_who_ss58);
log::debug!("to who ss58:{:?}", &to_who_ss58);
let to_who_id32 =
AccountId32::from_ss58check(&to_who_ss58).map_err(|_| PrecompileFailure::Error {
exit_status: ExitError::Other("AccountId32 from ss58check(string) failed".into()),
})?;
log::info!("to_who_ss58:{:?}, to_who_id32:{:?}", &to_who_ss58, &to_who_id32);
log::debug!("to_who_ss58:{:?}, to_who_id32:{:?}", &to_who_ss58, &to_who_id32);

let to_who: <T>::AccountId = to_who_id32.clone().into();

Expand All @@ -153,7 +151,7 @@ where

let amount_saturated: T::Balance = amount.into();

log::info!(
log::debug!(
"Preparing to mint: AssetId: {:?}, Beneficiary: {:?}, Amount: {:?}",
&asset_id,
&to_who_ss58,
Expand Down Expand Up @@ -238,9 +236,9 @@ where
}

let length_bytes = &input[offset..offset + 32];
log::info!("length_bytes:{:?}", &length_bytes);
log::debug!("length_bytes:{:?}", &length_bytes);
let length = u32::from_be_bytes(length_bytes[28..32].try_into().unwrap()) as usize;
log::info!("ss58 string len:{:?}", length);
log::debug!("ss58 string len:{:?}", length);

if input.len() < offset + 32 + length {
return Err("Input too short to contain string data");
Expand All @@ -249,7 +247,7 @@ where
let string_data_start = offset + 32;
let string_data_end = string_data_start + length;
let string_data = &input[string_data_start..string_data_end];
log::info!("ss58 string data:{:?}", &string_data);
log::debug!("ss58 string data:{:?}", &string_data);

let mut result_string = from_utf8(string_data)
.map_err(|_| "String data is not valid UTF-8")?
Expand Down
1 change: 0 additions & 1 deletion pallets/evm/precompile/transfer-to-magnet/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use sp_std::collections::{btree_map::BTreeMap, btree_set::BTreeSet};
use std::str::FromStr;

use xcm::latest::prelude::BodyId;
Expand Down

0 comments on commit c2ad635

Please sign in to comment.