timeoutProposeDelta
This commit is contained in:
parent
298928dc44
commit
9fc0726504
|
@ -76,6 +76,7 @@ func GetConfig(rootDir string) cfg.Config {
|
|||
mapConfig.SetDefault("rpc_laddr", "0.0.0.0:36657")
|
||||
mapConfig.SetDefault("prof_laddr", "")
|
||||
mapConfig.SetDefault("revision_file", rootDir+"/revision")
|
||||
mapConfig.SetDefault("cs_msg_log", rootDir+"/cs_msg_log")
|
||||
return mapConfig
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ func addVoteToFromMany(to *ConsensusState, votes []*types.Vote, froms ...*valida
|
|||
func addVoteToFrom(to *ConsensusState, from *validatorStub, vote *types.Vote) {
|
||||
valIndex, _ := to.Validators.GetByAddress(from.PrivValidator.Address)
|
||||
|
||||
to.peerMsgQueue <- msgInfo{msg: &VoteMessage{valIndex, vote}}
|
||||
to.peerMsgQueue <- msgInfo{Msg: &VoteMessage{valIndex, vote}}
|
||||
// added, err := to.TryAddVote(valIndex, vote, "")
|
||||
/*
|
||||
if _, ok := err.(*types.ErrVoteConflictingSignature); ok {
|
||||
|
@ -344,7 +344,7 @@ func subscribeToVoter(cs *ConsensusState, addr []byte) chan interface{} {
|
|||
go func() {
|
||||
for {
|
||||
v := <-voteCh0
|
||||
vote := v.(*types.EventDataVote)
|
||||
vote := v.(types.EventDataVote)
|
||||
// we only fire for our own votes
|
||||
if bytes.Equal(addr, vote.Address) {
|
||||
voteCh <- v
|
||||
|
|
|
@ -20,7 +20,8 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
timeoutPropose = 3000 * time.Millisecond // Maximum duration of RoundStepPropose
|
||||
timeoutPropose0 = 3000 * time.Millisecond // Wait this long for a proposal
|
||||
timeoutProposeDelta = 0500 * time.Millisecond // timeoutProposeN is timeoutPropose0 + timeoutProposeDelta*N
|
||||
timeoutPrevote0 = 1000 * time.Millisecond // After any +2/3 prevotes received, wait this long for stragglers.
|
||||
timeoutPrevoteDelta = 0500 * time.Millisecond // timeoutPrevoteN is timeoutPrevote0 + timeoutPrevoteDelta*N
|
||||
timeoutPrecommit0 = 1000 * time.Millisecond // After any +2/3 precommits received, wait this long for stragglers.
|
||||
|
@ -687,9 +688,6 @@ func (cs *ConsensusState) enterNewRound(height int, round int) {
|
|||
|
||||
// Enter: from NewRound(height,round).
|
||||
func (cs *ConsensusState) enterPropose(height int, round int) {
|
||||
// cs.mtx.Lock()
|
||||
// cs.mtx.Unlock()
|
||||
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPropose <= cs.Step) {
|
||||
log.Debug(Fmt("enterPropose(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -710,7 +708,7 @@ func (cs *ConsensusState) enterPropose(height int, round int) {
|
|||
}()
|
||||
|
||||
// This step times out after `timeoutPropose`
|
||||
cs.scheduleTimeout(timeoutPropose, height, round, RoundStepPropose)
|
||||
cs.scheduleTimeout(timeoutPropose0+timeoutProposeDelta*time.Duration(round), height, round, RoundStepPropose)
|
||||
|
||||
// Nothing more to do if we're not a validator
|
||||
if cs.privValidator == nil {
|
||||
|
@ -837,8 +835,6 @@ func (cs *ConsensusState) createProposalBlock() (block *types.Block, blockParts
|
|||
// Prevote for LockedBlock if we're locked, or ProposalBlock if valid.
|
||||
// Otherwise vote nil.
|
||||
func (cs *ConsensusState) enterPrevote(height int, round int) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPrevote <= cs.Step) {
|
||||
log.Debug(Fmt("enterPrevote(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -902,8 +898,6 @@ func (cs *ConsensusState) doPrevote(height int, round int) {
|
|||
|
||||
// Enter: any +2/3 prevotes at next round.
|
||||
func (cs *ConsensusState) enterPrevoteWait(height int, round int) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPrevoteWait <= cs.Step) {
|
||||
log.Debug(Fmt("enterPrevoteWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -930,8 +924,6 @@ func (cs *ConsensusState) enterPrevoteWait(height int, round int) {
|
|||
// else, unlock an existing lock and precommit nil if +2/3 of prevotes were nil,
|
||||
// else, precommit nil otherwise.
|
||||
func (cs *ConsensusState) enterPrecommit(height int, round int) {
|
||||
//cs.mtx.Lock()
|
||||
// defer cs.mtx.Unlock()
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPrecommit <= cs.Step) {
|
||||
log.Debug(Fmt("enterPrecommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -1027,8 +1019,6 @@ func (cs *ConsensusState) enterPrecommit(height int, round int) {
|
|||
|
||||
// Enter: any +2/3 precommits for next round.
|
||||
func (cs *ConsensusState) enterPrecommitWait(height int, round int) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
if cs.Height != height || round < cs.Round || (cs.Round == round && RoundStepPrecommitWait <= cs.Step) {
|
||||
log.Debug(Fmt("enterPrecommitWait(%v/%v): Invalid args. Current step: %v/%v/%v", height, round, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -1051,8 +1041,6 @@ func (cs *ConsensusState) enterPrecommitWait(height int, round int) {
|
|||
|
||||
// Enter: +2/3 precommits for block
|
||||
func (cs *ConsensusState) enterCommit(height int, commitRound int) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
if cs.Height != height || RoundStepCommit <= cs.Step {
|
||||
log.Debug(Fmt("enterCommit(%v/%v): Invalid args. Current step: %v/%v/%v", height, commitRound, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -1117,9 +1105,6 @@ func (cs *ConsensusState) tryFinalizeCommit(height int) {
|
|||
|
||||
// Increment height and goto RoundStepNewHeight
|
||||
func (cs *ConsensusState) finalizeCommit(height int) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
|
||||
if cs.Height != height || cs.Step != RoundStepCommit {
|
||||
log.Debug(Fmt("finalizeCommit(%v): Invalid args. Current step: %v/%v/%v", height, cs.Height, cs.Round, cs.Step))
|
||||
return
|
||||
|
@ -1199,9 +1184,6 @@ func (cs *ConsensusState) finalizeCommit(height int) {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
func (cs *ConsensusState) setProposal(proposal *types.Proposal) error {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
|
||||
// Already have one
|
||||
if cs.Proposal != nil {
|
||||
return nil
|
||||
|
@ -1236,9 +1218,6 @@ func (cs *ConsensusState) setProposal(proposal *types.Proposal) error {
|
|||
// NOTE: block is not necessarily valid.
|
||||
// This can trigger us to go into enterPrevote asynchronously (before we timeout of propose) or to attempt to commit
|
||||
func (cs *ConsensusState) addProposalBlockPart(height int, part *types.Part) (added bool, err error) {
|
||||
//cs.mtx.Lock()
|
||||
//defer cs.mtx.Unlock()
|
||||
|
||||
// Blocks might be reused, so round mismatch is OK
|
||||
if cs.Height != height {
|
||||
return false, nil
|
||||
|
|
|
@ -46,7 +46,8 @@ x * TestHalt1 - if we see +2/3 precommits after timing out into new round, we sh
|
|||
|
||||
func init() {
|
||||
fmt.Println("")
|
||||
timeoutPropose = 500 * time.Millisecond
|
||||
timeoutPropose0 = 100 * time.Millisecond
|
||||
timeoutProposeDelta = 1 * time.Millisecond
|
||||
}
|
||||
|
||||
func TestProposerSelection0(t *testing.T) {
|
||||
|
@ -123,7 +124,7 @@ func TestEnterProposeNoPrivValidator(t *testing.T) {
|
|||
startTestRound(cs, height, round)
|
||||
|
||||
// if we're not a validator, EnterPropose should timeout
|
||||
ticker := time.NewTicker(timeoutPropose * 2)
|
||||
ticker := time.NewTicker(timeoutPropose0 * 2)
|
||||
select {
|
||||
case <-timeoutCh:
|
||||
case <-ticker.C:
|
||||
|
@ -164,7 +165,7 @@ func TestEnterProposeYesPrivValidator(t *testing.T) {
|
|||
}
|
||||
|
||||
// if we're a validator, enterPropose should not timeout
|
||||
ticker := time.NewTicker(timeoutPropose * 2)
|
||||
ticker := time.NewTicker(timeoutPropose0 * 2)
|
||||
select {
|
||||
case <-timeoutCh:
|
||||
t.Fatal("Expected EnterPropose not to timeout")
|
||||
|
|
Loading…
Reference in New Issue