mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Add peer score adjustment msgs (#2901)
## Issue Addressed N/A ## Proposed Changes This PR adds the `msg` field to `Peer score adjusted` log messages. These `msg` fields help identify *why* a peer was banned. Example: ``` Jan 11 04:18:48.096 DEBG Peer score adjusted score: -100.00, peer_id: 16Uiu2HAmQskxKWWGYfginwZ51n5uDbhvjHYnvASK7PZ5gBdLmzWj, msg: attn_unknown_head, service: libp2p Jan 11 04:18:48.096 DEBG Peer score adjusted score: -27.86, peer_id: 16Uiu2HAmA7cCb3MemVDbK3MHZoSb7VN3cFUG3vuSZgnGesuVhPDE, msg: sync_past_slot, service: libp2p Jan 11 04:18:48.096 DEBG Peer score adjusted score: -100.00, peer_id: 16Uiu2HAmQskxKWWGYfginwZ51n5uDbhvjHYnvASK7PZ5gBdLmzWj, msg: attn_unknown_head, service: libp2p Jan 11 04:18:48.096 DEBG Peer score adjusted score: -28.86, peer_id: 16Uiu2HAmA7cCb3MemVDbK3MHZoSb7VN3cFUG3vuSZgnGesuVhPDE, msg: sync_past_slot, service: libp2p Jan 11 04:18:48.096 DEBG Peer score adjusted score: -29.86, peer_id: 16Uiu2HAmA7cCb3MemVDbK3MHZoSb7VN3cFUG3vuSZgnGesuVhPDE, msg: sync_past_slot, service: libp2p ``` There is also a `libp2p_report_peer_msgs_total` metrics which allows us to see count of reports per `msg` tag. ## Additional Info NA
This commit is contained in:
@@ -180,11 +180,12 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
/* Auxiliary functions */
|
||||
|
||||
/// Penalizes a peer for misbehaviour.
|
||||
fn gossip_penalize_peer(&self, peer_id: PeerId, action: PeerAction) {
|
||||
fn gossip_penalize_peer(&self, peer_id: PeerId, action: PeerAction, msg: &'static str) {
|
||||
self.send_network_message(NetworkMessage::ReportPeer {
|
||||
peer_id,
|
||||
action,
|
||||
source: ReportSource::Gossipsub,
|
||||
msg,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -738,16 +739,24 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
self.send_sync_message(SyncMessage::UnknownBlock(peer_id, block));
|
||||
return None;
|
||||
}
|
||||
Err(e @ BlockError::BeaconChainError(_)) => {
|
||||
debug!(
|
||||
self.log,
|
||||
"Gossip block beacon chain error";
|
||||
"error" => ?e,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
return None;
|
||||
}
|
||||
Err(e @ BlockError::FutureSlot { .. })
|
||||
| Err(e @ BlockError::WouldRevertFinalizedSlot { .. })
|
||||
| Err(e @ BlockError::BlockIsAlreadyKnown)
|
||||
| Err(e @ BlockError::RepeatProposal { .. })
|
||||
| Err(e @ BlockError::NotFinalizedDescendant { .. })
|
||||
| Err(e @ BlockError::BeaconChainError(_)) => {
|
||||
| Err(e @ BlockError::NotFinalizedDescendant { .. }) => {
|
||||
debug!(self.log, "Could not verify block for gossip, ignoring the block";
|
||||
"error" => %e);
|
||||
// Prevent recurring behaviour by penalizing the peer slightly.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError, "gossip_block_high");
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
return None;
|
||||
}
|
||||
@@ -780,7 +789,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
warn!(self.log, "Could not verify block for gossip, rejecting the block";
|
||||
"error" => %e);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError, "gossip_block_low");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
@@ -931,7 +940,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"block root" => ?block.canonical_root(),
|
||||
"block slot" => block.slot()
|
||||
);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"bad_gossip_block_ssz",
|
||||
);
|
||||
trace!(
|
||||
self.log,
|
||||
"Invalid gossip beacon block ssz";
|
||||
@@ -973,7 +986,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
// the fault on the peer.
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// We still penalize a peer slightly to prevent overuse of invalids.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"invalid_gossip_exit",
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -1032,7 +1049,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
|
||||
// Penalize peer slightly for invalids.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"invalid_gossip_proposer_slashing",
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -1083,7 +1104,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize peer slightly for invalids.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"invalid_gossip_attester_slashing",
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -1248,9 +1273,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
let attestation_type = failed_att.kind();
|
||||
metrics::register_attestation_error(&error);
|
||||
match &error {
|
||||
AttnError::FutureEpoch { .. }
|
||||
| AttnError::PastEpoch { .. }
|
||||
| AttnError::FutureSlot { .. } => {
|
||||
AttnError::FutureSlot { .. } => {
|
||||
/*
|
||||
* These errors can be triggered by a mismatch between our slot and the peer.
|
||||
*
|
||||
@@ -1267,7 +1290,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
// Peers that are slow or not to spec can spam us with these messages draining our
|
||||
// bandwidth. We therefore penalize these peers when they do this.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_future_slot",
|
||||
);
|
||||
|
||||
// Do not propagate these messages.
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
@@ -1285,7 +1312,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
// Only penalize the peer if it would have been invalid at the moment we received
|
||||
// it.
|
||||
if hindsight_verification.is_err() {
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_past_slot",
|
||||
);
|
||||
}
|
||||
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
@@ -1297,7 +1328,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_selection_proof",
|
||||
);
|
||||
}
|
||||
AttnError::EmptyAggregationBitfield => {
|
||||
/*
|
||||
@@ -1307,7 +1342,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
*
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_empty_agg_bitfield",
|
||||
);
|
||||
}
|
||||
AttnError::AggregatorPubkeyUnknown(_) => {
|
||||
/*
|
||||
@@ -1324,7 +1363,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_agg_pubkey",
|
||||
);
|
||||
}
|
||||
AttnError::AggregatorNotInCommittee { .. } => {
|
||||
/*
|
||||
@@ -1341,7 +1384,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_agg_not_in_committee",
|
||||
);
|
||||
}
|
||||
AttnError::AttestationAlreadyKnown { .. } => {
|
||||
/*
|
||||
@@ -1417,7 +1464,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"type" => ?attestation_type,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_val_index_too_high",
|
||||
);
|
||||
}
|
||||
AttnError::UnknownHeadBlock { beacon_block_root } => {
|
||||
trace!(
|
||||
@@ -1482,7 +1533,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
} else {
|
||||
// We shouldn't make any further attempts to process this attestation.
|
||||
// Downscore the peer.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_unknown_head",
|
||||
);
|
||||
self.propagate_validation_result(
|
||||
message_id,
|
||||
peer_id,
|
||||
@@ -1510,7 +1565,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_unknown_target",
|
||||
);
|
||||
}
|
||||
AttnError::BadTargetEpoch => {
|
||||
/*
|
||||
@@ -1520,7 +1579,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_bad_target",
|
||||
);
|
||||
}
|
||||
AttnError::NoCommitteeForSlotAndIndex { .. } => {
|
||||
/*
|
||||
@@ -1529,7 +1592,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_no_committee",
|
||||
);
|
||||
}
|
||||
AttnError::NotExactlyOneAggregationBitSet(_) => {
|
||||
/*
|
||||
@@ -1538,7 +1605,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_too_many_agg_bits",
|
||||
);
|
||||
}
|
||||
AttnError::AttestsToFutureBlock { .. } => {
|
||||
/*
|
||||
@@ -1547,7 +1618,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_future_block",
|
||||
);
|
||||
}
|
||||
AttnError::InvalidSubnetId { received, expected } => {
|
||||
/*
|
||||
@@ -1560,7 +1635,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"received" => ?received,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_invalid_subnet_id",
|
||||
);
|
||||
}
|
||||
AttnError::Invalid(_) => {
|
||||
/*
|
||||
@@ -1569,7 +1648,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_invalid_state_processing",
|
||||
);
|
||||
}
|
||||
AttnError::InvalidTargetEpoch { .. } => {
|
||||
/*
|
||||
@@ -1578,7 +1661,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_invalid_target_epoch",
|
||||
);
|
||||
}
|
||||
AttnError::InvalidTargetRoot { .. } => {
|
||||
/*
|
||||
@@ -1587,7 +1674,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"attn_invalid_target_root",
|
||||
);
|
||||
}
|
||||
AttnError::TooManySkippedSlots {
|
||||
head_block_slot,
|
||||
@@ -1607,7 +1698,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
// In this case we wish to penalize gossipsub peers that do this to avoid future
|
||||
// attestations that have too many skip slots.
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"attn_too_many_skipped_slots",
|
||||
);
|
||||
}
|
||||
AttnError::BeaconChainError(BeaconChainError::DBError(Error::HotColdDBError(
|
||||
HotColdDBError::AttestationStateIsFinalized { .. },
|
||||
@@ -1630,8 +1725,6 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"error" => ?e,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize the peer slightly
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1675,7 +1768,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
// Unlike attestations, we have a zero slot buffer in case of sync committee messages,
|
||||
// so we don't penalize heavily.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_future_slot",
|
||||
);
|
||||
|
||||
// Do not propagate these messages.
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
@@ -1719,7 +1816,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
// Penalize the peer if the message was more than one slot late
|
||||
if excessively_late && invalid_in_hindsight() {
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_past_slot",
|
||||
);
|
||||
}
|
||||
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
@@ -1732,7 +1833,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
*
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_empty_agg_bitfield",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::InvalidSelectionProof { .. }
|
||||
| SyncCommitteeError::InvalidSignature => {
|
||||
@@ -1742,7 +1847,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_invalid_proof_or_sig",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::AggregatorNotInCommittee { .. }
|
||||
| SyncCommitteeError::AggregatorPubkeyUnknown(_) => {
|
||||
@@ -1753,7 +1862,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_bad_aggregator",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::SyncContributionAlreadyKnown(_)
|
||||
| SyncCommitteeError::AggregatorAlreadyKnown(_) => {
|
||||
@@ -1786,7 +1899,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"type" => ?message_type,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_unknown_validator",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::UnknownValidatorPubkey(_) => {
|
||||
debug!(
|
||||
@@ -1796,7 +1913,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"type" => ?message_type,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_unknown_validator_pubkey",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::InvalidSubnetId { received, expected } => {
|
||||
/*
|
||||
@@ -1809,7 +1930,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"received" => ?received,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_invalid_subnet_id",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::Invalid(_) => {
|
||||
/*
|
||||
@@ -1818,7 +1943,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
* The peer has published an invalid consensus message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_invalid_state_processing",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::PriorSyncCommitteeMessageKnown { .. } => {
|
||||
/*
|
||||
@@ -1834,7 +1963,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
);
|
||||
// We still penalize the peer slightly. We don't want this to be a recurring
|
||||
// behaviour.
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_prior_known",
|
||||
);
|
||||
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
|
||||
@@ -1855,8 +1988,6 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"error" => ?e,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize the peer slightly
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
}
|
||||
SyncCommitteeError::BeaconStateError(e) => {
|
||||
/*
|
||||
@@ -1874,7 +2005,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize the peer slightly
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_beacon_state_error",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::ContributionError(e) => {
|
||||
error!(
|
||||
@@ -1885,7 +2020,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize the peer slightly
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_contribution_error",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::SyncCommitteeError(e) => {
|
||||
error!(
|
||||
@@ -1896,7 +2035,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
// Penalize the peer slightly
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::HighToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::HighToleranceError,
|
||||
"sync_committee_error",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::ArithError(e) => {
|
||||
/*
|
||||
@@ -1909,7 +2052,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
"error" => ?e,
|
||||
);
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Ignore);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_arith_error",
|
||||
);
|
||||
}
|
||||
SyncCommitteeError::InvalidSubcommittee { .. } => {
|
||||
/*
|
||||
@@ -1917,7 +2064,11 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
an invalid message.
|
||||
*/
|
||||
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
|
||||
self.gossip_penalize_peer(peer_id, PeerAction::LowToleranceError);
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::LowToleranceError,
|
||||
"sync_invalid_subcommittee",
|
||||
);
|
||||
}
|
||||
}
|
||||
debug!(
|
||||
|
||||
@@ -96,6 +96,7 @@ pub enum NetworkMessage<T: EthSpec> {
|
||||
peer_id: PeerId,
|
||||
action: PeerAction,
|
||||
source: ReportSource,
|
||||
msg: &'static str,
|
||||
},
|
||||
/// Disconnect an ban a peer, providing a reason.
|
||||
GoodbyePeer {
|
||||
@@ -445,7 +446,7 @@ fn spawn_service<T: BeaconChainTypes>(
|
||||
);
|
||||
service.libp2p.swarm.behaviour_mut().publish(messages);
|
||||
}
|
||||
NetworkMessage::ReportPeer { peer_id, action, source } => service.libp2p.report_peer(&peer_id, action, source),
|
||||
NetworkMessage::ReportPeer { peer_id, action, source, msg } => service.libp2p.report_peer(&peer_id, action, source, msg),
|
||||
NetworkMessage::GoodbyePeer { peer_id, reason, source } => service.libp2p.goodbye_peer(&peer_id, reason, source),
|
||||
NetworkMessage::AttestationSubscribe { subscriptions } => {
|
||||
if let Err(e) = service
|
||||
|
||||
@@ -682,7 +682,7 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
|
||||
|
||||
if let Some(peer_action) = peer_action {
|
||||
for peer in self.participating_peers.drain() {
|
||||
network.report_peer(peer, *peer_action);
|
||||
network.report_peer(peer, *peer_action, "backfill_batch_failed");
|
||||
}
|
||||
}
|
||||
self.fail_sync(BackFillError::BatchProcessingFailed(batch_id))
|
||||
@@ -804,7 +804,11 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
|
||||
"batch_epoch" => id, "score_adjustment" => %action,
|
||||
"original_peer" => %attempt.peer_id, "new_peer" => %processed_attempt.peer_id
|
||||
);
|
||||
network.report_peer(attempt.peer_id, action);
|
||||
network.report_peer(
|
||||
attempt.peer_id,
|
||||
action,
|
||||
"backfill_reprocessed_original_peer",
|
||||
);
|
||||
} else {
|
||||
// The same peer corrected it's previous mistake. There was an error, so we
|
||||
// negative score the original peer.
|
||||
@@ -813,7 +817,11 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
|
||||
"batch_epoch" => id, "score_adjustment" => %action,
|
||||
"original_peer" => %attempt.peer_id, "new_peer" => %processed_attempt.peer_id
|
||||
);
|
||||
network.report_peer(attempt.peer_id, action);
|
||||
network.report_peer(
|
||||
attempt.peer_id,
|
||||
action,
|
||||
"backfill_reprocessed_same_peer",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,8 +369,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
} else {
|
||||
crit!(self.log, "Parent chain has no blocks");
|
||||
}
|
||||
self.network
|
||||
.report_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.network.report_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"bbroot_failed_chains",
|
||||
);
|
||||
return;
|
||||
}
|
||||
// add the block to response
|
||||
@@ -388,8 +391,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
// tolerate this behaviour.
|
||||
if !single_block_request.block_returned {
|
||||
warn!(self.log, "Peer didn't respond with a block it referenced"; "referenced_block_hash" => %single_block_request.hash, "peer_id" => %peer_id);
|
||||
self.network
|
||||
.report_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.network.report_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"bbroot_no_block",
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -512,8 +518,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
warn!(self.log, "Single block lookup failed"; "outcome" => ?outcome);
|
||||
// This could be a range of errors. But we couldn't process the block.
|
||||
// For now we consider this a mid tolerance error.
|
||||
self.network
|
||||
.report_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.network.report_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"single_block_lookup_failed",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -836,8 +845,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
self.request_parent(parent_request);
|
||||
// We do not tolerate these kinds of errors. We will accept a few but these are signs
|
||||
// of a faulty peer.
|
||||
self.network
|
||||
.report_peer(peer, PeerAction::LowToleranceError);
|
||||
self.network.report_peer(
|
||||
peer,
|
||||
PeerAction::LowToleranceError,
|
||||
"parent_request_bad_hash",
|
||||
);
|
||||
} else {
|
||||
// The last block in the queue is the only one that has not attempted to be processed yet.
|
||||
//
|
||||
@@ -907,6 +919,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
self.network.report_peer(
|
||||
parent_request.last_submitted_peer,
|
||||
PeerAction::MidToleranceError,
|
||||
"parent_request_err",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -945,6 +958,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
self.network.report_peer(
|
||||
parent_request.last_submitted_peer,
|
||||
PeerAction::LowToleranceError,
|
||||
"request_parent_import_failed",
|
||||
);
|
||||
return; // drop the request
|
||||
}
|
||||
@@ -1112,8 +1126,11 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
// A peer sent an object (block or attestation) that referenced a parent.
|
||||
// The processing of this chain failed.
|
||||
self.failed_chains.insert(chain_head);
|
||||
self.network
|
||||
.report_peer(peer_id, PeerAction::MidToleranceError);
|
||||
self.network.report_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"parent_lookup_failed",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,13 +170,14 @@ impl<T: EthSpec> SyncNetworkContext<T> {
|
||||
}
|
||||
|
||||
/// Reports to the scoring algorithm the behaviour of a peer.
|
||||
pub fn report_peer(&mut self, peer_id: PeerId, action: PeerAction) {
|
||||
pub fn report_peer(&mut self, peer_id: PeerId, action: PeerAction, msg: &'static str) {
|
||||
debug!(self.log, "Sync reporting peer"; "peer_id" => %peer_id, "action" => %action);
|
||||
self.network_send
|
||||
.send(NetworkMessage::ReportPeer {
|
||||
peer_id,
|
||||
action,
|
||||
source: ReportSource::SyncService,
|
||||
msg,
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
warn!(self.log, "Could not report peer, channel failed"; "error"=> %e);
|
||||
|
||||
@@ -533,7 +533,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
|
||||
|
||||
if let Some(peer_action) = peer_action {
|
||||
for (peer, _) in self.peers.drain() {
|
||||
network.report_peer(peer, *peer_action);
|
||||
network.report_peer(peer, *peer_action, "batch_failed");
|
||||
}
|
||||
}
|
||||
Err(RemoveChain::ChainFailed(batch_id))
|
||||
@@ -624,7 +624,11 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
|
||||
"batch_epoch" => id, "score_adjustment" => %action,
|
||||
"original_peer" => %attempt.peer_id, "new_peer" => %processed_attempt.peer_id
|
||||
);
|
||||
network.report_peer(attempt.peer_id, action);
|
||||
network.report_peer(
|
||||
attempt.peer_id,
|
||||
action,
|
||||
"batch_reprocessed_original_peer",
|
||||
);
|
||||
} else {
|
||||
// The same peer corrected it's previous mistake. There was an error, so we
|
||||
// negative score the original peer.
|
||||
@@ -633,7 +637,11 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
|
||||
"batch_epoch" => id, "score_adjustment" => %action,
|
||||
"original_peer" => %attempt.peer_id, "new_peer" => %processed_attempt.peer_id
|
||||
);
|
||||
network.report_peer(attempt.peer_id, action);
|
||||
network.report_peer(
|
||||
attempt.peer_id,
|
||||
action,
|
||||
"batch_reprocessed_same_peer",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user