Skip to main content

tempo_commonware_node/executor/
mod.rs

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