From f0777277ad116458f0174ef978167e091770d6b0 Mon Sep 17 00:00:00 2001 From: Prince Sinha Date: Mon, 16 Dec 2019 20:17:36 +0530 Subject: [PATCH] rpc: added proposer in consensus_state (#4250) * added proposer in consensus_state * added proposer in consensus_state * proposer changes * added proposer in consensus_state * proposer added --- CHANGELOG_PENDING.md | 4 ++-- consensus/types/round_state.go | 21 +++++++++++++++------ rpc/swagger/swagger.yaml | 10 ++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index 2e58ecb8c..def3681d9 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -122,8 +122,8 @@ program](https://hackerone.com/tendermint). - [cli] [\#4065](https://github.com/tendermint/tendermint/issues/4065) Add `--consensus.create_empty_blocks_interval` flag (@jgimeno) - [docs] [\#4065](https://github.com/tendermint/tendermint/issues/4065) Document `--consensus.create_empty_blocks_interval` flag (@jgimeno) - [crypto] [\#4190](https://github.com/tendermint/tendermint/pull/4190) Added SR25519 signature scheme -- [abci] \#4177 kvstore: Return `LastBlockHeight` and `LastBlockAppHash` in `Info` (@princesinha19) - +- [abci] [\#4177] kvstore: Return `LastBlockHeight` and `LastBlockAppHash` in `Info` (@princesinha19) +- [rpc] [\#2741](https://github.com/tendermint/tendermint/issues/2741) Add `proposer` to `/consensus_state` response (@princesinha19) ### BUG FIXES: diff --git a/consensus/types/round_state.go b/consensus/types/round_state.go index 490110357..0a18b6d04 100644 --- a/consensus/types/round_state.go +++ b/consensus/types/round_state.go @@ -95,12 +95,13 @@ type RoundState struct { // Compressed version of the RoundState for use in RPC type RoundStateSimple struct { - HeightRoundStep string `json:"height/round/step"` - StartTime time.Time `json:"start_time"` - ProposalBlockHash bytes.HexBytes `json:"proposal_block_hash"` - LockedBlockHash bytes.HexBytes `json:"locked_block_hash"` - ValidBlockHash bytes.HexBytes `json:"valid_block_hash"` - Votes json.RawMessage `json:"height_vote_set"` + HeightRoundStep string `json:"height/round/step"` + StartTime time.Time `json:"start_time"` + ProposalBlockHash bytes.HexBytes `json:"proposal_block_hash"` + LockedBlockHash bytes.HexBytes `json:"locked_block_hash"` + ValidBlockHash bytes.HexBytes `json:"valid_block_hash"` + Votes json.RawMessage `json:"height_vote_set"` + Proposer types.ValidatorInfo `json:"proposer"` } // Compress the RoundState to RoundStateSimple @@ -109,6 +110,10 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple { if err != nil { panic(err) } + + addr := rs.Validators.GetProposer().Address + idx, _ := rs.Validators.GetByAddress(addr) + return RoundStateSimple{ HeightRoundStep: fmt.Sprintf("%d/%d/%d", rs.Height, rs.Round, rs.Step), StartTime: rs.StartTime, @@ -116,6 +121,10 @@ func (rs *RoundState) RoundStateSimple() RoundStateSimple { LockedBlockHash: rs.LockedBlock.Hash(), ValidBlockHash: rs.ValidBlock.Hash(), Votes: votesJSON, + Proposer: types.ValidatorInfo{ + Address: addr, + Index: idx, + }, } } diff --git a/rpc/swagger/swagger.yaml b/rpc/swagger/swagger.yaml index 564d4b7c2..67aee023b 100644 --- a/rpc/swagger/swagger.yaml +++ b/rpc/swagger/swagger.yaml @@ -2351,6 +2351,7 @@ components: - "locked_block_hash" - "valid_block_hash" - "height_vote_set" + - "proposer" properties: height/round/step: type: "string" @@ -2395,6 +2396,15 @@ components: precommits_bit_array: type: "string" example: "BA{100:xxxxxx_xxxxx_xxxx_x_xxx_xx_xx_xx__x_x_x__xxxxxxxxxxxxxx_xxxx_xx_xxxxxx_xxxxxxxx_xxxx_xxx_x_xxxx__xxx} 118726247/170151262 = 0.70" + proposer: + type: "object" + properties: + address: + type: "string" + example: "D540AB022088612AC74B287D076DBFBC4A377A2E" + index: + type: "string" + example: "0" type: "object" type: "object" ConsensusParamsResponse: