Skip to content

Commit

Permalink
Merge pull request #498 from XinFinOrg/ppx-01
Browse files Browse the repository at this point in the history
PPX-01 add verification of vote signer belonging to masternodes
  • Loading branch information
wgr523 authored Apr 1, 2024
2 parents 7c8317a + 04c3f48 commit c16bd66
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions consensus/XDPoS/engines/engine_v2/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,20 @@ func (x *XDPoS_v2) verifyVotes(chain consensus.ChainReader, votes map[common.Has
for h, vote := range votes {
go func(hash common.Hash, v *types.Vote) {
defer wg.Done()
if v.GetSigner() != emptySigner {
// verify before
signerAddress := v.GetSigner()
if signerAddress != emptySigner {
// verify that signer belongs to the final masternodes, we have not do so in previous steps
if len(masternodes) == 0 {
log.Error("[verifyVotes] empty masternode list detected when verifying message signatures")
}
for _, mn := range masternodes {
if mn == signerAddress {
return
}
}
// if signer does not belong to final masternodes, we remove the signer
v.SetSigner(emptySigner)
log.Debug("[verifyVotes] find a vote does not belong to final masternodes", "signer", signerAddress)
return
}
signedVote := types.VoteSigHash(&types.VoteForSign{
Expand Down

0 comments on commit c16bd66

Please sign in to comment.