mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 08:52:54 +00:00
Emit NewHead SSE event earlier in block import (#8718)
Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
@@ -41,7 +41,7 @@ use crate::{
|
||||
metrics,
|
||||
validator_monitor::get_slot_delay_ms,
|
||||
};
|
||||
use eth2::types::{EventKind, SseChainReorg, SseFinalizedCheckpoint, SseHead, SseLateHead};
|
||||
use eth2::types::{EventKind, SseChainReorg, SseFinalizedCheckpoint, SseLateHead};
|
||||
use fork_choice::{
|
||||
ExecutionStatus, ForkChoiceStore, ForkChoiceView, ForkchoiceUpdateParameters, ProtoBlock,
|
||||
ResetPayloadStatuses,
|
||||
@@ -824,15 +824,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
.slot()
|
||||
.epoch(T::EthSpec::slots_per_epoch());
|
||||
|
||||
// These fields are used for server-sent events.
|
||||
let state_root = new_snapshot.beacon_state_root();
|
||||
// This field is used for server-sent events.
|
||||
let head_slot = new_snapshot.beacon_state.slot();
|
||||
let dependent_root = new_snapshot
|
||||
.beacon_state
|
||||
.attester_shuffling_decision_root(self.genesis_block_root, RelativeEpoch::Next);
|
||||
let prev_dependent_root = new_snapshot
|
||||
.beacon_state
|
||||
.attester_shuffling_decision_root(self.genesis_block_root, RelativeEpoch::Current);
|
||||
|
||||
match BlockShufflingIds::try_from_head(
|
||||
new_snapshot.beacon_block_root,
|
||||
@@ -870,33 +863,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
self.op_pool.prune_attestations(self.epoch()?);
|
||||
}
|
||||
|
||||
// Register server-sent-events for a new head.
|
||||
if let Some(event_handler) = self
|
||||
.event_handler
|
||||
.as_ref()
|
||||
.filter(|handler| handler.has_head_subscribers())
|
||||
{
|
||||
match (dependent_root, prev_dependent_root) {
|
||||
(Ok(current_duty_dependent_root), Ok(previous_duty_dependent_root)) => {
|
||||
event_handler.register(EventKind::Head(SseHead {
|
||||
slot: head_slot,
|
||||
block: new_snapshot.beacon_block_root,
|
||||
state: state_root,
|
||||
current_duty_dependent_root,
|
||||
previous_duty_dependent_root,
|
||||
epoch_transition: is_epoch_transition,
|
||||
execution_optimistic: new_head_is_optimistic,
|
||||
}));
|
||||
}
|
||||
(Err(e), _) | (_, Err(e)) => {
|
||||
warn!(
|
||||
error = ?e,
|
||||
"Unable to find dependent roots, cannot register head event"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register a server-sent-event for a reorg (if necessary).
|
||||
if let Some(depth) = reorg_distance
|
||||
&& let Some(event_handler) = self
|
||||
|
||||
Reference in New Issue
Block a user