commonware_consensus/ordered_broadcast/
config.rs

1use super::types::{Activity, Context, Epoch};
2use crate::{Automaton, Monitor, Relay, Reporter, Supervisor, ThresholdSupervisor};
3use commonware_cryptography::{bls12381::primitives::variant::Variant, Digest, Signer};
4use commonware_runtime::buffer::PoolRef;
5use std::{num::NonZeroUsize, time::Duration};
6
7/// Configuration for the [super::Engine].
8pub struct Config<
9    C: Signer,
10    V: Variant,
11    D: Digest,
12    A: Automaton<Context = Context<C::PublicKey>, Digest = D>,
13    R: Relay<Digest = D>,
14    Z: Reporter<Activity = Activity<C::PublicKey, V, D>>,
15    M: Monitor<Index = Epoch>,
16    Su: Supervisor<Index = Epoch, PublicKey = C::PublicKey>,
17    TSu: ThresholdSupervisor<Index = Epoch, PublicKey = C::PublicKey>,
18> {
19    /// The cryptographic scheme used if the engine is a sequencer.
20    pub crypto: C,
21
22    /// Tracks the current state of consensus (to determine which participants should
23    /// be involved in the current broadcast attempt).
24    pub monitor: M,
25
26    /// Manages the set of validators and the group polynomial.
27    /// Also manages the cryptographic partial share if the engine is a validator.
28    pub validators: TSu,
29
30    /// Manages the set of sequencers.
31    pub sequencers: Su,
32
33    /// Proposes and verifies digests.
34    pub automaton: A,
35
36    /// Broadcasts the raw payload.
37    pub relay: R,
38
39    /// Notified when a chunk receives a threshold of acks.
40    pub reporter: Z,
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 proposals are sent as priority.
47    pub priority_proposals: bool,
48
49    /// Whether acks are sent as priority.
50    pub priority_acks: bool,
51
52    /// How often a proposal is rebroadcast to all validators if no threshold is reached.
53    pub rebroadcast_timeout: Duration,
54
55    /// A tuple representing the epochs to keep in memory.
56    /// The first element is the number of old epochs to keep.
57    /// The second element is the number of future epochs to accept.
58    ///
59    /// For example, if the current epoch is 10, and the bounds are (1, 2), then
60    /// epochs 9, 10, 11, and 12 are kept (and accepted);
61    /// all others are pruned or rejected.
62    pub epoch_bounds: (u64, u64),
63
64    /// The number of future heights to accept acks for.
65    /// This is used to prevent spam of acks for arbitrary heights.
66    ///
67    /// For example, if the current tip for a sequencer is at height 100,
68    /// and the height_bound is 10, then acks for heights 100-110 are accepted.
69    pub height_bound: u64,
70
71    /// A prefix for the journal names.
72    /// The rest of the name is the hex-encoded public keys of the relevant sequencer.
73    pub journal_name_prefix: String,
74
75    /// The number of entries to keep per journal section.
76    pub journal_heights_per_section: u64,
77
78    /// The number of bytes to buffer when replaying a journal.
79    pub journal_replay_buffer: NonZeroUsize,
80
81    /// The size of the write buffer to use for each blob in the journal.
82    pub journal_write_buffer: NonZeroUsize,
83
84    /// Compression level for the journal.
85    pub journal_compression: Option<u8>,
86
87    /// Buffer pool for the journal.
88    pub journal_buffer_pool: PoolRef,
89}