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

Migrate {x/auth, x/gov, x/staking} missing CLI queries to proto #6994

Merged
merged 51 commits into from
Sep 10, 2020

Conversation

sahith-narahari
Copy link
Contributor

@sahith-narahari sahith-narahari commented Aug 9, 2020

Description

This PR updates queries using QueryByTxs to use proto.
Also:

  • tx.Tx (the proto Message) now implements sdk.Tx

ref: #6987


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
  • Review Codecov Report in the comment section below once CI passes

@codecov
Copy link

codecov bot commented Aug 9, 2020

Codecov Report

Merging #6994 into master will decrease coverage by 0.02%.
The diff coverage is 35.84%.

@@            Coverage Diff             @@
##           master    #6994      +/-   ##
==========================================
- Coverage   55.17%   55.15%   -0.03%     
==========================================
  Files         584      584              
  Lines       40538    40504      -34     
==========================================
- Hits        22367    22340      -27     
+ Misses      16301    16290      -11     
- Partials     1870     1874       +4     

@anilcse anilcse changed the title Migrate pending cli queries Migrate pending cli queries to proto Aug 10, 2020
@sahith-narahari
Copy link
Contributor Author

Blocked on #7067, will update once I add tests.

@anilcse anilcse marked this pull request as ready for review August 24, 2020 19:19
@anilcse anilcse self-assigned this Aug 24, 2020
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

tested and not working.

  1. create a network ($ make clean localnet-start)
  2. send a tx
  3. query for that tx by events
$ simd q txs --events="message.sender=cosmos13dtdcpyv0z2tda9vcv6e8unamkkah3zhxyafn8"
Error: cannot protobuf JSON encode unsupported type: *types.SearchTxsResult
Usage:
  simd query txs [flags]

Flags:
      --events string            list of transaction events in the form of {eventType}.{eventAttribute}={value}
  -h, --help                     help for txs
      --keyring-backend string   Select keyring's backend (os|file|kwallet|pass|test) (default "os")
      --limit int                Query number of transactions results per page returned (default 30)
  -n, --node string              Node to connect to (default "tcp://localhost:26657")
      --page int                 Query a specific page of paginated results (default 1)

Global Flags:
      --chain-id string   The network chain ID
      --home string       directory for config and data (default "/Users/aleksbez/.simapp")
      --trace             print out full stack trace on errors

@alexanderbez
Copy link
Contributor

Also, querying by hash fails too:

$ simd q tx 5A07FC41325447C33D856A9122C93DEA83479C5F1596C9375427493B10C7D9A0
Error: unknown message type ""
Usage:
  simd query tx [hash] [flags]

Flags:
  -h, --help                     help for tx
      --keyring-backend string   Select keyring's backend (os|file|kwallet|pass|test) (default "os")
  -n, --node string              Node to connect to (default "tcp://localhost:26657")

Global Flags:
      --chain-id string   The network chain ID
      --home string       directory for config and data (default "/Users/aleksbez/.simapp")
      --trace             print out full stack trace on errors

@anilcse
Copy link
Collaborator

anilcse commented Aug 25, 2020

$ simd q txs --events="message.sender=cosmos13dtdcpyv0z2tda9vcv6e8unamkkah3zhxyafn8"
Error: cannot protobuf JSON encode unsupported type: *types.SearchTxsResult

Migrated SearchTxsResult to proto but still getting empty response from node.TxSearch.

@anilcse anilcse changed the title Migrate {x/auth, x/gov, x/staking} missing CLI queries to use proto Migrate {x/auth, x/gov, x/staking} missing CLI queries to proto Sep 5, 2020
Comment on lines +103 to +110
any, ok := txBuilder.(codectypes.IntoAny)
s.Require().True(ok)
cached := any.AsAny().GetCachedValue()
txTx, ok := cached.(*txtypes.Tx)
s.Require().True(ok)
res, err := s.queryClient.Simulate(
context.Background(),
&simulate.SimulateRequest{Tx: txBuilder.GetProtoTx()},
&simulate.SimulateRequest{Tx: txTx},
Copy link
Contributor

Choose a reason for hiding this comment

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

GetProtoTx() is a little bit more verbose, but at least it makes sense in the StdTx case too.

var _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}
var _ sdk.Tx = &Tx{}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove WrapTx now that tx.Tx implements sdk.Tx.

However, in this PR, I just modified the minimal code on Tx to make it work. For clarity, I propose to leave it to another PR (I can do it) to remove WrapTx, and also add GetGas on tx.Tx to make simulation work.

Copy link
Contributor

Choose a reason for hiding this comment

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

++

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looks good! I think some of the tx indirection between types can get a bit confusing.

Also, all the tx wrapper stuff is being removed, correct?

client/tx/tx.go Outdated Show resolved Hide resolved
@@ -50,7 +50,7 @@ func (any *Any) UnmarshalAmino(bz []byte) error {
return nil
}

func (any Any) MarshalJSON() ([]byte, error) {
func (any *Any) MarshalJSON() ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a pointer reference when marshaling?

Copy link
Contributor

Choose a reason for hiding this comment

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

Using Any, any.compat (just below) is nil. Using *Any, any.compat is correct. I'm not 100% I understand why; it's set on this line btw.

I didn't dig too much into it, but anyways, without the reference, tests fail.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@amaurymartiny , this could be some weird concurrency issue.

If you use Any then a method receiver works on an object copy. Sometimes it's a source of errors in methods which modifies the object. Here all methods which modifies the object are using pointer receivers. So that's why my guess is that tests are doing something weird in parallel.

var _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}
var _ sdk.Tx = &Tx{}
Copy link
Contributor

Choose a reason for hiding this comment

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

++

x/auth/client/cli/cli_test.go Outdated Show resolved Hide resolved
@anilcse anilcse added the C:CLI label Sep 8, 2020
@anilcse anilcse requested a review from blushi September 10, 2020 09:44
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

I worked a bit on this PR, so approving.

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Sep 10, 2020
@mergify mergify bot merged commit b234818 into master Sep 10, 2020
@mergify mergify bot deleted the sahith/update-query-cli branch September 10, 2020 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass. C:CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants