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.

119 lines
2.5 KiB

7 years ago
7 years ago
7 years ago
8 years ago
7 years ago
8 years ago
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
7 years ago
  1. package core
  2. import (
  3. "time"
  4. crypto "github.com/tendermint/go-crypto"
  5. "github.com/tendermint/tendermint/consensus"
  6. cstypes "github.com/tendermint/tendermint/consensus/types"
  7. p2p "github.com/tendermint/tendermint/p2p"
  8. "github.com/tendermint/tendermint/proxy"
  9. sm "github.com/tendermint/tendermint/state"
  10. "github.com/tendermint/tendermint/state/txindex"
  11. "github.com/tendermint/tendermint/types"
  12. dbm "github.com/tendermint/tmlibs/db"
  13. "github.com/tendermint/tmlibs/log"
  14. )
  15. var subscribeTimeout = 5 * time.Second
  16. //----------------------------------------------
  17. // These interfaces are used by RPC and must be thread safe
  18. type Consensus interface {
  19. GetState() sm.State
  20. GetValidators() (int64, []*types.Validator)
  21. GetRoundState() *cstypes.RoundState
  22. }
  23. type P2P interface {
  24. Listeners() []p2p.Listener
  25. Peers() p2p.IPeerSet
  26. NumPeers() (outbound, inbound, dialig int)
  27. NodeInfo() p2p.NodeInfo
  28. IsListening() bool
  29. DialPeersAsync(p2p.AddrBook, []string, bool) error
  30. }
  31. //----------------------------------------------
  32. // These package level globals come with setters
  33. // that are expected to be called only once, on startup
  34. var (
  35. // external, thread safe interfaces
  36. proxyAppQuery proxy.AppConnQuery
  37. // interfaces defined in types and above
  38. stateDB dbm.DB
  39. blockStore types.BlockStore
  40. mempool types.Mempool
  41. evidencePool types.EvidencePool
  42. consensusState Consensus
  43. p2pSwitch P2P
  44. // objects
  45. pubKey crypto.PubKey
  46. genDoc *types.GenesisDoc // cache the genesis structure
  47. addrBook p2p.AddrBook
  48. txIndexer txindex.TxIndexer
  49. consensusReactor *consensus.ConsensusReactor
  50. eventBus *types.EventBus // thread safe
  51. logger log.Logger
  52. )
  53. func SetStateDB(db dbm.DB) {
  54. stateDB = db
  55. }
  56. func SetBlockStore(bs types.BlockStore) {
  57. blockStore = bs
  58. }
  59. func SetMempool(mem types.Mempool) {
  60. mempool = mem
  61. }
  62. func SetEvidencePool(evpool types.EvidencePool) {
  63. evidencePool = evpool
  64. }
  65. func SetConsensusState(cs Consensus) {
  66. consensusState = cs
  67. }
  68. func SetSwitch(sw P2P) {
  69. p2pSwitch = sw
  70. }
  71. func SetPubKey(pk crypto.PubKey) {
  72. pubKey = pk
  73. }
  74. func SetGenesisDoc(doc *types.GenesisDoc) {
  75. genDoc = doc
  76. }
  77. func SetAddrBook(book p2p.AddrBook) {
  78. addrBook = book
  79. }
  80. func SetProxyAppQuery(appConn proxy.AppConnQuery) {
  81. proxyAppQuery = appConn
  82. }
  83. func SetTxIndexer(indexer txindex.TxIndexer) {
  84. txIndexer = indexer
  85. }
  86. func SetConsensusReactor(conR *consensus.ConsensusReactor) {
  87. consensusReactor = conR
  88. }
  89. func SetLogger(l log.Logger) {
  90. logger = l
  91. }
  92. func SetEventBus(b *types.EventBus) {
  93. eventBus = b
  94. }