Skip to content

Commit

Permalink
Merge pull request #1 from b-harvest/v0.34.25/priority-patch
Browse files Browse the repository at this point in the history
fix: priority problem
  • Loading branch information
zsystm authored Aug 12, 2024
2 parents 1132e3c + b8a1e8f commit 7a7afcf
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/tendermint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"net"
"net/http"
_ "net/http/pprof" //nolint: gosec // securely exposed on separate, optional port
"strings"
"time"

Expand Down Expand Up @@ -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
)

Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions types/priority_reset.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package types

import "math"

var (
PriorityResetHeight int64 = math.MaxInt64
)
7 changes: 7 additions & 0 deletions types/validator_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7a7afcf

Please sign in to comment.