commonware_consensus/aggregation/
config.rs

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