Cosmos-sdk: Return transactions in blocks

Created on 25 Feb 2019  Â·  10Comments  Â·  Source: cosmos/cosmos-sdk

Summary

We should return the transactions in a block when querying GET /blocks/{height}.

Problem Definition

Currently the txs inside the response are base64 as the response comes from Tendermint. The transactions should at least be their hashes so that we don't mix content and the response is easy to parse.
Better would be to directly return the transactions as part of the response. The assumption is, that apps querying for blocks will mostly include some information about the blocks in it.
Alternative: Is it possible to query all transactions by height?

Proposal

Decode the raw Tendermint txs in data.txs to sdk.StdTxs in the /blocks/{height} query.


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
good first issue proposal proposal-accepted

Most helpful comment

@ruanqunfeng you misspelled height.


There are two endpoints in question here:

  1. /blocks/{height}: Returns the Tendermint block as-is. The response includes a data.txs array which includes base64 encoded txs. You may base64 decode these and then amino decode them.
  2. /txs?tx.height={height} (tag-based query). This returns to you the already decoded txs _without_ any block information.

So (1) is just a simple request proxy to the Tendermint RPC. What we can do is simply take the response and decode the txs for the user like we do in (2).

All 10 comments

This seems like a pretty common sense feature request.

You can query txs by height, it’s just not documented GET /txs?tx.heigth=<block>

In that case I'm going to backlog this issue as it can be done with two requests.

You can query txs by height, it’s just not documented /txs?tx.heigth=

I try to call this endpoint, but it seems unexist. On testnet: gaia-13003.
What's the suggestion to do chain scanner to extract all txs ?

It's weird, but I just calculate the txid from encoded raw transaction data. And I call the /txs/{hash} to get the transaction data.

@fedekunze
image
The result is null.

It's weird, but I just calculate the txid from encoded raw transaction data. And I call the /txs/{hash} to get the transaction data.

Hello,how to calculate the txid from encoded raw transaction data?

@jackzampolin more people seem to create hacks around this issue. Should this maybe be implemented?

@ruanqunfeng you misspelled height.


There are two endpoints in question here:

  1. /blocks/{height}: Returns the Tendermint block as-is. The response includes a data.txs array which includes base64 encoded txs. You may base64 decode these and then amino decode them.
  2. /txs?tx.height={height} (tag-based query). This returns to you the already decoded txs _without_ any block information.

So (1) is just a simple request proxy to the Tendermint RPC. What we can do is simply take the response and decode the txs for the user like we do in (2).

This would be extremely helpful!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValarDragon picture ValarDragon  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments

faboweb picture faboweb  Â·  3Comments

ValarDragon picture ValarDragon  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments