Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change proposer address cast for sdk_block conversion #15243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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