Skip to content

Commit

Permalink
fix: validators and lastValidators change while rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink committed Jan 23, 2024
1 parent 066015f commit dfcd5b8
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions state/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package state
import (
"errors"
"fmt"

Check failure on line 5 in state/rollback.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `goimports`-ed (goimports)
"github.com/cometbft/cometbft/types"

cmtstate "github.com/cometbft/cometbft/proto/tendermint/state"
cmtversion "github.com/cometbft/cometbft/proto/tendermint/version"
Expand Down Expand Up @@ -77,14 +78,20 @@ func Rollback(bs BlockStore, ss Store, removeBlock bool, rollbackBlocks int64) (
paramsChangeHeight = rollbackHeight + 1
}

validators, err := ss.LoadValidators(rollbackHeight)
if err != nil {
return -1, nil, err
}

nextValidators, err := ss.LoadValidators(rollbackHeight + 1)
if err != nil {
return -1, nil, err
var validators *types.ValidatorSet
var nextValidators *types.ValidatorSet
if rollbackBlocks == 1 {
validators = invalidState.LastValidators
nextValidators = invalidState.Validators
} else {
validators, err = ss.LoadValidators(rollbackHeight + 1)
if err != nil {
return -1, nil, err
}
nextValidators, err = ss.LoadValidators(rollbackHeight + 2)
if err != nil {
return -1, nil, err
}
}

// build the new state from the old state and the prior block
Expand Down

0 comments on commit dfcd5b8

Please sign in to comment.