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

x/ibc: gRPC query service #6466

Merged
merged 47 commits into from
Jul 6, 2020
Merged

x/ibc: gRPC query service #6466

merged 47 commits into from
Jul 6, 2020

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Jun 18, 2020

Description

ref: #5921

TODO:

  • Connection
  • Channel
  • IBC transfer
  • Tests

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

@fedekunze fedekunze added this to the IBC 1.0 milestone Jun 18, 2020
@lgtm-com
Copy link

lgtm-com bot commented Jun 18, 2020

This pull request introduces 2 alerts when merging e82f809 into 257354d - view on LGTM.com

new alerts:

  • 2 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jun 24, 2020

This pull request introduces 4 alerts when merging 447b0e5 into cb6c552 - view on LGTM.com

new alerts:

  • 4 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jun 25, 2020

This pull request introduces 4 alerts when merging 20c6b7a into dcd5781 - view on LGTM.com

new alerts:

  • 4 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jun 26, 2020

This pull request introduces 4 alerts when merging 2296bb7 into 7c0fa69 - view on LGTM.com

new alerts:

  • 4 for Useless assignment to local variable

@lgtm-com
Copy link

lgtm-com bot commented Jun 26, 2020

This pull request introduces 4 alerts when merging 774185e into 98a3645 - view on LGTM.com

new alerts:

  • 4 for Useless assignment to local variable

@codecov
Copy link

codecov bot commented Jun 29, 2020

Codecov Report

Merging #6466 into master will increase coverage by 0.21%.
The diff coverage is 69.31%.

@@            Coverage Diff             @@
##           master    #6466      +/-   ##
==========================================
+ Coverage   57.30%   57.52%   +0.21%     
==========================================
  Files         491      493       +2     
  Lines       29470    29539      +69     
==========================================
+ Hits        16889    16991     +102     
+ Misses      11372    11336      -36     
- Partials     1209     1212       +3     

@tac0turtle
Copy link
Member

remove buf file plz

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left lots of suggestions, I'm open ears to doing some of the suggested changes in a followup pr since I think there will still need some refactor of cli stuff to be done. Some of my suggestions got outdated as I understood the entire pr, I'm going to leave them, but comment and resolve with the answer to them in case other reviewers have the same q

x/ibc-transfer/client/cli/cli.go Show resolved Hide resolved
proto/ibc/connection/query.proto Show resolved Hide resolved
proto/ibc/connection/query.proto Show resolved Hide resolved
proto/ibc/connection/query.proto Outdated Show resolved Hide resolved
x/ibc/03-connection/client/cli/query.go Outdated Show resolved Hide resolved
x/ibc/04-channel/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
x/ibc/04-channel/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
x/ibc/04-channel/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
func() {
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think UnrelayedPackets might not be working as intended. Basically we want a query function that can indicate if given a list of packet commitment sequences:

  • does the packet commitment need to be relayed? (no ack exists)
  • does the ack need to be relayed? (ack exists and packet commitment exists)

looking at this test, an ack is set, but no packet commitment is created for the corresponding ack (ack has been relayed, packet cycle complete), so the sequences returned should be empty.

It's probably best to split the unrelayed packets into two funcs to avoid confusion or just add a bool in the request.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably best to split the unrelayed packets into two funcs to avoid confusion or just add a bool in the request.

Do you want to split the command as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that sounds good, a bool flag could work as well. Whichever is easier

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool flag might be easier:
gaia q ibc channel unrelayed-packets --acknowledgements true would return all unrelayed acknowledgements

x/ibc/04-channel/client/cli/query.go Show resolved Hide resolved
seqStrs := strings.Split(args[2], ",")

seqs := make([]uint64, len(seqStrs))
seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah I meant if the sequence flag is unused that the default behaviour is to query for the packet commitments and supply them as the sequence arg. This can be done in a followup pr though

Copy link
Collaborator

@anilcse anilcse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loogs good @fedekunze , added a few comments

proto/ibc/channel/channel.proto Show resolved Hide resolved
x/ibc-transfer/module.go Show resolved Hide resolved

page, _ := cmd.Flags().GetInt(flags.FlagPage)
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
page, err := cmd.Flags().GetInt(flags.FlagPage)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Page is confusing, we might need to introduce Offset flag

Suggested change
page, err := cmd.Flags().GetInt(flags.FlagPage)
offset, err := cmd.Flags().GetInt(flags.FlagOffset)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlagOffset is not defined. We should also add a FlagPaginationKey 👍

}

// Connections implements the Query/Connections gRPC method
func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any filters for Connections? May be would be good to introduce them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, not in this PR tho 👍

x/ibc/03-connection/keeper/grpc_query_test.go Outdated Show resolved Hide resolved
@fedekunze fedekunze merged commit f35e3b2 into master Jul 6, 2020
@fedekunze fedekunze deleted the fedekunze/ibc-grpc branch July 6, 2020 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants