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.

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