Skip to main content

tempo_consensus/dkg/manager/
mod.rs

1use std::sync::Arc;
2
3use commonware_consensus::types::FixedEpocher;
4use commonware_cryptography::{bls12381::primitives::group::Share, ed25519::PrivateKey};
5use commonware_runtime::{BufferPooler, Clock, Metrics, Spawner, Storage};
6use eyre::WrapErr as _;
7use futures::channel::mpsc;
8use rand_core::CryptoRngCore;
9use tempo_node::TempoFullNode;
10
11mod actor;
12mod ingress;
13
14pub(crate) use actor::Actor;
15pub(crate) use ingress::Mailbox;
16
17use crate::epoch;
18
19use ingress::{Command, Message};
20
21pub(crate) async fn init<TContext>(
22    context: TContext,
23    config: Config,
24) -> eyre::Result<(Actor<TContext>, Mailbox)>
25where
26    TContext: BufferPooler + Clock + CryptoRngCore + Metrics + Spawner + Storage,
27{
28    let (tx, rx) = mpsc::unbounded();
29
30    let actor = Actor::new(config, context, rx)
31        .await
32        .wrap_err("failed initializing actor")?;
33    let mailbox = Mailbox::new(tx);
34    Ok((actor, mailbox))
35}
36
37pub(crate) struct Config {
38    pub(crate) epoch_strategy: FixedEpocher,
39
40    pub(crate) epoch_manager: epoch::manager::Mailbox,
41
42    /// The namespace the dkg manager will use when sending messages during
43    /// a dkg ceremony.
44    pub(crate) namespace: Vec<u8>,
45
46    pub(crate) me: PrivateKey,
47
48    pub(crate) mailbox_size: usize,
49
50    /// The mailbox to the marshal actor. Used to determine if an epoch
51    /// can be started at startup.
52    pub(crate) marshal: crate::alias::marshal::Mailbox,
53
54    /// The partition prefix to use when persisting ceremony metadata during
55    /// rounds.
56    pub(crate) partition_prefix: String,
57
58    /// The full execution layer node. On init, used to read the initial set
59    /// of peers and public polynomial.
60    ///
61    /// During normal operation, used to read the validator config at the end
62    /// of each epoch.
63    pub(crate) execution_node: Arc<TempoFullNode>,
64
65    /// This node's initial share of the bls12381 private key.
66    pub(crate) initial_share: Option<Share>,
67}