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

Failure to query tx by hash or txs by events via legacy API #7281

Closed
4 tasks
alexanderbez opened this issue Sep 10, 2020 · 27 comments
Closed
4 tasks

Failure to query tx by hash or txs by events via legacy API #7281

alexanderbez opened this issue Sep 10, 2020 · 27 comments
Assignees
Labels

Comments

@alexanderbez
Copy link
Contributor

Summary of Bug

An attempt to query for a tx by hash or a set of tx(s) by event(s) via the legacy API yields the following error:

{
    "error": "Unregistered interface types.isPublicKey_Sum"
}

Version

master -- d4b0e5b

Steps to Reproduce

  1. Start a local network
  2. Broadcast a valid tx
  3. Query for the tx via the legacy API (either by hash or by event(s))

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez alexanderbez added this to the v0.40 [Stargate] milestone Sep 10, 2020
@alexanderbez alexanderbez changed the title Failure to query tx by hash or txs by events Failure to query tx by hash or txs by events via legacy API Sep 10, 2020
@aaronc
Copy link
Member

aaronc commented Sep 16, 2020

This appears related to marshaling a public key with amino when that isn't supported. This will be address in #7276.

@amaury1093
Copy link
Contributor

@anilcse to double-check that this issue is solved once #7276 is merged.

@zmanian zmanian mentioned this issue Sep 19, 2020
10 tasks
@zmanian
Copy link
Member

zmanian commented Sep 19, 2020

Tested with #7276

{"error":"Unregistered interface tx.isModeInfo_Sum"}

on the legacy 1317 interface

@michaelfig
Copy link
Contributor

michaelfig commented Sep 21, 2020

{"error":"Unregistered interface tx.isModeInfo_Sum"}

Is this still an issue now that #7276 has been merged?

@zmanian zmanian closed this as completed Sep 21, 2020
@zmanian
Copy link
Member

zmanian commented Nov 19, 2020

@amaury1093
Copy link
Contributor

amaury1093 commented Nov 20, 2020

I added (thorough) tests in #7992, however, I am still failing to reproduce the issue on simapp.

@zmanian Do you have by any chance the txHash of this tx? I'll query it via gRPC, see its content, reproduce the same tx on simapp, and try querying it again.

@clevinson I see you re-opened, did you manage to reproduce?

@anilcse
Copy link
Collaborator

anilcse commented Nov 20, 2020

I couldn't reproduce this either.

@zmanian
Copy link
Member

zmanian commented Nov 20, 2020

This isn't happening for every tx. For instance this works.

http://34.66.55.131:1317/txs?transfer.recipient=cosmos13qhqwhzx74703avazhuf5hfxkwdx6wvsea4vgt

@zmanian
Copy link
Member

zmanian commented Nov 20, 2020

This also produces the error.
http://34.66.55.131:1317/txs?limit=100&page=1&tx.height=11101

@amaury1093
Copy link
Contributor

This isn't happening for every tx.

Could you provide the details of a failing tx? A txHash should suffice.

@zmanian
Copy link
Member

zmanian commented Nov 20, 2020

There is evidence that is related to the existence of an IBC transaction in the response path.

@zmanian
Copy link
Member

zmanian commented Nov 20, 2020

For instance, http://34.66.55.131:1317/txs?transfer.recipient=cosmos1h2gacd88hkvlmz5g04md87r54kjf0klnwt25n9 has received an ibc transfer.

http://34.66.55.131:1317/txs?transfer.recipient=cosmos13qhqwhzx74703avazhuf5hfxkwdx6wvsea4vgt has not received an IBC transfer.

@amaury1093
Copy link
Contributor

amaury1093 commented Nov 20, 2020

Printing a pretty error message on IBC txs has been solved in #7856, which I believe isn't included in rc3.

However, looking at that PR, i'm not 100% sure it handles all potential errors, so I added this: #7992 (comment)

@faboweb
Copy link
Contributor

faboweb commented Nov 23, 2020

What is the grpc query path to get transactions by tag?

@amaury1093
Copy link
Contributor

@faboweb

option (google.api.http).get = "/cosmos/tx/v1beta1/txs";

@faboweb
Copy link
Contributor

faboweb commented Nov 23, 2020

How do you use the grpc endpoint with query parameters? http://34.66.55.131:1317/cosmos/tx/v1beta1/txs?transfer.recipient=cosmos1q9wtnlwdjrhwtcjmt2uq77jrgx7z3usrq2yz7z doesn't work

@clevinson
Copy link
Contributor

clevinson commented Nov 24, 2020

@faboweb Unfortunately we only added the /txs grpc-gateway endpoint in quite recently (#7842), and there hasn't been a release candidate tagged since. You should be able to verify that query paramters work when runing against a local node built off of master though.

Here's basic reference docs for using query parameters w/ grpc gateway

@anilcse
Copy link
Collaborator

anilcse commented Nov 24, 2020

Also, looks like the URL is slightly different. It takes event query params with event key now, ex:
https://github.com/cosmos/cosmos-sdk/pull/7842/files#diff-61a9cb62b0e38da35032d7bc195c38b2c35c342c7302bf6dde5a483f63a96186R143

@faboweb
Copy link
Contributor

faboweb commented Nov 24, 2020

Any ETA on the next release version?

@aaronc
Copy link
Member

aaronc commented Nov 24, 2020

Can someone please post an example URL with the query params? Ideally @faboweb's initial query

@amaury1093
Copy link
Contributor

amaury1093 commented Nov 24, 2020

The new endpoint for querying txs by event:
{base_url}/cosmos/tx/v1beta1/txs?event=transfer.recipient=cosmos1q9wtnlwdjrhwtcjmt2uq77jrgx7z3usrq2yz7z&pagination.offset=0&pagination.limit=30

However, as Cory said, there's no live public node running SDK master.

This test on simapp might also help.

@aaronc
Copy link
Member

aaronc commented Nov 24, 2020

does the second = need to be URL escaped @amaurymartiny ?

@clevinson
Copy link
Contributor

clevinson commented Nov 25, 2020

@faboweb @aaronc I've just ran locally and verified that querying for single event attributes does work without URL encoding the value of event. However, I do think we should be encouraging developers to URL encode the event param value, as this is the only way to successfully query for multiple event attributes:

Example:
{base_url}/cosmos/tx/v1beta1/txs?event=transfer.recipient=cosmos1q9wtnlwdjrhwtcjmt2uq77jrgx7z3usrq2yz7z&message.action=send&pagination.offset=0&pagination.limit=1
will not correctly search for both both transfer.recipient and message.action.

The correct request URL should look like:
{base_url}/cosmos/tx/v1beta1/txs?event=transfer.amount%3D100node0token%26message.action%3Dsend&pagination.offset=0&pagination.limit=1

@faboweb as for a next release version, we're currently coordinating with @zmanian to figure out the best timing for a next RC. Most likely sometime next week is my guess.

@anilcse
Copy link
Collaborator

anilcse commented Nov 25, 2020

@faboweb @aaronc I've just ran locally and verified that querying for single event attributes does work without URL encoding the value of event. However, I do think we should be encouraging developers to URL encode the event param value, as this is the only way to successfully query for multiple event attributes:

Example:
{base_url}/cosmos/tx/v1beta1/txs?event=transfer.recipient=cosmos1q9wtnlwdjrhwtcjmt2uq77jrgx7z3usrq2yz7z&message.action=send&pagination.offset=0&pagination.limit=1
will not correctly search for both both transfer.recipient and message.action.

The correct request URL should look like:
{base_url}/cosmos/tx/v1beta1/txs?event=transfer.amount%3D100node0token%26message.action%3Dsend&pagination.offset=0&pagination.limit=1

@clevinson did you try with multiple event queryParam entries, something like below

{base_url}/cosmos/tx/v1beta1/txs?event=transfer.recipient=cosmos1q9wtnlwdjrhwtcjmt2uq77jrgx7z3usrq2yz7z&event=message.action=send&pagination.offset=0&pagination.limit=1

@anilcse
Copy link
Collaborator

anilcse commented Nov 25, 2020

@clevinson #8029 makes the event query params to be url escaped. The following request should work now:

{base_url}/cosmos/tx/v1beta1/txs?event=transfer.amount%3D100node0token%26message.action%3Dsend

@anilcse
Copy link
Collaborator

anilcse commented Dec 4, 2020

Addressed in #8039 . events is array now, following requests are valid

  • Using URL escaped :
    {base_url}/cosmos/tx/v1beta1/txs?event=transfer.amount%3D100node0token%26message.action%3Dsend
  • Using multiple entries:
    /cosmos/tx/v1beta1/txs?events=message.action=send&events=message.module=bank")

@anilcse anilcse closed this as completed Dec 4, 2020
@aaronc aaronc removed the in progress label Dec 4, 2020
@ziyi-zhang-1130
Copy link

ziyi-zhang-1130 commented Apr 9, 2021

FYI, the latest params of querying txs looks like this:
/cosmos/tx/v1beta1/txs?events=message.sender=%27cosmos1ut2jnfjlwpq520y06wyadys8nwg8gk3u74k9tv%27, where %27(') is needed around value.
Reference: https://github.com/cosmos/cosmos-sdk/blob/master/x/auth/tx/service_test.go#L257-L304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants