Data column gossip validation and error handling (#6181)

* Add gossip verification and error handling.

* Merge branch 'unstable' into das-gossip-validation

* Add inclusion proof verification and some renames for consistency
This commit is contained in:
Jimmy Chen
2024-07-29 15:52:10 +10:00
committed by GitHub
parent a3b1ef3129
commit 19b3ab39ee
7 changed files with 494 additions and 59 deletions

View File

@@ -6,7 +6,7 @@ use crate::{
};
use beacon_chain::blob_verification::{GossipBlobError, GossipVerifiedBlob};
use beacon_chain::block_verification_types::AsBlock;
use beacon_chain::data_column_verification::GossipVerifiedDataColumn;
use beacon_chain::data_column_verification::{GossipDataColumnError, GossipVerifiedDataColumn};
use beacon_chain::store::Error;
use beacon_chain::{
attestation_verification::{self, Error as AttnError, VerifiedAttestation},
@@ -621,7 +621,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
);
match self
.chain
.verify_data_column_sidecar_for_gossip(column_sidecar, *subnet_id)
.verify_data_column_sidecar_for_gossip(column_sidecar.clone(), *subnet_id)
{
Ok(gossip_verified_data_column) => {
metrics::inc_counter(
@@ -656,8 +656,82 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
)
.await
}
Err(_) => {
// TODO(das) implement gossip error handling
Err(err) => {
match err {
GossipDataColumnError::ParentUnknown { parent_root } => {
debug!(
self.log,
"Unknown parent hash for column";
"action" => "requesting parent",
"block_root" => %block_root,
"parent_root" => %parent_root,
);
self.send_sync_message(SyncMessage::UnknownParentDataColumn(
peer_id,
column_sidecar,
));
}
GossipDataColumnError::KzgNotInitialized
| GossipDataColumnError::PubkeyCacheTimeout
| GossipDataColumnError::BeaconChainError(_) => {
crit!(
self.log,
"Internal error when verifying column sidecar";
"error" => ?err,
)
}
GossipDataColumnError::ProposalSignatureInvalid
| GossipDataColumnError::UnknownValidator(_)
| GossipDataColumnError::ProposerIndexMismatch { .. }
| GossipDataColumnError::IsNotLaterThanParent { .. }
| GossipDataColumnError::InvalidSubnetId { .. }
| GossipDataColumnError::InvalidInclusionProof { .. }
| GossipDataColumnError::InvalidKzgProof { .. }
| GossipDataColumnError::NotFinalizedDescendant { .. } => {
debug!(
self.log,
"Could not verify column sidecar for gossip. Rejecting the column sidecar";
"error" => ?err,
"slot" => %slot,
"block_root" => %block_root,
"index" => %index,
);
// Prevent recurring behaviour by penalizing the peer slightly.
self.gossip_penalize_peer(
peer_id,
PeerAction::LowToleranceError,
"gossip_data_column_low",
);
self.propagate_validation_result(
message_id,
peer_id,
MessageAcceptance::Reject,
);
}
GossipDataColumnError::FutureSlot { .. }
| GossipDataColumnError::PriorKnown { .. }
| GossipDataColumnError::PastFinalizedSlot { .. } => {
debug!(
self.log,
"Could not verify column sidecar for gossip. Ignoring the column sidecar";
"error" => ?err,
"slot" => %slot,
"block_root" => %block_root,
"index" => %index,
);
// Prevent recurring behaviour by penalizing the peer slightly.
self.gossip_penalize_peer(
peer_id,
PeerAction::HighToleranceError,
"gossip_data_column_high",
);
self.propagate_validation_result(
message_id,
peer_id,
MessageAcceptance::Ignore,
);
}
}
}
}
}