mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
reprocess envelope:
This commit is contained in:
@@ -3290,6 +3290,69 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
envelope: Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>,
|
envelope: Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>,
|
||||||
seen_duration: Duration,
|
seen_duration: Duration,
|
||||||
) -> Option<GossipVerifiedEnvelope<T>> {
|
) -> Option<GossipVerifiedEnvelope<T>> {
|
||||||
|
let beacon_block_root = envelope.message.beacon_block_root;
|
||||||
|
let envelope_slot = envelope.slot();
|
||||||
|
|
||||||
|
// Check if the envelope's block is known to fork choice before attempting full
|
||||||
|
// verification. If the block isn't known yet, defer the envelope to the reprocess
|
||||||
|
// queue so it can be processed once the block is imported.
|
||||||
|
let block_known = self
|
||||||
|
.chain
|
||||||
|
.canonical_head
|
||||||
|
.fork_choice_read_lock()
|
||||||
|
.contains_block(&beacon_block_root);
|
||||||
|
|
||||||
|
if !block_known {
|
||||||
|
debug!(
|
||||||
|
?beacon_block_root,
|
||||||
|
%envelope_slot,
|
||||||
|
"Envelope references unknown block, deferring"
|
||||||
|
);
|
||||||
|
|
||||||
|
let inner_self = self.clone();
|
||||||
|
let chain = self.chain.clone();
|
||||||
|
let process_fn = Box::pin(async move {
|
||||||
|
match chain.verify_envelope_for_gossip(envelope).await {
|
||||||
|
Ok(verified_envelope) => {
|
||||||
|
inner_self
|
||||||
|
.process_gossip_verified_execution_payload_envelope(
|
||||||
|
peer_id,
|
||||||
|
verified_envelope,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
debug!(
|
||||||
|
error = ?e,
|
||||||
|
"Deferred envelope failed verification"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if self
|
||||||
|
.beacon_processor_send
|
||||||
|
.try_send(WorkEvent {
|
||||||
|
drop_during_sync: false,
|
||||||
|
work: Work::Reprocess(ReprocessQueueMessage::UnknownBlockEnvelope(
|
||||||
|
QueuedGossipEnvelope {
|
||||||
|
beacon_block_slot: envelope_slot,
|
||||||
|
beacon_block_root,
|
||||||
|
process_fn,
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
})
|
||||||
|
.is_err()
|
||||||
|
{
|
||||||
|
error!(
|
||||||
|
%envelope_slot,
|
||||||
|
?beacon_block_root,
|
||||||
|
"Failed to defer envelope import"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let envelope_delay =
|
let envelope_delay =
|
||||||
get_slot_delay_ms(seen_duration, envelope.slot(), &self.chain.slot_clock);
|
get_slot_delay_ms(seen_duration, envelope.slot(), &self.chain.slot_clock);
|
||||||
|
|
||||||
@@ -3347,7 +3410,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
// TODO(gloas) update metrics to note how early the envelope arrived
|
// TODO(gloas) update metrics to note how early the envelope arrived
|
||||||
|
|
||||||
let inner_self = self.clone();
|
let inner_self = self.clone();
|
||||||
let process_fn = Box::pin(async move {
|
let _process_fn = Box::pin(async move {
|
||||||
inner_self
|
inner_self
|
||||||
.process_gossip_verified_execution_payload_envelope(
|
.process_gossip_verified_execution_payload_envelope(
|
||||||
peer_id,
|
peer_id,
|
||||||
@@ -3356,27 +3419,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
|||||||
.await;
|
.await;
|
||||||
});
|
});
|
||||||
|
|
||||||
if self
|
// TODO(gloas) send to reprocess queue
|
||||||
.beacon_processor_send
|
|
||||||
.try_send(WorkEvent {
|
|
||||||
drop_during_sync: false,
|
|
||||||
work: Work::Reprocess(ReprocessQueueMessage::UnknownBlockEnvelope(
|
|
||||||
QueuedGossipEnvelope {
|
|
||||||
beacon_block_slot: envelope_slot,
|
|
||||||
beacon_block_root,
|
|
||||||
process_fn,
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
})
|
|
||||||
.is_err()
|
|
||||||
{
|
|
||||||
error!(
|
|
||||||
%envelope_slot,
|
|
||||||
?beacon_block_root,
|
|
||||||
location = "envelope gossip",
|
|
||||||
"Failed to defer envelope import"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
Ok(_) => Some(verified_envelope),
|
Ok(_) => Some(verified_envelope),
|
||||||
|
|||||||
Reference in New Issue
Block a user