Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Jul 17, 2024
1 parent 1e403df commit d349906
Show file tree
Hide file tree
Showing 131 changed files with 760 additions and 752 deletions.
4 changes: 2 additions & 2 deletions crates/anvil/core/src/eth/serde_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub mod sequence {
return Err(serde::de::Error::custom(format!(
"expected params sequence with length 1 but got {}",
seq.len()
)))
)));
}
Ok(seq.remove(0))
}
Expand All @@ -46,7 +46,7 @@ pub mod empty_params {
return Err(serde::de::Error::custom(format!(
"expected params sequence with length 0 but got {}",
seq.len()
)))
)));
}
Ok(())
}
Expand Down
44 changes: 22 additions & 22 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ pub fn transaction_request_to_typed(
to,
) {
// legacy transaction
(Some(0), _, None, None, None, None, None, None, _) |
(None, Some(_), None, None, None, None, None, None, _) => {
(Some(0), _, None, None, None, None, None, None, _)
| (None, Some(_), None, None, None, None, None, None, _) => {
Some(TypedTransactionRequest::Legacy(TxLegacy {
nonce: nonce.unwrap_or_default(),
gas_price: gas_price.unwrap_or_default(),
Expand All @@ -93,8 +93,8 @@ pub fn transaction_request_to_typed(
}))
}
// EIP2930
(Some(1), _, None, None, _, None, None, None, _) |
(None, _, None, None, Some(_), None, None, None, _) => {
(Some(1), _, None, None, _, None, None, None, _)
| (None, _, None, None, Some(_), None, None, None, _) => {
Some(TypedTransactionRequest::EIP2930(TxEip2930 {
nonce: nonce.unwrap_or_default(),
gas_price: gas_price.unwrap_or_default(),
Expand All @@ -107,10 +107,10 @@ pub fn transaction_request_to_typed(
}))
}
// EIP1559
(Some(2), None, _, _, _, _, None, None, _) |
(None, None, Some(_), _, _, _, None, None, _) |
(None, None, _, Some(_), _, _, None, None, _) |
(None, None, None, None, None, _, None, None, _) => {
(Some(2), None, _, _, _, _, None, None, _)
| (None, None, Some(_), _, _, _, None, None, _)
| (None, None, _, Some(_), _, _, None, None, _)
| (None, None, None, None, None, _, None, None, _) => {
// Empty fields fall back to the canonical transaction schema.
Some(TypedTransactionRequest::EIP1559(TxEip1559 {
nonce: nonce.unwrap_or_default(),
Expand Down Expand Up @@ -151,9 +151,9 @@ pub fn transaction_request_to_typed(
}

fn has_optimism_fields(other: &OtherFields) -> bool {
other.contains_key("sourceHash") &&
other.contains_key("mint") &&
other.contains_key("isSystemTx")
other.contains_key("sourceHash")
&& other.contains_key("mint")
&& other.contains_key("isSystemTx")
}

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -214,7 +214,7 @@ impl MaybeImpersonatedTransaction {
#[cfg(feature = "impersonated-tx")]
pub fn hash(&self) -> B256 {
if let Some(sender) = self.impersonated_sender {
return self.transaction.impersonated_hash(sender)
return self.transaction.impersonated_hash(sender);
}
self.transaction.hash()
}
Expand Down Expand Up @@ -1137,12 +1137,12 @@ pub struct DepositReceipt<T = alloy_primitives::Log> {

impl DepositReceipt {
fn payload_len(&self) -> usize {
self.inner.receipt.status.length() +
self.inner.receipt.cumulative_gas_used.length() +
self.inner.logs_bloom.length() +
self.inner.receipt.logs.length() +
self.deposit_nonce.map_or(0, |n| n.length()) +
self.deposit_receipt_version.map_or(0, |n| n.length())
self.inner.receipt.status.length()
+ self.inner.receipt.cumulative_gas_used.length()
+ self.inner.logs_bloom.length()
+ self.inner.receipt.logs.length()
+ self.deposit_nonce.map_or(0, |n| n.length())
+ self.deposit_receipt_version.map_or(0, |n| n.length())
}

/// Returns the rlp header for the receipt payload.
Expand Down Expand Up @@ -1249,10 +1249,10 @@ impl<T> TypedReceipt<T> {
impl<T> From<TypedReceipt<T>> for ReceiptWithBloom<T> {
fn from(value: TypedReceipt<T>) -> Self {
match value {
TypedReceipt::Legacy(r) |
TypedReceipt::EIP1559(r) |
TypedReceipt::EIP2930(r) |
TypedReceipt::EIP4844(r) => r,
TypedReceipt::Legacy(r)
| TypedReceipt::EIP1559(r)
| TypedReceipt::EIP2930(r)
| TypedReceipt::EIP4844(r) => r,
TypedReceipt::Deposit(r) => r.inner,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/server/src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl tokio_util::codec::Decoder for JsonRpcCodec {
return match String::from_utf8(bts.as_ref().to_vec()) {
Ok(val) => Ok(Some(val)),
Err(_) => Ok(None),
}
};
}
}
Ok(None)
Expand Down
16 changes: 8 additions & 8 deletions crates/anvil/server/src/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<Handler: PubSubRpcHandler> PubSubContext<Handler> {
let mut subscriptions = self.subscriptions.lock();
if let Some(idx) = subscriptions.iter().position(|(i, _)| id == i) {
trace!(target: "rpc", ?id, "removed subscription");
return Some(subscriptions.swap_remove(idx).1)
return Some(subscriptions.swap_remove(idx).1);
}
None
}
Expand Down Expand Up @@ -174,7 +174,7 @@ where
error!(target: "rpc", ?err, "Failed to send message");
}
} else {
break
break;
}
}

Expand All @@ -183,7 +183,7 @@ where
if let Poll::Ready(Err(err)) = pin.connection.poll_flush_unpin(cx) {
trace!(target: "rpc", ?err, "websocket err");
// close the connection
return Poll::Ready(())
return Poll::Ready(());
}

loop {
Expand All @@ -195,25 +195,25 @@ where
Err(err) => match err {
RequestError::Axum(err) => {
trace!(target: "rpc", ?err, "client disconnected");
return Poll::Ready(())
return Poll::Ready(());
}
RequestError::Io(err) => {
trace!(target: "rpc", ?err, "client disconnected");
return Poll::Ready(())
return Poll::Ready(());
}
RequestError::Serde(err) => {
pin.process_request(Err(err));
}
RequestError::Disconnect => {
trace!(target: "rpc", "client disconnected");
return Poll::Ready(())
return Poll::Ready(());
}
},
_ => {}
},
Poll::Ready(None) => {
trace!(target: "rpc", "socket connection finished");
return Poll::Ready(())
return Poll::Ready(());
}
Poll::Pending => break,
}
Expand Down Expand Up @@ -256,7 +256,7 @@ where
}

if !progress {
return Poll::Pending
return Poll::Pending;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn main() -> eyre::Result<()> {
&mut std::io::stdout(),
),
}
return Ok(())
return Ok(());
}

let _ = fdlimit::raise_fd_limit();
Expand Down
12 changes: 6 additions & 6 deletions crates/anvil/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ impl Future for PeriodicStateDumper {
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();
if this.dump_state.is_none() {
return Poll::Pending
return Poll::Pending;
}

loop {
Expand All @@ -607,7 +607,7 @@ impl Future for PeriodicStateDumper {
}
Poll::Pending => {
this.in_progress_dump = Some(flush);
return Poll::Pending
return Poll::Pending;
}
}
}
Expand All @@ -617,7 +617,7 @@ impl Future for PeriodicStateDumper {
let path = this.dump_state.clone().expect("exists; see above");
this.in_progress_dump = Some(Box::pin(Self::dump_state(api, path)));
} else {
break
break;
}
}

Expand Down Expand Up @@ -647,7 +647,7 @@ impl StateFile {
}
let mut state = Self { path, state: None };
if !state.path.exists() {
return Ok(state)
return Ok(state);
}

state.state = Some(SerializableState::load(&state.path).map_err(|err| err.to_string())?);
Expand Down Expand Up @@ -682,14 +682,14 @@ impl FromStr for ForkUrl {
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Some((url, block)) = s.rsplit_once('@') {
if block == "latest" {
return Ok(Self { url: url.to_string(), block: None })
return Ok(Self { url: url.to_string(), block: None });
}
// this will prevent false positives for auths `user:[email protected]`
if !block.is_empty() && !block.contains(':') && !block.contains('.') {
let block: u64 = block
.parse()
.map_err(|_| format!("Failed to parse block number: `{block}`"))?;
return Ok(Self { url: url.to_string(), block: Some(block) })
return Ok(Self { url: url.to_string(), block: Some(block) });
}
}
Ok(Self { url: s.to_string(), block: None })
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/cheats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl CheatsManager {
// which does not check that list when auto impersonation is enabeld.
if state.impersonated_accounts.contains(&addr) {
// need to check if already impersonated, so we don't overwrite the code
return true
return true;
}
state.impersonated_accounts.insert(addr)
}
Expand Down
14 changes: 7 additions & 7 deletions crates/anvil/src/eth/backend/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,22 +143,22 @@ impl<'a, DB: Db + ?Sized, Validator: TransactionValidator> TransactionExecutor<'
}
TransactionExecutionOutcome::Exhausted(tx) => {
trace!(target: "backend", tx_gas_limit = %tx.pending_transaction.transaction.gas_limit(), ?tx, "block gas limit exhausting, skipping transaction");
continue
continue;
}
TransactionExecutionOutcome::BlobGasExhausted(tx) => {
trace!(target: "backend", blob_gas = %tx.pending_transaction.transaction.blob_gas().unwrap_or_default(), ?tx, "block blob gas limit exhausting, skipping transaction");
continue
continue;
}
TransactionExecutionOutcome::Invalid(tx, _) => {
trace!(target: "backend", ?tx, "skipping invalid transaction");
invalid.push(tx);
continue
continue;
}
TransactionExecutionOutcome::DatabaseError(_, err) => {
// Note: this is only possible in forking mode, if for example a rpc request
// failed
trace!(target: "backend", ?err, "Failed to execute transaction due to database error");
continue
continue;
}
};
if is_cancun {
Expand Down Expand Up @@ -277,15 +277,15 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator
// check that we comply with the block's gas limit, if not disabled
let max_gas = self.gas_used.saturating_add(env.tx.gas_limit as u128);
if !env.cfg.disable_block_gas_limit && max_gas > env.block.gas_limit.to::<u128>() {
return Some(TransactionExecutionOutcome::Exhausted(transaction))
return Some(TransactionExecutionOutcome::Exhausted(transaction));
}

// check that we comply with the block's blob gas limit
let max_blob_gas = self.blob_gas_used.saturating_add(
transaction.pending_transaction.transaction.transaction.blob_gas().unwrap_or(0u128),
);
if max_blob_gas > MAX_BLOB_GAS_PER_BLOCK as u128 {
return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction))
return Some(TransactionExecutionOutcome::BlobGasExhausted(transaction));
}

// validate before executing
Expand All @@ -295,7 +295,7 @@ impl<'a, 'b, DB: Db + ?Sized, Validator: TransactionValidator> Iterator
&env,
) {
warn!(target: "backend", "Skipping invalid tx execution [{:?}] {}", transaction.hash(), err);
return Some(TransactionExecutionOutcome::Invalid(transaction, err))
return Some(TransactionExecutionOutcome::Invalid(transaction, err));
}

let nonce = account.nonce;
Expand Down
Loading

0 comments on commit d349906

Please sign in to comment.