Skip to content

Commit

Permalink
Fix expected proposer calculation for equal priorities (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-coreum authored Mar 12, 2024
1 parent ac01e32 commit cb79a84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/consensus/handle_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ func (m *Module) countProposalsByValidator(block *tmctypes.ResultBlock, vals *tm
return
}

// Based on https://github.com/cometbft/cometbft/blob/613d602e48adc723e41bd4c9a9ba37a95a510c7c/types/validator.go#L65
expectedNextProposer := vals.Validators[0]
if len(vals.Validators) > 1 {
for _, v := range vals.Validators[1:] {
if v.ProposerPriority > expectedNextProposer.ProposerPriority {
if v.ProposerPriority > expectedNextProposer.ProposerPriority ||
(v.ProposerPriority == expectedNextProposer.ProposerPriority &&
bytes.Compare(v.Address, expectedNextProposer.Address) < 0) {
expectedNextProposer = v
}
}
Expand Down

0 comments on commit cb79a84

Please sign in to comment.