commonware_consensus/ordered_broadcast/
config.rs

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