fix various clippy (#6020)

Co-authored-by: Dan Cline <6798349+Rjected@users.noreply.github.com>
This commit is contained in:
Thomas Coratger
2024-01-11 00:27:57 +01:00
committed by GitHub
parent 08dff3642d
commit 4660da4a3f
8 changed files with 187 additions and 15 deletions

View File

@ -43,7 +43,7 @@ impl<T> FullProvider for T where
/// The trait that is implemented for the Node command.
pub trait RethNodeComponents: Clone + Send + Sync + 'static {
/// The Provider type that is provided by the not itself
/// The Provider type that is provided by the node itself
type Provider: FullProvider;
/// The transaction pool type
type Pool: TransactionPool + Clone + Unpin + 'static;

View File

@ -976,7 +976,6 @@ where
return invalid_ancestor;
}
#[allow(clippy::single_match)]
match &error {
RethError::Canonical(
error @ CanonicalError::Validation(BlockValidationError::BlockPreMerge { .. }),

View File

@ -9,38 +9,73 @@ use std::io;
/// Errors when sending/receiving p2p messages. These should result in kicking the peer.
#[derive(thiserror::Error, Debug)]
#[allow(missing_docs)]
pub enum P2PStreamError {
/// I/O error.
#[error(transparent)]
Io(#[from] io::Error),
/// RLP encoding/decoding error.
#[error(transparent)]
Rlp(#[from] alloy_rlp::Error),
/// Error in compression/decompression using Snappy.
#[error(transparent)]
Snap(#[from] snap::Error),
/// Error during the P2P handshake.
#[error(transparent)]
HandshakeError(#[from] P2PHandshakeError),
/// Message size exceeds maximum length error.
#[error("message size ({message_size}) exceeds max length ({max_size})")]
MessageTooBig { message_size: usize, max_size: usize },
MessageTooBig {
/// The actual size of the message received.
message_size: usize,
/// The maximum allowed size for the message.
max_size: usize,
},
/// Unknown reserved P2P message ID error.
#[error("unknown reserved p2p message id: {0}")]
UnknownReservedMessageId(u8),
/// Empty protocol message received error.
#[error("empty protocol message received")]
EmptyProtocolMessage,
/// Error related to the Pinger.
#[error(transparent)]
PingerError(#[from] PingerError),
/// Ping timeout error.
#[error("ping timed out with")]
PingTimeout,
/// Error parsing shared capabilities.
#[error(transparent)]
ParseSharedCapability(#[from] SharedCapabilityError),
/// Capability not supported on the stream to this peer.
#[error("capability not supported on stream to this peer")]
CapabilityNotShared,
/// Mismatched protocol version error.
#[error("mismatched protocol version in Hello message: {0}")]
MismatchedProtocolVersion(GotExpected<ProtocolVersion>),
/// Ping started before the handshake completed.
#[error("started ping task before the handshake completed")]
PingBeforeHandshake,
/// Too many messages buffered before sending.
#[error("too many messages buffered before sending")]
SendBufferFull,
/// Disconnected error.
#[error("disconnected")]
Disconnected(DisconnectReason),
/// Unknown disconnect reason error.
#[error("unknown disconnect reason: {0}")]
UnknownDisconnectReason(#[from] UnknownDisconnectReason),
}
@ -60,22 +95,34 @@ impl P2PStreamError {
}
}
/// Errors when conducting a p2p handshake
/// Errors when conducting a p2p handshake.
#[derive(thiserror::Error, Debug, Clone, Eq, PartialEq)]
#[allow(missing_docs)]
pub enum P2PHandshakeError {
/// Hello message received/sent outside of handshake error.
#[error("hello message can only be recv/sent in handshake")]
HelloNotInHandshake,
/// Received a non-hello message when trying to handshake.
#[error("received non-hello message when trying to handshake")]
NonHelloMessageInHandshake,
/// No capabilities shared with the peer.
#[error("no capabilities shared with peer")]
NoSharedCapabilities,
/// No response received when sending out handshake.
#[error("no response received when sending out handshake")]
NoResponse,
/// Handshake timed out.
#[error("handshake timed out")]
Timeout,
/// Disconnected by peer with a specific reason.
#[error("disconnected by peer: {0}")]
Disconnected(DisconnectReason),
/// Error decoding a message during handshake.
#[error("error decoding a message during handshake: {0}")]
DecodeError(#[from] alloy_rlp::Error),
}

View File

@ -44,7 +44,6 @@ macro_rules! fuzz_type_and_name {
};
}
#[allow(non_snake_case)]
#[cfg(any(test, feature = "bench"))]
pub mod fuzz_rlp {
use crate::roundtrip_encoding;

View File

@ -284,38 +284,49 @@ impl Borrow<(PeerId, GetBlockHeaders)> for RespondedGetBlockHeaders {
/// All `eth` request related to blocks delegated by the network.
#[derive(Debug)]
#[allow(missing_docs)]
pub enum IncomingEthRequest {
/// Request Block headers from the peer.
///
/// The response should be sent through the channel.
GetBlockHeaders {
/// The ID of the peer to request block headers from.
peer_id: PeerId,
/// The specific block headers requested.
request: GetBlockHeaders,
/// The channel sender for the response containing block headers.
response: oneshot::Sender<RequestResult<BlockHeaders>>,
},
/// Request Block headers from the peer.
/// Request Block bodies from the peer.
///
/// The response should be sent through the channel.
GetBlockBodies {
/// The ID of the peer to request block bodies from.
peer_id: PeerId,
/// The specific block bodies requested.
request: GetBlockBodies,
/// The channel sender for the response containing block bodies.
response: oneshot::Sender<RequestResult<BlockBodies>>,
},
/// Request Node Data from the peer.
///
/// The response should be sent through the channel.
GetNodeData {
/// The ID of the peer to request node data from.
peer_id: PeerId,
/// The specific node data requested.
request: GetNodeData,
/// The channel sender for the response containing node data.
response: oneshot::Sender<RequestResult<NodeData>>,
},
/// Request Receipts from the peer.
///
/// The response should be sent through the channel.
GetReceipts {
/// The ID of the peer to request receipts from.
peer_id: PeerId,
/// The specific receipts requested.
request: GetReceipts,
/// The channel sender for the response containing receipts.
response: oneshot::Sender<RequestResult<Receipts>>,
},
}

View File

@ -2,8 +2,6 @@
//! transaction deserialized from the json input of an RPC call. Depending on what fields are set,
//! it can be converted into the container type [`TypedTransactionRequest`].
#![allow(missing_docs)]
use alloy_primitives::{Address, Bytes, B256, U128, U256, U64};
use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError};
use alloy_rpc_types::{
@ -21,65 +19,105 @@ use serde::{Deserialize, Serialize};
/// 4. EIP4844 [`EIP4844TransactionRequest`]
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum TypedTransactionRequest {
/// Represents a Legacy (pre-EIP2718) transaction request
Legacy(LegacyTransactionRequest),
/// Represents an EIP2930 (state access lists) transaction request
EIP2930(EIP2930TransactionRequest),
/// Represents an EIP1559 transaction request
EIP1559(EIP1559TransactionRequest),
/// Represents an EIP4844 transaction request
EIP4844(EIP4844TransactionRequest),
}
/// Represents a legacy transaction request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LegacyTransactionRequest {
/// The nonce of the transaction
pub nonce: U64,
/// The gas price for the transaction
pub gas_price: U128,
/// The gas limit for the transaction
pub gas_limit: U256,
/// The kind of transaction (e.g., Call, Create)
pub kind: TransactionKind,
/// The value of the transaction
pub value: U256,
/// The input data for the transaction
pub input: Bytes,
/// The optional chain ID for the transaction
pub chain_id: Option<u64>,
}
/// Represents an EIP-2930 transaction request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EIP2930TransactionRequest {
/// The chain ID for the transaction
pub chain_id: u64,
/// The nonce of the transaction
pub nonce: U64,
/// The gas price for the transaction
pub gas_price: U128,
/// The gas limit for the transaction
pub gas_limit: U256,
/// The kind of transaction (e.g., Call, Create)
pub kind: TransactionKind,
/// The value of the transaction
pub value: U256,
/// The input data for the transaction
pub input: Bytes,
/// The access list for the transaction
pub access_list: AccessList,
}
/// Represents an EIP-1559 transaction request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EIP1559TransactionRequest {
/// The chain ID for the transaction
pub chain_id: u64,
/// The nonce of the transaction
pub nonce: U64,
/// The maximum priority fee per gas for the transaction
pub max_priority_fee_per_gas: U128,
/// The maximum fee per gas for the transaction
pub max_fee_per_gas: U128,
/// The gas limit for the transaction
pub gas_limit: U256,
/// The kind of transaction (e.g., Call, Create)
pub kind: TransactionKind,
/// The value of the transaction
pub value: U256,
/// The input data for the transaction
pub input: Bytes,
/// The access list for the transaction
pub access_list: AccessList,
}
/// Represents an EIP-4844 transaction request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EIP4844TransactionRequest {
/// The chain ID for the transaction
pub chain_id: u64,
/// The nonce of the transaction
pub nonce: U64,
/// The maximum priority fee per gas for the transaction
pub max_priority_fee_per_gas: U128,
/// The maximum fee per gas for the transaction
pub max_fee_per_gas: U128,
/// The gas limit for the transaction
pub gas_limit: U256,
/// The kind of transaction (e.g., Call, Create)
pub kind: TransactionKind,
/// The value of the transaction
pub value: U256,
/// The input data for the transaction
pub input: Bytes,
/// The access list for the transaction
pub access_list: AccessList,
/// The maximum fee per blob gas for the transaction
pub max_fee_per_blob_gas: U128,
/// Versioned hashes associated with the transaction
pub blob_versioned_hashes: Vec<B256>,
/// Sidecar information for the transaction
pub sidecar: BlobTransactionSidecar,
}

View File

@ -1,7 +1,5 @@
//! MEV bundle type bindings
#![allow(missing_docs)]
use crate::{BlockId, BlockNumberOrTag, Log};
use alloy_primitives::{Address, Bytes, TxHash, B256, U256, U64};
use serde::{
@ -148,60 +146,77 @@ pub struct PrivacyHint {
}
impl PrivacyHint {
/// Sets the flag indicating inclusion of calldata and returns the modified PrivacyHint
/// instance.
pub fn with_calldata(mut self) -> Self {
self.calldata = true;
self
}
/// Sets the flag indicating inclusion of contract address and returns the modified PrivacyHint
/// instance.
pub fn with_contract_address(mut self) -> Self {
self.contract_address = true;
self
}
/// Sets the flag indicating inclusion of logs and returns the modified PrivacyHint instance.
pub fn with_logs(mut self) -> Self {
self.logs = true;
self
}
/// Sets the flag indicating inclusion of function selector and returns the modified PrivacyHint
/// instance.
pub fn with_function_selector(mut self) -> Self {
self.function_selector = true;
self
}
/// Sets the flag indicating inclusion of hash and returns the modified PrivacyHint instance.
pub fn with_hash(mut self) -> Self {
self.hash = true;
self
}
/// Sets the flag indicating inclusion of transaction hash and returns the modified PrivacyHint
/// instance.
pub fn with_tx_hash(mut self) -> Self {
self.tx_hash = true;
self
}
/// Checks if calldata inclusion flag is set.
pub fn has_calldata(&self) -> bool {
self.calldata
}
/// Checks if contract address inclusion flag is set.
pub fn has_contract_address(&self) -> bool {
self.contract_address
}
/// Checks if logs inclusion flag is set.
pub fn has_logs(&self) -> bool {
self.logs
}
/// Checks if function selector inclusion flag is set.
pub fn has_function_selector(&self) -> bool {
self.function_selector
}
/// Checks if hash inclusion flag is set.
pub fn has_hash(&self) -> bool {
self.hash
}
/// Checks if transaction hash inclusion flag is set.
pub fn has_tx_hash(&self) -> bool {
self.tx_hash
}
/// Calculates the number of hints set within the PrivacyHint instance.
fn num_hints(&self) -> usize {
let mut num_hints = 0;
if self.calldata {
@ -391,6 +406,7 @@ pub struct PrivateTransactionRequest {
/// be included.
#[serde(skip_serializing_if = "Option::is_none")]
pub max_block_number: Option<U64>,
/// Preferences for private transaction.
#[serde(default, skip_serializing_if = "PrivateTransactionPreferences::is_empty")]
pub preferences: PrivateTransactionPreferences,
}
@ -514,17 +530,23 @@ pub struct StatsSimulated {
pub sealed_by_builders_at: Vec<SealedByBuildersAt>,
}
/// Represents information about when a bundle was considered by a builder.
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConsideredByBuildersAt {
/// The public key of the builder.
pub pubkey: String,
/// The timestamp indicating when the bundle was considered by the builder.
pub timestamp: String,
}
/// Represents information about when a bundle was sealed by a builder.
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SealedByBuildersAt {
/// The public key of the builder.
pub pubkey: String,
/// The timestamp indicating when the bundle was sealed by the builder.
pub timestamp: String,
}
@ -615,17 +637,25 @@ pub struct EthCallBundle {
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct EthCallBundleResponse {
/// The hash of the bundle bodies.
pub bundle_hash: B256,
/// The gas price of the entire bundle
#[serde(with = "u256_numeric_string")]
pub bundle_gas_price: U256,
/// The difference in Ether sent to the coinbase after all transactions in the bundle
#[serde(with = "u256_numeric_string")]
pub coinbase_diff: U256,
/// The total amount of Ether sent to the coinbase after all transactions in the bundle
#[serde(with = "u256_numeric_string")]
pub eth_sent_to_coinbase: U256,
/// The total gas fees paid for all transactions in the bundle
#[serde(with = "u256_numeric_string")]
pub gas_fees: U256,
/// Results of individual transactions within the bundle
pub results: Vec<EthCallBundleTransactionResult>,
/// The block number used as a base for this simulation
pub state_block_number: u64,
/// The total gas used by all transactions in the bundle
pub total_gas_used: u64,
}
@ -633,17 +663,25 @@ pub struct EthCallBundleResponse {
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EthCallBundleTransactionResult {
/// The difference in Ether sent to the coinbase after the transaction
#[serde(with = "u256_numeric_string")]
pub coinbase_diff: U256,
/// The amount of Ether sent to the coinbase after the transaction
#[serde(with = "u256_numeric_string")]
pub eth_sent_to_coinbase: U256,
/// The address from which the transaction originated
pub from_address: Address,
/// The gas fees paid for the transaction
#[serde(with = "u256_numeric_string")]
pub gas_fees: U256,
/// The gas price used for the transaction
#[serde(with = "u256_numeric_string")]
pub gas_price: U256,
/// The amount of gas used by the transaction
pub gas_used: u64,
/// The address to which the transaction is sent (optional)
pub to_address: Option<Address>,
/// The transaction hash
pub tx_hash: B256,
/// Contains the return data if the transaction succeeded
///

View File

@ -1,7 +1,5 @@
//! Relay API bindings: <https://flashbots.github.io/relay-specs/>
#![allow(missing_docs)]
use crate::{
beacon::{BlsPublicKey, BlsSignature},
engine::{
@ -18,28 +16,42 @@ pub mod error;
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Validator {
/// The slot number for the validator entry.
#[serde_as(as = "DisplayFromStr")]
pub slot: u64,
/// The index of the validator.
#[serde_as(as = "DisplayFromStr")]
pub validator_index: u64,
/// Details of the validator registration.
pub entry: ValidatorRegistration,
}
/// Details of a validator registration.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ValidatorRegistration {
/// The registration message.
pub message: ValidatorRegistrationMessage,
/// The signature for the registration.
pub signature: BlsSignature,
}
/// Represents the message of a validator registration.
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ValidatorRegistrationMessage {
/// The fee recipient's address.
#[serde(rename = "fee_recipient")]
pub fee_recipient: Address,
/// The gas limit for the registration.
#[serde_as(as = "DisplayFromStr")]
pub gas_limit: u64,
/// The timestamp of the registration.
#[serde_as(as = "DisplayFromStr")]
pub timestamp: u64,
/// The public key of the validator.
pub pubkey: BlsPublicKey,
}
@ -50,19 +62,28 @@ pub struct ValidatorRegistrationMessage {
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
pub struct BidTrace {
/// The slot associated with the block.
#[serde_as(as = "DisplayFromStr")]
pub slot: u64,
/// The parent hash of the block.
pub parent_hash: B256,
/// The hash of the block.
pub block_hash: B256,
/// The public key of the builder.
#[serde(rename = "builder_pubkey")]
pub builder_public_key: BlsPublicKey,
/// The public key of the proposer.
#[serde(rename = "proposer_pubkey")]
pub proposer_public_key: BlsPublicKey,
/// The recipient of the proposer's fee.
pub proposer_fee_recipient: Address,
/// The gas limit associated with the block.
#[serde_as(as = "DisplayFromStr")]
pub gas_limit: u64,
/// The gas used within the block.
#[serde_as(as = "DisplayFromStr")]
pub gas_used: u64,
/// The value associated with the block.
#[serde_as(as = "DisplayFromStr")]
pub value: U256,
}
@ -71,7 +92,9 @@ pub struct BidTrace {
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Encode, ssz_derive::Decode))]
pub struct SignedBidTrace {
/// The BidTrace message associated with the submission.
pub message: BidTrace,
/// The signature associated with the submission.
pub signature: BlsSignature,
}
@ -80,9 +103,12 @@ pub struct SignedBidTrace {
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
pub struct SignedBidSubmissionV1 {
/// The BidTrace message associated with the submission.
pub message: BidTrace,
/// The execution payload for the submission.
#[serde(with = "crate::beacon::payload::beacon_payload_v1")]
pub execution_payload: ExecutionPayloadV1,
/// The signature associated with the submission.
pub signature: BlsSignature,
}
@ -91,9 +117,12 @@ pub struct SignedBidSubmissionV1 {
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
pub struct SignedBidSubmissionV2 {
/// The BidTrace message associated with the submission.
pub message: BidTrace,
/// The execution payload for the submission.
#[serde(with = "crate::beacon::payload::beacon_payload_v2")]
pub execution_payload: ExecutionPayloadV2,
/// The signature associated with the submission.
pub signature: BlsSignature,
}
@ -102,20 +131,26 @@ pub struct SignedBidSubmissionV2 {
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
pub struct SignedBidSubmissionV3 {
/// The BidTrace message associated with the submission.
pub message: BidTrace,
/// The execution payload for the submission.
#[serde(with = "crate::beacon::payload::beacon_payload_v3")]
pub execution_payload: ExecutionPayloadV3,
/// The Deneb block bundle for this bid.
pub blobs_bundle: BlobsBundleV1,
/// The signature associated with the submission.
pub signature: BlsSignature,
}
/// SubmitBlockRequest is the request from the builder to submit a block.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SubmitBlockRequest {
/// The BidTrace message associated with the block submission.
pub message: BidTrace,
/// The execution payload for the block submission.
#[serde(with = "crate::beacon::payload::beacon_payload")]
pub execution_payload: ExecutionPayload,
/// The signature associated with the block submission.
pub signature: BlsSignature,
}
@ -123,8 +158,10 @@ pub struct SubmitBlockRequest {
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequest {
/// The [SubmitBlockRequest] data to be validated.
#[serde(flatten)]
pub request: SubmitBlockRequest,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
}
@ -133,10 +170,13 @@ pub struct BuilderBlockValidationRequest {
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequestV2 {
/// The [SubmitBlockRequest] data to be validated.
#[serde(flatten)]
pub request: SubmitBlockRequest,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
/// The withdrawals root for the validation request.
pub withdrawals_root: B256,
}