Skip to content

Commit

Permalink
fix: add verification of vote signer belonging to masternodes
Browse files Browse the repository at this point in the history
  • Loading branch information
wgr523 committed Mar 19, 2024
1 parent 42c57c6 commit 04c3f48
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 04c3f48

Please sign in to comment.