[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 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 |
|
- package core_types
-
- import (
- "encoding/json"
- "strings"
- "time"
-
- abci "github.com/tendermint/abci/types"
- crypto "github.com/tendermint/go-crypto"
- cmn "github.com/tendermint/tmlibs/common"
-
- "github.com/tendermint/tendermint/p2p"
- "github.com/tendermint/tendermint/state"
- "github.com/tendermint/tendermint/types"
- )
-
- // List of blocks
- type ResultBlockchainInfo struct {
- LastHeight int64 `json:"last_height"`
- BlockMetas []*types.BlockMeta `json:"block_metas"`
- }
-
- // Genesis file
- type ResultGenesis struct {
- Genesis *types.GenesisDoc `json:"genesis"`
- }
-
- // Single block (with meta)
- type ResultBlock struct {
- BlockMeta *types.BlockMeta `json:"block_meta"`
- Block *types.Block `json:"block"`
- }
-
- // Commit and Header
- type ResultCommit struct {
- // SignedHeader is header and commit, embedded so we only have
- // one level in the json output
- types.SignedHeader
- CanonicalCommit bool `json:"canonical"`
- }
-
- // ABCI results from a block
- type ResultBlockResults struct {
- Height int64 `json:"height"`
- Results *state.ABCIResponses `json:"results"`
- }
-
- // NewResultCommit is a helper to initialize the ResultCommit with
- // the embedded struct
- func NewResultCommit(header *types.Header, commit *types.Commit,
- canonical bool) *ResultCommit {
-
- return &ResultCommit{
- SignedHeader: types.SignedHeader{
- Header: header,
- Commit: commit,
- },
- CanonicalCommit: canonical,
- }
- }
-
- // Info about the node's syncing state
- type SyncInfo struct {
- LatestBlockHash cmn.HexBytes `json:"latest_block_hash"`
- LatestAppHash cmn.HexBytes `json:"latest_app_hash"`
- LatestBlockHeight int64 `json:"latest_block_height"`
- LatestBlockTime time.Time `json:"latest_block_time"`
- Syncing bool `json:"syncing"`
- }
-
- // Info about the node's validator
- type ValidatorInfo struct {
- Address cmn.HexBytes `json:"address"`
- PubKey crypto.PubKey `json:"pub_key"`
- VotingPower int64 `json:"voting_power"`
- }
-
- // Node Status
- type ResultStatus struct {
- NodeInfo p2p.NodeInfo `json:"node_info"`
- SyncInfo SyncInfo `json:"sync_info"`
- ValidatorInfo ValidatorInfo `json:"validator_info"`
- }
-
- // Is TxIndexing enabled
- func (s *ResultStatus) TxIndexEnabled() bool {
- if s == nil {
- return false
- }
- for _, s := range s.NodeInfo.Other {
- info := strings.Split(s, "=")
- if len(info) == 2 && info[0] == "tx_index" {
- return info[1] == "on"
- }
- }
- return false
- }
-
- // Info about peer connections
- type ResultNetInfo struct {
- Listening bool `json:"listening"`
- Listeners []string `json:"listeners"`
- NPeers int `json:"n_peers"`
- Peers []Peer `json:"peers"`
- }
-
- // Log from dialing seeds
- type ResultDialSeeds struct {
- Log string `json:"log"`
- }
-
- // Log from dialing peers
- type ResultDialPeers struct {
- Log string `json:"log"`
- }
-
- // A peer
- type Peer struct {
- p2p.NodeInfo `json:"node_info"`
- IsOutbound bool `json:"is_outbound"`
- ConnectionStatus p2p.ConnectionStatus `json:"connection_status"`
- }
-
- // Validators for a height
- type ResultValidators struct {
- BlockHeight int64 `json:"block_height"`
- Validators []*types.Validator `json:"validators"`
- }
-
- // Info about the consensus state.
- // UNSTABLE
- type ResultDumpConsensusState struct {
- RoundState json.RawMessage `json:"round_state"`
- Peers []PeerStateInfo `json:"peers"`
- }
-
- // UNSTABLE
- type PeerStateInfo struct {
- NodeAddress string `json:"node_address"`
- PeerState json.RawMessage `json:"peer_state"`
- }
-
- // UNSTABLE
- type ResultConsensusState struct {
- RoundState json.RawMessage `json:"round_state"`
- }
-
- // CheckTx result
- type ResultBroadcastTx struct {
- Code uint32 `json:"code"`
- Data cmn.HexBytes `json:"data"`
- Log string `json:"log"`
-
- Hash cmn.HexBytes `json:"hash"`
- }
-
- // CheckTx and DeliverTx results
- type ResultBroadcastTxCommit struct {
- CheckTx abci.ResponseCheckTx `json:"check_tx"`
- DeliverTx abci.ResponseDeliverTx `json:"deliver_tx"`
- Hash cmn.HexBytes `json:"hash"`
- Height int64 `json:"height"`
- }
-
- // Result of querying for a tx
- type ResultTx struct {
- Hash cmn.HexBytes `json:"hash"`
- Height int64 `json:"height"`
- Index uint32 `json:"index"`
- TxResult abci.ResponseDeliverTx `json:"tx_result"`
- Tx types.Tx `json:"tx"`
- Proof types.TxProof `json:"proof,omitempty"`
- }
-
- // Result of searching for txs
- type ResultTxSearch struct {
- Txs []*ResultTx `json:"txs"`
- TotalCount int `json:"total_count"`
- }
-
- // List of mempool txs
- type ResultUnconfirmedTxs struct {
- N int `json:"n_txs"`
- Txs []types.Tx `json:"txs"`
- }
-
- // Info abci msg
- type ResultABCIInfo struct {
- Response abci.ResponseInfo `json:"response"`
- }
-
- // Query abci msg
- type ResultABCIQuery struct {
- Response abci.ResponseQuery `json:"response"`
- }
-
- // empty results
- type (
- ResultUnsafeFlushMempool struct{}
- ResultUnsafeProfile struct{}
- ResultSubscribe struct{}
- ResultUnsubscribe struct{}
- ResultHealth struct{}
- )
-
- // Event data from a subscription
- type ResultEvent struct {
- Query string `json:"query"`
- Data types.TMEventData `json:"data"`
- }
|