tempo_commonware_node/consensus/application/
mod.rs

1//! Drives the execution engine by forwarding consensus messages.
2
3use std::time::Duration;
4
5use commonware_runtime::{Metrics, Pacer, Spawner, Storage};
6
7use eyre::WrapErr as _;
8use rand::{CryptoRng, Rng};
9use tempo_node::TempoFullNode;
10
11mod executor;
12
13mod actor;
14mod ingress;
15
16pub(super) use actor::Actor;
17pub(crate) use ingress::Mailbox;
18
19use crate::{epoch::SchemeProvider, subblocks};
20
21pub(super) async fn init<TContext>(
22    config: Config<TContext>,
23) -> eyre::Result<(Actor<TContext>, Mailbox)>
24where
25    TContext: Pacer + governor::clock::Clock + Rng + CryptoRng + Spawner + Storage + Metrics,
26{
27    let actor = Actor::init(config)
28        .await
29        .wrap_err("failed initializing actor")?;
30    let mailbox = actor.mailbox().clone();
31    Ok((actor, mailbox))
32}
33
34pub(super) struct Config<TContext> {
35    /// The execution context of the commonwarexyz application (tokio runtime, etc).
36    pub(super) context: TContext,
37
38    /// Used as PayloadAttributes.suggested_fee_recipient
39    pub(super) fee_recipient: alloy_primitives::Address,
40
41    /// Number of messages from consensus to hold in our backlog
42    /// before blocking.
43    pub(super) mailbox_size: usize,
44
45    /// For subscribing to blocks distributed via the consensus p2p network.
46    pub(super) marshal: crate::alias::marshal::Mailbox,
47
48    /// A handle to the execution node to verify and create new payloads.
49    pub(super) execution_node: TempoFullNode,
50
51    /// A handle to the subblocks service to get subblocks for proposals.
52    pub(crate) subblocks: subblocks::Mailbox,
53
54    /// The minimum amount of time to wait before resolving a new payload from the builder
55    pub(super) new_payload_wait_time: Duration,
56
57    /// The number of heights H in an epoch. For a given epoch E, all heights
58    /// `E*H` to and including `(E+1)*H-1` make up the epoch. The block at
59    /// `E*H-1` (saturating) is said to be the genesis (or parent) of the epoch.
60    pub(super) epoch_length: u64,
61
62    /// The scheme provider to use for the application.
63    pub(crate) scheme_provider: SchemeProvider,
64}