tempo_commonware_node/dkg/manager/
mod.rs1use std::net::SocketAddr;
2
3use commonware_cryptography::{
4 bls12381::primitives::group::Share,
5 ed25519::{PrivateKey, PublicKey},
6};
7use commonware_runtime::{Clock, Metrics, Spawner, Storage};
8use commonware_utils::set::OrderedAssociated;
9use eyre::WrapErr as _;
10use futures::channel::mpsc;
11use rand_core::CryptoRngCore;
12use tempo_node::TempoFullNode;
13
14mod actor;
15mod ingress;
16mod validators;
17
18pub(crate) use actor::Actor;
19pub(crate) use ingress::Mailbox;
20
21use validators::DecodedValidator;
22
23use ingress::{Command, Message};
24
25use crate::epoch;
26
27pub(crate) async fn init<TContext, TPeerManager>(
28 context: TContext,
29 config: Config<TPeerManager>,
30) -> eyre::Result<(Actor<TContext, TPeerManager>, Mailbox)>
31where
32 TContext: Clock + CryptoRngCore + Metrics + Spawner + Storage,
33 TPeerManager: commonware_p2p::Manager<
34 PublicKey = PublicKey,
35 Peers = OrderedAssociated<PublicKey, SocketAddr>,
36 >,
37{
38 let (tx, rx) = mpsc::unbounded();
39
40 let actor = Actor::new(config, context, rx)
41 .await
42 .wrap_err("failed initializing actor")?;
43 let mailbox = Mailbox { inner: tx };
44 Ok((actor, mailbox))
45}
46
47pub(crate) struct Config<TPeerManager> {
48 pub(crate) epoch_manager: epoch::manager::Mailbox,
49
50 pub(crate) namespace: Vec<u8>,
53
54 pub(crate) me: PrivateKey,
55
56 pub(crate) epoch_length: u64,
58
59 pub(crate) mailbox_size: usize,
60
61 pub(crate) marshal: crate::alias::marshal::Mailbox,
64
65 pub(crate) partition_prefix: String,
68
69 pub(crate) execution_node: TempoFullNode,
77
78 pub(crate) initial_share: Option<Share>,
80
81 pub(crate) peer_manager: TPeerManager,
84}