make progress asap on full precommit votes optional (Refs #348)
This commit is contained in:
parent
b096651e10
commit
a1fd312bb1
|
@ -84,6 +84,8 @@ func GetConfig(rootDir string) cfg.Config {
|
|||
mapConfig.SetDefault("timeout_precommit", 1000)
|
||||
mapConfig.SetDefault("timeout_precommit_delta", 500)
|
||||
mapConfig.SetDefault("timeout_commit", 1000)
|
||||
// make progress asap (no `timeout_commit`) on full precommit votes
|
||||
mapConfig.SetDefault("skip_timeout_commit", false)
|
||||
mapConfig.SetDefault("mempool_recheck", true)
|
||||
mapConfig.SetDefault("mempool_recheck_empty", true)
|
||||
mapConfig.SetDefault("mempool_broadcast", true)
|
||||
|
|
|
@ -98,6 +98,7 @@ func ResetConfig(localPath string) cfg.Config {
|
|||
mapConfig.SetDefault("timeout_precommit", 10)
|
||||
mapConfig.SetDefault("timeout_precommit_delta", 1)
|
||||
mapConfig.SetDefault("timeout_commit", 10)
|
||||
mapConfig.SetDefault("skip_timeout_commit", false)
|
||||
mapConfig.SetDefault("mempool_recheck", true)
|
||||
mapConfig.SetDefault("mempool_recheck_empty", true)
|
||||
mapConfig.SetDefault("mempool_broadcast", true)
|
||||
|
|
|
@ -149,6 +149,12 @@ func TestValidatorSetChanges(t *testing.T) {
|
|||
nPeers := 8
|
||||
nVals := 4
|
||||
css := randConsensusNetWithPeers(nVals, nPeers, "consensus_val_set_changes_test", newMockTickerFunc(true), newPersistentDummy)
|
||||
|
||||
// otherwise, the test is failing with timeout error
|
||||
for i := 0; i < nPeers; i++ {
|
||||
css[i].timeoutParams.SkipCommit0 = true
|
||||
}
|
||||
|
||||
reactors := make([]*ConsensusReactor, nPeers)
|
||||
eventChans := make([]chan interface{}, nPeers)
|
||||
for i := 0; i < nPeers; i++ {
|
||||
|
|
|
@ -24,7 +24,8 @@ import (
|
|||
//-----------------------------------------------------------------------------
|
||||
// Timeout Parameters
|
||||
|
||||
// All in milliseconds
|
||||
// TimeoutParams holds timeouts and deltas for each round step.
|
||||
// All timeouts and deltas in milliseconds.
|
||||
type TimeoutParams struct {
|
||||
Propose0 int
|
||||
ProposeDelta int
|
||||
|
@ -33,6 +34,7 @@ type TimeoutParams struct {
|
|||
Precommit0 int
|
||||
PrecommitDelta int
|
||||
Commit0 int
|
||||
SkipTimeoutCommit bool
|
||||
}
|
||||
|
||||
// Wait this long for a proposal
|
||||
|
@ -55,7 +57,7 @@ func (tp *TimeoutParams) Commit(t time.Time) time.Time {
|
|||
return t.Add(time.Duration(tp.Commit0) * time.Millisecond)
|
||||
}
|
||||
|
||||
// Initialize parameters from config
|
||||
// InitTimeoutParamsFromConfig initializes parameters from config
|
||||
func InitTimeoutParamsFromConfig(config cfg.Config) *TimeoutParams {
|
||||
return &TimeoutParams{
|
||||
Propose0: config.GetInt("timeout_propose"),
|
||||
|
@ -65,6 +67,7 @@ func InitTimeoutParamsFromConfig(config cfg.Config) *TimeoutParams {
|
|||
Precommit0: config.GetInt("timeout_precommit"),
|
||||
PrecommitDelta: config.GetInt("timeout_precommit_delta"),
|
||||
Commit0: config.GetInt("timeout_commit"),
|
||||
SkipTimeoutCommit: config.GetBool("skip_timeout_commit"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1388,8 +1391,8 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerKey string) (added bool,
|
|||
log.Info(Fmt("Added to lastPrecommits: %v", cs.LastCommit.StringShort()))
|
||||
types.FireEventVote(cs.evsw, types.EventDataVote{vote})
|
||||
|
||||
if cs.LastCommit.HasAll() {
|
||||
// if we have all the votes now,
|
||||
// if we can skip timeoutCommit and have all the votes now,
|
||||
if cs.timeoutParams.SkipTimeoutCommit && cs.LastCommit.HasAll() {
|
||||
// go straight to new round (skip timeout commit)
|
||||
// cs.scheduleTimeout(time.Duration(0), cs.Height, 0, RoundStepNewHeight)
|
||||
cs.enterNewRound(cs.Height, 0)
|
||||
|
@ -1452,7 +1455,7 @@ func (cs *ConsensusState) addVote(vote *types.Vote, peerKey string) (added bool,
|
|||
cs.enterPrecommit(height, vote.Round)
|
||||
cs.enterCommit(height, vote.Round)
|
||||
|
||||
if precommits.HasAll() {
|
||||
if cs.timeoutParams.SkipTimeoutCommit && cs.LastCommit.HasAll() {
|
||||
// if we have all the votes now,
|
||||
// go straight to new round (skip timeout commit)
|
||||
// cs.scheduleTimeout(time.Duration(0), cs.Height, 0, RoundStepNewHeight)
|
||||
|
|
Loading…
Reference in New Issue