Rust clippy 1.87 lint fixes (#7471)

Fix clippy lints for `rustc` 1.87


  clippy complains about `BeaconChainError` being too large. I went on a bit of a boxing spree because of this. We may instead want to `Box` some of the `BeaconChainError` variants?
This commit is contained in:
Eitan Seri-Levi
2025-05-15 22:03:00 -07:00
committed by GitHub
parent c4182e362b
commit 268809a530
24 changed files with 223 additions and 195 deletions

View File

@@ -537,7 +537,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
attestation: single_attestation,
},
None,
AttnError::BeaconChainError(error),
AttnError::BeaconChainError(Box::new(error)),
seen_timestamp,
);
}
@@ -2734,41 +2734,57 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
"attn_to_finalized_block",
);
}
AttnError::BeaconChainError(BeaconChainError::DBError(Error::HotColdDBError(
HotColdDBError::FinalizedStateNotInHotDatabase { .. },
))) => {
debug!(%peer_id, "Attestation for finalized state");
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
}
e @ AttnError::BeaconChainError(BeaconChainError::MaxCommitteePromises(_)) => {
debug!(
target_root = ?failed_att.attestation_data().target.root,
?beacon_block_root,
slot = ?failed_att.attestation_data().slot,
?attestation_type,
error = ?e,
%peer_id,
"Dropping attestation"
);
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
}
AttnError::BeaconChainError(e) => {
/*
* Lighthouse hit an unexpected error whilst processing the attestation. It
* should be impossible to trigger a `BeaconChainError` from the network,
* so we have a bug.
*
* It's not clear if the message is invalid/malicious.
*/
error!(
?beacon_block_root,
slot = ?failed_att.attestation_data().slot,
?attestation_type,
%peer_id,
error = ?e,
"Unable to validate attestation"
);
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
match e.as_ref() {
BeaconChainError::DBError(Error::HotColdDBError(
HotColdDBError::FinalizedStateNotInHotDatabase { .. },
)) => {
debug!(%peer_id, "Attestation for finalized state");
self.propagate_validation_result(
message_id,
peer_id,
MessageAcceptance::Ignore,
);
}
BeaconChainError::MaxCommitteePromises(e) => {
debug!(
target_root = ?failed_att.attestation_data().target.root,
?beacon_block_root,
slot = ?failed_att.attestation_data().slot,
?attestation_type,
error = ?e,
%peer_id,
"Dropping attestation"
);
self.propagate_validation_result(
message_id,
peer_id,
MessageAcceptance::Ignore,
);
}
_ => {
/*
* Lighthouse hit an unexpected error whilst processing the attestation. It
* should be impossible to trigger a `BeaconChainError` from the network,
* so we have a bug.
*
* It's not clear if the message is invalid/malicious.
*/
error!(
?beacon_block_root,
slot = ?failed_att.attestation_data().slot,
?attestation_type,
%peer_id,
error = ?e,
"Unable to validate attestation"
);
self.propagate_validation_result(
message_id,
peer_id,
MessageAcceptance::Ignore,
);
}
}
}
}

View File

@@ -66,7 +66,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
fn check_peer_relevance(
&self,
remote: &StatusMessage,
) -> Result<Option<String>, BeaconChainError> {
) -> Result<Option<String>, Box<BeaconChainError>> {
let local = self.chain.status_message();
let start_slot = |epoch: Epoch| epoch.start_slot(T::EthSpec::slots_per_epoch());
@@ -112,7 +112,8 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
if self
.chain
.block_root_at_slot(remote_finalized_slot, WhenSlotSkipped::Prev)
.map(|root_opt| root_opt != Some(remote.finalized_root))?
.map(|root_opt| root_opt != Some(remote.finalized_root))
.map_err(Box::new)?
{
Some("Different finalized chain".to_string())
} else {