mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
minor: Throw error if proposer/signer are not in the validator set (2.28)
This commit is contained in:
parent
bfab1d932d
commit
18266b0d7a
2 changed files with 33 additions and 0 deletions
27
consensus/bor/errors.go
Normal file
27
consensus/bor/errors.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package bor
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/maticnetwork/bor/common"
|
||||
)
|
||||
|
||||
// Will include any new bor consensus errors here in an attempt to make error messages more descriptive
|
||||
|
||||
// ProposerNotFoundError is returned if the given proposer address is not present in the validator set
|
||||
type ProposerNotFoundError struct {
|
||||
Address common.Address
|
||||
}
|
||||
|
||||
func (e *ProposerNotFoundError) Error() string {
|
||||
return fmt.Sprintf("Proposer: %s not found", e.Address.Hex())
|
||||
}
|
||||
|
||||
// SignerNotFoundError is returned when the signer address is not present in the validator set
|
||||
type SignerNotFoundError struct {
|
||||
Address common.Address
|
||||
}
|
||||
|
||||
func (e *SignerNotFoundError) Error() string {
|
||||
return fmt.Sprintf("Signer: %s not found", e.Address.Hex())
|
||||
}
|
||||
|
|
@ -164,7 +164,13 @@ func (s *Snapshot) apply(headers []*types.Header) (*Snapshot, error) {
|
|||
// proposer will be the last signer if block is not epoch block
|
||||
proposer := snap.ValidatorSet.GetProposer().Address
|
||||
proposerIndex, _ := snap.ValidatorSet.GetByAddress(proposer)
|
||||
if proposerIndex == -1 {
|
||||
return nil, &ProposerNotFoundError{proposer}
|
||||
}
|
||||
signerIndex, _ := snap.ValidatorSet.GetByAddress(signer)
|
||||
if signerIndex == -1 {
|
||||
return nil, &SignerNotFoundError{signer}
|
||||
}
|
||||
limit := len(validators)/2 + 1
|
||||
|
||||
// temp index
|
||||
|
|
|
|||
Loading…
Reference in a new issue