forked from cometbft/cometbft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.go
126 lines (99 loc) · 3.25 KB
/
errors.go
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
package evidence
import (
"errors"
"fmt"
"github.com/zeu5/cometbft/libs/bytes"
"github.com/zeu5/cometbft/types"
)
var (
ErrEvidenceAlreadyCommitted = errors.New("evidence was already committed")
ErrDuplicateEvidence = errors.New("duplicate evidence")
)
type (
ErrNoHeaderAtHeight struct {
Height int64
}
ErrNoCommitAtHeight struct {
Height int64
}
ErrUnrecognizedEvidenceType struct {
Evidence types.Evidence
}
// ErrVotingPowerDoesNotMatch is returned when voting power from trusted validator set does not match voting power from evidence
ErrVotingPowerDoesNotMatch struct {
TrustedVotingPower int64
EvidenceVotingPower int64
}
ErrAddressNotValidatorAtHeight struct {
Address bytes.HexBytes
Height int64
}
// ErrValidatorAddressesDoNotMatch is returned when provided DuplicateVoteEvidence's votes have different validators as signers
ErrValidatorAddressesDoNotMatch struct {
ValidatorA bytes.HexBytes
ValidatorB bytes.HexBytes
}
// ErrSameBlockIDs is returned if a duplicate vote evidence has votes from the same block id (should be different)
ErrSameBlockIDs struct {
BlockID types.BlockID
}
// ErrInvalidEvidenceValidators is returned when evidence validation spots an error related to validator set
ErrInvalidEvidenceValidators struct {
ValError error
}
ErrConflictingBlock struct {
ConflictingBlockError error
}
ErrInvalidEvidence struct {
EvidenceError error
}
// ErrDuplicateEvidenceHRTMismatch is returned when double sign evidence's votes are not from the same height, round or type.
ErrDuplicateEvidenceHRTMismatch struct {
VoteA types.Vote
VoteB types.Vote
}
)
func (e ErrNoHeaderAtHeight) Error() string {
return fmt.Sprintf("don't have header at height #%d", e.Height)
}
func (e ErrNoCommitAtHeight) Error() string {
return fmt.Sprintf("don't have commit at height #%d", e.Height)
}
func (e ErrUnrecognizedEvidenceType) Error() string {
return fmt.Sprintf("unrecognized evidence type: %T", e.Evidence)
}
func (e ErrVotingPowerDoesNotMatch) Error() string {
return fmt.Sprintf("total voting power from the evidence and our validator set does not match (%d != %d)", e.TrustedVotingPower, e.EvidenceVotingPower)
}
func (e ErrAddressNotValidatorAtHeight) Error() string {
return fmt.Sprintf("address %X was not a validator at height %d", e.Address, e.Height)
}
func (e ErrValidatorAddressesDoNotMatch) Error() string {
return fmt.Sprintf("validator addresses do not match: %X vs %X",
e.ValidatorA,
e.ValidatorB,
)
}
func (e ErrSameBlockIDs) Error() string {
return fmt.Sprintf(
"block IDs are the same (%v) - not a real duplicate vote",
e.BlockID,
)
}
func (e ErrInvalidEvidenceValidators) Error() string {
return fmt.Sprintf("invalid evidence validators: %v", e.ValError)
}
func (e ErrInvalidEvidenceValidators) Unwrap() error {
return e.ValError
}
func (e ErrConflictingBlock) Error() string {
return fmt.Sprintf("conflicting block error: %v", e.ConflictingBlockError)
}
func (e ErrInvalidEvidence) Error() string {
return fmt.Sprintf("evidence error: %v", e.EvidenceError)
}
func (e ErrDuplicateEvidenceHRTMismatch) Error() string {
return fmt.Sprintf("h/r/t does not match: %d/%d/%v vs %d/%d/%v",
e.VoteA.Height, e.VoteA.Round, e.VoteA.Type,
e.VoteB.Height, e.VoteB.Round, e.VoteB.Type)
}