1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use super::types::Activity;
use crate::{
Automaton, Monitor, Reporter,
types::{Epoch, EpochDelta, Height, HeightDelta},
};
use commonware_cryptography::{
Digest,
certificate::{Provider, Verifier},
};
use commonware_p2p::Blocker;
use commonware_parallel::Strategy;
use commonware_runtime::buffer::paged::CacheRef;
use commonware_utils::NonZeroDuration;
use std::num::{NonZeroU64, NonZeroUsize};
/// Configuration for the [super::Engine].
pub struct Config<
P: Provider<Scope = Epoch>,
D: Digest,
A: Automaton<Context = Height, Digest = D>,
Z: Reporter<Activity = Activity<P::Scheme, D>>,
M: Monitor<Index = Epoch>,
B: Blocker<PublicKey = <P::Scheme as Verifier>::PublicKey>,
T: Strategy,
> {
/// Tracks the current state of consensus (to determine which participants should
/// be involved in the current broadcast attempt).
pub monitor: M,
/// Provider for epoch-specific signing schemes.
pub provider: P,
/// Proposes and verifies [Digest]s.
pub automaton: A,
/// Notified when a chunk receives a quorum of [super::types::Ack]s.
pub reporter: Z,
/// Blocker for the network.
///
/// Blocking is handled by [commonware_p2p].
pub blocker: B,
/// Whether acks are sent as priority.
pub priority_acks: bool,
/// How often an ack is rebroadcast to all validators if no quorum is reached.
pub rebroadcast_timeout: NonZeroDuration,
/// A tuple representing the epochs to keep in memory.
/// The first element is the number of old epochs to keep.
/// The second element is the number of future epochs to accept.
///
/// For example, if the current epoch is 10, and the bounds are (1, 2), then
/// epochs 9, 10, 11, and 12 are kept (and accepted);
/// all others are pruned or rejected.
pub epoch_bounds: (EpochDelta, EpochDelta),
/// The number of chunks to process concurrently.
pub window: NonZeroU64,
/// Number of heights to track below the tip when collecting acks and/or pruning.
pub activity_timeout: HeightDelta,
/// Partition for the [commonware_storage::journal::segmented::variable::Journal].
pub journal_partition: String,
/// The size of the write buffer to use for each blob in the journal.
pub journal_write_buffer: NonZeroUsize,
/// Number of bytes to buffer when replaying a journal.
pub journal_replay_buffer: NonZeroUsize,
/// The number of entries to keep per journal section.
pub journal_heights_per_section: NonZeroU64,
/// Compression level for the journal.
pub journal_compression: Option<u8>,
/// Page cache for the journal.
pub journal_page_cache: CacheRef,
/// Strategy for parallel operations.
pub strategy: T,
}