Skip to main content

arc_malachitebft_core_driver/
error.rs

1use derive_where::derive_where;
2
3use malachitebft_core_types::{Context, Round, Value};
4
5/// The type of errors that can be yielded by the `Driver`.
6#[derive_where(Clone, Debug, PartialEq, Eq)]
7#[derive(thiserror::Error)]
8pub enum Error<Ctx>
9where
10    Ctx: Context,
11{
12    /// No proposer was set for this round
13    #[error("No proposer set for height {0} at round {1}")]
14    NoProposer(Ctx::Height, Round),
15
16    /// Proposer not found
17    #[error("Proposer not found: {0}")]
18    ProposerNotFound(Ctx::Address),
19
20    /// Validator not found in validator set
21    #[error("Validator not found: {0}")]
22    ValidatorNotFound(Ctx::Address),
23
24    /// Received a proposal for another height
25    #[error("Received proposal for height {proposal_height} different from consensus height {consensus_height}")]
26    InvalidProposalHeight {
27        /// Proposal height
28        proposal_height: Ctx::Height,
29        /// Consensus height
30        consensus_height: Ctx::Height,
31    },
32
33    /// Received a vote for another height
34    #[error(
35        "Received vote for height {vote_height} different from consensus height {consensus_height}"
36    )]
37    InvalidVoteHeight {
38        /// Vote height
39        vote_height: Ctx::Height,
40        /// Consensus height
41        consensus_height: Ctx::Height,
42    },
43
44    /// Received a certificate for another height
45    #[error("Received certificate for height {certificate_height} different from consensus height {consensus_height}")]
46    InvalidCertificateHeight {
47        /// Certificate height
48        certificate_height: Ctx::Height,
49        /// Consensus height
50        consensus_height: Ctx::Height,
51    },
52
53    /// Commit certificate not found for the given round and value
54    #[error("Commit certificate not found for round {round} and value {value_id}")]
55    CertificateNotFound {
56        /// The round
57        round: Round,
58        /// The value ID
59        value_id: <Ctx::Value as Value>::Id,
60    },
61}