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.

632 lines
19 KiB

  1. package evidence_test
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/stretchr/testify/assert"
  7. "github.com/stretchr/testify/mock"
  8. "github.com/stretchr/testify/require"
  9. dbm "github.com/tendermint/tm-db"
  10. "github.com/tendermint/tendermint/internal/eventbus"
  11. "github.com/tendermint/tendermint/internal/evidence"
  12. "github.com/tendermint/tendermint/internal/evidence/mocks"
  13. sm "github.com/tendermint/tendermint/internal/state"
  14. smmocks "github.com/tendermint/tendermint/internal/state/mocks"
  15. sf "github.com/tendermint/tendermint/internal/state/test/factory"
  16. "github.com/tendermint/tendermint/internal/store"
  17. "github.com/tendermint/tendermint/internal/test/factory"
  18. "github.com/tendermint/tendermint/libs/log"
  19. "github.com/tendermint/tendermint/types"
  20. "github.com/tendermint/tendermint/version"
  21. tmpubsub "github.com/tendermint/tendermint/internal/pubsub"
  22. tmquery "github.com/tendermint/tendermint/internal/pubsub/query"
  23. )
  24. const evidenceChainID = "test_chain"
  25. var (
  26. defaultEvidenceTime = time.Date(2019, 1, 1, 0, 0, 0, 0, time.UTC)
  27. defaultEvidenceMaxBytes int64 = 1000
  28. )
  29. func startPool(t *testing.T, pool *evidence.Pool, store sm.Store) {
  30. t.Helper()
  31. state, err := store.Load()
  32. if err != nil {
  33. t.Fatalf("cannot load state: %v", err)
  34. }
  35. if err := pool.Start(state); err != nil {
  36. t.Fatalf("cannot start state pool: %v", err)
  37. }
  38. }
  39. func TestEvidencePoolBasic(t *testing.T) {
  40. var (
  41. height = int64(1)
  42. stateStore = &smmocks.Store{}
  43. evidenceDB = dbm.NewMemDB()
  44. blockStore = &mocks.BlockStore{}
  45. )
  46. ctx, cancel := context.WithCancel(context.Background())
  47. defer cancel()
  48. valSet, privVals := factory.ValidatorSet(ctx, t, 1, 10)
  49. blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return(
  50. &types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}},
  51. )
  52. stateStore.On("LoadValidators", mock.AnythingOfType("int64")).Return(valSet, nil)
  53. stateStore.On("Load").Return(createState(height+1, valSet), nil)
  54. logger := log.NewNopLogger()
  55. eventBus := eventbus.NewDefault(logger)
  56. require.NoError(t, eventBus.Start(ctx))
  57. pool := evidence.NewPool(logger, evidenceDB, stateStore, blockStore, evidence.NopMetrics(), eventBus)
  58. startPool(t, pool, stateStore)
  59. // evidence not seen yet:
  60. evs, size := pool.PendingEvidence(defaultEvidenceMaxBytes)
  61. require.Equal(t, 0, len(evs))
  62. require.Zero(t, size)
  63. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(ctx, height, defaultEvidenceTime, privVals[0], evidenceChainID)
  64. require.NoError(t, err)
  65. // good evidence
  66. evAdded := make(chan struct{})
  67. go func() {
  68. <-pool.EvidenceWaitChan()
  69. close(evAdded)
  70. }()
  71. // evidence seen but not yet committed:
  72. err = pool.AddEvidence(ctx, ev)
  73. require.NoError(t, err)
  74. select {
  75. case <-evAdded:
  76. case <-time.After(5 * time.Second):
  77. t.Fatal("evidence was not added to list after 5s")
  78. }
  79. next := pool.EvidenceFront()
  80. require.Equal(t, ev, next.Value.(types.Evidence))
  81. const evidenceBytes int64 = 372
  82. evs, size = pool.PendingEvidence(evidenceBytes)
  83. require.Equal(t, 1, len(evs))
  84. require.Equal(t, evidenceBytes, size) // check that the size of the single evidence in bytes is correct
  85. // shouldn't be able to add evidence twice
  86. err = pool.AddEvidence(ctx, ev)
  87. require.NoError(t, err)
  88. evs, _ = pool.PendingEvidence(defaultEvidenceMaxBytes)
  89. require.Equal(t, 1, len(evs))
  90. }
  91. // Tests inbound evidence for the right time and height
  92. func TestAddExpiredEvidence(t *testing.T) {
  93. ctx, cancel := context.WithCancel(context.Background())
  94. defer cancel()
  95. var (
  96. val = types.NewMockPV()
  97. height = int64(30)
  98. stateStore = initializeValidatorState(ctx, t, val, height)
  99. evidenceDB = dbm.NewMemDB()
  100. blockStore = &mocks.BlockStore{}
  101. expiredEvidenceTime = time.Date(2018, 1, 1, 0, 0, 0, 0, time.UTC)
  102. expiredHeight = int64(2)
  103. )
  104. blockStore.On("LoadBlockMeta", mock.AnythingOfType("int64")).Return(func(h int64) *types.BlockMeta {
  105. if h == height || h == expiredHeight {
  106. return &types.BlockMeta{Header: types.Header{Time: defaultEvidenceTime}}
  107. }
  108. return &types.BlockMeta{Header: types.Header{Time: expiredEvidenceTime}}
  109. })
  110. logger := log.NewNopLogger()
  111. eventBus := eventbus.NewDefault(logger)
  112. require.NoError(t, eventBus.Start(ctx))
  113. pool := evidence.NewPool(logger, evidenceDB, stateStore, blockStore, evidence.NopMetrics(), eventBus)
  114. startPool(t, pool, stateStore)
  115. testCases := []struct {
  116. evHeight int64
  117. evTime time.Time
  118. expErr bool
  119. evDescription string
  120. }{
  121. {height, defaultEvidenceTime, false, "valid evidence"},
  122. {expiredHeight, defaultEvidenceTime, false, "valid evidence (despite old height)"},
  123. {height - 1, expiredEvidenceTime, false, "valid evidence (despite old time)"},
  124. {expiredHeight - 1, expiredEvidenceTime, true,
  125. "evidence from height 1 (created at: 2019-01-01 00:00:00 +0000 UTC) is too old"},
  126. {height, defaultEvidenceTime.Add(1 * time.Minute), true, "evidence time and block time is different"},
  127. }
  128. for _, tc := range testCases {
  129. tc := tc
  130. t.Run(tc.evDescription, func(t *testing.T) {
  131. ctx, cancel := context.WithCancel(context.Background())
  132. defer cancel()
  133. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(ctx, tc.evHeight, tc.evTime, val, evidenceChainID)
  134. require.NoError(t, err)
  135. err = pool.AddEvidence(ctx, ev)
  136. if tc.expErr {
  137. require.Error(t, err)
  138. } else {
  139. require.NoError(t, err)
  140. }
  141. })
  142. }
  143. }
  144. func TestReportConflictingVotes(t *testing.T) {
  145. var height int64 = 10
  146. ctx, cancel := context.WithCancel(context.Background())
  147. defer cancel()
  148. pool, pv, _ := defaultTestPool(ctx, t, height)
  149. val := types.NewValidator(pv.PrivKey.PubKey(), 10)
  150. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(ctx, height+1, defaultEvidenceTime, pv, evidenceChainID)
  151. require.NoError(t, err)
  152. pool.ReportConflictingVotes(ev.VoteA, ev.VoteB)
  153. // shouldn't be able to submit the same evidence twice
  154. pool.ReportConflictingVotes(ev.VoteA, ev.VoteB)
  155. // evidence from consensus should not be added immediately but reside in the consensus buffer
  156. evList, evSize := pool.PendingEvidence(defaultEvidenceMaxBytes)
  157. require.Empty(t, evList)
  158. require.Zero(t, evSize)
  159. next := pool.EvidenceFront()
  160. require.Nil(t, next)
  161. // move to next height and update state and evidence pool
  162. state := pool.State()
  163. state.LastBlockHeight++
  164. state.LastBlockTime = ev.Time()
  165. state.LastValidators = types.NewValidatorSet([]*types.Validator{val})
  166. pool.Update(ctx, state, []types.Evidence{})
  167. // should be able to retrieve evidence from pool
  168. evList, _ = pool.PendingEvidence(defaultEvidenceMaxBytes)
  169. require.Equal(t, []types.Evidence{ev}, evList)
  170. next = pool.EvidenceFront()
  171. require.NotNil(t, next)
  172. }
  173. func TestEvidencePoolUpdate(t *testing.T) {
  174. height := int64(21)
  175. ctx, cancel := context.WithCancel(context.Background())
  176. defer cancel()
  177. pool, val, _ := defaultTestPool(ctx, t, height)
  178. state := pool.State()
  179. // create two lots of old evidence that we expect to be pruned when we update
  180. prunedEv, err := types.NewMockDuplicateVoteEvidenceWithValidator(ctx,
  181. 1,
  182. defaultEvidenceTime.Add(1*time.Minute),
  183. val,
  184. evidenceChainID,
  185. )
  186. require.NoError(t, err)
  187. notPrunedEv, err := types.NewMockDuplicateVoteEvidenceWithValidator(ctx,
  188. 2,
  189. defaultEvidenceTime.Add(2*time.Minute),
  190. val,
  191. evidenceChainID,
  192. )
  193. require.NoError(t, err)
  194. require.NoError(t, pool.AddEvidence(ctx, prunedEv))
  195. require.NoError(t, pool.AddEvidence(ctx, notPrunedEv))
  196. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  197. ctx,
  198. height,
  199. defaultEvidenceTime.Add(21*time.Minute),
  200. val,
  201. evidenceChainID,
  202. )
  203. require.NoError(t, err)
  204. lastCommit := makeCommit(height, val.PrivKey.PubKey().Address())
  205. block := types.MakeBlock(height+1, []types.Tx{}, lastCommit, []types.Evidence{ev})
  206. // update state (partially)
  207. state.LastBlockHeight = height + 1
  208. state.LastBlockTime = defaultEvidenceTime.Add(22 * time.Minute)
  209. evList, _ := pool.PendingEvidence(2 * defaultEvidenceMaxBytes)
  210. require.Equal(t, 2, len(evList))
  211. require.Equal(t, uint32(2), pool.Size())
  212. require.NoError(t, pool.CheckEvidence(ctx, types.EvidenceList{ev}))
  213. evList, _ = pool.PendingEvidence(3 * defaultEvidenceMaxBytes)
  214. require.Equal(t, 3, len(evList))
  215. require.Equal(t, uint32(3), pool.Size())
  216. pool.Update(ctx, state, block.Evidence)
  217. // a) Update marks evidence as committed so pending evidence should be empty
  218. evList, _ = pool.PendingEvidence(defaultEvidenceMaxBytes)
  219. require.Equal(t, []types.Evidence{notPrunedEv}, evList)
  220. // b) If we try to check this evidence again it should fail because it has already been committed
  221. err = pool.CheckEvidence(ctx, types.EvidenceList{ev})
  222. if assert.Error(t, err) {
  223. assert.Equal(t, "evidence was already committed", err.(*types.ErrInvalidEvidence).Reason.Error())
  224. }
  225. }
  226. func TestVerifyPendingEvidencePasses(t *testing.T) {
  227. var height int64 = 1
  228. ctx, cancel := context.WithCancel(context.Background())
  229. defer cancel()
  230. pool, val, _ := defaultTestPool(ctx, t, height)
  231. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  232. ctx,
  233. height,
  234. defaultEvidenceTime.Add(1*time.Minute),
  235. val,
  236. evidenceChainID,
  237. )
  238. require.NoError(t, err)
  239. require.NoError(t, pool.AddEvidence(ctx, ev))
  240. require.NoError(t, pool.CheckEvidence(ctx, types.EvidenceList{ev}))
  241. }
  242. func TestVerifyDuplicatedEvidenceFails(t *testing.T) {
  243. var height int64 = 1
  244. ctx, cancel := context.WithCancel(context.Background())
  245. defer cancel()
  246. pool, val, _ := defaultTestPool(ctx, t, height)
  247. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  248. ctx,
  249. height,
  250. defaultEvidenceTime.Add(1*time.Minute),
  251. val,
  252. evidenceChainID,
  253. )
  254. require.NoError(t, err)
  255. err = pool.CheckEvidence(ctx, types.EvidenceList{ev, ev})
  256. if assert.Error(t, err) {
  257. assert.Equal(t, "duplicate evidence", err.(*types.ErrInvalidEvidence).Reason.Error())
  258. }
  259. }
  260. // Check that we generate events when evidence is added into the evidence pool
  261. func TestEventOnEvidenceValidated(t *testing.T) {
  262. const height = 1
  263. ctx, cancel := context.WithCancel(context.Background())
  264. defer cancel()
  265. pool, val, eventBus := defaultTestPool(ctx, t, height)
  266. ev, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  267. ctx,
  268. height,
  269. defaultEvidenceTime.Add(1*time.Minute),
  270. val,
  271. evidenceChainID,
  272. )
  273. require.NoError(t, err)
  274. const query = `tm.event='EvidenceValidated'`
  275. evSub, err := eventBus.SubscribeWithArgs(ctx, tmpubsub.SubscribeArgs{
  276. ClientID: "test",
  277. Query: tmquery.MustCompile(query),
  278. })
  279. require.NoError(t, err)
  280. done := make(chan struct{})
  281. go func() {
  282. defer close(done)
  283. msg, err := evSub.Next(ctx)
  284. if ctx.Err() != nil {
  285. return
  286. }
  287. assert.NoError(t, err)
  288. edt := msg.Data().(types.EventDataEvidenceValidated)
  289. assert.Equal(t, ev, edt.Evidence)
  290. }()
  291. err = pool.AddEvidence(ctx, ev)
  292. require.NoError(t, err)
  293. select {
  294. case <-done:
  295. case <-time.After(1 * time.Second):
  296. t.Fatal("did not receive a block header after 1 sec.")
  297. }
  298. }
  299. // check that valid light client evidence is correctly validated and stored in
  300. // evidence pool
  301. func TestLightClientAttackEvidenceLifecycle(t *testing.T) {
  302. var (
  303. height int64 = 100
  304. commonHeight int64 = 90
  305. )
  306. ctx, cancel := context.WithCancel(context.Background())
  307. defer cancel()
  308. ev, trusted, common := makeLunaticEvidence(ctx, t, height, commonHeight,
  309. 10, 5, 5, defaultEvidenceTime, defaultEvidenceTime.Add(1*time.Hour))
  310. state := sm.State{
  311. LastBlockTime: defaultEvidenceTime.Add(2 * time.Hour),
  312. LastBlockHeight: 110,
  313. ConsensusParams: *types.DefaultConsensusParams(),
  314. }
  315. stateStore := &smmocks.Store{}
  316. stateStore.On("LoadValidators", height).Return(trusted.ValidatorSet, nil)
  317. stateStore.On("LoadValidators", commonHeight).Return(common.ValidatorSet, nil)
  318. stateStore.On("Load").Return(state, nil)
  319. blockStore := &mocks.BlockStore{}
  320. blockStore.On("LoadBlockMeta", height).Return(&types.BlockMeta{Header: *trusted.Header})
  321. blockStore.On("LoadBlockMeta", commonHeight).Return(&types.BlockMeta{Header: *common.Header})
  322. blockStore.On("LoadBlockCommit", height).Return(trusted.Commit)
  323. blockStore.On("LoadBlockCommit", commonHeight).Return(common.Commit)
  324. logger := log.NewNopLogger()
  325. eventBus := eventbus.NewDefault(logger)
  326. require.NoError(t, eventBus.Start(ctx))
  327. pool := evidence.NewPool(logger, dbm.NewMemDB(), stateStore, blockStore, evidence.NopMetrics(), eventBus)
  328. hash := ev.Hash()
  329. err := pool.AddEvidence(ctx, ev)
  330. require.NoError(t, err)
  331. err = pool.AddEvidence(ctx, ev)
  332. require.NoError(t, err)
  333. pendingEv, _ := pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
  334. require.Equal(t, 1, len(pendingEv))
  335. require.Equal(t, ev, pendingEv[0])
  336. require.NoError(t, pool.CheckEvidence(ctx, pendingEv))
  337. require.Equal(t, ev, pendingEv[0])
  338. state.LastBlockHeight++
  339. state.LastBlockTime = state.LastBlockTime.Add(1 * time.Minute)
  340. pool.Update(ctx, state, pendingEv)
  341. require.Equal(t, hash, pendingEv[0].Hash())
  342. remaindingEv, _ := pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
  343. require.Empty(t, remaindingEv)
  344. // evidence is already committed so it shouldn't pass
  345. require.Error(t, pool.CheckEvidence(ctx, types.EvidenceList{ev}))
  346. err = pool.AddEvidence(ctx, ev)
  347. require.NoError(t, err)
  348. remaindingEv, _ = pool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
  349. require.Empty(t, remaindingEv)
  350. }
  351. // Tests that restarting the evidence pool after a potential failure will recover the
  352. // pending evidence and continue to gossip it
  353. func TestRecoverPendingEvidence(t *testing.T) {
  354. ctx, cancel := context.WithCancel(context.Background())
  355. defer cancel()
  356. height := int64(10)
  357. val := types.NewMockPV()
  358. valAddress := val.PrivKey.PubKey().Address()
  359. evidenceDB := dbm.NewMemDB()
  360. stateStore := initializeValidatorState(ctx, t, val, height)
  361. state, err := stateStore.Load()
  362. require.NoError(t, err)
  363. blockStore, err := initializeBlockStore(dbm.NewMemDB(), state, valAddress)
  364. require.NoError(t, err)
  365. logger := log.NewNopLogger()
  366. eventBus := eventbus.NewDefault(logger)
  367. require.NoError(t, eventBus.Start(ctx))
  368. // create previous pool and populate it
  369. pool := evidence.NewPool(logger, evidenceDB, stateStore, blockStore, evidence.NopMetrics(), eventBus)
  370. startPool(t, pool, stateStore)
  371. goodEvidence, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  372. ctx,
  373. height,
  374. defaultEvidenceTime.Add(10*time.Minute),
  375. val,
  376. evidenceChainID,
  377. )
  378. require.NoError(t, err)
  379. expiredEvidence, err := types.NewMockDuplicateVoteEvidenceWithValidator(
  380. ctx,
  381. int64(1),
  382. defaultEvidenceTime.Add(1*time.Minute),
  383. val,
  384. evidenceChainID,
  385. )
  386. require.NoError(t, err)
  387. err = pool.AddEvidence(ctx, goodEvidence)
  388. require.NoError(t, err)
  389. err = pool.AddEvidence(ctx, expiredEvidence)
  390. require.NoError(t, err)
  391. // now recover from the previous pool at a different time
  392. newStateStore := &smmocks.Store{}
  393. newStateStore.On("Load").Return(sm.State{
  394. LastBlockTime: defaultEvidenceTime.Add(25 * time.Minute),
  395. LastBlockHeight: height + 15,
  396. ConsensusParams: types.ConsensusParams{
  397. Block: types.BlockParams{
  398. MaxBytes: 22020096,
  399. MaxGas: -1,
  400. },
  401. Evidence: types.EvidenceParams{
  402. MaxAgeNumBlocks: 20,
  403. MaxAgeDuration: 20 * time.Minute,
  404. MaxBytes: defaultEvidenceMaxBytes,
  405. },
  406. },
  407. }, nil)
  408. newPool := evidence.NewPool(logger, evidenceDB, newStateStore, blockStore, evidence.NopMetrics(), nil)
  409. startPool(t, newPool, newStateStore)
  410. evList, _ := newPool.PendingEvidence(defaultEvidenceMaxBytes)
  411. require.Equal(t, 1, len(evList))
  412. next := newPool.EvidenceFront()
  413. require.Equal(t, goodEvidence, next.Value.(types.Evidence))
  414. }
  415. func initializeStateFromValidatorSet(t *testing.T, valSet *types.ValidatorSet, height int64) sm.Store {
  416. stateDB := dbm.NewMemDB()
  417. stateStore := sm.NewStore(stateDB)
  418. state := sm.State{
  419. ChainID: evidenceChainID,
  420. InitialHeight: 1,
  421. LastBlockHeight: height,
  422. LastBlockTime: defaultEvidenceTime,
  423. Validators: valSet,
  424. NextValidators: valSet.CopyIncrementProposerPriority(1),
  425. LastValidators: valSet,
  426. LastHeightValidatorsChanged: 1,
  427. ConsensusParams: types.ConsensusParams{
  428. Block: types.BlockParams{
  429. MaxBytes: 22020096,
  430. MaxGas: -1,
  431. },
  432. Evidence: types.EvidenceParams{
  433. MaxAgeNumBlocks: 20,
  434. MaxAgeDuration: 20 * time.Minute,
  435. MaxBytes: 1000,
  436. },
  437. },
  438. }
  439. // save all states up to height
  440. for i := int64(0); i <= height; i++ {
  441. state.LastBlockHeight = i
  442. require.NoError(t, stateStore.Save(state))
  443. }
  444. return stateStore
  445. }
  446. func initializeValidatorState(ctx context.Context, t *testing.T, privVal types.PrivValidator, height int64) sm.Store {
  447. pubKey, _ := privVal.GetPubKey(ctx)
  448. validator := &types.Validator{Address: pubKey.Address(), VotingPower: 10, PubKey: pubKey}
  449. // create validator set and state
  450. valSet := &types.ValidatorSet{
  451. Validators: []*types.Validator{validator},
  452. Proposer: validator,
  453. }
  454. return initializeStateFromValidatorSet(t, valSet, height)
  455. }
  456. // initializeBlockStore creates a block storage and populates it w/ a dummy
  457. // block at +height+.
  458. func initializeBlockStore(db dbm.DB, state sm.State, valAddr []byte) (*store.BlockStore, error) {
  459. blockStore := store.NewBlockStore(db)
  460. for i := int64(1); i <= state.LastBlockHeight; i++ {
  461. lastCommit := makeCommit(i-1, valAddr)
  462. block, err := sf.MakeBlock(state, i, lastCommit)
  463. if err != nil {
  464. return nil, err
  465. }
  466. block.Header.Time = defaultEvidenceTime.Add(time.Duration(i) * time.Minute)
  467. block.Header.Version = version.Consensus{Block: version.BlockProtocol, App: 1}
  468. const parts = 1
  469. partSet, err := block.MakePartSet(parts)
  470. if err != nil {
  471. return nil, err
  472. }
  473. seenCommit := makeCommit(i, valAddr)
  474. blockStore.SaveBlock(block, partSet, seenCommit)
  475. }
  476. return blockStore, nil
  477. }
  478. func makeCommit(height int64, valAddr []byte) *types.Commit {
  479. commitSigs := []types.CommitSig{{
  480. BlockIDFlag: types.BlockIDFlagCommit,
  481. ValidatorAddress: valAddr,
  482. Timestamp: defaultEvidenceTime,
  483. Signature: []byte("Signature"),
  484. }}
  485. return types.NewCommit(height, 0, types.BlockID{}, commitSigs)
  486. }
  487. func defaultTestPool(ctx context.Context, t *testing.T, height int64) (*evidence.Pool, types.MockPV, *eventbus.EventBus) {
  488. t.Helper()
  489. val := types.NewMockPV()
  490. valAddress := val.PrivKey.PubKey().Address()
  491. evidenceDB := dbm.NewMemDB()
  492. stateStore := initializeValidatorState(ctx, t, val, height)
  493. state, err := stateStore.Load()
  494. require.NoError(t, err)
  495. blockStore, err := initializeBlockStore(dbm.NewMemDB(), state, valAddress)
  496. require.NoError(t, err)
  497. logger := log.NewNopLogger()
  498. eventBus := eventbus.NewDefault(logger)
  499. require.NoError(t, eventBus.Start(ctx))
  500. pool := evidence.NewPool(logger, evidenceDB, stateStore, blockStore, evidence.NopMetrics(), eventBus)
  501. startPool(t, pool, stateStore)
  502. return pool, val, eventBus
  503. }
  504. func createState(height int64, valSet *types.ValidatorSet) sm.State {
  505. return sm.State{
  506. ChainID: evidenceChainID,
  507. LastBlockHeight: height,
  508. LastBlockTime: defaultEvidenceTime,
  509. Validators: valSet,
  510. ConsensusParams: *types.DefaultConsensusParams(),
  511. }
  512. }