Browse Source

fast sync fixes

pull/192/head
Ethan Buchman 9 years ago
parent
commit
50ac66f79b
6 changed files with 22 additions and 4 deletions
  1. +4
    -1
      blockchain/pool.go
  2. +1
    -1
      blockchain/reactor.go
  3. +2
    -0
      cmd/tendermint/main.go
  4. +8
    -0
      cmd/tendermint/reset_priv_validator.go
  5. +1
    -0
      consensus/reactor.go
  6. +6
    -2
      consensus/state.go

+ 4
- 1
blockchain/pool.go View File

@ -132,6 +132,7 @@ func (pool *BlockPool) IsCaughtUp() bool {
// Need at least 1 peer to be considered caught up.
if len(pool.peers) == 0 {
log.Debug("Blockpool has no peers")
return false
}
@ -142,7 +143,9 @@ func (pool *BlockPool) IsCaughtUp() bool {
}
pool.peersMtx.Unlock()
return (height > 0 || time.Now().Sub(pool.startTime) > 5*time.Second) && (maxPeerHeight == 0 || height == maxPeerHeight)
isCaughtUp := (height > 0 || time.Now().Sub(pool.startTime) > 5*time.Second) && (maxPeerHeight == 0 || height >= maxPeerHeight)
log.Notice(Fmt("IsCaughtUp: %v", isCaughtUp), "height", height, "maxPeerHeight", maxPeerHeight)
return isCaughtUp
}
// We need to see the second block's Validation to validate the first block.


+ 1
- 1
blockchain/reactor.go View File

@ -8,9 +8,9 @@ import (
"time"
. "github.com/tendermint/go-common"
"github.com/tendermint/go-events"
"github.com/tendermint/go-p2p"
"github.com/tendermint/go-wire"
"github.com/tendermint/go-events"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"


+ 2
- 0
cmd/tendermint/main.go View File

@ -49,6 +49,8 @@ Commands:
gen_validator()
case "probe_upnp":
probe_upnp()
case "unsafe_reset_all":
reset_all()
case "unsafe_reset_priv_validator":
reset_priv_validator()
case "version":


+ 8
- 0
cmd/tendermint/reset_priv_validator.go View File

@ -6,6 +6,14 @@ import (
"github.com/tendermint/tendermint/types"
)
// NOTE: this is totally unsafe.
// it's only suitable for testnets.
func reset_all() {
reset_priv_validator()
os.RemoveAll(config.GetString("db_dir"))
os.Remove(config.GetString("cswal"))
}
// NOTE: this is totally unsafe.
// it's only suitable for testnets.
func reset_priv_validator() {


+ 1
- 0
consensus/reactor.go View File

@ -73,6 +73,7 @@ func (conR *ConsensusReactor) OnStop() {
// reset the state, turn off fast_sync, start the consensus-state-machine
func (conR *ConsensusReactor) SwitchToConsensus(state *sm.State) {
log.Notice("SwitchToConsensus")
conR.conS.reconstructLastCommit(state)
// NOTE: The line below causes broadcastNewRoundStepRoutine() to
// broadcast a NewRoundStepMessage.
conR.conS.updateToState(state)


+ 6
- 2
consensus/state.go View File

@ -618,7 +618,7 @@ func (cs *ConsensusState) handleMsg(mi msgInfo, rs RoundState) {
log.Warn("Unknown msg type", reflect.TypeOf(msg))
}
if err != nil {
log.Error("error with msg", "error", err)
log.Error("Error with msg", "type", reflect.TypeOf(msg), "error", err, "msg", msg)
}
}
@ -1281,7 +1281,11 @@ func (cs *ConsensusState) tryAddVote(valIndex int, vote *types.Vote, peerKey str
if err == ErrVoteHeightMismatch {
return err
} else if _, ok := err.(*types.ErrVoteConflictingSignature); ok {
log.Warn("Found conflicting vote. Publish evidence")
if peerKey == "" {
log.Warn("Found conflicting vote from ourselves. Did you unsafe_reset a validator?", "height", vote.Height, "round", vote.Round, "type", vote.Type)
return err
}
log.Warn("Found conflicting vote. Publish evidence (TODO)")
/* TODO
evidenceTx := &types.DupeoutTx{
Address: address,


Loading…
Cancel
Save