Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
);

Expand All @@ -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);

Expand All @@ -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(),
}));
}
}
}
Loading