mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-10 19:49:35 +00:00
Emit SSE: execution_payload (#9065)
Emit `execution_payload` on successful import of an execution payload. Co-Authored-By: Daniel Knopik <daniel@dknopik.de>
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use eth2::types::{EventKind, SseExecutionPayload};
|
||||
use fork_choice::PayloadVerificationStatus;
|
||||
use slot_clock::SlotClock;
|
||||
use store::StoreOp;
|
||||
use tracing::{debug, error, info, info_span, instrument, warn};
|
||||
use types::{BeaconState, BlockImportSource, Hash256, Slot};
|
||||
use types::{BeaconState, BlockImportSource, Hash256, SignedExecutionPayloadEnvelope};
|
||||
|
||||
use super::{
|
||||
AvailableEnvelope, AvailableExecutedEnvelope, EnvelopeError, EnvelopeImportData,
|
||||
@@ -225,7 +226,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
signed_envelope: AvailableEnvelope<T::EthSpec>,
|
||||
block_root: Hash256,
|
||||
state: BeaconState<T::EthSpec>,
|
||||
_payload_verification_status: PayloadVerificationStatus,
|
||||
payload_verification_status: PayloadVerificationStatus,
|
||||
) -> Result<Hash256, EnvelopeError> {
|
||||
// Everything in this initial section is on the hot path for processing the envelope.
|
||||
// Take an upgradable read lock on fork choice so we can check if this block has already
|
||||
@@ -317,8 +318,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
metrics::stop_timer(db_write_timer);
|
||||
|
||||
self.import_envelope_update_metrics_and_events(
|
||||
signed_envelope,
|
||||
block_root,
|
||||
signed_envelope.slot(),
|
||||
payload_verification_status,
|
||||
envelope_time_imported,
|
||||
);
|
||||
|
||||
@@ -327,10 +329,12 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
|
||||
fn import_envelope_update_metrics_and_events(
|
||||
&self,
|
||||
signed_envelope: Arc<SignedExecutionPayloadEnvelope<T::EthSpec>>,
|
||||
block_root: Hash256,
|
||||
envelope_slot: Slot,
|
||||
payload_verification_status: PayloadVerificationStatus,
|
||||
envelope_time_imported: Duration,
|
||||
) {
|
||||
let envelope_slot = signed_envelope.slot();
|
||||
let envelope_delay_total =
|
||||
get_slot_delay_ms(envelope_time_imported, envelope_slot, &self.slot_clock);
|
||||
|
||||
@@ -349,6 +353,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(gloas) emit SSE event for envelope import (similar to SseBlock for blocks).
|
||||
if let Some(event_handler) = self.event_handler.as_ref()
|
||||
&& event_handler.has_execution_payload_subscribers()
|
||||
{
|
||||
event_handler.register(EventKind::ExecutionPayload(SseExecutionPayload {
|
||||
slot: envelope_slot,
|
||||
builder_index: signed_envelope.message.builder_index,
|
||||
block_hash: signed_envelope.block_hash(),
|
||||
block_root,
|
||||
state_root: signed_envelope.message.state_root,
|
||||
execution_optimistic: payload_verification_status.is_optimistic(),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user