From 78830e5caaf67a711b57e98f0b92f6c1a067dfde Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:50:03 +0200 Subject: [PATCH] fix: correct validator increment --- internal/state/current_round_state.go | 8 +------- internal/state/store.go | 5 ++++- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/state/current_round_state.go b/internal/state/current_round_state.go index 77eee27152..45ed183dbc 100644 --- a/internal/state/current_round_state.go +++ b/internal/state/current_round_state.go @@ -105,12 +105,6 @@ func (candidate *CurrentRoundState) UpdateState(target *State) error { return nil } -// UpdateFunc implements UpdateFunc -func (candidate *CurrentRoundState) UpdateFunc(state State) (State, error) { - err := candidate.UpdateState(&state) - return state, err -} - // GetHeight returns height of current block func (candidate *CurrentRoundState) GetHeight() int64 { if candidate.Base.LastBlockHeight == 0 { @@ -202,7 +196,7 @@ func (candidate *CurrentRoundState) populateValsetUpdates() error { // we take validator sets as they arrive from InitChainSource response if updateSource != InitChainSource { - newValSet.IncrementProposerPriority(1 + candidate.Round) + newValSet.IncrementProposerPriority(1 + candidate.Params.Round) } candidate.NextValidators = newValSet diff --git a/internal/state/store.go b/internal/state/store.go index 0c97f9af30..129791226f 100644 --- a/internal/state/store.go +++ b/internal/state/store.go @@ -499,6 +499,9 @@ func (store dbStore) SaveValidatorSets(lowerHeight, upperHeight int64, vals *typ // LoadValidators loads the ValidatorSet for a given height. // Returns ErrNoValSetForHeight if the validator set can't be found for this height. +// +// TODO: The returned ValidatorSet proposer score does not take into account changing round numbers +// and is not guaranteed to be correct. func (store dbStore) LoadValidators(height int64) (*types.ValidatorSet, error) { valInfo, err := loadValidatorsInfo(store.db, height) @@ -525,7 +528,7 @@ func (store dbStore) LoadValidators(height int64) (*types.ValidatorSet, error) { if err != nil { return nil, err } - + // TODO: rounds should be also considered here vs.IncrementProposerPriority(h) // mutate vi2, err := vs.ToProto() if err != nil {