diff --git a/Cargo.toml b/Cargo.toml index e72dd83f0..09d8149ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -196,6 +196,7 @@ or_fun_call = "warn" path_buf_push_overwrite = "warn" read_zero_byte_vec = "warn" redundant_clone = "warn" +redundant_else = "warn" single_char_pattern = "warn" string_lit_as_bytes = "warn" suboptimal_flops = "warn" diff --git a/crates/consensus/beacon/src/engine/hooks/controller.rs b/crates/consensus/beacon/src/engine/hooks/controller.rs index bd5c8a9e2..0ff33d26b 100644 --- a/crates/consensus/beacon/src/engine/hooks/controller.rs +++ b/crates/consensus/beacon/src/engine/hooks/controller.rs @@ -156,9 +156,8 @@ impl EngineHooksController { ); return Poll::Ready(Ok(result)) - } else { - debug!(target: "consensus::engine::hooks", hook = hook.name(), "Next hook is not ready"); } + debug!(target: "consensus::engine::hooks", hook = hook.name(), "Next hook is not ready"); Poll::Pending } diff --git a/crates/engine/util/src/skip_fcu.rs b/crates/engine/util/src/skip_fcu.rs index f7492860c..e110ceced 100644 --- a/crates/engine/util/src/skip_fcu.rs +++ b/crates/engine/util/src/skip_fcu.rs @@ -51,10 +51,9 @@ where tracing::warn!(target: "engine::stream::skip_fcu", ?state, ?payload_attrs, threshold=this.threshold, skipped=this.skipped, "Skipping FCU"); let _ = tx.send(Ok(OnForkChoiceUpdated::syncing())); continue - } else { - *this.skipped = 0; - Some(BeaconEngineMessage::ForkchoiceUpdated { state, payload_attrs, tx }) } + *this.skipped = 0; + Some(BeaconEngineMessage::ForkchoiceUpdated { state, payload_attrs, tx }) } next => next, }; diff --git a/crates/engine/util/src/skip_new_payload.rs b/crates/engine/util/src/skip_new_payload.rs index 1c69f412d..f4ed8a543 100644 --- a/crates/engine/util/src/skip_new_payload.rs +++ b/crates/engine/util/src/skip_new_payload.rs @@ -54,10 +54,9 @@ where ); let _ = tx.send(Ok(PayloadStatus::from_status(PayloadStatusEnum::Syncing))); continue - } else { - *this.skipped = 0; - Some(BeaconEngineMessage::NewPayload { payload, cancun_fields, tx }) } + *this.skipped = 0; + Some(BeaconEngineMessage::NewPayload { payload, cancun_fields, tx }) } next => next, }; diff --git a/crates/net/network/src/session/active.rs b/crates/net/network/src/session/active.rs index f8aa4fcae..e83f5d9f1 100644 --- a/crates/net/network/src/session/active.rs +++ b/crates/net/network/src/session/active.rs @@ -599,10 +599,9 @@ impl Future for ActiveSession { Poll::Ready(None) => { if this.is_disconnecting() { break - } else { - debug!(target: "net::session", remote_peer_id=?this.remote_peer_id, "eth stream completed"); - return this.emit_disconnect(cx) } + debug!(target: "net::session", remote_peer_id=?this.remote_peer_id, "eth stream completed"); + return this.emit_disconnect(cx) } Poll::Ready(Some(res)) => { match res { diff --git a/crates/net/network/src/transactions/fetcher.rs b/crates/net/network/src/transactions/fetcher.rs index 71db299ec..8a5b2fbad 100644 --- a/crates/net/network/src/transactions/fetcher.rs +++ b/crates/net/network/src/transactions/fetcher.rs @@ -275,9 +275,8 @@ impl TransactionFetcher { // tx is really big, pack request with single tx if size >= self.info.soft_limit_byte_size_pooled_transactions_response_on_pack_request { return hashes_from_announcement_iter.collect::() - } else { - acc_size_response = size; } + acc_size_response = size; } let mut surplus_hashes = RequestTxHashes::with_capacity(hashes_from_announcement_len - 1); @@ -692,14 +691,9 @@ impl TransactionFetcher { Some(new_announced_hashes) } } - } else { - // stores a new request future for the request - self.inflight_requests.push(GetPooledTxRequestFut::new( - peer_id, - new_announced_hashes, - rx, - )) } + // stores a new request future for the request + self.inflight_requests.push(GetPooledTxRequestFut::new(peer_id, new_announced_hashes, rx)); None } diff --git a/crates/node/events/src/cl.rs b/crates/node/events/src/cl.rs index 47f1de668..6d29c9bbf 100644 --- a/crates/node/events/src/cl.rs +++ b/crates/node/events/src/cl.rs @@ -53,14 +53,13 @@ impl Stream for ConsensusLayerHealthEvents { if fork_choice.elapsed() <= NO_FORKCHOICE_UPDATE_RECEIVED_PERIOD { // We had an FCU, and it's recent. CL is healthy. continue - } else { - // We had an FCU, but it's too old. - return Poll::Ready(Some( - ConsensusLayerHealthEvent::HaveNotReceivedUpdatesForAWhile( - fork_choice.elapsed(), - ), - )) } + // We had an FCU, but it's too old. + return Poll::Ready(Some( + ConsensusLayerHealthEvent::HaveNotReceivedUpdatesForAWhile( + fork_choice.elapsed(), + ), + )) } if let Some(transition_config) = diff --git a/crates/rpc/ipc/src/server/connection.rs b/crates/rpc/ipc/src/server/connection.rs index 0dede77ac..10bb2a035 100644 --- a/crates/rpc/ipc/src/server/connection.rs +++ b/crates/rpc/ipc/src/server/connection.rs @@ -118,9 +118,8 @@ where } 'inner: loop { - let mut drained = false; // drain all calls that are ready and put them in the output item queue - if !this.pending_calls.is_empty() { + let drained = if !this.pending_calls.is_empty() { if let Poll::Ready(Some(res)) = this.pending_calls.as_mut().poll_next(cx) { let item = match res { Ok(Some(resp)) => resp, @@ -128,11 +127,12 @@ where Err(err) => err.into().to_string(), }; this.items.push_back(item); - continue 'outer - } else { - drained = true; + continue 'outer; } - } + true + } else { + false + }; // read from the stream match this.conn.as_mut().poll_next(cx) { diff --git a/crates/stages/stages/src/stages/hashing_storage.rs b/crates/stages/stages/src/stages/hashing_storage.rs index 73bd2b435..10873b7ad 100644 --- a/crates/stages/stages/src/stages/hashing_storage.rs +++ b/crates/stages/stages/src/stages/hashing_storage.rs @@ -273,9 +273,9 @@ mod tests { // Continue from checkpoint input.checkpoint = Some(checkpoint); continue - } else { - assert_eq!(checkpoint.block_number, previous_stage); - assert_matches!(checkpoint.storage_hashing_stage_checkpoint(), Some(StorageHashingCheckpoint { + } + assert_eq!(checkpoint.block_number, previous_stage); + assert_matches!(checkpoint.storage_hashing_stage_checkpoint(), Some(StorageHashingCheckpoint { progress: EntitiesCheckpoint { processed, total, @@ -284,14 +284,13 @@ mod tests { }) if processed == total && total == runner.db.table::().unwrap().len() as u64); - // Validate the stage execution - assert!( - runner.validate_execution(input, Some(result)).is_ok(), - "execution validation" - ); + // Validate the stage execution + assert!( + runner.validate_execution(input, Some(result)).is_ok(), + "execution validation" + ); - break - } + break } panic!("Failed execution"); } diff --git a/crates/storage/provider/src/providers/database/provider.rs b/crates/storage/provider/src/providers/database/provider.rs index a4b738ea3..faf41f3ae 100644 --- a/crates/storage/provider/src/providers/database/provider.rs +++ b/crates/storage/provider/src/providers/database/provider.rs @@ -259,9 +259,8 @@ where } else if block_number <= sharded_key.as_ref().highest_block_number { // Filter out all elements greater than block number. return Ok(list.iter().take_while(|i| *i < block_number).collect::>()) - } else { - return Ok(list.iter().collect::>()) } + return Ok(list.iter().collect::>()) } Ok(Vec::new()) @@ -1591,9 +1590,8 @@ impl DatabaseProvider { if done { break true - } else { - deleted_entries += 1; } + deleted_entries += 1; }; Ok((deleted_entries, done)) diff --git a/crates/transaction-pool/src/pool/best.rs b/crates/transaction-pool/src/pool/best.rs index 1b4a8eafe..8567c2ed4 100644 --- a/crates/transaction-pool/src/pool/best.rs +++ b/crates/transaction-pool/src/pool/best.rs @@ -57,9 +57,8 @@ impl Iterator for BestTransactionsWithFees { .map_or(true, |fee| fee >= self.base_fee_per_blob_gas as u128) { return Some(best); - } else { - crate::traits::BestTransactions::mark_invalid(self, &best); } + crate::traits::BestTransactions::mark_invalid(self, &best); } } } @@ -227,9 +226,8 @@ where let best = self.best.next()?; if (self.predicate)(&best) { return Some(best) - } else { - self.best.mark_invalid(&best); } + self.best.mark_invalid(&best); } } } diff --git a/crates/trie/common/src/root.rs b/crates/trie/common/src/root.rs index 434eea20b..3779991cd 100644 --- a/crates/trie/common/src/root.rs +++ b/crates/trie/common/src/root.rs @@ -75,6 +75,7 @@ pub fn state_root_unsorted>( } /// Calculates the root hash of the state represented as MPT. +/// /// Corresponds to [geth's `deriveHash`](https://github.com/ethereum/go-ethereum/blob/6c149fd4ad063f7c24d726a73bc0546badd1bc73/core/genesis.go#L119). /// /// # Panics