fix blob slot validation

This commit is contained in:
realbigsean 2022-12-07 13:49:24 -05:00
parent dbc57ba2d9
commit 6d4fb41b84
No known key found for this signature in database
GPG Key ID: B372B64D866BF8CC
3 changed files with 22 additions and 16 deletions

View File

@ -19,15 +19,15 @@ pub enum BlobError {
message_slot: Slot,
latest_permissible_slot: Slot,
},
/// The blob sidecar is from a slot that is prior to the earliest permissible slot (with
/// respect to the gossip clock disparity).
/// The blob sidecar has a different slot than the block.
///
/// ## Peer scoring
///
/// Assuming the local clock is correct, the peer has sent an invalid message.
PastSlot {
message_slot: Slot,
earliest_permissible_slot: Slot,
SlotMismatch {
blob_slot: Slot,
block_slot: Slot,
},
/// The blob sidecar contains an incorrectly formatted `BLSFieldElement` > `BLS_MODULUS`.
@ -122,14 +122,10 @@ pub fn validate_blob_for_gossip<T: BeaconChainTypes>(
});
}
let earliest_permissible_slot = chain
.slot_clock
.now_with_past_tolerance(MAXIMUM_GOSSIP_CLOCK_DISPARITY)
.ok_or(BeaconChainError::UnableToReadSlot)?;
if blob_slot > earliest_permissible_slot {
return Err(BlobError::PastSlot {
message_slot: earliest_permissible_slot,
earliest_permissible_slot: blob_slot,
if blob_slot != block_slot {
return Err(BlobError::SlotMismatch {
blob_slot,
block_slot,
});
}

View File

@ -840,7 +840,17 @@ impl<T: BeaconChainTypes> Worker<T> {
);
return None;
}
Err(blob_errors) => unimplemented!("handle")
Err(e@ BlockError::BlobValidation(_)) => {
warn!(self.log, "Could not verify blob for gossip. Rejecting the block and blob";
"error" => %e);
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);
self.gossip_penalize_peer(
peer_id,
PeerAction::LowToleranceError,
"gossip_blob_low",
);
return None;
}
};
metrics::inc_counter(&metrics::BEACON_PROCESSOR_GOSSIP_BLOCK_VERIFIED_TOTAL);

View File

@ -12,8 +12,8 @@
"berlinBlock": 0,
"londonBlock": 0,
"mergeNetsplitBlock": 0,
"shanghaiTime": 1670428733,
"shardingForkTime": 1670428829,
"shanghaiTime": 1670438240,
"shardingForkTime": 1670438336,
"terminalTotalDifficulty": 0
},
"alloc": {