Skip to main content

tempo_commonware_node/executor/
mod.rs

1//! The executor is sending fork-choice-updates to the execution layer.
2use commonware_consensus::types::Height;
3use commonware_runtime::{Clock, Metrics, Pacer, Spawner};
4
5mod actor;
6mod ingress;
7
8pub(crate) use actor::Actor;
9use eyre::WrapErr as _;
10use futures::channel::mpsc;
11pub(crate) use ingress::Mailbox;
12use tempo_node::TempoFullNode;
13
14pub(crate) fn init<TContext>(
15    context: TContext,
16    config: Config,
17) -> eyre::Result<(Actor<TContext>, Mailbox)>
18where
19    TContext: Clock + Metrics + Pacer + Spawner,
20{
21    let (tx, rx) = mpsc::unbounded();
22    let mailbox = Mailbox { inner: tx };
23    let actor = Actor::init(context, config, rx).wrap_err("failed initializing actor")?;
24    Ok((actor, mailbox))
25}
26
27pub(crate) struct Config {
28    /// A handle to the execution node layer. Used to forward finalized blocks
29    /// and to update the canonical chain by sending forkchoice updates.
30    pub(crate) execution_node: TempoFullNode,
31
32    /// The last finalized height according to the consensus layer.
33    /// If on startup there is a mismatch between the execution layer and the
34    /// consensus, then the node will fill the gap by backfilling blocks to
35    /// the execution layer until `last_finalized_height` is reached.
36    pub(crate) last_finalized_height: Height,
37
38    /// The mailbox of the marshal actor. Used to backfill blocks.
39    pub(crate) marshal: crate::alias::marshal::Mailbox,
40
41    /// The interval at which to send a forkchoice update heartbeat to the
42    /// execution layer.
43    pub(crate) fcu_heartbeat_interval: std::time::Duration,
44}