From be3e8979c0c9c245ab2eaeff9dbc2096e6d667a6 Mon Sep 17 00:00:00 2001 From: Wojtek Date: Mon, 11 Mar 2024 13:06:40 +0100 Subject: [PATCH] Fix expected proposer calculation for equal priorities --- modules/consensus/handle_block.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/consensus/handle_block.go b/modules/consensus/handle_block.go index 06b4b8cf9..82ce0c88f 100644 --- a/modules/consensus/handle_block.go +++ b/modules/consensus/handle_block.go @@ -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 } }