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.

152 lines
3.8 KiB

[rpc] DumpConsensusState: output state as json rather than string Before: ``` { "jsonrpc": "2.0", "id": "", "result": { "round_state": "RoundState{\n H:10 R:0 S:RoundStepNewHeight\n StartTime: 2017-10-09 13:07:24.841134374 +0400 +04\n CommitTime: 2017-10-09 13:07:23.841134374 +0400 +04\n Validators: ValidatorSet{\n Proposer: Validator{EF243CC0E9B88D0161D24D733BDE9003518CEA27 {PubKeyEd25519{2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202}} VP:10 A:0}\n Validators:\n Validator{EF243CC0E9B88D0161D24D733BDE9003518CEA27 {PubKeyEd25519{2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202}} VP:10 A:0}\n }\n Proposal: \u003cnil\u003e\n ProposalBlock: nil-PartSet nil-Block\n LockedRound: 0\n LockedBlock: nil-PartSet nil-Block\n Votes: HeightVoteSet{H:10 R:0~0\n VoteSet{H:10 R:0 T:1 +2/3:\u003cnil\u003e BA{1:_} map[]}\n VoteSet{H:10 R:0 T:2 +2/3:\u003cnil\u003e BA{1:_} map[]}\n }\n LastCommit: VoteSet{H:9 R:0 T:2 +2/3:947F67A7B85439AF2CD5DFED376C51AC7BD67AEE:1:365E9983E466 BA{1:X} map[]}\n LastValidators: ValidatorSet{\n Proposer: Validator{EF243CC0E9B88D0161D24D733BDE9003518CEA27 {PubKeyEd25519{2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202}} VP:10 A:0}\n Validators:\n Validator{EF243CC0E9B88D0161D24D733BDE9003518CEA27 {PubKeyEd25519{2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202}} VP:10 A:0}\n }\n}", "peer_round_states": [] } } ``` After: ``` { "jsonrpc": "2.0", "id": "", "result": { "round_state": { "Height": 1691, "Round": 0, "Step": 1, "StartTime": "2017-10-09T14:08:09.129491764+04:00", "CommitTime": "2017-10-09T14:08:08.129491764+04:00", "Validators": { "validators": [ { "address": "EF243CC0E9B88D0161D24D733BDE9003518CEA27", "pub_key": { "type": "ed25519", "data": "2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202" }, "voting_power": 10, "accum": 0 } ], "proposer": { "address": "EF243CC0E9B88D0161D24D733BDE9003518CEA27", "pub_key": { "type": "ed25519", "data": "2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202" }, "voting_power": 10, "accum": 0 } }, "Proposal": null, "ProposalBlock": null, "ProposalBlockParts": null, "LockedRound": 0, "LockedBlock": null, "LockedBlockParts": null, "Votes": {}, "CommitRound": -1, "LastCommit": {}, "LastValidators": { "validators": [ { "address": "EF243CC0E9B88D0161D24D733BDE9003518CEA27", "pub_key": { "type": "ed25519", "data": "2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202" }, "voting_power": 10, "accum": 0 } ], "proposer": { "address": "EF243CC0E9B88D0161D24D733BDE9003518CEA27", "pub_key": { "type": "ed25519", "data": "2E0B9301334FCDAB193D514022F81BA09BBEC028685C96602BE9DD0BD4F9E202" }, "voting_power": 10, "accum": 0 } } }, "peer_round_states": { "75EC8F15D244A421202F9725CD4DE509EE50303670310CF7530EF25E2B7C524B": { "Height": 1691, "Round": 0, "Step": 1, "StartTime": "2017-10-09T14:08:08.563251997+04:00", "Proposal": false, "ProposalBlockPartsHeader": { "total": 0, "hash": "" }, "ProposalBlockParts": null, "ProposalPOLRound": -1, "ProposalPOL": null, "Prevotes": null, "Precommits": null, "LastCommitRound": 0, "LastCommit": null, "CatchupCommitRound": -1, "CatchupCommit": null } } } } ```
7 years ago
7 years ago
8 years ago
7 years ago
8 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_types
  2. import (
  3. "strings"
  4. "time"
  5. abci "github.com/tendermint/abci/types"
  6. crypto "github.com/tendermint/go-crypto"
  7. "github.com/tendermint/go-wire/data"
  8. cstypes "github.com/tendermint/tendermint/consensus/types"
  9. "github.com/tendermint/tendermint/p2p"
  10. "github.com/tendermint/tendermint/state"
  11. "github.com/tendermint/tendermint/types"
  12. )
  13. type ResultBlockchainInfo struct {
  14. LastHeight int64 `json:"last_height"`
  15. BlockMetas []*types.BlockMeta `json:"block_metas"`
  16. }
  17. type ResultGenesis struct {
  18. Genesis *types.GenesisDoc `json:"genesis"`
  19. }
  20. type ResultBlock struct {
  21. BlockMeta *types.BlockMeta `json:"block_meta"`
  22. Block *types.Block `json:"block"`
  23. }
  24. type ResultCommit struct {
  25. // SignedHeader is header and commit, embedded so we only have
  26. // one level in the json output
  27. types.SignedHeader
  28. CanonicalCommit bool `json:"canonical"`
  29. }
  30. type ResultBlockResults struct {
  31. Height int64 `json:"height"`
  32. Results *state.ABCIResponses `json:"results"`
  33. }
  34. // NewResultCommit is a helper to initialize the ResultCommit with
  35. // the embedded struct
  36. func NewResultCommit(header *types.Header, commit *types.Commit,
  37. canonical bool) *ResultCommit {
  38. return &ResultCommit{
  39. SignedHeader: types.SignedHeader{
  40. Header: header,
  41. Commit: commit,
  42. },
  43. CanonicalCommit: canonical,
  44. }
  45. }
  46. type ResultStatus struct {
  47. NodeInfo *p2p.NodeInfo `json:"node_info"`
  48. PubKey crypto.PubKey `json:"pub_key"`
  49. LatestBlockHash data.Bytes `json:"latest_block_hash"`
  50. LatestAppHash data.Bytes `json:"latest_app_hash"`
  51. LatestBlockHeight int64 `json:"latest_block_height"`
  52. LatestBlockTime time.Time `json:"latest_block_time"`
  53. Syncing bool `json:"syncing"`
  54. }
  55. func (s *ResultStatus) TxIndexEnabled() bool {
  56. if s == nil || s.NodeInfo == nil {
  57. return false
  58. }
  59. for _, s := range s.NodeInfo.Other {
  60. info := strings.Split(s, "=")
  61. if len(info) == 2 && info[0] == "tx_index" {
  62. return info[1] == "on"
  63. }
  64. }
  65. return false
  66. }
  67. type ResultNetInfo struct {
  68. Listening bool `json:"listening"`
  69. Listeners []string `json:"listeners"`
  70. Peers []Peer `json:"peers"`
  71. }
  72. type ResultDialSeeds struct {
  73. Log string `json:"log"`
  74. }
  75. type Peer struct {
  76. p2p.NodeInfo `json:"node_info"`
  77. IsOutbound bool `json:"is_outbound"`
  78. ConnectionStatus p2p.ConnectionStatus `json:"connection_status"`
  79. }
  80. type ResultValidators struct {
  81. BlockHeight int64 `json:"block_height"`
  82. Validators []*types.Validator `json:"validators"`
  83. }
  84. type ResultDumpConsensusState struct {
  85. RoundState *cstypes.RoundState `json:"round_state"`
  86. PeerRoundStates map[string]*cstypes.PeerRoundState `json:"peer_round_states"`
  87. }
  88. type ResultBroadcastTx struct {
  89. Code uint32 `json:"code"`
  90. Data data.Bytes `json:"data"`
  91. Log string `json:"log"`
  92. Hash data.Bytes `json:"hash"`
  93. }
  94. type ResultBroadcastTxCommit struct {
  95. CheckTx abci.ResponseCheckTx `json:"check_tx"`
  96. DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
  97. Hash data.Bytes `json:"hash"`
  98. Height int64 `json:"height"`
  99. }
  100. type ResultTx struct {
  101. Height int64 `json:"height"`
  102. Index uint32 `json:"index"`
  103. TxResult abci.ResponseDeliverTx `json:"tx_result"`
  104. Tx types.Tx `json:"tx"`
  105. Proof types.TxProof `json:"proof,omitempty"`
  106. }
  107. type ResultUnconfirmedTxs struct {
  108. N int `json:"n_txs"`
  109. Txs []types.Tx `json:"txs"`
  110. }
  111. type ResultABCIInfo struct {
  112. Response abci.ResponseInfo `json:"response"`
  113. }
  114. type ResultABCIQuery struct {
  115. Response abci.ResponseQuery `json:"response"`
  116. }
  117. type ResultUnsafeFlushMempool struct{}
  118. type ResultUnsafeProfile struct{}
  119. type ResultSubscribe struct{}
  120. type ResultUnsubscribe struct{}
  121. type ResultEvent struct {
  122. Query string `json:"query"`
  123. Data types.TMEventData `json:"data"`
  124. }