github.com/ImPedro29/bor@v0.2.7/consensus/bor/errors.go (about) 1 package bor 2 3 import ( 4 "fmt" 5 "time" 6 ) 7 8 // TotalVotingPowerExceededError is returned when the maximum allowed total voting power is exceeded 9 type TotalVotingPowerExceededError struct { 10 Sum int64 11 Validators []*Validator 12 } 13 14 func (e *TotalVotingPowerExceededError) Error() string { 15 return fmt.Sprintf( 16 "Total voting power should be guarded to not exceed %v; got: %v; for validator set: %v", 17 MaxTotalVotingPower, 18 e.Sum, 19 e.Validators, 20 ) 21 } 22 23 type InvalidStartEndBlockError struct { 24 Start uint64 25 End uint64 26 CurrentHeader uint64 27 } 28 29 func (e *InvalidStartEndBlockError) Error() string { 30 return fmt.Sprintf( 31 "Invalid parameters start: %d and end block: %d params", 32 e.Start, 33 e.End, 34 ) 35 } 36 37 type MaxCheckpointLengthExceededError struct { 38 Start uint64 39 End uint64 40 } 41 42 func (e *MaxCheckpointLengthExceededError) Error() string { 43 return fmt.Sprintf( 44 "Start: %d and end block: %d exceed max allowed checkpoint length: %d", 45 e.Start, 46 e.End, 47 MaxCheckpointLength, 48 ) 49 } 50 51 // MismatchingValidatorsError is returned if a last block in sprint contains a 52 // list of validators different from the one that local node calculated 53 type MismatchingValidatorsError struct { 54 Number uint64 55 ValidatorSetSnap []byte 56 ValidatorSetHeader []byte 57 } 58 59 func (e *MismatchingValidatorsError) Error() string { 60 return fmt.Sprintf( 61 "Mismatching validators at block %d\nValidatorBytes from snapshot: 0x%x\nValidatorBytes in Header: 0x%x\n", 62 e.Number, 63 e.ValidatorSetSnap, 64 e.ValidatorSetHeader, 65 ) 66 } 67 68 type BlockTooSoonError struct { 69 Number uint64 70 Succession int 71 } 72 73 func (e *BlockTooSoonError) Error() string { 74 return fmt.Sprintf( 75 "Block %d was created too soon. Signer turn-ness number is %d\n", 76 e.Number, 77 e.Succession, 78 ) 79 } 80 81 // UnauthorizedProposerError is returned if a header is [being] signed by an unauthorized entity. 82 type UnauthorizedProposerError struct { 83 Number uint64 84 Proposer []byte 85 } 86 87 func (e *UnauthorizedProposerError) Error() string { 88 return fmt.Sprintf( 89 "Proposer 0x%x is not a part of the producer set at block %d", 90 e.Proposer, 91 e.Number, 92 ) 93 } 94 95 // UnauthorizedSignerError is returned if a header is [being] signed by an unauthorized entity. 96 type UnauthorizedSignerError struct { 97 Number uint64 98 Signer []byte 99 } 100 101 func (e *UnauthorizedSignerError) Error() string { 102 return fmt.Sprintf( 103 "Signer 0x%x is not a part of the producer set at block %d", 104 e.Signer, 105 e.Number, 106 ) 107 } 108 109 // WrongDifficultyError is returned if the difficulty of a block doesn't match the 110 // turn of the signer. 111 type WrongDifficultyError struct { 112 Number uint64 113 Expected uint64 114 Actual uint64 115 Signer []byte 116 } 117 118 func (e *WrongDifficultyError) Error() string { 119 return fmt.Sprintf( 120 "Wrong difficulty at block %d, expected: %d, actual %d. Signer was %x\n", 121 e.Number, 122 e.Expected, 123 e.Actual, 124 e.Signer, 125 ) 126 } 127 128 type InvalidStateReceivedError struct { 129 Number uint64 130 LastStateID uint64 131 To *time.Time 132 Event *EventRecordWithTime 133 } 134 135 func (e *InvalidStateReceivedError) Error() string { 136 return fmt.Sprintf( 137 "Received invalid event %s at block %d. Requested events until %s. Last state id was %d", 138 e.Event, 139 e.Number, 140 e.To.Format(time.RFC3339), 141 e.LastStateID, 142 ) 143 }