You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

647 lines
19 KiB

8 years ago
8 years ago
9 years ago
8 years ago
8 years ago
  1. package consensus
  2. import (
  3. "bytes"
  4. "errors"
  5. "fmt"
  6. "io"
  7. "io/ioutil"
  8. "os"
  9. "path"
  10. "strings"
  11. "testing"
  12. "time"
  13. "github.com/spf13/viper"
  14. "github.com/tendermint/abci/example/dummy"
  15. "github.com/tendermint/go-crypto"
  16. "github.com/tendermint/go-wire"
  17. "github.com/tendermint/tendermint/config/tendermint_test"
  18. "github.com/tendermint/tendermint/proxy"
  19. sm "github.com/tendermint/tendermint/state"
  20. "github.com/tendermint/tendermint/types"
  21. cmn "github.com/tendermint/tmlibs/common"
  22. dbm "github.com/tendermint/tmlibs/db"
  23. )
  24. func init() {
  25. config = tendermint_test.ResetConfig("consensus_replay_test")
  26. }
  27. // These tests ensure we can always recover from failure at any part of the consensus process.
  28. // There are two general failure scenarios: failure during consensus, and failure while applying the block.
  29. // Only the latter interacts with the app and store,
  30. // but the former has to deal with restrictions on re-use of priv_validator keys.
  31. // The `WAL Tests` are for failures during the consensus;
  32. // the `Handshake Tests` are for failures in applying the block.
  33. // With the help of the WAL, we can recover from it all!
  34. var data_dir = path.Join(cmn.GoPath, "src/github.com/tendermint/tendermint/consensus", "test_data")
  35. //------------------------------------------------------------------------------------------
  36. // WAL Tests
  37. // TODO: It would be better to verify explicitly which states we can recover from without the wal
  38. // and which ones we need the wal for - then we'd also be able to only flush the
  39. // wal writer when we need to, instead of with every message.
  40. // the priv validator changes step at these lines for a block with 1 val and 1 part
  41. var baseStepChanges = []int{3, 6, 8}
  42. // test recovery from each line in each testCase
  43. var testCases = []*testCase{
  44. newTestCase("empty_block", baseStepChanges), // empty block (has 1 block part)
  45. newTestCase("small_block1", baseStepChanges), // small block with txs in 1 block part
  46. newTestCase("small_block2", []int{3, 10, 12}), // small block with txs across 5 smaller block parts
  47. }
  48. type testCase struct {
  49. name string
  50. log string //full cs wal
  51. stepMap map[int]int8 // map lines of log to privval step
  52. proposeLine int
  53. prevoteLine int
  54. precommitLine int
  55. }
  56. func newTestCase(name string, stepChanges []int) *testCase {
  57. if len(stepChanges) != 3 {
  58. panic(cmn.Fmt("a full wal has 3 step changes! Got array %v", stepChanges))
  59. }
  60. return &testCase{
  61. name: name,
  62. log: readWAL(path.Join(data_dir, name+".cswal")),
  63. stepMap: newMapFromChanges(stepChanges),
  64. proposeLine: stepChanges[0],
  65. prevoteLine: stepChanges[1],
  66. precommitLine: stepChanges[2],
  67. }
  68. }
  69. func newMapFromChanges(changes []int) map[int]int8 {
  70. changes = append(changes, changes[2]+1) // so we add the last step change to the map
  71. m := make(map[int]int8)
  72. var count int
  73. for changeNum, nextChange := range changes {
  74. for ; count < nextChange; count++ {
  75. m[count] = int8(changeNum)
  76. }
  77. }
  78. return m
  79. }
  80. func readWAL(p string) string {
  81. b, err := ioutil.ReadFile(p)
  82. if err != nil {
  83. panic(err)
  84. }
  85. return string(b)
  86. }
  87. func writeWAL(walMsgs string) string {
  88. tempDir := os.TempDir()
  89. walDir := path.Join(tempDir, "/wal"+cmn.RandStr(12))
  90. walFile := path.Join(walDir, "wal")
  91. // Create WAL directory
  92. err := cmn.EnsureDir(walDir, 0700)
  93. if err != nil {
  94. panic(err)
  95. }
  96. // Write the needed WAL to file
  97. err = cmn.WriteFile(walFile, []byte(walMsgs), 0600)
  98. if err != nil {
  99. panic(err)
  100. }
  101. return walFile
  102. }
  103. func waitForBlock(newBlockCh chan interface{}, thisCase *testCase, i int) {
  104. after := time.After(time.Second * 10)
  105. select {
  106. case <-newBlockCh:
  107. case <-after:
  108. panic(cmn.Fmt("Timed out waiting for new block for case '%s' line %d", thisCase.name, i))
  109. }
  110. }
  111. func runReplayTest(t *testing.T, cs *ConsensusState, walFile string, newBlockCh chan interface{},
  112. thisCase *testCase, i int) {
  113. cs.config.Set("cs_wal_file", walFile)
  114. started, err := cs.Start()
  115. if err != nil {
  116. t.Fatalf("Cannot start consensus: %v", err)
  117. }
  118. if !started {
  119. t.Error("Consensus did not start")
  120. }
  121. // Wait to make a new block.
  122. // This is just a signal that we haven't halted; its not something contained in the WAL itself.
  123. // Assuming the consensus state is running, replay of any WAL, including the empty one,
  124. // should eventually be followed by a new block, or else something is wrong
  125. waitForBlock(newBlockCh, thisCase, i)
  126. cs.evsw.Stop()
  127. cs.Stop()
  128. LOOP:
  129. for {
  130. select {
  131. case <-newBlockCh:
  132. default:
  133. break LOOP
  134. }
  135. }
  136. cs.Wait()
  137. }
  138. func toPV(pv PrivValidator) *types.PrivValidator {
  139. return pv.(*types.PrivValidator)
  140. }
  141. func setupReplayTest(thisCase *testCase, nLines int, crashAfter bool) (*ConsensusState, chan interface{}, string, string) {
  142. fmt.Println("-------------------------------------")
  143. log.Notice(cmn.Fmt("Starting replay test %v (of %d lines of WAL). Crash after = %v", thisCase.name, nLines, crashAfter))
  144. lineStep := nLines
  145. if crashAfter {
  146. lineStep -= 1
  147. }
  148. split := strings.Split(thisCase.log, "\n")
  149. lastMsg := split[nLines]
  150. // we write those lines up to (not including) one with the signature
  151. walFile := writeWAL(strings.Join(split[:nLines], "\n") + "\n")
  152. cs := fixedConsensusStateDummy()
  153. // set the last step according to when we crashed vs the wal
  154. toPV(cs.privValidator).LastHeight = 1 // first block
  155. toPV(cs.privValidator).LastStep = thisCase.stepMap[lineStep]
  156. log.Warn("setupReplayTest", "LastStep", toPV(cs.privValidator).LastStep)
  157. newBlockCh := subscribeToEvent(cs.evsw, "tester", types.EventStringNewBlock(), 1)
  158. return cs, newBlockCh, lastMsg, walFile
  159. }
  160. func readTimedWALMessage(t *testing.T, walMsg string) TimedWALMessage {
  161. var err error
  162. var msg TimedWALMessage
  163. wire.ReadJSON(&msg, []byte(walMsg), &err)
  164. if err != nil {
  165. t.Fatalf("Error reading json data: %v", err)
  166. }
  167. return msg
  168. }
  169. //-----------------------------------------------
  170. // Test the log at every iteration, and set the privVal last step
  171. // as if the log was written after signing, before the crash
  172. func TestWALCrashAfterWrite(t *testing.T) {
  173. for _, thisCase := range testCases {
  174. split := strings.Split(thisCase.log, "\n")
  175. for i := 0; i < len(split)-1; i++ {
  176. cs, newBlockCh, _, walFile := setupReplayTest(thisCase, i+1, true)
  177. runReplayTest(t, cs, walFile, newBlockCh, thisCase, i+1)
  178. }
  179. }
  180. }
  181. //-----------------------------------------------
  182. // Test the log as if we crashed after signing but before writing.
  183. // This relies on privValidator.LastSignature being set
  184. func TestWALCrashBeforeWritePropose(t *testing.T) {
  185. for _, thisCase := range testCases {
  186. lineNum := thisCase.proposeLine
  187. // setup replay test where last message is a proposal
  188. cs, newBlockCh, proposalMsg, walFile := setupReplayTest(thisCase, lineNum, false)
  189. msg := readTimedWALMessage(t, proposalMsg)
  190. proposal := msg.Msg.(msgInfo).Msg.(*ProposalMessage)
  191. // Set LastSig
  192. toPV(cs.privValidator).LastSignBytes = types.SignBytes(cs.state.ChainID, proposal.Proposal)
  193. toPV(cs.privValidator).LastSignature = proposal.Proposal.Signature
  194. runReplayTest(t, cs, walFile, newBlockCh, thisCase, lineNum)
  195. }
  196. }
  197. func TestWALCrashBeforeWritePrevote(t *testing.T) {
  198. for _, thisCase := range testCases {
  199. testReplayCrashBeforeWriteVote(t, thisCase, thisCase.prevoteLine, types.EventStringCompleteProposal())
  200. }
  201. }
  202. func TestWALCrashBeforeWritePrecommit(t *testing.T) {
  203. for _, thisCase := range testCases {
  204. testReplayCrashBeforeWriteVote(t, thisCase, thisCase.precommitLine, types.EventStringPolka())
  205. }
  206. }
  207. func testReplayCrashBeforeWriteVote(t *testing.T, thisCase *testCase, lineNum int, eventString string) {
  208. // setup replay test where last message is a vote
  209. cs, newBlockCh, voteMsg, walFile := setupReplayTest(thisCase, lineNum, false)
  210. types.AddListenerForEvent(cs.evsw, "tester", eventString, func(data types.TMEventData) {
  211. msg := readTimedWALMessage(t, voteMsg)
  212. vote := msg.Msg.(msgInfo).Msg.(*VoteMessage)
  213. // Set LastSig
  214. toPV(cs.privValidator).LastSignBytes = types.SignBytes(cs.state.ChainID, vote.Vote)
  215. toPV(cs.privValidator).LastSignature = vote.Vote.Signature
  216. })
  217. runReplayTest(t, cs, walFile, newBlockCh, thisCase, lineNum)
  218. }
  219. //------------------------------------------------------------------------------------------
  220. // Handshake Tests
  221. var (
  222. NUM_BLOCKS = 6 // number of blocks in the test_data/many_blocks.cswal
  223. mempool = types.MockMempool{}
  224. testPartSize int
  225. )
  226. //---------------------------------------
  227. // Test handshake/replay
  228. // 0 - all synced up
  229. // 1 - saved block but app and state are behind
  230. // 2 - save block and committed but state is behind
  231. var modes = []uint{0, 1, 2}
  232. // Sync from scratch
  233. func TestHandshakeReplayAll(t *testing.T) {
  234. for _, m := range modes {
  235. testHandshakeReplay(t, 0, m)
  236. }
  237. }
  238. // Sync many, not from scratch
  239. func TestHandshakeReplaySome(t *testing.T) {
  240. for _, m := range modes {
  241. testHandshakeReplay(t, 1, m)
  242. }
  243. }
  244. // Sync from lagging by one
  245. func TestHandshakeReplayOne(t *testing.T) {
  246. for _, m := range modes {
  247. testHandshakeReplay(t, NUM_BLOCKS-1, m)
  248. }
  249. }
  250. // Sync from caught up
  251. func TestHandshakeReplayNone(t *testing.T) {
  252. for _, m := range modes {
  253. testHandshakeReplay(t, NUM_BLOCKS, m)
  254. }
  255. }
  256. // Make some blocks. Start a fresh app and apply nBlocks blocks. Then restart the app and sync it up with the remaining blocks
  257. func testHandshakeReplay(t *testing.T, nBlocks int, mode uint) {
  258. config := tendermint_test.ResetConfig("proxy_test_")
  259. // copy the many_blocks file
  260. walBody, err := cmn.ReadFile(path.Join(data_dir, "many_blocks.cswal"))
  261. if err != nil {
  262. t.Fatal(err)
  263. }
  264. walFile := writeWAL(string(walBody))
  265. config.Set("cs_wal_file", walFile)
  266. privVal := types.LoadPrivValidator(config.GetString("priv_validator_file"))
  267. testPartSize = config.GetInt("block_part_size")
  268. wal, err := NewWAL(walFile, false)
  269. if err != nil {
  270. t.Fatal(err)
  271. }
  272. chain, commits, err := makeBlockchainFromWAL(wal)
  273. if err != nil {
  274. t.Fatalf(err.Error())
  275. }
  276. state, store := stateAndStore(config, privVal.PubKey)
  277. store.chain = chain
  278. store.commits = commits
  279. // run the chain through state.ApplyBlock to build up the tendermint state
  280. latestAppHash := buildTMStateFromChain(config, state, chain, mode)
  281. // make a new client creator
  282. dummyApp := dummy.NewPersistentDummyApplication(path.Join(config.GetString("db_dir"), "2"))
  283. clientCreator2 := proxy.NewLocalClientCreator(dummyApp)
  284. if nBlocks > 0 {
  285. // run nBlocks against a new client to build up the app state.
  286. // use a throwaway tendermint state
  287. proxyApp := proxy.NewAppConns(config, clientCreator2, nil)
  288. state, _ := stateAndStore(config, privVal.PubKey)
  289. buildAppStateFromChain(proxyApp, state, chain, nBlocks, mode)
  290. }
  291. // now start the app using the handshake - it should sync
  292. handshaker := NewHandshaker(config, state, store)
  293. proxyApp := proxy.NewAppConns(config, clientCreator2, handshaker)
  294. if _, err := proxyApp.Start(); err != nil {
  295. t.Fatalf("Error starting proxy app connections: %v", err)
  296. }
  297. // get the latest app hash from the app
  298. res, err := proxyApp.Query().InfoSync()
  299. if err != nil {
  300. t.Fatal(err)
  301. }
  302. // the app hash should be synced up
  303. if !bytes.Equal(latestAppHash, res.LastBlockAppHash) {
  304. t.Fatalf("Expected app hashes to match after handshake/replay. got %X, expected %X", res.LastBlockAppHash, latestAppHash)
  305. }
  306. expectedBlocksToSync := NUM_BLOCKS - nBlocks
  307. if nBlocks == NUM_BLOCKS && mode > 0 {
  308. expectedBlocksToSync += 1
  309. } else if nBlocks > 0 && mode == 1 {
  310. expectedBlocksToSync += 1
  311. }
  312. if handshaker.NBlocks() != expectedBlocksToSync {
  313. t.Fatalf("Expected handshake to sync %d blocks, got %d", expectedBlocksToSync, handshaker.NBlocks())
  314. }
  315. }
  316. func applyBlock(st *sm.State, blk *types.Block, proxyApp proxy.AppConns) {
  317. err := st.ApplyBlock(nil, proxyApp.Consensus(), blk, blk.MakePartSet(testPartSize).Header(), mempool)
  318. if err != nil {
  319. panic(err)
  320. }
  321. }
  322. func buildAppStateFromChain(proxyApp proxy.AppConns,
  323. state *sm.State, chain []*types.Block, nBlocks int, mode uint) {
  324. // start a new app without handshake, play nBlocks blocks
  325. if _, err := proxyApp.Start(); err != nil {
  326. panic(err)
  327. }
  328. defer proxyApp.Stop()
  329. switch mode {
  330. case 0:
  331. for i := 0; i < nBlocks; i++ {
  332. block := chain[i]
  333. applyBlock(state, block, proxyApp)
  334. }
  335. case 1, 2:
  336. for i := 0; i < nBlocks-1; i++ {
  337. block := chain[i]
  338. applyBlock(state, block, proxyApp)
  339. }
  340. if mode == 2 {
  341. // update the dummy height and apphash
  342. // as if we ran commit but not
  343. applyBlock(state, chain[nBlocks-1], proxyApp)
  344. }
  345. }
  346. }
  347. func buildTMStateFromChain(config *viper.Viper, state *sm.State, chain []*types.Block, mode uint) []byte {
  348. // run the whole chain against this client to build up the tendermint state
  349. clientCreator := proxy.NewLocalClientCreator(dummy.NewPersistentDummyApplication(path.Join(config.GetString("db_dir"), "1")))
  350. proxyApp := proxy.NewAppConns(config, clientCreator, nil) // sm.NewHandshaker(config, state, store, ReplayLastBlock))
  351. if _, err := proxyApp.Start(); err != nil {
  352. panic(err)
  353. }
  354. defer proxyApp.Stop()
  355. var latestAppHash []byte
  356. switch mode {
  357. case 0:
  358. // sync right up
  359. for _, block := range chain {
  360. applyBlock(state, block, proxyApp)
  361. }
  362. latestAppHash = state.AppHash
  363. case 1, 2:
  364. // sync up to the penultimate as if we stored the block.
  365. // whether we commit or not depends on the appHash
  366. for _, block := range chain[:len(chain)-1] {
  367. applyBlock(state, block, proxyApp)
  368. }
  369. // apply the final block to a state copy so we can
  370. // get the right next appHash but keep the state back
  371. stateCopy := state.Copy()
  372. applyBlock(stateCopy, chain[len(chain)-1], proxyApp)
  373. latestAppHash = stateCopy.AppHash
  374. }
  375. return latestAppHash
  376. }
  377. //--------------------------
  378. // utils for making blocks
  379. func makeBlockchainFromWAL(wal *WAL) ([]*types.Block, []*types.Commit, error) {
  380. // Search for height marker
  381. gr, found, err := wal.group.Search("#ENDHEIGHT: ", makeHeightSearchFunc(0))
  382. if err != nil {
  383. return nil, nil, err
  384. }
  385. if !found {
  386. return nil, nil, errors.New(cmn.Fmt("WAL does not contain height %d.", 1))
  387. }
  388. defer gr.Close()
  389. log.Notice("Build a blockchain by reading from the WAL")
  390. var blockParts *types.PartSet
  391. var blocks []*types.Block
  392. var commits []*types.Commit
  393. for {
  394. line, err := gr.ReadLine()
  395. if err != nil {
  396. if err == io.EOF {
  397. break
  398. } else {
  399. return nil, nil, err
  400. }
  401. }
  402. piece, err := readPieceFromWAL([]byte(line))
  403. if err != nil {
  404. return nil, nil, err
  405. }
  406. if piece == nil {
  407. continue
  408. }
  409. switch p := piece.(type) {
  410. case *types.PartSetHeader:
  411. // if its not the first one, we have a full block
  412. if blockParts != nil {
  413. var n int
  414. block := wire.ReadBinary(&types.Block{}, blockParts.GetReader(), types.MaxBlockSize, &n, &err).(*types.Block)
  415. blocks = append(blocks, block)
  416. }
  417. blockParts = types.NewPartSetFromHeader(*p)
  418. case *types.Part:
  419. _, err := blockParts.AddPart(p, false)
  420. if err != nil {
  421. return nil, nil, err
  422. }
  423. case *types.Vote:
  424. if p.Type == types.VoteTypePrecommit {
  425. commit := &types.Commit{
  426. BlockID: p.BlockID,
  427. Precommits: []*types.Vote{p},
  428. }
  429. commits = append(commits, commit)
  430. }
  431. }
  432. }
  433. // grab the last block too
  434. var n int
  435. block := wire.ReadBinary(&types.Block{}, blockParts.GetReader(), types.MaxBlockSize, &n, &err).(*types.Block)
  436. blocks = append(blocks, block)
  437. return blocks, commits, nil
  438. }
  439. func readPieceFromWAL(msgBytes []byte) (interface{}, error) {
  440. // Skip over empty and meta lines
  441. if len(msgBytes) == 0 || msgBytes[0] == '#' {
  442. return nil, nil
  443. }
  444. var err error
  445. var msg TimedWALMessage
  446. wire.ReadJSON(&msg, msgBytes, &err)
  447. if err != nil {
  448. fmt.Println("MsgBytes:", msgBytes, string(msgBytes))
  449. return nil, fmt.Errorf("Error reading json data: %v", err)
  450. }
  451. // for logging
  452. switch m := msg.Msg.(type) {
  453. case msgInfo:
  454. switch msg := m.Msg.(type) {
  455. case *ProposalMessage:
  456. return &msg.Proposal.BlockPartsHeader, nil
  457. case *BlockPartMessage:
  458. return msg.Part, nil
  459. case *VoteMessage:
  460. return msg.Vote, nil
  461. }
  462. }
  463. return nil, nil
  464. }
  465. // make some bogus txs
  466. func txsFunc(blockNum int) (txs []types.Tx) {
  467. for i := 0; i < 10; i++ {
  468. txs = append(txs, types.Tx([]byte{byte(blockNum), byte(i)}))
  469. }
  470. return txs
  471. }
  472. // sign a commit vote
  473. func signCommit(chainID string, privVal *types.PrivValidator, height, round int, hash []byte, header types.PartSetHeader) *types.Vote {
  474. vote := &types.Vote{
  475. ValidatorIndex: 0,
  476. ValidatorAddress: privVal.Address,
  477. Height: height,
  478. Round: round,
  479. Type: types.VoteTypePrecommit,
  480. BlockID: types.BlockID{hash, header},
  481. }
  482. sig := privVal.Sign(types.SignBytes(chainID, vote))
  483. vote.Signature = sig
  484. return vote
  485. }
  486. // make a blockchain with one validator
  487. func makeBlockchain(t *testing.T, chainID string, nBlocks int, privVal *types.PrivValidator, proxyApp proxy.AppConns, state *sm.State) (blockchain []*types.Block, commits []*types.Commit) {
  488. prevHash := state.LastBlockID.Hash
  489. lastCommit := new(types.Commit)
  490. prevParts := types.PartSetHeader{}
  491. valHash := state.Validators.Hash()
  492. prevBlockID := types.BlockID{prevHash, prevParts}
  493. for i := 1; i < nBlocks+1; i++ {
  494. block, parts := types.MakeBlock(i, chainID, txsFunc(i), lastCommit,
  495. prevBlockID, valHash, state.AppHash, testPartSize)
  496. fmt.Println(i)
  497. fmt.Println(block.LastBlockID)
  498. err := state.ApplyBlock(nil, proxyApp.Consensus(), block, block.MakePartSet(testPartSize).Header(), mempool)
  499. if err != nil {
  500. t.Fatal(i, err)
  501. }
  502. voteSet := types.NewVoteSet(chainID, i, 0, types.VoteTypePrecommit, state.Validators)
  503. vote := signCommit(chainID, privVal, i, 0, block.Hash(), parts.Header())
  504. _, err = voteSet.AddVote(vote)
  505. if err != nil {
  506. t.Fatal(err)
  507. }
  508. prevHash = block.Hash()
  509. prevParts = parts.Header()
  510. lastCommit = voteSet.MakeCommit()
  511. prevBlockID = types.BlockID{prevHash, prevParts}
  512. blockchain = append(blockchain, block)
  513. commits = append(commits, lastCommit)
  514. }
  515. return blockchain, commits
  516. }
  517. // fresh state and mock store
  518. func stateAndStore(config *viper.Viper, pubKey crypto.PubKey) (*sm.State, *mockBlockStore) {
  519. stateDB := dbm.NewMemDB()
  520. return sm.MakeGenesisState(stateDB, &types.GenesisDoc{
  521. ChainID: config.GetString("chain_id"),
  522. Validators: []types.GenesisValidator{
  523. types.GenesisValidator{pubKey, 10000, "test"},
  524. },
  525. AppHash: nil,
  526. }), NewMockBlockStore(config)
  527. }
  528. //----------------------------------
  529. // mock block store
  530. type mockBlockStore struct {
  531. config *viper.Viper
  532. chain []*types.Block
  533. commits []*types.Commit
  534. }
  535. // TODO: NewBlockStore(db.NewMemDB) ...
  536. func NewMockBlockStore(config *viper.Viper) *mockBlockStore {
  537. return &mockBlockStore{config, nil, nil}
  538. }
  539. func (bs *mockBlockStore) Height() int { return len(bs.chain) }
  540. func (bs *mockBlockStore) LoadBlock(height int) *types.Block { return bs.chain[height-1] }
  541. func (bs *mockBlockStore) LoadBlockMeta(height int) *types.BlockMeta {
  542. block := bs.chain[height-1]
  543. return &types.BlockMeta{
  544. BlockID: types.BlockID{block.Hash(), block.MakePartSet(bs.config.GetInt("block_part_size")).Header()},
  545. Header: block.Header,
  546. }
  547. }
  548. func (bs *mockBlockStore) LoadBlockPart(height int, index int) *types.Part { return nil }
  549. func (bs *mockBlockStore) SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) {
  550. }
  551. func (bs *mockBlockStore) LoadBlockCommit(height int) *types.Commit {
  552. return bs.commits[height-1]
  553. }
  554. func (bs *mockBlockStore) LoadSeenCommit(height int) *types.Commit {
  555. return bs.commits[height-1]
  556. }