Skip to content

Commit

Permalink
fix: use -1 as default for v1 selection algo
Browse files Browse the repository at this point in the history
  • Loading branch information
dumbeng committed Nov 24, 2024
1 parent 3bf8cc9 commit ae954d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/themisd/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ which accepts a path for the resulting pprof file.
FlagMinGasPrices, "",
"Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photino;0.0001stake)",
)
cmd.Flags().Uint64(FlagSelectionAlgoV1Height, 0, "Height at which to switch to election algorithm v1")
cmd.Flags().Int64(FlagSelectionAlgoV1Height, -1, "Height at which to switch to election algorithm v1")
cmd.Flags().Uint64(FlagHaltHeight, 0, "Height at which to gracefully halt the chain and shutdown the node")
cmd.Flags().Uint64(FlagHaltTime, 0, "Minimum block time (in Unix seconds) at which to gracefully halt the chain and shutdown the node")
cmd.Flags().String(flagCPUProfile, "", "Enable CPU profiling and write to the provided file")
Expand Down
3 changes: 2 additions & 1 deletion helper/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ var Logger logger.Logger
// GenesisDoc contains the genesis file
var GenesisDoc tmTypes.GenesisDoc

var newSelectionAlgoHeight int64 = 0
var newSelectionAlgoHeight int64 = -1

var spanOverrideHeight int64 = 0

Expand Down Expand Up @@ -366,6 +366,7 @@ func InitThemisConfigWith(homeDir string, themisConfigFileFromFLag string) {
spanOverrideHeight = 0
}

panic(conf.SelectionAlgoV1Height)
}

// GetDefaultThemisConfig returns configration with default params
Expand Down
2 changes: 1 addition & 1 deletion metis/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func SelectNextProducers(ctx sdk.Context, blkHash common.Hash, spanEligibleValid
*/

var targetWeight uint64
if ctx.BlockHeight() < helper.GetNewSelectionAlgoHeight() {
if helper.GetNewSelectionAlgoHeight() < 0 || ctx.BlockHeight() < helper.GetNewSelectionAlgoHeight() {
targetWeight = randomRangeInclusive(1, totalVotingPower)
ctx.Logger().Debug("Selecting new proposer", "algoVersion", 0, "totalVotingPower",
totalVotingPower, "targetWeight", targetWeight,
Expand Down

0 comments on commit ae954d0

Please sign in to comment.