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