From 0c01b0ded95e568adf829a13f9394b4aa88546ab Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 22 Dec 2016 19:30:09 -0500 Subject: [PATCH] state.State and wal.writeHeight after handshake --- consensus/replay.go | 1 + consensus/state.go | 8 ++++++++ state/execution.go | 4 +++- test/docker/Dockerfile | 3 +++ test/persist/test_failure_indices.sh | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/consensus/replay.go b/consensus/replay.go index b69b4384..124d3b5f 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -101,6 +101,7 @@ func (cs *ConsensusState) catchupReplay(csHeight int) error { // Search for height marker gr, found, err = cs.wal.group.Search("#HEIGHT: ", makeHeightSearchFunc(csHeight)) if err == io.EOF { + log.Warn("Replay: wal.group.Search returned EOF", "height", csHeight) return nil } else if err != nil { return err diff --git a/consensus/state.go b/consensus/state.go index 31a2e2c9..9dead0cf 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -362,6 +362,14 @@ func (cs *ConsensusState) OnStart() error { // let's go for it anyways, maybe we're fine } + // If the latest block was applied in the tmsp handshake, + // we may not have written the current height to the wal, + // so write it here in case + if cs.Step == RoundStepNewHeight { + log.Warn("wal.writeHeight", "height", cs.Height) + cs.wal.writeHeight(cs.Height) + } + // now start the receiveRoutine go cs.receiveRoutine(0) diff --git a/state/execution.go b/state/execution.go index e1cea605..47ca0149 100644 --- a/state/execution.go +++ b/state/execution.go @@ -344,6 +344,9 @@ func (h *Handshaker) Handshake(proxyApp proxy.AppConns) error { return errors.New(Fmt("Error on replay: %v", err)) } + // Save the state + h.state.Save() + // TODO: (on restart) replay mempool return nil @@ -378,7 +381,6 @@ func (h *Handshaker) ReplayBlocks(appHash []byte, appBlockHeight int, appConnCon // so load the intermediate state and update the hash h.state.LoadIntermediate() h.state.AppHash = appHash - h.state.Save() log.Debug("TMSP RelpayBlocks: Loaded intermediate state and updated state.AppHash") } else { PanicSanity(Fmt("Unexpected state.AppHash: state.AppHash %X; app.AppHash %X, lastBlock.AppHash %X", stateAppHash, appHash, lastBlockAppHash)) diff --git a/test/docker/Dockerfile b/test/docker/Dockerfile index 7cc95254..5a859a28 100644 --- a/test/docker/Dockerfile +++ b/test/docker/Dockerfile @@ -21,5 +21,8 @@ COPY . $REPO RUN go install ./cmd/tendermint RUN bash scripts/install_tmsp_apps.sh +# expose the volume for debugging +VOLUME $REPO + EXPOSE 46656 EXPOSE 46657 diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index 7302ccac..d6012fbe 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -18,7 +18,7 @@ function start_procs(){ PID_TENDERMINT=$! else # run in foreground, fail - FAIL_TEST_INDEX=$indexToFail tendermint node &> tendermint_${name}.log + FAIL_TEST_INDEX=$indexToFail tendermint node --log_level=debug &> tendermint_${name}.log PID_TENDERMINT=$! fi }