diff --git a/src/components/abciapp/src/abci/staking/test.rs b/src/components/abciapp/src/abci/staking/test.rs index cc0bc2346..b046ba6fb 100644 --- a/src/components/abciapp/src/abci/staking/test.rs +++ b/src/components/abciapp/src/abci/staking/test.rs @@ -64,7 +64,7 @@ fn check_block_rewards_rate() -> Result<()> { { let rate = ledger.staking_get_block_rewards_rate(); - let rate = [rate[0] as u128, rate[1] as u128]; + let rate = [rate[0], rate[1]]; // max value: 105% assert!(rate[0] * 100 <= rate[1] * 105); // min value: 2% diff --git a/src/components/abciapp/src/api/query_server/query_api/ledger_api.rs b/src/components/abciapp/src/api/query_server/query_api/ledger_api.rs index 664747e66..4a80483e2 100644 --- a/src/components/abciapp/src/api/query_server/query_api/ledger_api.rs +++ b/src/components/abciapp/src/api/query_server/query_api/ledger_api.rs @@ -253,7 +253,7 @@ pub async fn query_validators( }) .collect(); return Ok(web::Json(ValidatorList::new( - staking.cur_height() as u64, + staking.cur_height(), validators_list, ))); }; diff --git a/src/components/contracts/modules/evm/tests/utils/solidity.rs b/src/components/contracts/modules/evm/tests/utils/solidity.rs index 17ea27a17..6fda0f06f 100644 --- a/src/components/contracts/modules/evm/tests/utils/solidity.rs +++ b/src/components/contracts/modules/evm/tests/utils/solidity.rs @@ -30,7 +30,7 @@ impl ContractConstructor { { let bin_file = format!("{}.bin", contract_name); let abi_file = format!("{}.abi", contract_name); - let hex_path = artifacts_base_path.as_ref().join(&bin_file); + let hex_path = artifacts_base_path.as_ref().join(bin_file); let hex_rep = match std::fs::read_to_string(&hex_path) { Ok(hex) => hex, Err(_) => { @@ -40,8 +40,8 @@ impl ContractConstructor { std::fs::read_to_string(hex_path).unwrap() } }; - let code = hex::decode(&hex_rep).unwrap(); - let abi_path = artifacts_base_path.as_ref().join(&abi_file); + let code = hex::decode(hex_rep).unwrap(); + let abi_path = artifacts_base_path.as_ref().join(abi_file); let reader = std::fs::File::open(abi_path).unwrap(); let abi = ethabi::Contract::load(reader).unwrap(); diff --git a/src/components/contracts/primitives/mocks/src/lib.rs b/src/components/contracts/primitives/mocks/src/lib.rs index 339e1cb08..7e297349b 100644 --- a/src/components/contracts/primitives/mocks/src/lib.rs +++ b/src/components/contracts/primitives/mocks/src/lib.rs @@ -91,7 +91,7 @@ pub struct KeyPair { } pub fn generate_address(seed: u8) -> KeyPair { - let private_key = H256::from_slice(&[(seed + 1) as u8; 32]); + let private_key = H256::from_slice(&[seed + 1; 32]); let secret_key = libsecp256k1::SecretKey::parse_slice(&private_key[..]).unwrap(); let public_key = &libsecp256k1::PublicKey::from_secret_key(&secret_key).serialize()[1..65]; diff --git a/src/components/contracts/primitives/types/src/crypto.rs b/src/components/contracts/primitives/types/src/crypto.rs index 7649e5323..3759feec9 100644 --- a/src/components/contracts/primitives/types/src/crypto.rs +++ b/src/components/contracts/primitives/types/src/crypto.rs @@ -411,7 +411,7 @@ pub fn secp256k1_ecdsa_recover(sig: &[u8; 65], msg: &[u8; 32]) -> ruc::Result<[u .map_err(|_| eg!("Ecdsa signature verify error: bad RS"))?; let v = libsecp256k1::RecoveryId::parse( - if sig[64] > 26 { sig[64] - 27 } else { sig[64] } as u8, + if sig[64] > 26 { sig[64] - 27 } else { sig[64] } ) .map_err(|_| eg!("Ecdsa signature verify error: bad V"))?; let pubkey = libsecp256k1::recover(&libsecp256k1::Message::parse(msg), &rs, &v) diff --git a/src/components/contracts/primitives/utils/src/ecdsa.rs b/src/components/contracts/primitives/utils/src/ecdsa.rs index 0ed8c9686..8f262a619 100644 --- a/src/components/contracts/primitives/utils/src/ecdsa.rs +++ b/src/components/contracts/primitives/utils/src/ecdsa.rs @@ -72,7 +72,7 @@ impl<'de> Deserialize<'de> for Public { D: Deserializer<'de>, { let pk = - base64::decode_config(&String::deserialize(deserializer)?, base64::URL_SAFE) + base64::decode_config(String::deserialize(deserializer)?, base64::URL_SAFE) .map_err(|e| de::Error::custom(format!("{:?}", e)))?; Public::try_from(pk.as_slice()) .map_err(|e| de::Error::custom(format!("{:?}", e))) @@ -173,7 +173,7 @@ impl<'de> Deserialize<'de> for Signature { where D: Deserializer<'de>, { - let signature_hex = hex::decode(&String::deserialize(deserializer)?) + let signature_hex = hex::decode(String::deserialize(deserializer)?) .map_err(|e| de::Error::custom(format!("{:?}", e)))?; Signature::try_from(signature_hex.as_ref()) .map_err(|e| de::Error::custom(format!("{:?}", e))) diff --git a/src/components/contracts/primitives/utils/src/lib.rs b/src/components/contracts/primitives/utils/src/lib.rs index 5b3a12983..cd8b15993 100644 --- a/src/components/contracts/primitives/utils/src/lib.rs +++ b/src/components/contracts/primitives/utils/src/lib.rs @@ -10,7 +10,7 @@ use primitive_types::H160; pub fn timestamp_converter(timestamp: protobuf::well_known_types::Timestamp) -> u64 { let unix_time = core::time::Duration::new(timestamp.seconds as u64, timestamp.nanos as u32); - unix_time.as_secs() as u64 + unix_time.as_secs() } pub fn proposer_converter(address: Vec) -> Option { diff --git a/src/components/contracts/primitives/wasm/src/wasm.rs b/src/components/contracts/primitives/wasm/src/wasm.rs index d02cbde2d..562511d73 100644 --- a/src/components/contracts/primitives/wasm/src/wasm.rs +++ b/src/components/contracts/primitives/wasm/src/wasm.rs @@ -35,7 +35,7 @@ pub fn recover_signer(transaction: &Transaction) -> Option { #[wasm_bindgen] pub fn recover_tx_signer(raw_tx: String) -> Result { - let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE) + let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE) .c(d!()) .map_err(error_to_jsvalue)?; let raw_tx = EvmRawTxWrapper::unwrap(&tx_bytes) @@ -55,7 +55,7 @@ pub fn recover_tx_signer(raw_tx: String) -> Result { #[wasm_bindgen] pub fn evm_tx_hash(raw_tx: String) -> Result { - let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE) + let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE) .c(d!()) .map_err(error_to_jsvalue)?; let raw_tx = EvmRawTxWrapper::unwrap(&tx_bytes) @@ -82,7 +82,7 @@ mod test { #[test] fn recover_signer_works() { let raw_tx = String::from("ZXZtOnsic2lnbmF0dXJlIjpudWxsLCJmdW5jdGlvbiI6eyJFdGhlcmV1bSI6eyJUcmFuc2FjdCI6eyJub25jZSI6IjB4MSIsImdhc19wcmljZSI6IjB4MTc0ODc2ZTgwMCIsImdhc19saW1pdCI6IjB4NTIwOCIsImFjdGlvbiI6eyJDYWxsIjoiMHgyYWQzMjg0NmM2ZGQyZmZkM2VkYWRiZTUxY2Q1YWUwNGFhNWU1NzVlIn0sInZhbHVlIjoiMHg1NmJjNzVlMmQ2MzEwMDAwMCIsImlucHV0IjpbXSwic2lnbmF0dXJlIjp7InYiOjEwODIsInIiOiIweGY4YWVmN2Y4MDUzZDg5ZmVlMzk1MGM0ZDcwMjA4MGJmM2E4MDcyYmVkNWQ4NGEzYWYxOWEzNjAwODFiNjM2YTIiLCJzIjoiMHgyOTYyOTlhOGYyNDMwYjg2ZmQzZWI5NzZlYWJjNzMwYWMxY2ZiYmJlMzZlYjY5ZWFlMzM4Y2ZmMzNjNGE5OGMxIn19fX19"); - let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE).unwrap(); + let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE).unwrap(); let evm_tx = EvmRawTxWrapper::unwrap(&tx_bytes).unwrap(); let unchecked_tx: UncheckedTransaction<()> = serde_json::from_slice(evm_tx).unwrap(); @@ -100,7 +100,7 @@ mod test { #[test] fn evm_tx_hash_works() { let raw_tx = String::from("eyJzaWduYXR1cmUiOm51bGwsImZ1bmN0aW9uIjp7IkV0aGVyZXVtIjp7IlRyYW5zYWN0Ijp7Im5vbmNlIjoiMHg5IiwiZ2FzX3ByaWNlIjoiMHhlOGQ0YTUxMDAwIiwiZ2FzX2xpbWl0IjoiMHg1MjA4IiwiYWN0aW9uIjp7IkNhbGwiOiIweGE1MjI1Y2JlZTUwNTIxMDBlYzJkMmQ5NGFhNmQyNTg1NTgwNzM3NTcifSwidmFsdWUiOiIweDk4YTdkOWI4MzE0YzAwMDAiLCJpbnB1dCI6W10sInNpZ25hdHVyZSI6eyJ2IjoxMDgyLCJyIjoiMHg4MDBjZjQ5ZTAzMmJhYzY4MjY3MzdhZGJhZDEzN2Y0MTk5OTRjNjgxZWE1ZDUyYjliMGJhZDJmNDAyYjMwMTI0IiwicyI6IjB4Mjk1Mjc3ZWY2NTYzNDAwY2VkNjFiODhkM2ZiNGM3YjMyY2NkNTcwYThiOWJiOGNiYmUyNTkyMTRhYjdkZTI1YSJ9fX19fQ=="); - let tx_bytes = base64::decode_config(&raw_tx, base64::URL_SAFE).unwrap(); + let tx_bytes = base64::decode_config(raw_tx, base64::URL_SAFE).unwrap(); let unchecked_tx: UncheckedTransaction<()> = serde_json::from_slice(tx_bytes.as_slice()).unwrap(); if let Action::Ethereum(EthAction::Transact(tx)) = unchecked_tx.function { diff --git a/src/components/contracts/rpc/src/eth_pubsub.rs b/src/components/contracts/rpc/src/eth_pubsub.rs index d5a79b07b..1d7d94206 100644 --- a/src/components/contracts/rpc/src/eth_pubsub.rs +++ b/src/components/contracts/rpc/src/eth_pubsub.rs @@ -228,7 +228,7 @@ impl SubscriptionResult { let transaction_hash: Option = if !receipt.logs.is_empty() { Some(H256::from_slice( Keccak256::digest(&rlp::encode( - &block.transactions[receipt_index as usize], + &block.transactions[receipt_index], )) .as_slice(), )) diff --git a/src/components/finutils/src/bins/stt/init/i_testing.rs b/src/components/finutils/src/bins/stt/init/i_testing.rs index 0adf1a933..909fdc10a 100644 --- a/src/components/finutils/src/bins/stt/init/i_testing.rs +++ b/src/components/finutils/src/bins/stt/init/i_testing.rs @@ -395,7 +395,7 @@ struct TmValidator { fn get_26657_validators(sa: &str) -> Result { let url = format!("{}:26657/validators", sa); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() diff --git a/src/components/finutils/src/common/utils.rs b/src/components/finutils/src/common/utils.rs index 11223b741..c9639682c 100644 --- a/src/components/finutils/src/common/utils.rs +++ b/src/components/finutils/src/common/utils.rs @@ -42,7 +42,7 @@ pub fn new_tx_builder() -> Result { #[allow(missing_docs)] pub fn send_tx(tx: &Transaction) -> Result<()> { let url = format!("{}:8669/submit_transaction", get_serv_addr().c(d!())?); - attohttpc::post(&url) + attohttpc::post(url) .header(attohttpc::header::CONTENT_TYPE, "application/json") .bytes(&serde_json::to_vec(tx).c(d!())?) .send() @@ -372,7 +372,7 @@ struct TmStatus { fn get_network_status(addr: &str) -> Result { let url = format!("{}:26657/status", addr); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -403,7 +403,7 @@ pub fn get_local_block_height() -> u64 { pub fn get_asset_type(code: &str) -> Result { let url = format!("{}:8668/asset_token/{}", get_serv_addr().c(d!())?, code); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -421,7 +421,7 @@ pub fn get_created_assets(addr: &XfrPublicKey) -> Result> { wallet::public_key_to_base64(addr) ); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -474,7 +474,7 @@ fn get_owned_utxos_x( wallet::public_key_to_base64(addr) ); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -497,7 +497,7 @@ fn get_seq_id() -> Result { let url = format!("{}:8668/global_state", get_serv_addr().c(d!())?); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -522,7 +522,7 @@ pub fn get_owner_memo_batch(ids: &[TxoSID]) -> Result>> { ids ); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -540,7 +540,7 @@ pub fn get_delegation_info(pk: &XfrPublicKey) -> Result { wallet::public_key_to_base64(pk) ); - attohttpc::get(&url) + attohttpc::get(url) .send() .c(d!())? .error_for_status() @@ -558,7 +558,7 @@ pub fn get_validator_detail(td_addr: TendermintAddrRef) -> Result Transaction { let issuance_operation = Operation::IssueAsset(asset_issuance.clone()); // Instantiate an DefineAsset operation - let mut asset = Box::new(Asset::default()); + let mut asset = Box::::default(); asset.code = AssetTypeCode::gen_random(); let asset_creation = DefineAsset::new( diff --git a/src/ledger/src/staking/cosig.rs b/src/ledger/src/staking/cosig.rs index 8214d125d..68fc8b63b 100644 --- a/src/ledger/src/staking/cosig.rs +++ b/src/ledger/src/staking/cosig.rs @@ -170,7 +170,7 @@ pub struct CoSigRule { impl CoSigRule { #[allow(missing_docs)] pub fn new(threshold: [u64; 2]) -> Result { - if threshold[0] > threshold[1] || threshold[1] > MAX_TOTAL_POWER as u64 { + if threshold[0] > threshold[1] || threshold[1] > MAX_TOTAL_POWER { return Err(eg!("invalid threshold")); } @@ -263,7 +263,7 @@ mod test { vd.cosig_rule = pnk!(CoSigRule::new([75, 100])); assert!(CoSigRule::new([200, 100]).is_err()); - assert!(CoSigRule::new([200, 1 + MAX_TOTAL_POWER as u64]).is_err()); + assert!(CoSigRule::new([200, 1 + MAX_TOTAL_POWER]).is_err()); let mut data = CoSigOp::create(Data::default(), no_replay_token()); pnk!(data.batch_sign(&kps.iter().skip(10).collect::>())); diff --git a/src/ledger/src/staking/mod.rs b/src/ledger/src/staking/mod.rs index fad64be7d..c2b2b201e 100644 --- a/src/ledger/src/staking/mod.rs +++ b/src/ledger/src/staking/mod.rs @@ -378,7 +378,7 @@ impl Staking { ) -> Result> { self.validator_info .remove(&h) - .map(|v| v.body.into_iter().map(|(_, v)| v).collect()) + .map(|v| v.body.into_values().collect()) .c(d!("not exists")) } diff --git a/src/ledger/src/store/api_cache.rs b/src/ledger/src/store/api_cache.rs index edd82a237..fedd7efaa 100644 --- a/src/ledger/src/store/api_cache.rs +++ b/src/ledger/src/store/api_cache.rs @@ -452,7 +452,7 @@ pub fn check_lost_data(ledger: &mut LedgerState) -> Result<()> { .as_mut() .unwrap() .last_sid - .insert("last_txo_sid".to_string(), index as u64); + .insert("last_txo_sid".to_string(), index); } } Ok(()) diff --git a/src/ledger/src/store/mod.rs b/src/ledger/src/store/mod.rs index 2339f8867..60e9b316b 100644 --- a/src/ledger/src/store/mod.rs +++ b/src/ledger/src/store/mod.rs @@ -1130,7 +1130,7 @@ impl LedgerStatus { ); if seq_id > self.block_commit_count { return Err(eg!(("Transaction seq_id ahead of block_count"))); - } else if seq_id + (TRANSACTION_WINDOW_WIDTH as u64) < self.block_commit_count { + } else if seq_id + TRANSACTION_WINDOW_WIDTH < self.block_commit_count { return Err(eg!(("Transaction seq_id too far behind block_count"))); } else { // Check to see that this nrpt has not been seen before diff --git a/src/libs/bitmap/src/lib.rs b/src/libs/bitmap/src/lib.rs index 26174cb77..3564a068b 100644 --- a/src/libs/bitmap/src/lib.rs +++ b/src/libs/bitmap/src/lib.rs @@ -567,7 +567,7 @@ fn count_byte(mask: usize) -> u8 { let mut result = 0; for i in 0..8 { - result += if mask & (1 << i) == 0 { 0 } else { 1 }; + result += u8::from(mask & (1 << i) != 0); } result @@ -1098,7 +1098,7 @@ impl BitMap { // Append a list of the set bits to the serialization // results. fn append_set(&self, index: usize, result: &mut Vec) { - let set_bits = self.set_bits[index] as u32; + let set_bits = self.set_bits[index]; // Append the header to the serialization. self.append_header(index, BIT_DESC_SET, set_bits, result); diff --git a/src/libs/globutils/src/wallet.rs b/src/libs/globutils/src/wallet.rs index 83cf0c882..0fdebbbeb 100644 --- a/src/libs/globutils/src/wallet.rs +++ b/src/libs/globutils/src/wallet.rs @@ -173,7 +173,7 @@ fn check_lang(lang: &str) -> Result { /// Convert a XfrPublicKey to base64 human-readable address #[inline(always)] pub fn public_key_to_base64(key: &XfrPublicKey) -> String { - base64::encode_config(&ZeiFromToBytes::zei_to_bytes(key), base64::URL_SAFE) + base64::encode_config(ZeiFromToBytes::zei_to_bytes(key), base64::URL_SAFE) } /// Restore a XfrPublicKey from base64 human-readable address diff --git a/src/libs/merkle_tree/src/lib.rs b/src/libs/merkle_tree/src/lib.rs index 637232fc4..4db52c3e1 100644 --- a/src/libs/merkle_tree/src/lib.rs +++ b/src/libs/merkle_tree/src/lib.rs @@ -1952,7 +1952,7 @@ impl AppendOnlyMerkle { self.check_lower(block, lower_list, lower_index).c(d!())?; } - leaf_count += block.valid_leaves() as u64; + leaf_count += block.valid_leaves(); } if leaf_count != leaves_at_this_level { @@ -2875,7 +2875,7 @@ mod tests { }; for i in 0..transactions { - test_append(&mut tree, i as u64, false); + test_append(&mut tree, i, false); if i == 1 || i == 2 diff --git a/src/libs/sliding_set/src/lib.rs b/src/libs/sliding_set/src/lib.rs index 5ad0320c3..417adbea9 100644 --- a/src/libs/sliding_set/src/lib.rs +++ b/src/libs/sliding_set/src/lib.rs @@ -25,7 +25,7 @@ impl SlidingSet { /// Create a new sliding window start with 0 #[inline(always)] pub fn new(width: usize) -> Self { - let mut map = Vec::with_capacity(width as usize); + let mut map = Vec::with_capacity(width); for _ in 0..width { map.push(Vec::new()); }