Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion crates/consensus/beacon/src/engine/forkchoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl ForkchoiceStateTracker {
}

/// Returns the last received `ForkchoiceState` to which we need to sync.
pub(crate) const fn sync_target_state(&self) -> Option<ForkchoiceState> {
pub const fn sync_target_state(&self) -> Option<ForkchoiceState> {
self.last_syncing
}

Expand Down
22 changes: 20 additions & 2 deletions crates/engine/tree/src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,21 @@ impl<T> TreeOutcome<T> {
/// Events that can be emitted by the [`EngineApiTreeHandler`].
#[derive(Debug)]
pub enum TreeEvent {
/// Tree action is needed.
TreeAction(TreeAction),
/// Backfill action is needed.
BackfillAction(BackfillAction),
/// Block download is needed.
Download(DownloadRequest),
}

/// The actions that can be performed on the tree.
#[derive(Debug)]
pub enum TreeAction {
/// Make target canonical.
MakeCanonical(B256),
}

#[derive(Debug)]
pub struct EngineApiTreeHandlerImpl<P, E, T: EngineTypes> {
provider: P,
Expand Down Expand Up @@ -498,7 +507,7 @@ where
return Ok(TreeOutcome::new(status))
}

let _status = if self.is_pipeline_active {
let status = if self.is_pipeline_active {
self.buffer_block_without_senders(block).unwrap();
PayloadStatus::from_status(PayloadStatusEnum::Syncing)
} else {
Expand Down Expand Up @@ -529,7 +538,16 @@ where
PayloadStatus::new(status, latest_valid_hash)
};

todo!()
let mut outcome = TreeOutcome::new(status);
if outcome.outcome.is_valid() {
if let Some(target) = self.state.forkchoice_state_tracker.sync_target_state() {
if target.head_block_hash == block_hash {
outcome = outcome
.with_event(TreeEvent::TreeAction(TreeAction::MakeCanonical(block_hash)));
}
}
}
Ok(outcome)
}

fn on_forkchoice_updated(
Expand Down