Skip to content

Commit

Permalink
fix: Change proposer address cast for sdk_block conversion (#15243)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-hontar committed Mar 2, 2023
1 parent 0141817 commit 07dc5e7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
* (server) [#13778](https://github.com/cosmos/cosmos-sdk/pull/13778) Set Cosmos SDK default endpoints to localhost to avoid unknown exposure of endpoints.
* (x/auth) [#13877](https://github.com/cosmos/cosmos-sdk/pull/13877) Fix account number handling during `InitGenesis`.
* (cli) [#14509](https://github.com/cosmos/cosmos-sdk/pull/14509) Added missing options to keyring-backend flag usage
* [#15243](https://github.com/cosmos/cosmos-sdk/pull/15243) `LatestBlockResponse` & `BlockByHeightResponse` types' field `sdk_block` was incorrectly cast `proposer_address` bytes to validator operator address, now to consensus address

### Deprecated

Expand Down
12 changes: 6 additions & 6 deletions client/grpc/cmtservice/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ func convertHeader(h cmtprototypes.Header) Header {
EvidenceHash: h.EvidenceHash,
LastResultsHash: h.LastResultsHash,
LastCommitHash: h.LastCommitHash,
ProposerAddress: sdk.ValAddress(h.ProposerAddress).String(),
ProposerAddress: sdk.ConsAddress(h.ProposerAddress).String(),
}
}

// convertBlock converts CometBFT block to sdk block
func convertBlock(tmblock *cmtprototypes.Block) *Block {
func convertBlock(cmtblock *cmtprototypes.Block) *Block {
b := new(Block)

b.Header = convertHeader(tmblock.Header)
b.LastCommit = tmblock.LastCommit
b.Data = tmblock.Data
b.Evidence = tmblock.Evidence
b.Header = convertHeader(cmtblock.Header)
b.LastCommit = cmtblock.LastCommit
b.Data = cmtblock.Data
b.Evidence = cmtblock.Evidence

return b
}
6 changes: 3 additions & 3 deletions tests/e2e/client/grpc/cmtservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ func (s *E2ETestSuite) TestQueryLatestBlock() {
s.Require().NoError(err)
var blockInfoRes cmtservice.GetLatestBlockResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
s.Require().Equal(types.ValAddress(blockInfoRes.Block.Header.ProposerAddress).String(), blockInfoRes.SdkBlock.Header.ProposerAddress)
s.Require().Contains(blockInfoRes.SdkBlock.Header.ProposerAddress, "cosmosvaloper")
s.Require().Equal(types.ConsAddress(blockInfoRes.Block.Header.ProposerAddress).String(), blockInfoRes.SdkBlock.Header.ProposerAddress)
s.Require().Contains(blockInfoRes.SdkBlock.Header.ProposerAddress, "cosmosvalcons")
}

func (s *E2ETestSuite) TestQueryBlockByHeight() {
Expand All @@ -105,7 +105,7 @@ func (s *E2ETestSuite) TestQueryBlockByHeight() {
s.Require().NoError(err)
var blockInfoRes cmtservice.GetBlockByHeightResponse
s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(restRes, &blockInfoRes))
s.Require().Contains(blockInfoRes.SdkBlock.Header.ProposerAddress, "cosmosvaloper")
s.Require().Contains(blockInfoRes.SdkBlock.Header.ProposerAddress, "cosmosvalcons")
}

func (s *E2ETestSuite) TestQueryLatestValidatorSet() {
Expand Down

0 comments on commit 07dc5e7

Please sign in to comment.