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

All txs for a single block in decoded json #8579

Closed
6 tasks
gotjoshua opened this issue Feb 13, 2021 · 12 comments
Closed
6 tasks

All txs for a single block in decoded json #8579

gotjoshua opened this issue Feb 13, 2021 · 12 comments
Labels
C: gRPC Issues and PRs related to the gRPC service and HTTP gateway.

Comments

@gotjoshua
Copy link
Contributor

gotjoshua commented Feb 13, 2021

Summary

foocli query txs -b <block-height> should be a thing.

Problem Definition

It is slow and annoying to get all txs for a specific block in usable readable json.

I can do two steps like in this gist:

curl -sX GET "http://127.0.0.1:26657/tx_search?query=\"tx.height%3D${BLOCK_HEIGHT}\"&prove=false&page=1&per_page=5000&order_by=\"asc\"" -H "accept: application/json" | jq -r '.result.txs[] | .hash'

and then loop through the hashes and get each one by one foocli query tx $eachHash

but that feels bogus and mega inefficient

ref:
#5453

Proposal

We need a single cli command that returns all txs for a single block in decoded json.

  • add -b (long --block or --height) for the foocli query txs command
  • add -e (long --encoded) for both the foocli query block and txs commands (decoded should be the default)

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@amaury1093 amaury1093 added the C: gRPC Issues and PRs related to the gRPC service and HTTP gateway. label Feb 15, 2021
@amaury1093
Copy link
Contributor

hey @gotjoshua, have you tried this endpoint?

// GetTxsEvent fetches txs by event.
rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) {
option (google.api.http).get = "/cosmos/tx/v1beta1/txs";
}
It should do exactly that.

@gotjoshua
Copy link
Contributor Author

Thanks for your reply @amaurymartiny,

have you tried this endpoint

i had not, but did now:
curl -X GET "http://localhost:26657/cosmos/tx/v1beta1/txs" -H "accept: application/json"
404 page not found

is that an incorrect URL for a local node (i'm running a regen testnet validator) ?

also how can i designate a specific block on that endpoint? ( docs say "event query" )?

@matsuro-hadouken
Copy link

This is great proposal which can save us allot of time @gotjoshua
Just checked http://localhost:26657/cosmos/tx/v1beta1/txs and it doesn't work on my end.
Probably v1beta1 can be different across networks.

Can we get please link to docummentation to read more abot this end point? @amaurymartiny

@amaury1093
Copy link
Contributor

amaury1093 commented Feb 15, 2021

It should be on the REST port (1317 by default). Make sure grpc-gateway is enabled too.

Probably v1beta1 can be different across networks.

As long as other networks use cosmos sdk 0.41, it will be v1beta1. The endpoint version might change in future releases of the SDK though.

Can we get please link to docummentation to read more abot this end point? @amaurymartiny

The swagger endpoint should give decent documentation of the different endpoints.

@gotjoshua
Copy link
Contributor Author

curl -X GET "http://localhost:1317/swagger" -H "accept: application/json"   
{
  "code": 12,
  "message": "Not Implemented",
  "details": [
  ]
}
 curl -X GET "http://localhost:1317/cosmos/tx/v1beta1/txs" -H "accept: application/json"   
{
  "code": 12,
  "message": "Not Implemented",
  "details": [
  ]
}

@amaury1093
Copy link
Contributor

Try /swagger/ with a trailing slash (I know...)

Which node are you using? If regen-ledger, try after this PR. If another node, make sure the TX service is wired up, as well as grpc-gateway routes for it.

@gotjoshua
Copy link
Contributor Author

Which node are you using?

regen (in the testnet on 0.6.0 - so not exactly gonna do an early update)...

also, in order to try that PR i would need to build from source, right? Will that PR be in the 0.6.1 release?

also, also, I still don't see how this endpoint can solve this issue...
what would the query string look like?

how can i designate a specific block
?

@amaury1093
Copy link
Contributor

also, in order to try that PR i would need to build from source, right? Will that PR be in the 0.6.1 release?

Yes. If you don't want to build it, you can either use gRPC, or use the CLI {appname} query txs --events 'tx.height=2'

what would the query string look like?

Same as before, so tx.height={block}

@gotjoshua
Copy link
Contributor Author

CLI {appname} query txs --events 'tx.height=2'

amazing! that is already working in 0.6.0!

regen query txs --events 'tx.height=42534' --limit 5000 | jq . | head                                                                          
{
  "total_count": "306",
  "count": "100",
  "page_number": "1",
  "page_total": "1",
  "limit": "5000",
  "txs": [
    {
      "height": "42534",
      "txhash": "26C2E9805972DC767BA91A1A7EA8BBF0294FA1BB052961822297AB95B0EF7650",
     ....

what i don't get is the hard cap at 100txs (even if i set --limit to 5000)
Is that configurable somewhere?

@gotjoshua
Copy link
Contributor Author

Here is a gist using the cli to summarize memos for a block:
https://gist.github.com/gotjoshua/9dd958d45bdcfd1ac4ae5f11a873653b

Thanks @AmauryM !!

@ghost
Copy link

ghost commented Mar 23, 2021

This is not working anymore as of 0.42.2

@amaury1093
Copy link
Contributor

@crussell-figure Could you create a new issue with exact repro steps? I'm not sure what you're referring to, in this issue we talked abotu CLI, REST and gRPC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: gRPC Issues and PRs related to the gRPC service and HTTP gateway.
Projects
None yet
Development

No branches or pull requests

3 participants