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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use std::collections::BTreeSet;
use brb_membership::signature;
use brb_membership::{Actor, Generation, Sig};
use crdts::Dot;
use thiserror::Error;
use core::fmt;
use std::error;
#[derive(Error, Debug)]
pub enum Error<A: Actor<S> + 'static, S: Sig + 'static, V: fmt::Debug + error::Error + 'static> {
#[error("error while processing membership change")]
Membership(#[from] brb_membership::Error<A, S>),
#[error("Failed to serialize all or part of a packet")]
Encoding(#[from] bincode::Error),
#[error("Packet failed validation")]
Validation(#[from] ValidationError<A, S, V>),
#[error("Failure when working with signature")]
Signature(#[from] signature::Error),
}
#[derive(Error, Debug)]
pub enum ValidationError<
A: Actor<S> + 'static,
S: Sig + 'static,
V: fmt::Debug + error::Error + 'static,
> {
#[error("The actor `{from}` who sent this packet is different from the actor who incremented the dot: `{dot:?}`")]
PacketSourceIsNotDot {
from: A,
dot: Dot<A>,
},
#[error("The dot in this message `{msg_dot:?}` is out of order (expected: {expected_dot:?})")]
MsgDotNotTheNextDot {
msg_dot: Dot<A>,
expected_dot: Dot<A>,
},
#[error("The source of this message already has a pending message, we can not start a new operation until the first one has completed")]
SourceAlreadyHasPendingMsg {
msg_dot: Dot<A>,
next_deliver_dot: Dot<A>,
},
#[error("This message is not from this generation {msg_gen} (expected: {gen})")]
MessageFromDifferentGeneration {
msg_gen: Generation,
gen: Generation,
},
#[error("Source is not a voting member ({from:?} not in {members:?})")]
SourceIsNotVotingMember {
from: A,
members: BTreeSet<A>,
},
#[error("the datatype failed to validate the operation")]
DataTypeFailedValidation(V),
#[error("Signature is invalid")]
InvalidSignature,
#[error("We received a SignedValidated packet for a message we did not request")]
SignedValidatedForPacketWeDidNotRequest,
#[error("Message dot {msg_dot:?} to be applied is not the next message to be delivered (expected: {expected_dot:?}")]
MsgDotNotNextDotToBeDelivered {
msg_dot: Dot<A>,
expected_dot: Dot<A>,
},
#[error("The proof did not contain enough signatures to form quorum")]
NotEnoughSignaturesToFormQuorum,
#[error("Proof contains signatures from non-members")]
ProofContainsSignaturesFromNonMembers,
#[error("Proof contains invalid signatures")]
ProofContainsInvalidSignatures,
#[error("This variant is only here to satisfy the type checker (we need to use S in a field)")]
PhantomSig(core::marker::PhantomData<S>),
}