diff --git a/crates/consensus/beacon/src/engine/forkchoice.rs b/crates/consensus/beacon/src/engine/forkchoice.rs index 54f5df568..461881c64 100644 --- a/crates/consensus/beacon/src/engine/forkchoice.rs +++ b/crates/consensus/beacon/src/engine/forkchoice.rs @@ -121,13 +121,12 @@ impl ForkchoiceStatus { /// Converts the general purpose [PayloadStatusEnum] into a [ForkchoiceStatus]. pub(crate) fn from_payload_status(status: &PayloadStatusEnum) -> Self { match status { - PayloadStatusEnum::Valid => ForkchoiceStatus::Valid, - PayloadStatusEnum::Invalid { .. } => ForkchoiceStatus::Invalid, - PayloadStatusEnum::Syncing => ForkchoiceStatus::Syncing, - PayloadStatusEnum::Accepted => { - // This is only returned on `newPayload` accepted would be a valid state here. + PayloadStatusEnum::Valid | PayloadStatusEnum::Accepted => { + // `Accepted` is only returned on `newPayload`. It would be a valid state here. ForkchoiceStatus::Valid } + PayloadStatusEnum::Invalid { .. } => ForkchoiceStatus::Invalid, + PayloadStatusEnum::Syncing => ForkchoiceStatus::Syncing, } } } @@ -169,8 +168,8 @@ impl ForkchoiceStateHash { impl AsRef for ForkchoiceStateHash { fn as_ref(&self) -> &B256 { match self { - ForkchoiceStateHash::Head(h) => h, - ForkchoiceStateHash::Safe(h) => h, + ForkchoiceStateHash::Head(h) | + ForkchoiceStateHash::Safe(h) | ForkchoiceStateHash::Finalized(h) => h, } } diff --git a/crates/net/downloaders/src/headers/reverse_headers.rs b/crates/net/downloaders/src/headers/reverse_headers.rs index 21f2511a7..dbd33b156 100644 --- a/crates/net/downloaders/src/headers/reverse_headers.rs +++ b/crates/net/downloaders/src/headers/reverse_headers.rs @@ -65,7 +65,7 @@ impl From for ReverseHeadersDownloaderError { /// the batches of headers that this downloader yields will start at the chain tip and move towards /// the local head: falling block numbers. #[must_use = "Stream does nothing unless polled"] -#[allow(missing_debug_implementations)] +#[derive(Debug)] pub struct ReverseHeadersDownloader { /// Consensus client used to validate headers consensus: Arc, @@ -892,6 +892,7 @@ where } /// A future that returns a list of [`Header`] on success. +#[derive(Debug)] struct HeadersRequestFuture { request: Option, fut: F, @@ -927,6 +928,7 @@ impl HeadersRequestOutcome { } /// Wrapper type to order responses +#[derive(Debug)] struct OrderedHeadersResponse { headers: Vec
, request: HeadersRequest, diff --git a/crates/primitives/benches/validate_blob_tx.rs b/crates/primitives/benches/validate_blob_tx.rs index 510c22b13..1f0db472f 100644 --- a/crates/primitives/benches/validate_blob_tx.rs +++ b/crates/primitives/benches/validate_blob_tx.rs @@ -1,6 +1,4 @@ #![allow(missing_docs)] -use std::sync::Arc; - use alloy_primitives::hex; use c_kzg::{KzgCommitment, KzgSettings}; use criterion::{ @@ -16,6 +14,7 @@ use reth_primitives::{ BlobTransactionSidecar, TxEip4844, }; use revm_primitives::MAX_BLOB_NUMBER_PER_BLOCK; +use std::sync::Arc; // constant seed to use for the rng const SEED: [u8; 32] = hex!("1337133713371337133713371337133713371337133713371337133713371337"); diff --git a/crates/primitives/src/receipt.rs b/crates/primitives/src/receipt.rs index f7c27771f..46dd862f7 100644 --- a/crates/primitives/src/receipt.rs +++ b/crates/primitives/src/receipt.rs @@ -6,15 +6,14 @@ use crate::{ }; use alloy_rlp::{length_of_length, Decodable, Encodable}; use bytes::{Buf, BufMut, BytesMut}; +#[cfg(any(test, feature = "arbitrary"))] +use proptest::strategy::Strategy; use reth_codecs::{add_arbitrary_tests, main_codec, Compact, CompactZstd}; use std::{ cmp::Ordering, ops::{Deref, DerefMut}, }; -#[cfg(any(test, feature = "arbitrary"))] -use proptest::strategy::Strategy; - /// Receipt containing result of transaction execution. #[main_codec(no_arbitrary, zstd)] #[add_arbitrary_tests] diff --git a/crates/rpc/rpc/src/layers/auth_layer.rs b/crates/rpc/rpc/src/layers/auth_layer.rs index 5a74ec72c..5e70799a9 100644 --- a/crates/rpc/rpc/src/layers/auth_layer.rs +++ b/crates/rpc/rpc/src/layers/auth_layer.rs @@ -69,7 +69,7 @@ where /// This type is the actual implementation of the middleware. It follows the [`Service`] /// specification to correctly proxy Http requests to its inner service after headers validation. -#[allow(missing_debug_implementations)] +#[derive(Debug)] pub struct AuthService { /// Performs auth validation logics validator: V, diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index 7f0e8c5e5..4e10dca29 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -222,13 +222,7 @@ where hash: B256, index: usize, ) -> EthResult> { - match self.trace_transaction(hash).await? { - None => Ok(None), - Some(traces) => { - let trace = traces.into_iter().nth(index); - Ok(trace) - } - } + Ok(self.trace_transaction(hash).await?.and_then(|traces| traces.into_iter().nth(index))) } /// Returns all transaction traces that match the given filter. diff --git a/crates/transaction-pool/src/test_utils/mock.rs b/crates/transaction-pool/src/test_utils/mock.rs index 1b9262770..e8b593145 100644 --- a/crates/transaction-pool/src/test_utils/mock.rs +++ b/crates/transaction-pool/src/test_utils/mock.rs @@ -84,15 +84,9 @@ macro_rules! set_value { ($this:ident => $field:ident) => { let new_value = $field; match $this { - MockTransaction::Legacy { ref mut $field, .. } => { - *$field = new_value; - } - MockTransaction::Eip1559 { ref mut $field, .. } => { - *$field = new_value; - } - MockTransaction::Eip4844 { ref mut $field, .. } => { - *$field = new_value; - } + MockTransaction::Legacy { ref mut $field, .. } | + MockTransaction::Eip1559 { ref mut $field, .. } | + MockTransaction::Eip4844 { ref mut $field, .. } | MockTransaction::Eip2930 { ref mut $field, .. } => { *$field = new_value; } @@ -109,9 +103,9 @@ macro_rules! set_value { macro_rules! get_value { ($this:tt => $field:ident) => { match $this { - MockTransaction::Legacy { $field, .. } => $field.clone(), - MockTransaction::Eip1559 { $field, .. } => $field.clone(), - MockTransaction::Eip4844 { $field, .. } => $field.clone(), + MockTransaction::Legacy { $field, .. } | + MockTransaction::Eip1559 { $field, .. } | + MockTransaction::Eip4844 { $field, .. } | MockTransaction::Eip2930 { $field, .. } => $field.clone(), #[cfg(feature = "optimism")] #[allow(unused_variables)] @@ -1377,22 +1371,17 @@ impl MockTransactionDistribution { /// Generates a new transaction pub fn tx(&self, nonce: u64, rng: &mut impl rand::Rng) -> MockTransaction { - let transaction_sample = self.transaction_ratio.sample(rng); - let tx = if transaction_sample == 0 { - MockTransaction::legacy().with_gas_price(self.fee_ranges.sample_gas_price(rng)) - } else if transaction_sample == 1 { - MockTransaction::eip2930().with_gas_price(self.fee_ranges.sample_gas_price(rng)) - } else if transaction_sample == 2 { - MockTransaction::eip1559() + let tx = match self.transaction_ratio.sample(rng) { + 0 => MockTransaction::legacy().with_gas_price(self.fee_ranges.sample_gas_price(rng)), + 1 => MockTransaction::eip2930().with_gas_price(self.fee_ranges.sample_gas_price(rng)), + 2 => MockTransaction::eip1559() + .with_priority_fee(self.fee_ranges.sample_priority_fee(rng)) + .with_max_fee(self.fee_ranges.sample_max_fee(rng)), + 3 => MockTransaction::eip4844() .with_priority_fee(self.fee_ranges.sample_priority_fee(rng)) .with_max_fee(self.fee_ranges.sample_max_fee(rng)) - } else if transaction_sample == 3 { - MockTransaction::eip4844() - .with_priority_fee(self.fee_ranges.sample_priority_fee(rng)) - .with_max_fee(self.fee_ranges.sample_max_fee(rng)) - .with_blob_fee(self.fee_ranges.sample_max_fee_blob(rng)) - } else { - unreachable!("unknown transaction type returned by the weighted index") + .with_blob_fee(self.fee_ranges.sample_max_fee_blob(rng)), + _ => unreachable!("unknown transaction type returned by the weighted index"), }; let size = self.size_range.sample(rng); diff --git a/crates/transaction-pool/src/validate/task.rs b/crates/transaction-pool/src/validate/task.rs index 58801fcac..c54a80201 100644 --- a/crates/transaction-pool/src/validate/task.rs +++ b/crates/transaction-pool/src/validate/task.rs @@ -17,6 +17,12 @@ use tokio::{ }; use tokio_stream::wrappers::ReceiverStream; +/// Represents a future outputting unit type and is sendable. +type ValidationFuture = Pin + Send>>; + +/// Represents a stream of validation futures. +type ValidationStream = ReceiverStream; + /// A service that performs validation jobs. /// /// This listens for incoming validation jobs and executes them. @@ -24,8 +30,7 @@ use tokio_stream::wrappers::ReceiverStream; /// This should be spawned as a task: [ValidationTask::run] #[derive(Clone)] pub struct ValidationTask { - #[allow(clippy::type_complexity)] - validation_jobs: Arc + Send>>>>>, + validation_jobs: Arc>, } impl ValidationTask { @@ -44,12 +49,8 @@ impl ValidationTask { /// /// This will run as long as the channel is alive and is expected to be spawned as a task. pub async fn run(self) { - loop { - let task = self.validation_jobs.lock().await.next().await; - match task { - None => return, - Some(task) => task.await, - } + while let Some(task) = self.validation_jobs.lock().await.next().await { + task.await; } } }