commonware_consensus/threshold_simplex/
config.rs1use super::types::{Activity, Context, View};
2use crate::{Automaton, Relay, Reporter, ThresholdSupervisor};
3use commonware_cryptography::{
4 bls12381::primitives::{group, variant::Variant},
5 Digest, Signer,
6};
7use commonware_p2p::Blocker;
8use governor::Quota;
9use std::time::Duration;
10
11pub struct Config<
13 C: Signer,
14 B: Blocker<PublicKey = C::PublicKey>,
15 V: Variant,
16 D: Digest,
17 A: Automaton<Context = Context<D>>,
18 R: Relay,
19 F: Reporter<Activity = Activity<V, D>>,
20 S: ThresholdSupervisor<
21 Index = View,
22 Identity = V::Public,
23 Seed = V::Signature,
24 PublicKey = C::PublicKey,
25 Share = group::Share,
26 >,
27> {
28 pub crypto: C,
30
31 pub blocker: B,
35
36 pub automaton: A,
38
39 pub relay: R,
41
42 pub reporter: F,
44
45 pub supervisor: S,
47
48 pub partition: String,
50
51 pub compression: Option<u8>,
53
54 pub mailbox_size: usize,
57
58 pub namespace: Vec<u8>,
60
61 pub replay_buffer: usize,
63
64 pub write_buffer: usize,
66
67 pub leader_timeout: Duration,
70
71 pub notarization_timeout: Duration,
74
75 pub nullify_retry: Duration,
78
79 pub activity_timeout: View,
82
83 pub skip_timeout: View,
89
90 pub fetch_timeout: Duration,
92
93 pub max_fetch_count: usize,
95
96 pub fetch_rate_per_peer: Quota,
100
101 pub fetch_concurrent: usize,
103}
104
105impl<
106 C: Signer,
107 B: Blocker<PublicKey = C::PublicKey>,
108 V: Variant,
109 D: Digest,
110 A: Automaton<Context = Context<D>>,
111 R: Relay,
112 F: Reporter<Activity = Activity<V, D>>,
113 S: ThresholdSupervisor<
114 Seed = V::Signature,
115 Index = View,
116 Share = group::Share,
117 Identity = V::Public,
118 PublicKey = C::PublicKey,
119 >,
120 > Config<C, B, V, D, A, R, F, S>
121{
122 pub fn assert(&self) {
124 assert!(
125 self.leader_timeout > Duration::default(),
126 "leader timeout must be greater than zero"
127 );
128 assert!(
129 self.notarization_timeout > Duration::default(),
130 "notarization timeout must be greater than zero"
131 );
132 assert!(
133 self.leader_timeout <= self.notarization_timeout,
134 "leader timeout must be less than or equal to notarization timeout"
135 );
136 assert!(
137 self.nullify_retry > Duration::default(),
138 "nullify retry broadcast must be greater than zero"
139 );
140 assert!(
141 self.activity_timeout > 0,
142 "activity timeout must be greater than zero"
143 );
144 assert!(
145 self.skip_timeout > 0,
146 "skip timeout must be greater than zero"
147 );
148 assert!(
149 self.skip_timeout <= self.activity_timeout,
150 "skip timeout must be less than or equal to activity timeout"
151 );
152 assert!(
153 self.fetch_timeout > Duration::default(),
154 "fetch timeout must be greater than zero"
155 );
156 assert!(
157 self.max_fetch_count > 0,
158 "it must be possible to fetch at least one container per request"
159 );
160 assert!(
161 self.fetch_concurrent > 0,
162 "it must be possible to fetch from at least one peer at a time"
163 );
164 }
165}