diff --git a/blockchain/pool.go b/blockchain/pool.go index dd54e493a..0409976f3 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -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. diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 06168903f..9bab832e7 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -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" diff --git a/cmd/tendermint/main.go b/cmd/tendermint/main.go index 64ac87e51..5072f5c9c 100644 --- a/cmd/tendermint/main.go +++ b/cmd/tendermint/main.go @@ -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": diff --git a/cmd/tendermint/reset_priv_validator.go b/cmd/tendermint/reset_priv_validator.go index 37f33d79c..795823c39 100644 --- a/cmd/tendermint/reset_priv_validator.go +++ b/cmd/tendermint/reset_priv_validator.go @@ -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() { diff --git a/consensus/reactor.go b/consensus/reactor.go index 8f4cacee4..c013f6a12 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -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) diff --git a/consensus/state.go b/consensus/state.go index 4670b1468..f5a0b636d 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -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,