cmpb/
tbft.rs

1/// ValidatorSet represents the set of validators
2#[allow(clippy::derive_partial_eq_without_eq)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ValidatorSet {
5    #[prost(string, repeated, tag = "1")]
6    pub validators: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
7}
8#[allow(clippy::derive_partial_eq_without_eq)]
9#[derive(Clone, PartialEq, ::prost::Message)]
10pub struct TbftMsg {
11    #[prost(enumeration = "TbftMsgType", tag = "1")]
12    pub r#type: i32,
13    #[prost(bytes = "vec", tag = "2")]
14    pub msg: ::prost::alloc::vec::Vec<u8>,
15}
16/// Proposal defined a consesensus proposal which can
17/// be gossiped to other node and can be serilized
18/// for persistent store.
19#[allow(clippy::derive_partial_eq_without_eq)]
20#[derive(Clone, PartialEq, ::prost::Message)]
21pub struct Proposal {
22    #[prost(string, tag = "1")]
23    pub voter: ::prost::alloc::string::String,
24    #[prost(uint64, tag = "2")]
25    pub height: u64,
26    #[prost(int32, tag = "3")]
27    pub round: i32,
28    #[prost(int32, tag = "4")]
29    pub pol_round: i32,
30    #[prost(message, optional, tag = "5")]
31    pub block: ::core::option::Option<super::common::Block>,
32    #[prost(message, optional, tag = "6")]
33    pub endorsement: ::core::option::Option<super::common::EndorsementEntry>,
34    #[prost(map = "string, message", tag = "7")]
35    pub txs_rw_set:
36        ::std::collections::HashMap<::prost::alloc::string::String, super::common::TxRwSet>,
37    #[prost(message, repeated, tag = "8")]
38    pub qc: ::prost::alloc::vec::Vec<Vote>,
39}
40/// Vote represents a tbft vote
41#[allow(clippy::derive_partial_eq_without_eq)]
42#[derive(Clone, PartialEq, ::prost::Message)]
43pub struct Vote {
44    #[prost(enumeration = "VoteType", tag = "1")]
45    pub r#type: i32,
46    #[prost(string, tag = "2")]
47    pub voter: ::prost::alloc::string::String,
48    #[prost(uint64, tag = "3")]
49    pub height: u64,
50    #[prost(int32, tag = "4")]
51    pub round: i32,
52    #[prost(bytes = "vec", tag = "5")]
53    pub hash: ::prost::alloc::vec::Vec<u8>,
54    #[prost(message, optional, tag = "6")]
55    pub endorsement: ::core::option::Option<super::common::EndorsementEntry>,
56    #[prost(string, repeated, tag = "7")]
57    pub invalid_txs: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
58}
59/// BlockVotes represents votes as key-value form
60#[allow(clippy::derive_partial_eq_without_eq)]
61#[derive(Clone, PartialEq, ::prost::Message)]
62pub struct BlockVotes {
63    #[prost(map = "string, message", tag = "1")]
64    pub votes: ::std::collections::HashMap<::prost::alloc::string::String, Vote>,
65    #[prost(uint64, tag = "2")]
66    pub sum: u64,
67}
68/// VoteSet represents a set of vote at `height` and `round`
69#[allow(clippy::derive_partial_eq_without_eq)]
70#[derive(Clone, PartialEq, ::prost::Message)]
71pub struct VoteSet {
72    #[prost(enumeration = "VoteType", tag = "1")]
73    pub r#type: i32,
74    #[prost(uint64, tag = "2")]
75    pub height: u64,
76    #[prost(int32, tag = "3")]
77    pub round: i32,
78    #[prost(uint64, tag = "4")]
79    pub sum: u64,
80    #[prost(bytes = "vec", tag = "5")]
81    pub maj23: ::prost::alloc::vec::Vec<u8>,
82    #[prost(map = "string, message", tag = "6")]
83    pub votes: ::std::collections::HashMap<::prost::alloc::string::String, Vote>,
84    #[prost(map = "string, message", tag = "7")]
85    pub votes_by_block: ::std::collections::HashMap<::prost::alloc::string::String, BlockVotes>,
86}
87/// RoundVoteSet represents voteSet of a `round`
88#[allow(clippy::derive_partial_eq_without_eq)]
89#[derive(Clone, PartialEq, ::prost::Message)]
90pub struct RoundVoteSet {
91    #[prost(uint64, tag = "1")]
92    pub height: u64,
93    #[prost(int32, tag = "2")]
94    pub round: i32,
95    #[prost(message, optional, tag = "3")]
96    pub prevotes: ::core::option::Option<VoteSet>,
97    #[prost(message, optional, tag = "4")]
98    pub precommits: ::core::option::Option<VoteSet>,
99}
100/// HeightRoundVoteSet represents voteSet of a `height`
101#[allow(clippy::derive_partial_eq_without_eq)]
102#[derive(Clone, PartialEq, ::prost::Message)]
103pub struct HeightRoundVoteSet {
104    #[prost(uint64, tag = "1")]
105    pub height: u64,
106    /// max round
107    #[prost(int32, tag = "2")]
108    pub round: i32,
109    #[prost(map = "int32, message", tag = "3")]
110    pub round_vote_sets: ::std::collections::HashMap<i32, RoundVoteSet>,
111}
112/// ConsensusState represents the state of tbft instance
113#[allow(clippy::derive_partial_eq_without_eq)]
114#[derive(Clone, PartialEq, ::prost::Message)]
115pub struct ConsensusState {
116    #[prost(string, tag = "1")]
117    pub id: ::prost::alloc::string::String,
118    #[prost(uint64, tag = "2")]
119    pub height: u64,
120    /// max round
121    #[prost(int32, tag = "3")]
122    pub round: i32,
123    /// step
124    #[prost(enumeration = "Step", tag = "4")]
125    pub step: i32,
126    #[prost(message, optional, tag = "5")]
127    pub proposal: ::core::option::Option<Proposal>,
128    #[prost(message, optional, tag = "6")]
129    pub verifing_proposal: ::core::option::Option<Proposal>,
130    #[prost(message, optional, tag = "7")]
131    pub locked_proposal: ::core::option::Option<Proposal>,
132    #[prost(message, optional, tag = "8")]
133    pub valid_proposal: ::core::option::Option<Proposal>,
134    #[prost(message, optional, tag = "9")]
135    pub height_round_vote_set: ::core::option::Option<HeightRoundVoteSet>,
136}
137/// FetchRoundQC defined a fetch roundQC request which can
138/// be gossiped to other node
139#[allow(clippy::derive_partial_eq_without_eq)]
140#[derive(Clone, PartialEq, ::prost::Message)]
141pub struct FetchRoundQc {
142    #[prost(string, tag = "1")]
143    pub id: ::prost::alloc::string::String,
144    #[prost(uint64, tag = "2")]
145    pub height: u64,
146    #[prost(int32, tag = "3")]
147    pub round: i32,
148}
149/// RoundQC represents the max round of qc
150#[allow(clippy::derive_partial_eq_without_eq)]
151#[derive(Clone, PartialEq, ::prost::Message)]
152pub struct RoundQc {
153    #[prost(string, tag = "1")]
154    pub id: ::prost::alloc::string::String,
155    #[prost(uint64, tag = "2")]
156    pub height: u64,
157    #[prost(int32, tag = "3")]
158    pub round: i32,
159    #[prost(message, optional, tag = "4")]
160    pub qc: ::core::option::Option<VoteSet>,
161}
162/// GossipState represents the state of tbft instance
163#[allow(clippy::derive_partial_eq_without_eq)]
164#[derive(Clone, PartialEq, ::prost::Message)]
165pub struct GossipState {
166    #[prost(string, tag = "1")]
167    pub id: ::prost::alloc::string::String,
168    #[prost(uint64, tag = "2")]
169    pub height: u64,
170    /// max round
171    #[prost(int32, tag = "3")]
172    pub round: i32,
173    /// step
174    #[prost(enumeration = "Step", tag = "4")]
175    pub step: i32,
176    #[prost(bytes = "vec", tag = "5")]
177    pub proposal: ::prost::alloc::vec::Vec<u8>,
178    #[prost(bytes = "vec", tag = "6")]
179    pub verifing_proposal: ::prost::alloc::vec::Vec<u8>,
180    #[prost(message, optional, tag = "7")]
181    pub round_vote_set: ::core::option::Option<RoundVoteSet>,
182}
183/// TimeoutInfo represents the timeout event
184#[allow(clippy::derive_partial_eq_without_eq)]
185#[derive(Clone, PartialEq, ::prost::Message)]
186pub struct TimeoutInfo {
187    #[prost(int64, tag = "1")]
188    pub duration: i64,
189    #[prost(uint64, tag = "2")]
190    pub height: u64,
191    #[prost(int32, tag = "3")]
192    pub round: i32,
193    #[prost(enumeration = "Step", tag = "4")]
194    pub step: i32,
195}
196/// WalEntry represents the log entry in Wal
197#[allow(clippy::derive_partial_eq_without_eq)]
198#[derive(Clone, PartialEq, ::prost::Message)]
199pub struct WalEntry {
200    #[prost(uint64, tag = "1")]
201    pub height: u64,
202    /// log entry type
203    #[prost(enumeration = "WalEntryType", tag = "2")]
204    pub r#type: i32,
205    /// data of entry
206    #[prost(bytes = "vec", tag = "3")]
207    pub data: ::prost::alloc::vec::Vec<u8>,
208}
209/// TBFTMsgType defines different type message in tbft
210#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
211#[repr(i32)]
212pub enum TbftMsgType {
213    MsgPropose = 0,
214    MsgPrevote = 1,
215    MsgPrecommit = 2,
216    MsgState = 3,
217    MsgFetchRoundqc = 4,
218    MsgSendRoundQc = 5,
219}
220impl TbftMsgType {
221    /// String value of the enum field names used in the ProtoBuf definition.
222    ///
223    /// The values are not transformed in any way and thus are considered stable
224    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
225    pub fn as_str_name(&self) -> &'static str {
226        match self {
227            TbftMsgType::MsgPropose => "MSG_PROPOSE",
228            TbftMsgType::MsgPrevote => "MSG_PREVOTE",
229            TbftMsgType::MsgPrecommit => "MSG_PRECOMMIT",
230            TbftMsgType::MsgState => "MSG_STATE",
231            TbftMsgType::MsgFetchRoundqc => "MSG_FETCH_ROUNDQC",
232            TbftMsgType::MsgSendRoundQc => "MSG_SEND_ROUND_QC",
233        }
234    }
235    /// Creates an enum from field names used in the ProtoBuf definition.
236    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
237        match value {
238            "MSG_PROPOSE" => Some(Self::MsgPropose),
239            "MSG_PREVOTE" => Some(Self::MsgPrevote),
240            "MSG_PRECOMMIT" => Some(Self::MsgPrecommit),
241            "MSG_STATE" => Some(Self::MsgState),
242            "MSG_FETCH_ROUNDQC" => Some(Self::MsgFetchRoundqc),
243            "MSG_SEND_ROUND_QC" => Some(Self::MsgSendRoundQc),
244            _ => None,
245        }
246    }
247}
248/// VoteType represents the type of vote
249#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
250#[repr(i32)]
251pub enum VoteType {
252    VotePrevote = 0,
253    VotePrecommit = 1,
254}
255impl VoteType {
256    /// String value of the enum field names used in the ProtoBuf definition.
257    ///
258    /// The values are not transformed in any way and thus are considered stable
259    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
260    pub fn as_str_name(&self) -> &'static str {
261        match self {
262            VoteType::VotePrevote => "VOTE_PREVOTE",
263            VoteType::VotePrecommit => "VOTE_PRECOMMIT",
264        }
265    }
266    /// Creates an enum from field names used in the ProtoBuf definition.
267    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
268        match value {
269            "VOTE_PREVOTE" => Some(Self::VotePrevote),
270            "VOTE_PRECOMMIT" => Some(Self::VotePrecommit),
271            _ => None,
272        }
273    }
274}
275/// Step represents the step in a round
276#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
277#[repr(i32)]
278pub enum Step {
279    NewHeight = 0,
280    NewRound = 1,
281    Propose = 2,
282    Prevote = 3,
283    PrevoteWait = 4,
284    Precommit = 5,
285    PrecommitWait = 6,
286    Commit = 7,
287}
288impl Step {
289    /// String value of the enum field names used in the ProtoBuf definition.
290    ///
291    /// The values are not transformed in any way and thus are considered stable
292    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
293    pub fn as_str_name(&self) -> &'static str {
294        match self {
295            Step::NewHeight => "NEW_HEIGHT",
296            Step::NewRound => "NEW_ROUND",
297            Step::Propose => "PROPOSE",
298            Step::Prevote => "PREVOTE",
299            Step::PrevoteWait => "PREVOTE_WAIT",
300            Step::Precommit => "PRECOMMIT",
301            Step::PrecommitWait => "PRECOMMIT_WAIT",
302            Step::Commit => "COMMIT",
303        }
304    }
305    /// Creates an enum from field names used in the ProtoBuf definition.
306    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
307        match value {
308            "NEW_HEIGHT" => Some(Self::NewHeight),
309            "NEW_ROUND" => Some(Self::NewRound),
310            "PROPOSE" => Some(Self::Propose),
311            "PREVOTE" => Some(Self::Prevote),
312            "PREVOTE_WAIT" => Some(Self::PrevoteWait),
313            "PRECOMMIT" => Some(Self::Precommit),
314            "PRECOMMIT_WAIT" => Some(Self::PrecommitWait),
315            "COMMIT" => Some(Self::Commit),
316            _ => None,
317        }
318    }
319}
320/// WalEntryType represents different types of entries in Wal
321#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
322#[repr(i32)]
323pub enum WalEntryType {
324    TimeoutEntry = 0,
325    ProposalEntry = 1,
326    VoteEntry = 2,
327    ProposalVoteEntry = 3,
328}
329impl WalEntryType {
330    /// String value of the enum field names used in the ProtoBuf definition.
331    ///
332    /// The values are not transformed in any way and thus are considered stable
333    /// (if the ProtoBuf definition does not change) and safe for programmatic use.
334    pub fn as_str_name(&self) -> &'static str {
335        match self {
336            WalEntryType::TimeoutEntry => "TIMEOUT_ENTRY",
337            WalEntryType::ProposalEntry => "PROPOSAL_ENTRY",
338            WalEntryType::VoteEntry => "VOTE_ENTRY",
339            WalEntryType::ProposalVoteEntry => "PROPOSAL_VOTE_ENTRY",
340        }
341    }
342    /// Creates an enum from field names used in the ProtoBuf definition.
343    pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
344        match value {
345            "TIMEOUT_ENTRY" => Some(Self::TimeoutEntry),
346            "PROPOSAL_ENTRY" => Some(Self::ProposalEntry),
347            "VOTE_ENTRY" => Some(Self::VoteEntry),
348            "PROPOSAL_VOTE_ENTRY" => Some(Self::ProposalVoteEntry),
349            _ => None,
350        }
351    }
352}