resolve merge conflicts between untstable and release-v7.0.0

This commit is contained in:
Eitan Seri-Levi
2025-03-23 11:09:02 -06:00
63 changed files with 1422 additions and 242 deletions

View File

@@ -1403,6 +1403,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
| Err(e @ BlockError::InconsistentFork(_))
| Err(e @ BlockError::ExecutionPayloadError(_))
| Err(e @ BlockError::ParentExecutionPayloadInvalid { .. })
| Err(e @ BlockError::KnownInvalidExecutionPayload(_))
| Err(e @ BlockError::GenesisBlock) => {
warn!(error = %e, "Could not verify block for gossip. Rejecting the block");
self.propagate_validation_result(message_id, peer_id, MessageAcceptance::Reject);

View File

@@ -17,7 +17,7 @@ use std::sync::Arc;
use tokio_stream::StreamExt;
use tracing::{debug, error, warn};
use types::blob_sidecar::BlobIdentifier;
use types::{Epoch, EthSpec, FixedBytesExtended, Hash256, Slot};
use types::{Epoch, EthSpec, Hash256, Slot};
impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
/* Auxiliary functions */
@@ -93,20 +93,42 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
// current slot. This could be because they are using a different genesis time, or that
// their or our system's clock is incorrect.
Some("Different system clocks or genesis time".to_string())
} else if remote.finalized_epoch <= local.finalized_epoch
&& remote.finalized_root != Hash256::zero()
&& local.finalized_root != Hash256::zero()
&& self
.chain
.block_root_at_slot(start_slot(remote.finalized_epoch), WhenSlotSkipped::Prev)
.map(|root_opt| root_opt != Some(remote.finalized_root))?
} else if (remote.finalized_epoch == local.finalized_epoch
&& remote.finalized_root == local.finalized_root)
|| remote.finalized_root.is_zero()
|| local.finalized_root.is_zero()
|| remote.finalized_epoch > local.finalized_epoch
{
// The remote's finalized epoch is less than or equal to ours, but the block root is
// different to the one in our chain. Therefore, the node is on a different chain and we
// should not communicate with them.
Some("Different finalized chain".to_string())
} else {
// Fast path. Remote finalized checkpoint is either identical, or genesis, or we are at
// genesis, or they are ahead. In all cases, we should allow this peer to connect to us
// so we can sync from them.
None
} else {
// Remote finalized epoch is less than ours.
let remote_finalized_slot = start_slot(remote.finalized_epoch);
if remote_finalized_slot < self.chain.store.get_oldest_block_slot() {
// Peer's finalized checkpoint is older than anything in our DB. We are unlikely
// to be able to help them sync.
Some("Old finality out of range".to_string())
} else if remote_finalized_slot < self.chain.store.get_split_slot() {
// Peer's finalized slot is in range for a quick block root check in our freezer DB.
// If that block root check fails, reject them as they're on a different finalized
// chain.
if self
.chain
.block_root_at_slot(remote_finalized_slot, WhenSlotSkipped::Prev)
.map(|root_opt| root_opt != Some(remote.finalized_root))?
{
Some("Different finalized chain".to_string())
} else {
None
}
} else {
// Peer's finality is older than ours, but newer than our split point, making a
// block root check infeasible. This case shouldn't happen particularly often so
// we give the peer the benefit of the doubt and let them connect to us.
None
}
};
Ok(irrelevant_reason)

View File

@@ -758,6 +758,18 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
debug!("Finalized or earlier block processed");
Ok(())
}
BlockError::NotFinalizedDescendant { block_parent_root } => {
debug!(
"Not syncing to a chain that conflicts with the canonical or manual finalized checkpoint"
);
Err(ChainSegmentFailed {
message: format!(
"Block with parent_root {} conflicts with our checkpoint state",
block_parent_root
),
peer_action: Some(PeerAction::Fatal),
})
}
BlockError::GenesisBlock => {
debug!("Genesis block was processed");
Ok(())
@@ -817,6 +829,17 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
peer_action: Some(PeerAction::LowToleranceError),
})
}
// Penalise peers for sending us banned blocks.
BlockError::KnownInvalidExecutionPayload(block_root) => {
warn!(
?block_root,
"Received block known to be invalid",
);
Err(ChainSegmentFailed {
message: format!("Banned block: {block_root:?}"),
peer_action: Some(PeerAction::Fatal),
})
}
other => {
debug!(
msg = "peer sent invalid block",