add match_same_arms clippy lint (#8549)

This commit is contained in:
Thomas Coratger
2024-06-03 19:42:25 +02:00
committed by GitHub
parent 0f1bad98f2
commit e02b935e94
34 changed files with 259 additions and 310 deletions

View File

@ -156,6 +156,7 @@ use_self = "warn"
missing_const_for_fn = "warn"
empty_line_after_doc_comments = "warn"
iter_on_single_items = "warn"
match_same_arms = "warn"
doc_markdown = "warn"
unnecessary_struct_initialization = "warn"
string_lit_as_bytes = "warn"

View File

@ -340,8 +340,7 @@ impl<T: Table> ExtraTableElement<T> {
/// Return the key for the extra element
const fn key(&self) -> &T::Key {
match self {
Self::First { key, .. } => key,
Self::Second { key, .. } => key,
Self::First { key, .. } | Self::Second { key, .. } => key,
}
}
}

View File

@ -280,6 +280,7 @@ impl InsertBlockErrorKind {
/// Returns true if the error is caused by an invalid block
///
/// This is intended to be used to determine if the block should be marked as invalid.
#[allow(clippy::match_same_arms)]
pub const fn is_invalid_block(&self) -> bool {
match self {
Self::SenderRecovery | Self::Consensus(_) => true,
@ -321,9 +322,9 @@ impl InsertBlockErrorKind {
CanonicalError::BlockchainTree(_) |
CanonicalError::CanonicalCommit(_) |
CanonicalError::CanonicalRevert(_) |
CanonicalError::OptimisticTargetRevert(_) => false,
CanonicalError::Validation(_) => true,
CanonicalError::OptimisticTargetRevert(_) |
CanonicalError::Provider(_) => false,
CanonicalError::Validation(_) => true,
},
Self::BlockchainTree(_) => false,
}

View File

@ -133,8 +133,7 @@ impl Hardfork {
Self::Tangerine => Some(2463000),
Self::SpuriousDragon => Some(2675000),
Self::Byzantium => Some(4370000),
Self::Constantinople => Some(7280000),
Self::Petersburg => Some(7280000),
Self::Constantinople | Self::Petersburg => Some(7280000),
Self::Istanbul => Some(9069000),
Self::MuirGlacier => Some(9200000),
Self::Berlin => Some(12244000),
@ -156,19 +155,19 @@ impl Hardfork {
Self::Paris => Some(1735371),
Self::Shanghai => Some(2990908),
Self::Cancun => Some(5187023),
Self::Frontier => Some(0),
Self::Homestead => Some(0),
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier => Some(0),
_ => None,
}
@ -178,20 +177,20 @@ impl Hardfork {
pub const fn arbitrum_sepolia_activation_block(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(0),
Self::Homestead => Some(0),
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::GrayGlacier => Some(0),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(0),
Self::Shanghai => Some(10653737),
// Hardfork::ArbOS11 => Some(10653737),
@ -205,20 +204,20 @@ impl Hardfork {
pub const fn arbitrum_activation_block(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(0),
Self::Homestead => Some(0),
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::GrayGlacier => Some(0),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(0),
Self::Shanghai => Some(184097479),
// Hardfork::ArbOS11 => Some(184097479),
@ -233,27 +232,25 @@ impl Hardfork {
pub const fn base_sepolia_activation_block(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(0),
Self::Homestead => Some(0),
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::GrayGlacier => Some(0),
Self::Paris => Some(0),
Self::Bedrock => Some(0),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris |
Self::Bedrock |
Self::Regolith => Some(0),
Self::Shanghai => Some(2106456),
Self::Canyon => Some(2106456),
Self::Cancun => Some(6383256),
Self::Ecotone => Some(6383256),
Self::Shanghai | Self::Canyon => Some(2106456),
Self::Cancun | Self::Ecotone => Some(6383256),
_ => None,
}
}
@ -263,27 +260,25 @@ impl Hardfork {
pub const fn base_mainnet_activation_block(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(0),
Self::Homestead => Some(0),
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::GrayGlacier => Some(0),
Self::Paris => Some(0),
Self::Bedrock => Some(0),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris |
Self::Bedrock |
Self::Regolith => Some(0),
Self::Shanghai => Some(9101527),
Self::Canyon => Some(9101527),
Self::Cancun => Some(11188936),
Self::Ecotone => Some(11188936),
Self::Shanghai | Self::Canyon => Some(9101527),
Self::Cancun | Self::Ecotone => Some(11188936),
_ => None,
}
}
@ -292,18 +287,18 @@ impl Hardfork {
const fn holesky_activation_block(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Dao => Some(0),
Self::Tangerine => Some(0),
Self::SpuriousDragon => Some(0),
Self::Byzantium => Some(0),
Self::Constantinople => Some(0),
Self::Petersburg => Some(0),
Self::Istanbul => Some(0),
Self::MuirGlacier => Some(0),
Self::Berlin => Some(0),
Self::London => Some(0),
Self::ArrowGlacier => Some(0),
Self::GrayGlacier => Some(0),
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(0),
Self::Shanghai => Some(6698),
Self::Cancun => Some(894733),
@ -345,8 +340,7 @@ impl Hardfork {
Self::Tangerine => Some(1476753571),
Self::SpuriousDragon => Some(1479788144),
Self::Byzantium => Some(1508131331),
Self::Constantinople => Some(1551340324),
Self::Petersburg => Some(1551340324),
Self::Constantinople | Self::Petersburg => Some(1551340324),
Self::Istanbul => Some(1575807909),
Self::MuirGlacier => Some(1577953849),
Self::Berlin => Some(1618481223),
@ -366,20 +360,20 @@ impl Hardfork {
pub const fn sepolia_activation_timestamp(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(1633267481),
Self::Homestead => Some(1633267481),
Self::Dao => Some(1633267481),
Self::Tangerine => Some(1633267481),
Self::SpuriousDragon => Some(1633267481),
Self::Byzantium => Some(1633267481),
Self::Constantinople => Some(1633267481),
Self::Petersburg => Some(1633267481),
Self::Istanbul => Some(1633267481),
Self::MuirGlacier => Some(1633267481),
Self::Berlin => Some(1633267481),
Self::London => Some(1633267481),
Self::ArrowGlacier => Some(1633267481),
Self::GrayGlacier => Some(1633267481),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(1633267481),
Self::Shanghai => Some(1677557088),
Self::Cancun => Some(1706655072),
@ -393,20 +387,20 @@ impl Hardfork {
match self {
Self::Shanghai => Some(1696000704),
Self::Cancun => Some(1707305664),
Self::Frontier => Some(1695902100),
Self::Homestead => Some(1695902100),
Self::Dao => Some(1695902100),
Self::Tangerine => Some(1695902100),
Self::SpuriousDragon => Some(1695902100),
Self::Byzantium => Some(1695902100),
Self::Constantinople => Some(1695902100),
Self::Petersburg => Some(1695902100),
Self::Istanbul => Some(1695902100),
Self::MuirGlacier => Some(1695902100),
Self::Berlin => Some(1695902100),
Self::London => Some(1695902100),
Self::ArrowGlacier => Some(1695902100),
Self::GrayGlacier => Some(1695902100),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(1695902100),
_ => None,
}
@ -417,20 +411,20 @@ impl Hardfork {
pub const fn arbitrum_sepolia_activation_timestamp(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(1692726996),
Self::Homestead => Some(1692726996),
Self::Dao => Some(1692726996),
Self::Tangerine => Some(1692726996),
Self::SpuriousDragon => Some(1692726996),
Self::Byzantium => Some(1692726996),
Self::Constantinople => Some(1692726996),
Self::Petersburg => Some(1692726996),
Self::Istanbul => Some(1692726996),
Self::MuirGlacier => Some(1692726996),
Self::Berlin => Some(1692726996),
Self::London => Some(1692726996),
Self::ArrowGlacier => Some(1692726996),
Self::GrayGlacier => Some(1692726996),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(1692726996),
Self::Shanghai => Some(1706634000),
// Hardfork::ArbOS11 => Some(1706634000),
@ -444,20 +438,20 @@ impl Hardfork {
pub const fn arbitrum_activation_timestamp(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(1622240000),
Self::Homestead => Some(1622240000),
Self::Dao => Some(1622240000),
Self::Tangerine => Some(1622240000),
Self::SpuriousDragon => Some(1622240000),
Self::Byzantium => Some(1622240000),
Self::Constantinople => Some(1622240000),
Self::Petersburg => Some(1622240000),
Self::Istanbul => Some(1622240000),
Self::MuirGlacier => Some(1622240000),
Self::Berlin => Some(1622240000),
Self::London => Some(1622240000),
Self::ArrowGlacier => Some(1622240000),
Self::GrayGlacier => Some(1622240000),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris => Some(1622240000),
Self::Shanghai => Some(1708804873),
// Hardfork::ArbOS11 => Some(1708804873),
@ -472,27 +466,25 @@ impl Hardfork {
pub const fn base_sepolia_activation_timestamp(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(1695768288),
Self::Homestead => Some(1695768288),
Self::Dao => Some(1695768288),
Self::Tangerine => Some(1695768288),
Self::SpuriousDragon => Some(1695768288),
Self::Byzantium => Some(1695768288),
Self::Constantinople => Some(1695768288),
Self::Petersburg => Some(1695768288),
Self::Istanbul => Some(1695768288),
Self::MuirGlacier => Some(1695768288),
Self::Berlin => Some(1695768288),
Self::London => Some(1695768288),
Self::ArrowGlacier => Some(1695768288),
Self::GrayGlacier => Some(1695768288),
Self::Paris => Some(1695768288),
Self::Bedrock => Some(1695768288),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris |
Self::Bedrock |
Self::Regolith => Some(1695768288),
Self::Shanghai => Some(1699981200),
Self::Canyon => Some(1699981200),
Self::Cancun => Some(1708534800),
Self::Ecotone => Some(1708534800),
Self::Shanghai | Self::Canyon => Some(1699981200),
Self::Cancun | Self::Ecotone => Some(1708534800),
_ => None,
}
}
@ -502,27 +494,25 @@ impl Hardfork {
pub const fn base_mainnet_activation_timestamp(&self) -> Option<u64> {
#[allow(unreachable_patterns)]
match self {
Self::Frontier => Some(1686789347),
Self::Homestead => Some(1686789347),
Self::Dao => Some(1686789347),
Self::Tangerine => Some(1686789347),
Self::SpuriousDragon => Some(1686789347),
Self::Byzantium => Some(1686789347),
Self::Constantinople => Some(1686789347),
Self::Petersburg => Some(1686789347),
Self::Istanbul => Some(1686789347),
Self::MuirGlacier => Some(1686789347),
Self::Berlin => Some(1686789347),
Self::London => Some(1686789347),
Self::ArrowGlacier => Some(1686789347),
Self::GrayGlacier => Some(1686789347),
Self::Paris => Some(1686789347),
Self::Bedrock => Some(1686789347),
Self::Frontier |
Self::Homestead |
Self::Dao |
Self::Tangerine |
Self::SpuriousDragon |
Self::Byzantium |
Self::Constantinople |
Self::Petersburg |
Self::Istanbul |
Self::MuirGlacier |
Self::Berlin |
Self::London |
Self::ArrowGlacier |
Self::GrayGlacier |
Self::Paris |
Self::Bedrock |
Self::Regolith => Some(1686789347),
Self::Shanghai => Some(1704992401),
Self::Canyon => Some(1704992401),
Self::Cancun => Some(1710374401),
Self::Ecotone => Some(1710374401),
Self::Shanghai | Self::Canyon => Some(1704992401),
Self::Cancun | Self::Ecotone => Some(1710374401),
_ => None,
}
}

View File

@ -17,7 +17,7 @@ pub enum StateRootError {
impl From<StateRootError> for DatabaseError {
fn from(err: StateRootError) -> Self {
match err {
StateRootError::DB(err) => err,
StateRootError::DB(err) |
StateRootError::StorageRootError(StorageRootError::DB(err)) => err,
}
}

View File

@ -167,7 +167,7 @@ impl Stream for MockDiscovery {
}))
}
}
Message::Pong(_) => {}
Message::Pong(_) | Message::Neighbours(_) => {}
Message::FindNode(msg) => {
if let Some(nodes) = this.pending_neighbours.remove(&msg.id) {
let msg = Message::Neighbours(Neighbours {
@ -181,7 +181,6 @@ impl Stream for MockDiscovery {
}))
}
}
Message::Neighbours(_) => {}
Message::EnrRequest(_) | Message::EnrResponse(_) => todo!(),
},
}

View File

@ -222,6 +222,7 @@ impl Discv5 {
/// Process an event from the underlying [`discv5::Discv5`] node.
pub fn on_discv5_update(&self, update: discv5::Event) -> Option<DiscoveredPeer> {
#[allow(clippy::match_same_arms)]
match update {
discv5::Event::SocketUpdated(_) | discv5::Event::TalkRequest(_) |
// `Discovered` not unique discovered peers

View File

@ -378,7 +378,7 @@ where
let target = headers.remove(0).seal_slow();
match sync_target {
SyncTargetBlock::Hash(hash) => {
SyncTargetBlock::Hash(hash) | SyncTargetBlock::HashAndNumber { hash, .. } => {
if target.hash() != hash {
return Err(HeadersResponseError {
request,
@ -403,18 +403,6 @@ where
.into())
}
}
SyncTargetBlock::HashAndNumber { hash, .. } => {
if target.hash() != hash {
return Err(HeadersResponseError {
request,
peer_id: Some(peer_id),
error: DownloadError::InvalidTip(
GotExpected { got: target.hash(), expected: hash }.into(),
),
}
.into())
}
}
}
trace!(target: "downloaders::headers", head=?self.local_block_number(), hash=?target.hash(), number=%target.number, "Received sync target");
@ -1014,17 +1002,19 @@ impl SyncTargetBlock {
const fn with_hash(self, hash: B256) -> Self {
match self {
Self::Hash(_) => Self::Hash(hash),
Self::Number(number) => Self::HashAndNumber { hash, number },
Self::HashAndNumber { number, .. } => Self::HashAndNumber { hash, number },
Self::Number(number) | Self::HashAndNumber { number, .. } => {
Self::HashAndNumber { hash, number }
}
}
}
/// Set a number on the instance.
const fn with_number(self, number: u64) -> Self {
match self {
Self::Hash(hash) => Self::HashAndNumber { hash, number },
Self::Hash(hash) | Self::HashAndNumber { hash, .. } => {
Self::HashAndNumber { hash, number }
}
Self::Number(_) => Self::Number(number),
Self::HashAndNumber { hash, .. } => Self::HashAndNumber { hash, number },
}
}
@ -1054,9 +1044,8 @@ impl SyncTargetBlock {
/// Return the hash of the target block, if it is set.
const fn hash(&self) -> Option<B256> {
match self {
Self::Hash(hash) => Some(*hash),
Self::Hash(hash) | Self::HashAndNumber { hash, .. } => Some(*hash),
Self::Number(_) => None,
Self::HashAndNumber { hash, .. } => Some(*hash),
}
}
@ -1064,8 +1053,7 @@ impl SyncTargetBlock {
const fn number(&self) -> Option<u64> {
match self {
Self::Hash(_) => None,
Self::Number(number) => Some(*number),
Self::HashAndNumber { number, .. } => Some(*number),
Self::Number(number) | Self::HashAndNumber { number, .. } => Some(*number),
}
}
}

View File

@ -389,8 +389,7 @@ mod tests {
let mut forkhash = ForkHash::from(genesis_hash);
for (_, condition) in hardforks {
forkhash += match condition {
ForkCondition::Block(n) => n,
ForkCondition::Timestamp(n) => n,
ForkCondition::Block(n) | ForkCondition::Timestamp(n) => n,
_ => unreachable!("only block and timestamp forks are used in this test"),
}
}

View File

@ -331,8 +331,7 @@ impl SharedCapability {
/// message id space.
pub const fn message_id_offset(&self) -> u8 {
match self {
Self::Eth { offset, .. } => *offset,
Self::UnknownCapability { offset, .. } => *offset,
Self::Eth { offset, .. } | Self::UnknownCapability { offset, .. } => *offset,
}
}

View File

@ -86,7 +86,7 @@ impl P2PStreamError {
/// Returns the [`DisconnectReason`] if it is the `Disconnected` variant.
pub const fn as_disconnected(&self) -> Option<DisconnectReason> {
let reason = match self {
Self::HandshakeError(P2PHandshakeError::Disconnected(reason)) => reason,
Self::HandshakeError(P2PHandshakeError::Disconnected(reason)) |
Self::Disconnected(reason) => reason,
_ => return None,
};

View File

@ -703,8 +703,7 @@ impl Encodable for P2PMessage {
Self::Hello(msg) => msg.length(),
Self::Disconnect(msg) => msg.length(),
// id + snappy encoded payload
Self::Ping => 3, // len([0x01, 0x00, 0xc0]) = 3
Self::Pong => 3, // len([0x01, 0x00, 0xc0]) = 3
Self::Ping | Self::Pong => 3, // len([0x01, 0x00, 0xc0]) = 3
};
payload_len + 1 // (1 for length of p2p message id)
}

View File

@ -125,8 +125,7 @@ pub mod proto {
let mut buf = BytesMut::new();
buf.put_u8(self.message_type as u8);
match &self.message {
TestProtoMessageKind::Ping => {}
TestProtoMessageKind::Pong => {}
TestProtoMessageKind::Ping | TestProtoMessageKind::Pong => {}
TestProtoMessageKind::Message(msg) => {
buf.put(msg.as_bytes());
}

View File

@ -215,7 +215,7 @@ impl Discovery {
fn on_discv4_update(&mut self, update: DiscoveryUpdate) {
match update {
DiscoveryUpdate::Added(record) => {
DiscoveryUpdate::Added(record) | DiscoveryUpdate::DiscoveredAtCapacity(record) => {
self.on_node_record_update(record, None);
}
DiscoveryUpdate::EnrForkId(node, fork_id) => {
@ -229,9 +229,6 @@ impl Discovery {
self.on_discv4_update(update);
}
}
DiscoveryUpdate::DiscoveredAtCapacity(record) => {
self.on_node_record_update(record, None);
}
}
}

View File

@ -431,8 +431,9 @@ impl DownloadRequest {
/// Returns the requested priority of this request
const fn get_priority(&self) -> &Priority {
match self {
Self::GetBlockHeaders { priority, .. } => priority,
Self::GetBlockBodies { priority, .. } => priority,
Self::GetBlockHeaders { priority, .. } | Self::GetBlockBodies { priority, .. } => {
priority
}
}
}

View File

@ -316,10 +316,7 @@ where
self.state_fetcher.on_pending_disconnect(&peer_id);
self.queued_messages.push_back(StateAction::Disconnect { peer_id, reason });
}
PeerAction::DisconnectBannedIncoming { peer_id } => {
self.state_fetcher.on_pending_disconnect(&peer_id);
self.queued_messages.push_back(StateAction::Disconnect { peer_id, reason: None });
}
PeerAction::DisconnectBannedIncoming { peer_id } |
PeerAction::DisconnectUntrustedIncoming { peer_id } => {
self.state_fetcher.on_pending_disconnect(&peer_id);
self.queued_messages.push_back(StateAction::Disconnect { peer_id, reason: None });
@ -334,8 +331,7 @@ where
PeerAction::PeerRemoved(peer_id) => {
self.queued_messages.push_back(StateAction::PeerRemoved(peer_id))
}
PeerAction::BanPeer { .. } => {}
PeerAction::UnBanPeer { .. } => {}
PeerAction::BanPeer { .. } | PeerAction::UnBanPeer { .. } => {}
}
}

View File

@ -244,7 +244,7 @@ impl ValidateTx68 for EthMessageFilter {
fn max_encoded_tx_length(&self, ty: TxType) -> Option<usize> {
// the biggest transaction so far is a blob transaction, which is currently max 2^17,
// encoded length, nonetheless, the blob tx may become bigger in the future.
#[allow(unreachable_patterns)]
#[allow(unreachable_patterns, clippy::match_same_arms)]
match ty {
TxType::Legacy | TxType::Eip2930 | TxType::Eip1559 => Some(MAX_MESSAGE_SIZE),
TxType::Eip4844 => None,

View File

@ -54,7 +54,7 @@ async fn test_establish_connections() {
let mut established = listener0.take(4);
while let Some(ev) = established.next().await {
match ev {
NetworkEvent::SessionClosed { .. } => {
NetworkEvent::SessionClosed { .. } | NetworkEvent::PeerRemoved(_) => {
panic!("unexpected event")
}
NetworkEvent::SessionEstablished { peer_id, .. } => {
@ -63,9 +63,6 @@ async fn test_establish_connections() {
NetworkEvent::PeerAdded(peer_id) => {
assert!(expected_peers.remove(&peer_id))
}
NetworkEvent::PeerRemoved(_) => {
panic!("unexpected event")
}
}
}
assert!(expected_connections.is_empty());

View File

@ -99,11 +99,8 @@ mod proto {
let mut buf = BytesMut::new();
buf.put_u8(self.message_type as u8);
match &self.message {
PingPongProtoMessageKind::Ping => {}
PingPongProtoMessageKind::Pong => {}
PingPongProtoMessageKind::PingMessage(msg) => {
buf.put(msg.as_bytes());
}
PingPongProtoMessageKind::Ping | PingPongProtoMessageKind::Pong => {}
PingPongProtoMessageKind::PingMessage(msg) |
PingPongProtoMessageKind::PongMessage(msg) => {
buf.put(msg.as_bytes());
}

View File

@ -61,11 +61,11 @@ impl EthResponseValidator for RequestResult<Vec<Header>> {
fn reputation_change_err(&self) -> Option<ReputationChangeKind> {
if let Err(err) = self {
match err {
RequestError::ChannelClosed => None,
RequestError::ConnectionDropped => None,
RequestError::UnsupportedCapability => None,
RequestError::Timeout => Some(ReputationChangeKind::Timeout),
RequestError::ChannelClosed |
RequestError::ConnectionDropped |
RequestError::UnsupportedCapability |
RequestError::BadResponse => None,
RequestError::Timeout => Some(ReputationChangeKind::Timeout),
}
} else {
None

View File

@ -848,9 +848,9 @@ impl ChainSpec {
// We filter out TTD-based forks w/o a pre-known block since those do not show up in the
// fork filter.
Some(match condition {
ForkCondition::Block(block) => ForkFilterKey::Block(block),
ForkCondition::Timestamp(time) => ForkFilterKey::Time(time),
ForkCondition::Block(block) |
ForkCondition::TTD { fork_block: Some(block), .. } => ForkFilterKey::Block(block),
ForkCondition::Timestamp(time) => ForkFilterKey::Time(time),
_ => return None,
})
});

View File

@ -213,7 +213,7 @@ impl BlobTransaction {
// decode the _first_ list header for the rest of the transaction
let outer_header = Header::decode(data)?;
if !outer_header.list {
return Err(RlpError::Custom("PooledTransactions blob tx must be encoded as a list"))
return Err(RlpError::Custom("PooledTransactions blob tx must be encoded as a list"));
}
let outer_remaining_len = data.len();
@ -225,7 +225,7 @@ impl BlobTransaction {
if !inner_header.list {
return Err(RlpError::Custom(
"PooledTransactions inner blob tx must be encoded as a list",
))
));
}
let inner_remaining_len = data.len();
@ -239,7 +239,7 @@ impl BlobTransaction {
// the inner header only decodes the transaction and signature, so we check the length here
let inner_consumed = inner_remaining_len - data.len();
if inner_consumed != inner_header.payload_length {
return Err(RlpError::UnexpectedLength)
return Err(RlpError::UnexpectedLength);
}
// All that's left are the blobs, commitments, and proofs

View File

@ -859,8 +859,8 @@ mod tests {
loop {
match select(closed, stream.next()).await {
// subscription closed.
Either::Left((_, _)) => break Ok(()),
// subscription closed or stream is closed.
Either::Left((_, _)) | Either::Right((None, _)) => break Ok(()),
// received new item from the stream.
Either::Right((Some(Ok(item)), c)) => {
@ -878,9 +878,6 @@ mod tests {
// Send back back the error.
Either::Right((Some(Err(e)), _)) => break Err(e.into()),
// Stream is closed.
Either::Right((None, _)) => break Ok(()),
}
}
}

View File

@ -49,8 +49,7 @@ fn fill(
#[allow(unreachable_patterns)]
let (gas_price, max_fee_per_gas) = match signed_tx.tx_type() {
TxType::Legacy => (Some(signed_tx.max_fee_per_gas()), None),
TxType::Eip2930 => (Some(signed_tx.max_fee_per_gas()), None),
TxType::Legacy | TxType::Eip2930 => (Some(signed_tx.max_fee_per_gas()), None),
TxType::Eip1559 | TxType::Eip4844 => {
// the gas price field for EIP1559 is set to `min(tip, gasFeeCap - baseFee) +
// baseFee`

View File

@ -150,7 +150,8 @@ impl From<EthApiError> for ErrorObject<'static> {
EthApiError::InvalidBlockData(_) |
EthApiError::Internal(_) |
EthApiError::TransactionNotFound |
EthApiError::EvmCustom(_) => internal_rpc_err(error.to_string()),
EthApiError::EvmCustom(_) |
EthApiError::InvalidRewardPercentiles => internal_rpc_err(error.to_string()),
EthApiError::UnknownBlockNumber | EthApiError::UnknownBlockOrTxIndex => {
rpc_error_with_code(EthRpcErrorCode::ResourceNotFound.code(), error.to_string())
}
@ -160,12 +161,12 @@ impl From<EthApiError> for ErrorObject<'static> {
EthApiError::Unsupported(msg) => internal_rpc_err(msg),
EthApiError::InternalJsTracerError(msg) => internal_rpc_err(msg),
EthApiError::InvalidParams(msg) => invalid_params_rpc_err(msg),
EthApiError::InvalidRewardPercentiles => internal_rpc_err(error.to_string()),
err @ EthApiError::ExecutionTimedOut(_) => {
rpc_error_with_code(CALL_EXECUTION_FAILED_CODE, err.to_string())
}
err @ EthApiError::InternalBlockingTaskError => internal_rpc_err(err.to_string()),
err @ EthApiError::InternalEthError => internal_rpc_err(err.to_string()),
err @ EthApiError::InternalBlockingTaskError | err @ EthApiError::InternalEthError => {
internal_rpc_err(err.to_string())
}
err @ EthApiError::TransactionInputError(_) => invalid_params_rpc_err(err.to_string()),
EthApiError::Other(err) => err.to_rpc_error(),
EthApiError::MuxTracerError(msg) => internal_rpc_err(msg.to_string()),
@ -392,10 +393,9 @@ impl RpcInvalidTransactionError {
pub(crate) const fn out_of_gas(reason: OutOfGasError, gas_limit: u64) -> Self {
match reason {
OutOfGasError::Basic => Self::BasicOutOfGas(gas_limit),
OutOfGasError::Memory => Self::MemoryOutOfGas(gas_limit),
OutOfGasError::Memory | OutOfGasError::MemoryLimit => Self::MemoryOutOfGas(gas_limit),
OutOfGasError::Precompile => Self::PrecompileOutOfGas(gas_limit),
OutOfGasError::InvalidOperand => Self::InvalidOperandOutOfGas(gas_limit),
OutOfGasError::MemoryLimit => Self::MemoryOutOfGas(gas_limit),
}
}
}
@ -471,7 +471,7 @@ impl From<reth_primitives::InvalidTransactionError> for RpcInvalidTransactionErr
InvalidTransactionError::ChainIdMismatch => Self::InvalidChainId,
InvalidTransactionError::Eip2930Disabled |
InvalidTransactionError::Eip1559Disabled |
InvalidTransactionError::Eip4844Disabled => Self::TxTypeNotSupported,
InvalidTransactionError::Eip4844Disabled |
InvalidTransactionError::TxTypeNotSupported => Self::TxTypeNotSupported,
InvalidTransactionError::GasUintOverflow => Self::GasUintOverflow,
InvalidTransactionError::GasTooLow => Self::GasTooLow,
@ -589,8 +589,9 @@ impl From<PoolError> for RpcPoolError {
match err.kind {
PoolErrorKind::ReplacementUnderpriced => Self::ReplaceUnderpriced,
PoolErrorKind::FeeCapBelowMinimumProtocolFeeCap(_) => Self::Underpriced,
PoolErrorKind::SpammerExceededCapacity(_) => Self::TxPoolOverflow,
PoolErrorKind::DiscardedOnInsert => Self::TxPoolOverflow,
PoolErrorKind::SpammerExceededCapacity(_) | PoolErrorKind::DiscardedOnInsert => {
Self::TxPoolOverflow
}
PoolErrorKind::InvalidTransaction(err) => err.into(),
PoolErrorKind::Other(err) => Self::Other(err),
PoolErrorKind::AlreadyImported => Self::AlreadyKnown,

View File

@ -711,12 +711,8 @@ impl From<FilterError> for jsonrpsee::types::error::ErrorObject<'static> {
rpc_error_with_code(jsonrpsee::types::error::INTERNAL_ERROR_CODE, err.to_string())
}
FilterError::EthAPIError(err) => err.into(),
err @ FilterError::InvalidBlockRangeParams => {
rpc_error_with_code(jsonrpsee::types::error::INVALID_PARAMS_CODE, err.to_string())
}
err @ FilterError::QueryExceedsMaxBlocks(_) => {
rpc_error_with_code(jsonrpsee::types::error::INVALID_PARAMS_CODE, err.to_string())
}
err @ FilterError::InvalidBlockRangeParams |
err @ FilterError::QueryExceedsMaxBlocks(_) |
err @ FilterError::QueryExceedsMaxResults(_) => {
rpc_error_with_code(jsonrpsee::types::error::INVALID_PARAMS_CODE, err.to_string())
}

View File

@ -57,9 +57,7 @@ impl StaticFileSegment {
};
match self {
Self::Headers => default_config,
Self::Transactions => default_config,
Self::Receipts => default_config,
Self::Headers | Self::Transactions | Self::Receipts => default_config,
}
}
@ -67,8 +65,7 @@ impl StaticFileSegment {
pub const fn columns(&self) -> usize {
match self {
Self::Headers => 3,
Self::Transactions => 1,
Self::Receipts => 1,
Self::Transactions | Self::Receipts => 1,
}
}

View File

@ -26,8 +26,7 @@ impl<'a> EnumHandler<'a> {
// The following method will advance the
// `fields_iterator` by itself and stop right before the next variant.
FieldTypes::EnumVariant(name) => self.to(name, ident),
FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::StructField(_) => unreachable!(),
FieldTypes::EnumUnnamedField(_) | FieldTypes::StructField(_) => unreachable!(),
}
}
self.enum_lines
@ -39,8 +38,7 @@ impl<'a> EnumHandler<'a> {
// The following method will advance the
// `fields_iterator` by itself and stop right before the next variant.
FieldTypes::EnumVariant(name) => self.from(name, ident),
FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::StructField(_) => unreachable!(),
FieldTypes::EnumUnnamedField(_) | FieldTypes::StructField(_) => unreachable!(),
}
}
self.enum_lines

View File

@ -23,8 +23,7 @@ impl<'a> StructHandler<'a> {
pub fn generate_to(mut self) -> Vec<TokenStream2> {
while let Some(field) = self.next_field() {
match field {
FieldTypes::EnumVariant(_) => unreachable!(),
FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::EnumVariant(_) | FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::StructField(field_descriptor) => self.to(field_descriptor),
}
}
@ -34,8 +33,7 @@ impl<'a> StructHandler<'a> {
pub fn generate_from(&mut self, known_types: &[&str]) -> Vec<TokenStream2> {
while let Some(field) = self.next_field() {
match field {
FieldTypes::EnumVariant(_) => unreachable!(),
FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::EnumVariant(_) | FieldTypes::EnumUnnamedField(_) => unreachable!(),
FieldTypes::StructField(field_descriptor) => {
self.from(field_descriptor, known_types)
}

View File

@ -191,10 +191,10 @@ impl Error {
Self::WannaRecovery => ffi::MDBX_WANNA_RECOVERY,
Self::KeyMismatch => ffi::MDBX_EKEYMISMATCH,
Self::DecodeErrorLenDiff | Self::DecodeError => ffi::MDBX_EINVAL,
Self::Access => ffi::MDBX_EACCESS,
Self::TooLarge => ffi::MDBX_TOO_LARGE,
Self::BadSignature => ffi::MDBX_EBADSIGN,
Self::WriteTransactionUnsupportedInReadOnlyMode => ffi::MDBX_EACCESS,
Self::Access |
Self::WriteTransactionUnsupportedInReadOnlyMode |
Self::NestedTransactionsUnsupportedWithWriteMap => ffi::MDBX_EACCESS,
Self::ReadTransactionTimeout => -96000, // Custom non-MDBX error code
Self::Other(err_code) => *err_code,

View File

@ -107,8 +107,7 @@ impl CanonStateNotification {
/// Returns the new committed [Chain] for [`Self::Reorg`] and [`Self::Commit`] variants.
pub fn committed(&self) -> Arc<Chain> {
match self {
Self::Commit { new } => new.clone(),
Self::Reorg { new, .. } => new.clone(),
Self::Commit { new } | Self::Reorg { new, .. } => new.clone(),
}
}
@ -118,8 +117,7 @@ impl CanonStateNotification {
/// 1 new block.
pub fn tip(&self) -> &SealedBlockWithSenders {
match self {
Self::Commit { new } => new.tip(),
Self::Reorg { new, .. } => new.tip(),
Self::Commit { new } | Self::Reorg { new, .. } => new.tip(),
}
}

View File

@ -92,6 +92,7 @@ impl PoolError {
/// erroneous transaction.
#[inline]
pub fn is_bad_transaction(&self) -> bool {
#[allow(clippy::match_same_arms)]
match &self.kind {
PoolErrorKind::AlreadyImported => {
// already imported but not bad
@ -213,6 +214,7 @@ impl InvalidPoolTransactionError {
/// context of the transaction pool and warrants peer penalization.
///
/// See [`PoolError::is_bad_transaction`].
#[allow(clippy::match_same_arms)]
#[inline]
fn is_bad_transaction(&self) -> bool {
match self {
@ -243,10 +245,10 @@ impl InvalidPoolTransactionError {
// settings
false
}
InvalidTransactionError::OldLegacyChainId => true,
InvalidTransactionError::ChainIdMismatch => true,
InvalidTransactionError::GasUintOverflow => true,
InvalidTransactionError::TxTypeNotSupported => true,
InvalidTransactionError::OldLegacyChainId |
InvalidTransactionError::ChainIdMismatch |
InvalidTransactionError::GasUintOverflow |
InvalidTransactionError::TxTypeNotSupported |
InvalidTransactionError::SignerAccountHasBytecode => true,
}
}

View File

@ -1036,7 +1036,7 @@ impl PoolTransaction for EthPooledTransaction {
///
/// This will return `None` for non-EIP1559 transactions
fn max_priority_fee_per_gas(&self) -> Option<u128> {
#[allow(unreachable_patterns)]
#[allow(unreachable_patterns, clippy::match_same_arms)]
match &self.transaction.transaction {
Transaction::Legacy(_) | Transaction::Eip2930(_) => None,
Transaction::Eip1559(tx) => Some(tx.max_priority_fee_per_gas),

View File

@ -333,9 +333,9 @@ impl From<ForkSpec> for ChainSpec {
ForkSpec::Istanbul => spec_builder.istanbul_activated(),
ForkSpec::Berlin => spec_builder.berlin_activated(),
ForkSpec::London | ForkSpec::BerlinToLondonAt5 => spec_builder.london_activated(),
ForkSpec::Merge => spec_builder.paris_activated(),
ForkSpec::MergeEOF => spec_builder.paris_activated(),
ForkSpec::MergeMeterInitCode => spec_builder.paris_activated(),
ForkSpec::Merge |
ForkSpec::MergeEOF |
ForkSpec::MergeMeterInitCode |
ForkSpec::MergePush0 => spec_builder.paris_activated(),
ForkSpec::Shanghai => spec_builder.shanghai_activated(),
ForkSpec::Cancun => spec_builder.cancun_activated(),