diff --git a/cmd/tendermint/main.go b/cmd/tendermint/main.go index 04665a88f96..51bbb7a400a 100644 --- a/cmd/tendermint/main.go +++ b/cmd/tendermint/main.go @@ -9,10 +9,12 @@ import ( cfg "github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/libs/cli" nm "github.com/tendermint/tendermint/node" + "github.com/tendermint/tendermint/types" ) func main() { rootCmd := cmd.RootCmd + rootCmd.PersistentFlags().Int64Var(&types.PriorityResetHeight, "reset-priority-height", 100, "reset priority height") rootCmd.AddCommand( cmd.GenValidatorCmd, cmd.InitFilesCmd, diff --git a/node/node.go b/node/node.go index 58d8daeb6ac..e608bdb588e 100644 --- a/node/node.go +++ b/node/node.go @@ -7,6 +7,7 @@ import ( "fmt" "net" "net/http" + _ "net/http/pprof" //nolint: gosec // securely exposed on separate, optional port "strings" "time" @@ -53,8 +54,6 @@ import ( tmtime "github.com/tendermint/tendermint/types/time" "github.com/tendermint/tendermint/version" - _ "net/http/pprof" //nolint: gosec // securely exposed on separate, optional port - _ "github.com/lib/pq" // provide the psql db driver ) @@ -727,6 +726,11 @@ func NewNode(config *cfg.Config, return nil, err } + if state.LastBlockHeight == types.PriorityResetHeight { + state.Validators.ResetPriorities() + state.NextValidators.ResetPriorities() + } + // Create the proxyApp and establish connections to the ABCI app (consensus, mempool, query). proxyApp, err := createAndStartProxyAppConns(clientCreator, logger) if err != nil { diff --git a/state/execution.go b/state/execution.go index 2cc3db6e799..8da0ce4affb 100644 --- a/state/execution.go +++ b/state/execution.go @@ -170,6 +170,10 @@ func (blockExec *BlockExecutor) ApplyBlock( blockExec.logger.Debug("updates to validators", "updates", types.ValidatorListString(validatorUpdates)) } + if block.Height == types.PriorityResetHeight+1 { + state.NextValidators.ResetPriorities() + } + // Update the state with the block and responses. state, err = updateState(state, blockID, &block.Header, abciResponses, validatorUpdates) if err != nil { diff --git a/types/priority_reset.go b/types/priority_reset.go new file mode 100644 index 00000000000..53cc1da5f2a --- /dev/null +++ b/types/priority_reset.go @@ -0,0 +1,7 @@ +package types + +import "math" + +var ( + PriorityResetHeight int64 = math.MaxInt64 +) diff --git a/types/validator_set.go b/types/validator_set.go index 39a004b0b6e..b5040b05874 100644 --- a/types/validator_set.go +++ b/types/validator_set.go @@ -895,6 +895,13 @@ func (vals *ValidatorSet) StringIndented(indent string) string { } +// ResetPriorities resets the ProposerPriority of all validators to 0. +func (vals *ValidatorSet) ResetPriorities() { + for _, val := range vals.Validators { + val.ProposerPriority = 0 + } +} + //------------------------------------- // ValidatorsByVotingPower implements sort.Interface for []*Validator based on