Skip to main content

reth_engine_tree/tree/
forkchoice.rs

1//! Forkchoice update handling of the engine API tree handler.
2
3use crate::{
4    backfill::BackfillAction,
5    engine::{DownloadRequest, EngineApiEvent},
6    tree::{
7        payload_validator::EngineValidator, EngineApiTreeHandler, TreeEvent, TreeOutcome,
8        WaitForCaches,
9    },
10};
11use alloy_consensus::BlockHeader;
12use alloy_primitives::B256;
13use alloy_rpc_types_engine::{ForkchoiceState, PayloadStatus, PayloadStatusEnum};
14use reth_chain_state::NewCanonicalChain;
15use reth_engine_primitives::OnForkChoiceUpdated;
16use reth_errors::ProviderResult;
17use reth_evm::ConfigureEvm;
18use reth_payload_builder::{BuildNewPayload, PayloadBuilderLease};
19use reth_payload_primitives::{BuiltPayload, PayloadAttributes, PayloadTypes};
20use reth_primitives_traits::{NodePrimitives, SealedHeader};
21use reth_provider::{
22    BalProvider, BlockReader, ChangeSetReader, DatabaseProviderFactory, ProviderError,
23    PruneCheckpointReader, StageCheckpointReader, StateProviderFactory, StateReader,
24    StorageChangeSetReader, StorageSettingsCache,
25};
26use tracing::{debug, error, instrument, trace, warn};
27
28impl<N, P, T, V, C> EngineApiTreeHandler<N, P, T, V, C>
29where
30    N: NodePrimitives,
31    P: DatabaseProviderFactory
32        + BlockReader<Block = N::Block, Header = N::BlockHeader>
33        + StateProviderFactory
34        + StateReader<Receipt = N::Receipt>
35        + BalProvider
36        + Clone
37        + 'static,
38    P::Provider: BlockReader<Block = N::Block, Header = N::BlockHeader>
39        + PruneCheckpointReader
40        + StageCheckpointReader
41        + ChangeSetReader
42        + StorageChangeSetReader
43        + StorageSettingsCache
44        + 'static,
45    C: ConfigureEvm<Primitives = N> + 'static,
46    T: PayloadTypes<BuiltPayload: BuiltPayload<Primitives = N>>,
47    V: EngineValidator<T> + WaitForCaches,
48{
49    /// Invoked when we receive a new forkchoice update message. Calls into the blockchain tree
50    /// to resolve chain forks and ensure that the Execution Layer is working with the latest valid
51    /// chain.
52    ///
53    /// These responses should adhere to the [Engine API Spec for
54    /// `engine_forkchoiceUpdated`](https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#specification-1).
55    ///
56    /// Returns an error if an internal error occurred like a database error.
57    #[instrument(level = "debug", target = "engine::tree", skip_all, fields(head = % state.head_block_hash, safe = % state.safe_block_hash,finalized = % state.finalized_block_hash))]
58    pub(super) fn on_forkchoice_updated(
59        &mut self,
60        state: ForkchoiceState,
61        attrs: Option<T::PayloadAttributes>,
62    ) -> ProviderResult<TreeOutcome<OnForkChoiceUpdated>> {
63        trace!(target: "engine::tree", ?attrs, "invoked forkchoice update");
64
65        // Record metrics
66        self.record_forkchoice_metrics();
67
68        // Pre-validation of forkchoice state
69        if let Some(early_result) = self.validate_forkchoice_state(state)? {
70            return Ok(TreeOutcome::new(early_result));
71        }
72
73        // Return early if we are on the correct fork
74        if let Some(result) = self.handle_canonical_head(state, &attrs)? {
75            return Ok(result);
76        }
77
78        // Attempt to apply a chain update when the head differs from our canonical chain.
79        // This handles reorgs and chain extensions by making the specified head canonical.
80        if let Some(result) = self.apply_chain_update(state, &attrs)? {
81            return Ok(result);
82        }
83
84        // Fallback that ensures to catch up to the network's state.
85        self.handle_missing_block(state)
86    }
87
88    /// Records metrics for forkchoice updated calls
89    fn record_forkchoice_metrics(&mut self) {
90        self.canonical_in_memory_state_writer.on_forkchoice_update_received();
91    }
92
93    /// Pre-validates the forkchoice state and returns early if validation fails.
94    ///
95    /// Returns `Some(OnForkChoiceUpdated)` if validation fails and an early response should be
96    /// returned. Returns `None` if validation passes and processing should continue.
97    pub(super) fn validate_forkchoice_state(
98        &mut self,
99        state: ForkchoiceState,
100    ) -> ProviderResult<Option<OnForkChoiceUpdated>> {
101        if state.head_block_hash.is_zero() {
102            return Ok(Some(OnForkChoiceUpdated::invalid_state()));
103        }
104
105        // Check if the new head hash is connected to any ancestor that we previously marked as
106        // invalid
107        let lowest_buffered_ancestor_fcu = self.lowest_buffered_ancestor_or(state.head_block_hash);
108        if let Some(status) = self.check_invalid_ancestor(lowest_buffered_ancestor_fcu)? {
109            return Ok(Some(OnForkChoiceUpdated::with_invalid(status)));
110        }
111
112        if !self.backfill_sync_state.is_idle() {
113            // Forward the head and finalized block, since a long-running backfill such as snap
114            // must follow them. A run awaiting revalidation has not started and reads the latest
115            // forkchoice when it does.
116            if self.backfill_sync_state.is_pending() || self.backfill_sync_state.is_active() {
117                self.send_event(EngineApiEvent::BackfillAction(BackfillAction::UpdateTarget(
118                    state.head_block_hash,
119                )));
120                self.forward_finalized(state.finalized_block_hash);
121            }
122            // We can only process new forkchoice updates if the pipeline is idle, since it requires
123            // exclusive access to the database
124            trace!(target: "engine::tree", "Pipeline is syncing, skipping forkchoice update");
125            return Ok(Some(OnForkChoiceUpdated::syncing()));
126        }
127
128        Ok(None)
129    }
130
131    /// Handles the case where the forkchoice head is already canonical.
132    ///
133    /// Returns `Some(TreeOutcome<OnForkChoiceUpdated>)` if the head is already canonical and
134    /// processing is complete. Returns `None` if the head is not canonical and processing
135    /// should continue.
136    pub(super) fn handle_canonical_head(
137        &mut self,
138        state: ForkchoiceState,
139        attrs: &Option<T::PayloadAttributes>, // Changed to reference
140    ) -> ProviderResult<Option<TreeOutcome<OnForkChoiceUpdated>>> {
141        // Process the forkchoice update by trying to make the head block canonical
142        //
143        // We can only process this forkchoice update if:
144        // - we have the `head` block
145        // - the head block is part of a chain that is connected to the canonical chain. This
146        //   includes reorgs.
147        //
148        // Performing a FCU involves:
149        // - marking the FCU's head block as canonical
150        // - updating in memory state to reflect the new canonical chain
151        // - updating canonical state trackers
152        // - emitting a canonicalization event for the new chain (including reorg)
153        // - if we have payload attributes, delegate them to the payload service
154
155        if self.state.tree_state.canonical_block_hash() != state.head_block_hash {
156            return Ok(None);
157        }
158
159        trace!(target: "engine::tree", "fcu head hash is already canonical");
160
161        if !self.is_consistent_forkchoice_state(state, None)? {
162            return Ok(Some(TreeOutcome::new(OnForkChoiceUpdated::invalid_state())));
163        }
164
165        // Update the safe and finalized blocks and ensure their values are valid
166        if let Err(outcome) = self.ensure_consistent_forkchoice_state(state) {
167            // safe or finalized hashes are invalid
168            return Ok(Some(TreeOutcome::new(outcome)));
169        }
170
171        self.payload_validator.on_canonical_head_changed(state.head_block_hash, &self.state);
172
173        // Process payload attributes if the head is already canonical
174        if let Some(attr) = attrs {
175            let tip = self
176                .sealed_header_by_hash(self.state.tree_state.canonical_block_hash())?
177                .ok_or_else(|| {
178                    // If we can't find the canonical block, then something is wrong and we need
179                    // to return an error
180                    ProviderError::HeaderNotFound(state.head_block_hash.into())
181                })?;
182            // Clone only when we actually need to process the attributes
183            let updated = self.process_payload_attributes(attr.clone(), &tip, state);
184            return Ok(Some(TreeOutcome::new(updated)));
185        }
186
187        // The head block is already canonical
188        Ok(Some(Self::valid_outcome(state)))
189    }
190
191    /// Applies chain update for the new head block and processes payload attributes.
192    ///
193    /// This method handles the case where the forkchoice head differs from our current canonical
194    /// head. It attempts to make the specified head block canonical by:
195    /// - Checking if the head is already part of the canonical chain
196    /// - Applying chain reorganizations (reorgs) if necessary
197    /// - Processing payload attributes if provided
198    /// - Returning the appropriate forkchoice update response
199    ///
200    /// Returns `Some(TreeOutcome<OnForkChoiceUpdated>)` if a chain update was successfully applied.
201    /// Returns `None` if no chain update was needed or possible.
202    pub(super) fn apply_chain_update(
203        &mut self,
204        state: ForkchoiceState,
205        attrs: &Option<T::PayloadAttributes>,
206    ) -> ProviderResult<Option<TreeOutcome<OnForkChoiceUpdated>>> {
207        // Check if the head is already part of the canonical chain
208        if let Ok(Some(canonical_header)) = self.find_canonical_header(state.head_block_hash) {
209            debug!(target: "engine::tree", head = canonical_header.number(), "fcu head block is already canonical");
210
211            // For OpStack, or if explicitly configured, the proposers are allowed to reorg their
212            // own chain at will, so we need to always trigger a new payload job if requested.
213            let always_trigger_payload_job = self.engine_kind.is_opstack() ||
214                self.config.always_process_payload_attributes_on_canonical_head();
215
216            // A canonical ancestor below the latest known finalized block can never become the
217            // head again, because this would reorg out the finalized block. Such a forkchoice
218            // update exceeds the supported reorg depth and is rejected regardless of the payload
219            // attributes:
220            // <https://github.com/ethereum/execution-apis/blob/bf20b4083284e677db19e7f3871bd669b88354a6/src/engine/paris.md?plain=1#L221>
221            //
222            // The stored finalized block is used because a forkchoice update MAY carry a zero
223            // finalized hash without clearing previously established finality.
224            if !always_trigger_payload_job &&
225                self.canonical_in_memory_state()
226                    .get_finalized_num_hash()
227                    .is_some_and(|finalized| canonical_header.number() < finalized.number)
228            {
229                debug!(target: "engine::tree", head = canonical_header.number(), "rejecting canonical ancestor fcu below the finalized block");
230                return Ok(Some(TreeOutcome::new(OnForkChoiceUpdated::too_deep_reorg())));
231            }
232
233            if !self.is_consistent_forkchoice_state(state, None)? {
234                return Ok(Some(TreeOutcome::new(OnForkChoiceUpdated::invalid_state())));
235            }
236
237            // We need to effectively unwind the _canonical_ chain to the FCU's head, which is
238            // part of the canonical chain. We need to update the latest block state to reflect
239            // the canonical ancestor. This ensures that state providers and the transaction
240            // pool operate with the correct chain state after forkchoice update processing, and
241            // new payloads built on the reorg'd head will be added to the tree immediately.
242            if always_trigger_payload_job && self.config.unwind_canonical_header() {
243                self.update_latest_block_to_canonical_ancestor(&canonical_header)?;
244            }
245
246            // A canonical ancestor at or above the latest known finalized block can become the
247            // parent of the next block, e.g. when the CL wants to reorg out the current head.
248            // The canonical chain remains untouched here; the block built on the ancestor
249            // triggers the actual reorg once it is inserted via newPayload and FCU'd.
250            if let Some(attr) = attrs {
251                debug!(target: "engine::tree", head = canonical_header.number(), "handling payload attributes for canonical head");
252                // Clone only when we actually need to process the attributes
253                let updated =
254                    self.process_payload_attributes(attr.clone(), &canonical_header, state);
255                return Ok(Some(TreeOutcome::new(updated)));
256            }
257
258            // The head block is already canonical and we're not processing payload attributes,
259            // so we're not triggering a payload job and can return right away
260            return Ok(Some(Self::valid_outcome(state)));
261        }
262
263        // Ensure we can apply a new chain update for the head block
264        if let Some(chain_update) = self.on_new_head(state.head_block_hash)? {
265            if !self.is_consistent_forkchoice_state(state, Some(&chain_update))? {
266                return Ok(Some(TreeOutcome::new(OnForkChoiceUpdated::invalid_state())));
267            }
268
269            let tip = chain_update.tip().clone_sealed_header();
270            self.on_canonical_chain_update(chain_update);
271
272            // Update the safe and finalized blocks and ensure their values are valid
273            if let Err(outcome) = self.ensure_consistent_forkchoice_state(state) {
274                // safe or finalized hashes are invalid
275                return Ok(Some(TreeOutcome::new(outcome)));
276            }
277
278            if let Some(attr) = attrs {
279                // Clone only when we actually need to process the attributes
280                let updated = self.process_payload_attributes(attr.clone(), &tip, state);
281                return Ok(Some(TreeOutcome::new(updated)));
282            }
283
284            return Ok(Some(Self::valid_outcome(state)));
285        }
286
287        Ok(None)
288    }
289
290    /// Handles the case where the head block is missing and needs to be downloaded.
291    ///
292    /// This is the fallback case when all other forkchoice update scenarios have been exhausted.
293    /// Returns a `TreeOutcome` with syncing status and download event.
294    pub(super) fn handle_missing_block(
295        &self,
296        state: ForkchoiceState,
297    ) -> ProviderResult<TreeOutcome<OnForkChoiceUpdated>> {
298        // We don't have the block to perform the forkchoice update
299        // We assume the FCU is valid and at least the head is missing,
300        // so we need to start syncing to it
301        //
302        // find the appropriate target to sync to, if we don't have the safe block hash then we
303        // start syncing to the safe block via backfill first
304        let target = if self.state.forkchoice_state_tracker.is_empty() &&
305        // check that safe block is valid and missing
306        !state.safe_block_hash.is_zero() &&
307        self.find_canonical_header(state.safe_block_hash).ok().flatten().is_none()
308        {
309            debug!(target: "engine::tree", "missing safe block on initial FCU, downloading safe block");
310            state.safe_block_hash
311        } else {
312            state.head_block_hash
313        };
314
315        let target = self.lowest_buffered_ancestor_or(target);
316        trace!(target: "engine::tree", %target, "downloading missing block");
317
318        Ok(TreeOutcome::new(OnForkChoiceUpdated::valid(PayloadStatus::from_status(
319            PayloadStatusEnum::Syncing,
320        )))
321        .with_event(TreeEvent::Download(
322            DownloadRequest::single_block(target)
323                .with_access_lists(self.should_download_access_lists()),
324        )))
325    }
326
327    /// Attempts to find the header for the given block hash if it is canonical.
328    ///
329    /// A persisted header can still be found by hash while its disk reorg is pending, so it is
330    /// only canonical if it is not above the canonical head and matches the canonical hash at its
331    /// height. The in-memory canonical hash is preferred over the persisted one.
332    pub fn find_canonical_header(
333        &self,
334        hash: B256,
335    ) -> Result<Option<SealedHeader<N::BlockHeader>>, ProviderError> {
336        if let Some(header) = self.canonical_in_memory_state().header_by_hash(hash) {
337            return Ok(Some(header))
338        }
339
340        let Some(header) = self.provider.sealed_header_by_hash(hash)? else { return Ok(None) };
341        // Reorged-out headers remain on disk until persistence catches up, so reject old tips above
342        // the in-memory head and use in-memory hashes to reject old blocks at shared heights.
343        let number = header.number();
344        if number > self.canonical_in_memory_state().get_canonical_block_number() {
345            return Ok(None)
346        }
347        let canonical_hash =
348            if let Some(hash) = self.canonical_in_memory_state().hash_by_number(number) {
349                Some(hash)
350            } else {
351                self.provider.block_hash(number)?
352            };
353
354        Ok((canonical_hash == Some(hash)).then_some(header))
355    }
356
357    /// Checks that nonzero safe and finalized hashes belong to the chain defined by the FCU head.
358    ///
359    /// The [Engine API forkchoiceUpdated specification] requires `-38002` when a `VALID` head's
360    /// safe or finalized hash is outside that chain, and requires all forkchoice state updates to
361    /// be atomic. In direct FCU processing, this check must therefore run before canonicalizing
362    /// the head or updating either marker; checking only after canonicalization would leave an
363    /// invalid reorg applied.
364    ///
365    /// `chain_update` describes a proposed commit or reorg that has not yet been applied. Its new
366    /// blocks and the canonical prefix below its first block form the proposed chain. Without a
367    /// chain update, the proposed head is already canonical, so only canonical blocks through its
368    /// height are eligible. Canonical-prefix hashes are resolved via
369    /// [`Self::find_canonical_header`], which rejects stale persisted headers whose disk reorg
370    /// cleanup is pending. A zero safe or finalized hash leaves that marker unchanged.
371    /// Returns `Ok(false)` for an unknown or off-chain hash and propagates provider errors.
372    ///
373    /// [Engine API forkchoiceUpdated specification]: https://github.com/ethereum/execution-apis/blob/main/src/engine/paris.md#specification-1
374    pub(super) fn is_consistent_forkchoice_state(
375        &self,
376        state: ForkchoiceState,
377        chain_update: Option<&NewCanonicalChain<N>>,
378    ) -> ProviderResult<bool> {
379        let canonical_head_number = match chain_update {
380            Some(chain_update) => {
381                let new = chain_update.new_blocks();
382                // Only the canonical prefix below the new branch remains on the proposed chain.
383                new.first().expect("non empty chain").block_number() - 1
384            }
385            None => {
386                let Some(head) = self.find_canonical_header(state.head_block_hash)? else {
387                    return Ok(false)
388                };
389                head.number()
390            }
391        };
392
393        for hash in [state.finalized_block_hash, state.safe_block_hash] {
394            if hash.is_zero() || chain_update.is_some_and(|update| update.contains(hash)) {
395                continue
396            }
397            let Some(header) = self.find_canonical_header(hash)? else { return Ok(false) };
398            if header.number() > canonical_head_number {
399                return Ok(false)
400            }
401        }
402        Ok(true)
403    }
404
405    /// Updates the tracked finalized block if we have it.
406    fn update_finalized_block(
407        &mut self,
408        finalized_block_hash: B256,
409    ) -> Result<(), OnForkChoiceUpdated> {
410        if finalized_block_hash.is_zero() {
411            return Ok(())
412        }
413
414        match self.find_canonical_header(finalized_block_hash) {
415            Ok(None) => {
416                debug!(target: "engine::tree", "Finalized block not found in canonical chain");
417                // if the finalized block is not known, we can't update the finalized block
418                return Err(OnForkChoiceUpdated::invalid_state())
419            }
420            Ok(Some(finalized)) => {
421                if Some(finalized.num_hash()) !=
422                    self.canonical_in_memory_state().get_finalized_num_hash()
423                {
424                    // we're also persisting the finalized block on disk so we can reload it on
425                    // restart this is required by optimism which queries the finalized block: <https://github.com/ethereum-optimism/optimism/blob/c383eb880f307caa3ca41010ec10f30f08396b2e/op-node/rollup/sync/start.go#L65-L65>
426                    let _ = self.persistence.save_finalized_block_number(finalized.number());
427                    self.canonical_in_memory_state_writer.set_finalized(finalized.clone());
428                    // Update finalized block height metric
429                    self.metrics.tree.finalized_block_height.set(finalized.number() as f64);
430                }
431            }
432            Err(err) => {
433                error!(target: "engine::tree", %err, "Failed to fetch finalized block header");
434            }
435        }
436
437        Ok(())
438    }
439
440    /// Updates the tracked safe block if we have it
441    fn update_safe_block(&mut self, safe_block_hash: B256) -> Result<(), OnForkChoiceUpdated> {
442        if safe_block_hash.is_zero() {
443            return Ok(())
444        }
445
446        match self.find_canonical_header(safe_block_hash) {
447            Ok(None) => {
448                debug!(target: "engine::tree", "Safe block not found in canonical chain");
449                // if the safe block is not known, we can't update the safe block
450                return Err(OnForkChoiceUpdated::invalid_state())
451            }
452            Ok(Some(safe)) => {
453                if Some(safe.num_hash()) != self.canonical_in_memory_state().get_safe_num_hash() {
454                    // we're also persisting the safe block on disk so we can reload it on
455                    // restart this is required by optimism which queries the safe block: <https://github.com/ethereum-optimism/optimism/blob/c383eb880f307caa3ca41010ec10f30f08396b2e/op-node/rollup/sync/start.go#L65-L65>
456                    let _ = self.persistence.save_safe_block_number(safe.number());
457                    self.canonical_in_memory_state_writer.set_safe(safe.clone());
458                    // Update safe block height metric
459                    self.metrics.tree.safe_block_height.set(safe.number() as f64);
460                }
461            }
462            Err(err) => {
463                error!(target: "engine::tree", %err, "Failed to fetch safe block header");
464            }
465        }
466
467        Ok(())
468    }
469
470    /// Ensures that the given forkchoice state is consistent, assuming the head block has been
471    /// made canonical.
472    ///
473    /// If the forkchoice state is consistent, this will return Ok(()). Otherwise, this will
474    /// return an instance of [`OnForkChoiceUpdated`] that is INVALID.
475    ///
476    /// This also updates the safe and finalized blocks in the [`CanonicalInMemoryState`], if they
477    /// are consistent with the head block.
478    ///
479    /// [`CanonicalInMemoryState`]: reth_chain_state::CanonicalInMemoryState
480    pub(super) fn ensure_consistent_forkchoice_state(
481        &mut self,
482        state: ForkchoiceState,
483    ) -> Result<(), OnForkChoiceUpdated> {
484        // Ensure that the finalized block, if not zero, is known and in the canonical chain
485        // after the head block is canonicalized.
486        //
487        // This ensures that the finalized block is consistent with the head block, i.e. the
488        // finalized block is an ancestor of the head block.
489        self.update_finalized_block(state.finalized_block_hash)?;
490
491        // Also ensure that the safe block, if not zero, is known and in the canonical chain
492        // after the head block is canonicalized.
493        //
494        // This ensures that the safe block is consistent with the head block, i.e. the safe
495        // block is an ancestor of the head block.
496        self.update_safe_block(state.safe_block_hash)
497    }
498
499    /// Validates the payload attributes with respect to the header and fork choice state.
500    ///
501    /// This is called during `engine_forkchoiceUpdated` when the CL provides payload attributes,
502    /// indicating it wants the EL to start building a new block.
503    ///
504    /// Runs [`PayloadValidator::validate_payload_attributes_against_header`](reth_engine_primitives::PayloadValidator::validate_payload_attributes_against_header) to ensure
505    /// `payloadAttributes.timestamp > headBlock.timestamp` per the Engine API spec.
506    ///
507    /// If validation passes, sends the attributes to the payload builder to start a new
508    /// payload job. If it fails, returns `INVALID_PAYLOAD_ATTRIBUTES` without rolling back
509    /// the forkchoice update.
510    ///
511    /// Note: At this point, the fork choice update is considered to be VALID, however, we can still
512    /// return an error if the payload attributes are invalid.
513    pub(super) fn process_payload_attributes(
514        &mut self,
515        attributes: T::PayloadAttributes,
516        head: &N::BlockHeader,
517        state: ForkchoiceState,
518    ) -> OnForkChoiceUpdated {
519        if let Err(err) =
520            self.payload_validator.validate_payload_attributes_against_header(&attributes, head)
521        {
522            warn!(target: "engine::tree", %err, ?head, "Invalid payload attributes");
523            return OnForkChoiceUpdated::invalid_payload_attributes()
524        }
525
526        // 8. Client software MUST begin a payload build process building on top of
527        //    forkchoiceState.headBlockHash and identified via buildProcessId value if
528        //    payloadAttributes is not null and the forkchoice state has been updated successfully.
529        //    The build process is specified in the Payload building section.
530
531        // Acquire this before preparing resources because state-root setup can already start
532        // workers that need the current in-memory overlay.
533        let payload_build = self.payload_builds.acquire();
534
535        let resources = self
536            .payload_validator
537            .payload_builder_resources(
538                state.head_block_hash,
539                head,
540                attributes.timestamp(),
541                &mut self.state,
542            )
543            .with_lease(PayloadBuilderLease::new(payload_build));
544
545        // send the payload to the builder and return the receiver for the pending payload
546        // id, initiating payload job is handled asynchronously
547        let pending_payload_id = self.payload_builder.send_new_payload(BuildNewPayload {
548            parent_hash: state.head_block_hash,
549            attributes,
550            resources,
551        });
552
553        // Client software MUST respond to this method call in the following way:
554        // {
555        //      payloadStatus: {
556        //          status: VALID,
557        //          latestValidHash: forkchoiceState.headBlockHash,
558        //          validationError: null
559        //      },
560        //      payloadId: buildProcessId
561        // }
562        //
563        // if the payload is deemed VALID and the build process has begun.
564        OnForkChoiceUpdated::updated_with_pending_payload_id(
565            PayloadStatus::new(PayloadStatusEnum::Valid, Some(state.head_block_hash)),
566            pending_payload_id,
567        )
568    }
569}