commonware_consensus/aggregation/
config.rs

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