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