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