From 3fc23d456d29425850ef2faa3244654065800a81 Mon Sep 17 00:00:00 2001 From: ManojJiSharma Date: Wed, 18 Dec 2024 13:34:09 +0530 Subject: [PATCH] cargo fmt fix --- chains/astar/server/src/lib.rs | 8 ++-- chains/ethereum/backend/src/jsonrpsee.rs | 4 +- chains/ethereum/server/src/proof.rs | 4 +- chains/ethereum/server/src/state.rs | 4 +- chains/ethereum/server/src/utils.rs | 4 +- chains/ethereum/types/src/crypto.rs | 4 +- chains/ethereum/types/src/header.rs | 38 +++++++++---------- chains/ethereum/types/src/i256.rs | 8 ++-- rosetta-client/src/client.rs | 14 +++---- rosetta-crypto/src/bip32.rs | 5 +-- rosetta-utils/src/jsonrpsee/auto_subscribe.rs | 14 +++---- 11 files changed, 53 insertions(+), 54 deletions(-) diff --git a/chains/astar/server/src/lib.rs b/chains/astar/server/src/lib.rs index 05f8b52e..f76e331f 100644 --- a/chains/astar/server/src/lib.rs +++ b/chains/astar/server/src/lib.rs @@ -144,13 +144,13 @@ impl AstarClient { // Verify if the ethereum block hash matches the provided ethereum block hash. // TODO: compute the block hash - if U256(actual_eth_block.header.number.0) - != U256::from(ethereum_block.header().number()) + if U256(actual_eth_block.header.number.0) != + U256::from(ethereum_block.header().number()) { anyhow::bail!("ethereum block hash mismatch"); } - if actual_eth_block.header.parent_hash.as_fixed_bytes() - != ðereum_block.header().header().parent_hash.0 + if actual_eth_block.header.parent_hash.as_fixed_bytes() != + ðereum_block.header().header().parent_hash.0 { anyhow::bail!("ethereum block hash mismatch"); } diff --git a/chains/ethereum/backend/src/jsonrpsee.rs b/chains/ethereum/backend/src/jsonrpsee.rs index b5afff5f..756e6459 100644 --- a/chains/ethereum/backend/src/jsonrpsee.rs +++ b/chains/ethereum/backend/src/jsonrpsee.rs @@ -189,8 +189,8 @@ where return Ok(revert); } } - } else if msg.message().contains("overflow") - || msg.message().contains("underflow") + } else if msg.message().contains("overflow") || + msg.message().contains("underflow") { // we assume it's an stack overflow or underflow error. return Ok(ExitReason::Error(msg.message().to_string().into())); diff --git a/chains/ethereum/server/src/proof.rs b/chains/ethereum/server/src/proof.rs index 3426221e..7a0c1b6c 100644 --- a/chains/ethereum/server/src/proof.rs +++ b/chains/ethereum/server/src/proof.rs @@ -30,8 +30,8 @@ pub fn verify_proof(proof: &[Bytes], root: &[u8], path: &[u8], value: &[u8]) -> } else if node_list.len() == 2 { if i == proof.len() - 1 { // exclusion proof - if !paths_match(&node_list[0], skip_length(&node_list[0]), path, path_offset) - && is_empty_value(value) + if !paths_match(&node_list[0], skip_length(&node_list[0]), path, path_offset) && + is_empty_value(value) { return true; } diff --git a/chains/ethereum/server/src/state.rs b/chains/ethereum/server/src/state.rs index e65e1233..99bf6269 100644 --- a/chains/ethereum/server/src/state.rs +++ b/chains/ethereum/server/src/state.rs @@ -131,8 +131,8 @@ impl StateInner { // Block is younger than the latest finalized block, so it can't be imported return Ok(()); } - if block.number() == (best_block.number() + 1) - && block.parent_hash() != best_block.hash() + if block.number() == (best_block.number() + 1) && + block.parent_hash() != best_block.hash() { // the block is not descendent of the best finalized block return Ok(()); diff --git a/chains/ethereum/server/src/utils.rs b/chains/ethereum/server/src/utils.rs index a7db0d90..14d1dfbf 100644 --- a/chains/ethereum/server/src/utils.rs +++ b/chains/ethereum/server/src/utils.rs @@ -130,8 +130,8 @@ fn estimate_priority_fee(rewards: &[Vec]) -> U256 { // If we encountered a big change in fees at a certain position, then consider only // the values >= it. - let values = if max_change >= F::EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE.into() - && (max_change_index >= (rewards.len() / 2)) + let values = if max_change >= F::EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE.into() && + (max_change_index >= (rewards.len() / 2)) { rewards[max_change_index..].to_vec() } else { diff --git a/chains/ethereum/types/src/crypto.rs b/chains/ethereum/types/src/crypto.rs index 69ed1a2d..0abb9e8d 100644 --- a/chains/ethereum/types/src/crypto.rs +++ b/chains/ethereum/types/src/crypto.rs @@ -340,8 +340,8 @@ impl Signer for Keypair { }; let v = u8::try_from(v) .map_err(|_| secp256k1::Error::InvalidRecoveryId) - .map(u64::from)? - & 1; + .map(u64::from)? & + 1; // All transaction signatures whose s-value is greater than secp256k1n/2 are invalid. // - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md diff --git a/chains/ethereum/types/src/header.rs b/chains/ethereum/types/src/header.rs index f3f90414..3f3ee502 100644 --- a/chains/ethereum/types/src/header.rs +++ b/chains/ethereum/types/src/header.rs @@ -273,24 +273,24 @@ impl rlp::Decodable for Header { impl rlp::Encodable for Header { fn rlp_append(&self, s: &mut rlp::RlpStream) { let mut size = 15; - if self.base_fee_per_gas.is_some() - || self.withdrawals_root.is_some() - || self.blob_gas_used.is_some() - || self.excess_blob_gas.is_some() - || self.parent_beacon_block_root.is_some() + if self.base_fee_per_gas.is_some() || + self.withdrawals_root.is_some() || + self.blob_gas_used.is_some() || + self.excess_blob_gas.is_some() || + self.parent_beacon_block_root.is_some() { size += 1; } - if self.withdrawals_root.is_some() - || self.blob_gas_used.is_some() - || self.excess_blob_gas.is_some() - || self.parent_beacon_block_root.is_some() + if self.withdrawals_root.is_some() || + self.blob_gas_used.is_some() || + self.excess_blob_gas.is_some() || + self.parent_beacon_block_root.is_some() { size += 1; } - if self.blob_gas_used.is_some() - || self.excess_blob_gas.is_some() - || self.parent_beacon_block_root.is_some() + if self.blob_gas_used.is_some() || + self.excess_blob_gas.is_some() || + self.parent_beacon_block_root.is_some() { size += 1; } @@ -322,10 +322,10 @@ impl rlp::Encodable for Header { // but withdrawals root is present. if let Some(ref base_fee) = self.base_fee_per_gas { s.append(&U256::from(*base_fee)); - } else if self.withdrawals_root.is_some() - || self.blob_gas_used.is_some() - || self.excess_blob_gas.is_some() - || self.parent_beacon_block_root.is_some() + } else if self.withdrawals_root.is_some() || + self.blob_gas_used.is_some() || + self.excess_blob_gas.is_some() || + self.parent_beacon_block_root.is_some() { s.begin_list(0); } @@ -334,9 +334,9 @@ impl rlp::Encodable for Header { // but blob gas used is present. if let Some(ref root) = self.withdrawals_root { s.append(root); - } else if self.blob_gas_used.is_some() - || self.excess_blob_gas.is_some() - || self.parent_beacon_block_root.is_some() + } else if self.blob_gas_used.is_some() || + self.excess_blob_gas.is_some() || + self.parent_beacon_block_root.is_some() { s.append_empty_data(); } diff --git a/chains/ethereum/types/src/i256.rs b/chains/ethereum/types/src/i256.rs index d677eab4..20bcb661 100644 --- a/chains/ethereum/types/src/i256.rs +++ b/chains/ethereum/types/src/i256.rs @@ -524,8 +524,8 @@ impl I256 { // the result. let overflow = matches!( (self.sign(), rhs.sign(), result.sign()), - (Sign::Positive, Sign::Positive, Sign::Negative) - | (Sign::Negative, Sign::Negative, Sign::Positive) + (Sign::Positive, Sign::Positive, Sign::Negative) | + (Sign::Negative, Sign::Negative, Sign::Positive) ); (result, overflow) @@ -583,8 +583,8 @@ impl I256 { // the result. let overflow = matches!( (self.sign(), rhs.sign(), result.sign()), - (Sign::Positive, Sign::Negative, Sign::Negative) - | (Sign::Negative, Sign::Positive, Sign::Positive) + (Sign::Positive, Sign::Negative, Sign::Negative) | + (Sign::Negative, Sign::Positive, Sign::Positive) ); (result, overflow) diff --git a/rosetta-client/src/client.rs b/rosetta-client/src/client.rs index ac20e9e9..f4c736d2 100644 --- a/rosetta-client/src/client.rs +++ b/rosetta-client/src/client.rs @@ -91,13 +91,13 @@ impl GenericClient { ) -> Result { let blockchain = Blockchain::from_str(config.blockchain)?; Ok(match blockchain { - Blockchain::Ethereum - | Blockchain::Polygon - | Blockchain::Arbitrum - | Blockchain::Binance - | Blockchain::Base - | Blockchain::Linea - | Blockchain::Avalanche => { + Blockchain::Ethereum | + Blockchain::Polygon | + Blockchain::Arbitrum | + Blockchain::Binance | + Blockchain::Base | + Blockchain::Linea | + Blockchain::Avalanche => { let client = EthereumClient::from_config(config, url, private_key).await?; Self::Ethereum(client) }, diff --git a/rosetta-crypto/src/bip32.rs b/rosetta-crypto/src/bip32.rs index 45cd9bd3..75f81a76 100644 --- a/rosetta-crypto/src/bip32.rs +++ b/rosetta-crypto/src/bip32.rs @@ -32,9 +32,8 @@ impl SecretKey { fn tweak_add(&self, secret_key: &Self) -> Result> { use ecdsa::elliptic_curve::NonZeroScalar; match (self, secret_key) { - (Self::EcdsaSecp256k1(secret), Self::EcdsaSecp256k1(secret2)) - | (Self::EcdsaRecoverableSecp256k1(secret), Self::EcdsaRecoverableSecp256k1(secret2)) => - { + (Self::EcdsaSecp256k1(secret), Self::EcdsaSecp256k1(secret2)) | + (Self::EcdsaRecoverableSecp256k1(secret), Self::EcdsaRecoverableSecp256k1(secret2)) => { let scalar = secret.as_nonzero_scalar().as_ref(); let tweak = secret2.as_nonzero_scalar().as_ref(); let scalar: Option> = diff --git a/rosetta-utils/src/jsonrpsee/auto_subscribe.rs b/rosetta-utils/src/jsonrpsee/auto_subscribe.rs index bc3b5a72..f2cca681 100644 --- a/rosetta-utils/src/jsonrpsee/auto_subscribe.rs +++ b/rosetta-utils/src/jsonrpsee/auto_subscribe.rs @@ -69,8 +69,8 @@ where #[must_use] pub const fn is_initializing(&self) -> bool { - matches!(self.state, State::Idle(_) | State::Subscribing(_)) - && self.total_subscriptions == 0 + matches!(self.state, State::Idle(_) | State::Subscribing(_)) && + self.total_subscriptions == 0 } #[must_use] @@ -94,11 +94,11 @@ where /// Consume the subscription and return the inner subscriber. pub fn into_subscriber(self) -> Option { match self.state { - State::Idle(subscriber) - | State::Subscribed { subscriber, .. } - | State::ResubscribeAfterDelay { subscriber, .. } - | State::Unsubscribing { subscriber, .. } - | State::Unsubscribed { subscriber, .. } => Some(subscriber), + State::Idle(subscriber) | + State::Subscribed { subscriber, .. } | + State::ResubscribeAfterDelay { subscriber, .. } | + State::Unsubscribing { subscriber, .. } | + State::Unsubscribed { subscriber, .. } => Some(subscriber), State::Subscribing(fut) => fut.now_or_never().map(|(subscriber, _)| subscriber), State::Poisoned => None, }