Skip to main content

tempo_commonware_node/dkg/manager/
mod.rs

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