Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohann committed Jul 4, 2024
1 parent c17f9e9 commit 35c1c60
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 49 deletions.
8 changes: 4 additions & 4 deletions chains/astar/server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
!= &ethereum_block.header().header().parent_hash.0
if actual_eth_block.header.parent_hash.as_fixed_bytes() !=
&ethereum_block.header().header().parent_hash.0
{
anyhow::bail!("ethereum block hash mismatch");
}
Expand Down
4 changes: 2 additions & 2 deletions chains/ethereum/backend/src/jsonrpsee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,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()));
Expand Down
1 change: 0 additions & 1 deletion chains/ethereum/server/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ where
Ok((tx, Some(signature))) => {
let tx_hash = tx.compute_tx_hash(&signature);
let sender = DefaultCrypto::secp256k1_ecdsa_recover(&signature, tx.sighash())?;

// Obs: this call is used only to retrieve the revert reason
let call_request = CallRequest {
from: Some(sender),
Expand Down
4 changes: 2 additions & 2 deletions chains/ethereum/server/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions chains/ethereum/server/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ impl State {
// 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(());
Expand Down
15 changes: 12 additions & 3 deletions chains/ethereum/server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ fn estimate_priority_fee(rewards: &[Vec<U256>]) -> U256 {

// If we encountered a big change in fees at a certain position, then consider only
// the values >= it.
let values = if max_change >= EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE.into()
&& (max_change_index >= (rewards.len() / 2))
let values = if max_change >= EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE.into() &&
(max_change_index >= (rewards.len() / 2))
{
rewards[max_change_index..].to_vec()
} else {
Expand Down Expand Up @@ -244,7 +244,16 @@ where
{
Ok(exit_reason) => exit_reason,
Err(error) => {
tracing::warn!("Failed to retrieve transaction result {tx_hash:?}: {error:?}");
if matches!(receipt.status_code, Some(0) | None) {
tracing::warn!(
"Failed to retrieve transaction revert reason: {tx_hash:?}: {error:?}"
);
} else {
// Using debug level, once retrieve the transaction result is not critical
tracing::debug!(
"Failed to retrieve transaction result: {tx_hash:?}: {error:?}"
);
}
return result_from_receipt(tx_hash, receipt);
},
};
Expand Down
4 changes: 2 additions & 2 deletions chains/ethereum/types/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 19 additions & 19 deletions chains/ethereum/types/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();
}
Expand Down
8 changes: 4 additions & 4 deletions chains/ethereum/types/src/i256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,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)
Expand Down Expand Up @@ -597,8 +597,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)
Expand Down
5 changes: 2 additions & 3 deletions rosetta-crypto/src/bip32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ impl SecretKey {
fn tweak_add(&self, secret_key: &Self) -> Result<Option<Self>> {
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<NonZeroScalar<_>> =
Expand Down
14 changes: 7 additions & 7 deletions rosetta-utils/src/jsonrpsee/auto_subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,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]
Expand All @@ -95,11 +95,11 @@ where
/// Consume the subscription and return the inner subscriber.
pub fn into_subscriber(self) -> Option<F> {
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,
}
Expand Down

0 comments on commit 35c1c60

Please sign in to comment.