Skip to content

Commit

Permalink
fix: correct validator increment
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Sep 4, 2024
1 parent 34c37eb commit 78830e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 1 addition & 7 deletions internal/state/current_round_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion internal/state/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit 78830e5

Please sign in to comment.