mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 03:12:41 +00:00
Merge branch 'remove-into-gossip-verified-block' of https://github.com/realbigsean/lighthouse into merge-unstable-deneb-june-6th
This commit is contained in:
@@ -836,6 +836,24 @@ impl<T: BeaconChainTypes> std::convert::From<ReadyWork<T>> for WorkEvent<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BeaconProcessorSend<T: BeaconChainTypes>(pub mpsc::Sender<WorkEvent<T>>);
|
||||
|
||||
impl<T: BeaconChainTypes> BeaconProcessorSend<T> {
|
||||
pub fn try_send(&self, message: WorkEvent<T>) -> Result<(), Box<TrySendError<WorkEvent<T>>>> {
|
||||
let work_type = message.work_type();
|
||||
match self.0.try_send(message) {
|
||||
Ok(res) => Ok(res),
|
||||
Err(e) => {
|
||||
metrics::inc_counter_vec(
|
||||
&metrics::BEACON_PROCESSOR_SEND_ERROR_PER_WORK_TYPE,
|
||||
&[work_type],
|
||||
);
|
||||
Err(Box::new(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A consensus message (or multiple) from the network that requires processing.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Debug(bound = "T: BeaconChainTypes"))]
|
||||
|
||||
@@ -929,6 +929,20 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
verified_block
|
||||
}
|
||||
Err(e @ BlockError::Slashable) => {
|
||||
warn!(
|
||||
self.log,
|
||||
"Received equivocating block from peer";
|
||||
"error" => ?e
|
||||
);
|
||||
/* punish peer for submitting an equivocation, but not too harshly as honest peers may conceivably forward equivocating blocks to us from time to time */
|
||||
self.gossip_penalize_peer(
|
||||
peer_id,
|
||||
PeerAction::MidToleranceError,
|
||||
"gossip_block_mid",
|
||||
);
|
||||
return None;
|
||||
}
|
||||
Err(BlockError::ParentUnknown(block)) => {
|
||||
debug!(
|
||||
self.log,
|
||||
@@ -950,7 +964,6 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
Err(e @ BlockError::FutureSlot { .. })
|
||||
| Err(e @ BlockError::WouldRevertFinalizedSlot { .. })
|
||||
| Err(e @ BlockError::BlockIsAlreadyKnown)
|
||||
| Err(e @ BlockError::RepeatProposal { .. })
|
||||
| Err(e @ BlockError::NotFinalizedDescendant { .. }) => {
|
||||
debug!(self.log, "Could not verify block for gossip. Ignoring the block";
|
||||
"error" => %e);
|
||||
@@ -1103,7 +1116,12 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
let result = self
|
||||
.chain
|
||||
.process_block(block_root, verified_block, NotifyExecutionLayer::Yes)
|
||||
.process_block(
|
||||
block_root,
|
||||
verified_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
|| Ok(()),
|
||||
)
|
||||
.await;
|
||||
|
||||
match &result {
|
||||
|
||||
@@ -103,33 +103,21 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
});
|
||||
|
||||
// Checks if a block from this proposer is already known.
|
||||
let proposal_already_known = || {
|
||||
let block_equivocates = || {
|
||||
match self
|
||||
.chain
|
||||
.observed_block_producers
|
||||
.read()
|
||||
.proposer_has_been_observed(block.message())
|
||||
.proposer_has_been_observed(block.message(), block.canonical_root())
|
||||
{
|
||||
Ok(is_observed) => is_observed,
|
||||
// Both of these blocks will be rejected, so reject them now rather
|
||||
Ok(seen_status) => seen_status.is_slashable(),
|
||||
//Both of these blocks will be rejected, so reject them now rather
|
||||
// than re-queuing them.
|
||||
Err(ObserveError::FinalizedBlock { .. })
|
||||
| Err(ObserveError::ValidatorIndexTooHigh { .. }) => false,
|
||||
}
|
||||
};
|
||||
|
||||
// Returns `true` if the block is already known to fork choice. Notably,
|
||||
// this will return `false` for blocks that we've already imported but
|
||||
// ancestors of the finalized checkpoint. That should not be an issue
|
||||
// for our use here since finalized blocks will always be late and won't
|
||||
// be requeued anyway.
|
||||
let block_is_already_known = || {
|
||||
self.chain
|
||||
.canonical_head
|
||||
.fork_choice_read_lock()
|
||||
.contains_block(&block_root)
|
||||
};
|
||||
|
||||
// If we've already seen a block from this proposer *and* the block
|
||||
// arrived before the attestation deadline, requeue it to ensure it is
|
||||
// imported late enough that it won't receive a proposer boost.
|
||||
@@ -137,7 +125,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
// Don't requeue blocks if they're already known to fork choice, just
|
||||
// push them through to block processing so they can be handled through
|
||||
// the normal channels.
|
||||
if !block_is_late && proposal_already_known() && !block_is_already_known() {
|
||||
if !block_is_late && block_equivocates() {
|
||||
debug!(
|
||||
self.log,
|
||||
"Delaying processing of duplicate RPC block";
|
||||
@@ -171,7 +159,7 @@ impl<T: BeaconChainTypes> Worker<T> {
|
||||
|
||||
let result = self
|
||||
.chain
|
||||
.process_block(block_root, block, NotifyExecutionLayer::Yes)
|
||||
.process_block(block_root, block, NotifyExecutionLayer::Yes, || Ok(()))
|
||||
.await;
|
||||
|
||||
metrics::inc_counter(&metrics::BEACON_PROCESSOR_RPC_BLOCK_IMPORTED_TOTAL);
|
||||
|
||||
Reference in New Issue
Block a user