From 25e665df17f2daabef089c4d75ca8bbeecdaf717 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Wed, 12 Jan 2022 15:55:42 -0500 Subject: [PATCH] internal/libs: delete unused functionality (#7569) --- internal/consensus/state.go | 19 ------------- internal/libs/fail/fail.go | 40 --------------------------- internal/libs/timer/throttle_timer.go | 7 ----- internal/state/execution.go | 9 ------ 4 files changed, 75 deletions(-) delete mode 100644 internal/libs/fail/fail.go diff --git a/internal/consensus/state.go b/internal/consensus/state.go index f2f65ca52..49559f15d 100644 --- a/internal/consensus/state.go +++ b/internal/consensus/state.go @@ -18,7 +18,6 @@ import ( "github.com/tendermint/tendermint/crypto" cstypes "github.com/tendermint/tendermint/internal/consensus/types" "github.com/tendermint/tendermint/internal/eventbus" - "github.com/tendermint/tendermint/internal/libs/fail" sm "github.com/tendermint/tendermint/internal/state" tmevents "github.com/tendermint/tendermint/libs/events" "github.com/tendermint/tendermint/libs/log" @@ -866,14 +865,6 @@ func (cs *State) receiveRoutine(ctx context.Context, maxSteps int) { )) } - if _, ok := mi.Msg.(*VoteMessage); ok { - // we actually want to simulate failing during - // the previous WriteSync, but this isn't easy to do. - // Equivalent would be to fail here and manually remove - // some bytes from the end of the wal. - fail.Fail() // XXX - } - // handles proposals, block parts, votes cs.handleMsg(ctx, mi) @@ -1705,8 +1696,6 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) { ) logger.Debug(fmt.Sprintf("%v", block)) - fail.Fail() // XXX - // Save to blockStore. if cs.blockStore.Height() < block.Height { // NOTE: the seenCommit is local justification to commit this block, @@ -1719,8 +1708,6 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) { logger.Debug("calling finalizeCommit on already stored block", "height", block.Height) } - fail.Fail() // XXX - // Write EndHeightMessage{} for this height, implying that the blockstore // has saved the block. // @@ -1742,8 +1729,6 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) { )) } - fail.Fail() // XXX - // Create a copy of the state for staging and an event cache for txs. stateCopy := cs.state.Copy() @@ -1762,16 +1747,12 @@ func (cs *State) finalizeCommit(ctx context.Context, height int64) { return } - fail.Fail() // XXX - // must be called before we update state cs.RecordMetrics(height, block) // NewHeightStep! cs.updateToState(ctx, stateCopy) - fail.Fail() // XXX - // Private validator might have changed it's key pair => refetch pubkey. if err := cs.updatePrivValidatorPubKey(ctx); err != nil { logger.Error("failed to get private validator pubkey", "err", err) diff --git a/internal/libs/fail/fail.go b/internal/libs/fail/fail.go deleted file mode 100644 index 03a2ca668..000000000 --- a/internal/libs/fail/fail.go +++ /dev/null @@ -1,40 +0,0 @@ -package fail - -import ( - "fmt" - "os" - "strconv" -) - -func envSet() int { - callIndexToFailS := os.Getenv("FAIL_TEST_INDEX") - - if callIndexToFailS == "" { - return -1 - } - - var err error - callIndexToFail, err := strconv.Atoi(callIndexToFailS) - if err != nil { - return -1 - } - - return callIndexToFail -} - -// Fail when FAIL_TEST_INDEX == callIndex -var callIndex int // indexes Fail calls - -func Fail() { - callIndexToFail := envSet() - if callIndexToFail < 0 { - return - } - - if callIndex == callIndexToFail { - fmt.Printf("*** fail-test %d ***\n", callIndex) - os.Exit(1) - } - - callIndex++ -} diff --git a/internal/libs/timer/throttle_timer.go b/internal/libs/timer/throttle_timer.go index 76db87ee8..7bf86e80c 100644 --- a/internal/libs/timer/throttle_timer.go +++ b/internal/libs/timer/throttle_timer.go @@ -55,13 +55,6 @@ func (t *ThrottleTimer) Set() { } } -func (t *ThrottleTimer) Unset() { - t.mtx.Lock() - defer t.mtx.Unlock() - t.isSet = false - t.timer.Stop() -} - // For ease of .Stop()'ing services before .Start()'ing them, // we ignore .Stop()'s on nil ThrottleTimers func (t *ThrottleTimer) Stop() bool { diff --git a/internal/state/execution.go b/internal/state/execution.go index 71c913f2a..f80d2fa9a 100644 --- a/internal/state/execution.go +++ b/internal/state/execution.go @@ -9,7 +9,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/encoding" "github.com/tendermint/tendermint/internal/eventbus" - "github.com/tendermint/tendermint/internal/libs/fail" "github.com/tendermint/tendermint/internal/mempool" "github.com/tendermint/tendermint/internal/proxy" "github.com/tendermint/tendermint/libs/log" @@ -171,15 +170,11 @@ func (blockExec *BlockExecutor) ApplyBlock( return state, ErrProxyAppConn(err) } - fail.Fail() // XXX - // Save the results before we commit. if err := blockExec.store.SaveABCIResponses(block.Height, abciResponses); err != nil { return state, err } - fail.Fail() // XXX - // validate the validator updates and convert to tendermint types abciValUpdates := abciResponses.EndBlock.ValidatorUpdates err = validateValidatorUpdates(abciValUpdates, state.ConsensusParams.Validator) @@ -210,16 +205,12 @@ func (blockExec *BlockExecutor) ApplyBlock( // Update evpool with the latest state. blockExec.evpool.Update(state, block.Evidence.Evidence) - fail.Fail() // XXX - // Update the app hash and save the state. state.AppHash = appHash if err := blockExec.store.Save(state); err != nil { return state, err } - fail.Fail() // XXX - // Prune old heights, if requested by ABCI app. if retainHeight > 0 { pruned, err := blockExec.pruneBlocks(retainHeight)