From 754572cf83a14562dc7aadba94ca49a11370fac9 Mon Sep 17 00:00:00 2001 From: Hendrik Hofstadt Date: Thu, 13 Dec 2018 00:26:39 +0100 Subject: [PATCH] Replayable --- consensus/replay.go | 2 ++ consensus/replay_file.go | 19 +++++++++++++++---- consensus/ticker.go | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index c9a779e3..4bece70d 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -47,6 +47,7 @@ func (cs *ConsensusState) readReplayMessage(msg *TimedWALMessage, newStepCh chan return nil } + cs.Logger.Debug("Next message time: " + msg.Time.String()) // for logging switch m := msg.Msg.(type) { case types.EventDataRoundState: @@ -58,6 +59,7 @@ func (cs *ConsensusState) readReplayMessage(msg *TimedWALMessage, newStepCh chan case mi := <-newStepCh: m2 := mi.(types.EventDataRoundState) if m.Height != m2.Height || m.Round != m2.Round || m.Step != m2.Step { + //TODO comment next line to continue -> H38 return fmt.Errorf("RoundState mismatch. Got %v; Expected %v", m2, m) } case <-ticker: diff --git a/consensus/replay_file.go b/consensus/replay_file.go index a326e70e..4f84fae4 100644 --- a/consensus/replay_file.go +++ b/consensus/replay_file.go @@ -4,13 +4,12 @@ import ( "bufio" "context" "fmt" + "github.com/pkg/errors" "io" "os" "strconv" "strings" - "github.com/pkg/errors" - bc "github.com/tendermint/tendermint/blockchain" cfg "github.com/tendermint/tendermint/config" cmn "github.com/tendermint/tendermint/libs/common" @@ -45,7 +44,7 @@ func (cs *ConsensusState) ReplayFile(file string, console bool) error { return errors.New("cs is already running, cannot replay") } if cs.wal != nil { - return errors.New("cs wal is open, cannot replay") + //return errors.New("cs wal is open, cannot replay") } cs.startForReplay() @@ -78,8 +77,20 @@ func (cs *ConsensusState) ReplayFile(file string, console bool) error { } pb := newPlayback(file, fp, cs, cs.state.Copy()) + pb.cs.Logger = log.NewTMLogger(os.Stdout) defer pb.fp.Close() // nolint: errcheck + go func() { + for { + <-cs.timeoutTicker.Chan() + } + }() + go func() { + for { + <-cs.statsMsgQueue + } + }() + var nextN int // apply N msgs in a row var msg *TimedWALMessage for { @@ -340,7 +351,7 @@ func newConsensusStateForReplay(config cfg.BaseConfig, csConfig *cfg.ConsensusCo mempool, evpool := sm.MockMempool{}, sm.MockEvidencePool{} blockExec := sm.NewBlockExecutor(stateDB, log.TestingLogger(), proxyApp.Consensus(), mempool, evpool) - consensusState := NewConsensusState(csConfig, state.Copy(), blockExec, + consensusState := NewConsensusState(csConfig, sm.LoadState(stateDB).Copy(), blockExec, blockStore, mempool, evpool) consensusState.SetEventBus(eventBus) diff --git a/consensus/ticker.go b/consensus/ticker.go index a1e2174c..82a69507 100644 --- a/consensus/ticker.go +++ b/consensus/ticker.go @@ -71,7 +71,7 @@ func (t *timeoutTicker) Chan() <-chan timeoutInfo { // The timeoutRoutine is always available to read from tickChan, so this won't block. // The scheduling may fail if the timeoutRoutine has already scheduled a timeout for a later height/round/step. func (t *timeoutTicker) ScheduleTimeout(ti timeoutInfo) { - t.tickChan <- ti + //t.tickChan <- ti } //-------------------------------------------------------------