good morning!!!!

Skip to content
Snippets Groups Projects
Commit 18266b0d authored by atvanguard's avatar atvanguard
Browse files

minor: Throw error if proposer/signer are not in the validator set (2.28)

parent bfab1d93
Branches
Tags
No related merge requests found
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment