commonware_consensus/aggregation/
config.rs

1use super::types::{Activity, Epoch, Index};
2use crate::{Automaton, Monitor, Reporter, ThresholdSupervisor};
3use commonware_cryptography::{bls12381::primitives::variant::Variant, Digest};
4use commonware_p2p::Blocker;
5use commonware_utils::{Array, NonZeroDuration};
6use std::num::{NonZeroU64, NonZeroUsize};
7
8/// Configuration for the [super::Engine].
9pub struct Config<
10    P: Array,
11    V: Variant,
12    D: Digest,
13    A: Automaton<Context = Index, Digest = D>,
14    Z: Reporter<Activity = Activity<V, D>>,
15    M: Monitor<Index = Epoch>,
16    B: Blocker<PublicKey = P>,
17    TSu: ThresholdSupervisor<Index = Epoch, PublicKey = P>,
18> {
19    /// Tracks the current state of consensus (to determine which participants should
20    /// be involved in the current broadcast attempt).
21    pub monitor: M,
22
23    /// Manages the set of validators and the group identity.
24    /// Also manages the cryptographic partial share if the engine is a validator.
25    pub validators: TSu,
26
27    /// Proposes and verifies [Digest]s.
28    pub automaton: A,
29
30    /// Notified when a chunk receives a threshold of [super::types::Ack]s.
31    pub reporter: Z,
32
33    /// Blocker for the network.
34    ///
35    /// Blocking is handled by [commonware_p2p].
36    pub blocker: B,
37
38    /// The application namespace used to sign over different types of messages.
39    /// Used to prevent replay attacks on other applications.
40    pub namespace: Vec<u8>,
41
42    /// Whether acks are sent as priority.
43    pub priority_acks: bool,
44
45    /// How often an ack is rebroadcast to all validators if no threshold is reached.
46    pub rebroadcast_timeout: NonZeroDuration,
47
48    /// A tuple representing the epochs to keep in memory.
49    /// The first element is the number of old epochs to keep.
50    /// The second element is the number of future epochs to accept.
51    ///
52    /// For example, if the current epoch is 10, and the bounds are (1, 2), then
53    /// epochs 9, 10, 11, and 12 are kept (and accepted);
54    /// all others are pruned or rejected.
55    pub epoch_bounds: (u64, u64),
56
57    /// The number of chunks to process concurrently.
58    pub window: NonZeroU64,
59
60    /// Partition for the [commonware_storage::journal::variable::Journal].
61    pub journal_partition: String,
62
63    /// The size of the write buffer to use for each blob in the journal.
64    pub journal_write_buffer: NonZeroUsize,
65
66    /// Number of bytes to buffer when replaying a journal.
67    pub journal_replay_buffer: NonZeroUsize,
68
69    /// The number of entries to keep per journal section.
70    pub journal_heights_per_section: NonZeroU64,
71
72    /// Compression level for the journal.
73    pub journal_compression: Option<u8>,
74}