Skip to content

Commit

Permalink
feat: include transactions in QueryBlockByHeight (backport cosmos#10880
Browse files Browse the repository at this point in the history
…) (cosmos#11248)

* feat: include transactions in QueryBlockByHeight  (cosmos#10880)

## Description

Closes: cosmos#3729

- adds a new query to the tx service in Auth, which gets block information + decoded txs
- added a new function to get the protoBlock from the node.

---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules)
- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)

(cherry picked from commit dd65ef8)

# Conflicts:
#	CHANGELOG.md
#	api/cosmos/group/v1beta1/types.pulsar.go
#	api/cosmos/tx/v1beta1/service.pulsar.go
#	api/cosmos/tx/v1beta1/service_grpc.pb.go
#	client/grpc/tmservice/block.go
#	testutil/testdata_pulsar/query.pulsar.go
#	testutil/testdata_pulsar/testdata.pulsar.go
#	testutil/testdata_pulsar/tx.pulsar.go
#	testutil/testdata_pulsar/unknonwnproto.pulsar.go
#	types/tx/service.pb.go

* fix conflicts

* remove pulsar

Co-authored-by: Tyler <[email protected]>
Co-authored-by: marbar3778 <[email protected]>
  • Loading branch information
3 people authored and zakir committed Apr 14, 2022
1 parent 6c81e0e commit f6311d0
Show file tree
Hide file tree
Showing 28 changed files with 2,304 additions and 795 deletions.
4 changes: 2 additions & 2 deletions client/grpc/reflection/reflection.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions client/grpc/tmservice/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tmservice
import (
"context"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
ctypes "github.com/tendermint/tendermint/rpc/core/types"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -17,3 +18,17 @@ func getBlock(ctx context.Context, clientCtx client.Context, height *int64) (*ct

return node.Block(ctx, height)
}

func GetProtoBlock(ctx context.Context, clientCtx client.Context, height *int64) (tmproto.BlockID, *tmproto.Block, error) {
block, err := getBlock(ctx, clientCtx, height)
if err != nil {
return tmproto.BlockID{}, nil, err
}
protoBlock, err := block.Block.ToProto()
if err != nil {
return tmproto.BlockID{}, nil, err
}
protoBlockId := block.BlockID.ToProto()

return protoBlockId, protoBlock, nil
}
12 changes: 6 additions & 6 deletions client/grpc/tmservice/query.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions client/grpc/tmservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ func (s queryServer) GetBlockByHeight(ctx context.Context, req *GetBlockByHeight
return nil, status.Error(codes.InvalidArgument, "requested block height is bigger then the chain length")
}

res, err := getBlock(ctx, s.clientCtx, &req.Height)
if err != nil {
return nil, err
}
protoBlockID := res.BlockID.ToProto()
protoBlock, err := res.Block.ToProto()
protoBlockID, protoBlock, err := GetProtoBlock(ctx, s.clientCtx, &req.Height)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit f6311d0

Please sign in to comment.