Cosmos-sdk: Provide TX uids

Created on 4 Jan 2018  路  15Comments  路  Source: cosmos/cosmos-sdk

To be able to request detailed information on txs and to be able to organize txs client side, it would be great to have uids per tx.

proposal

All 15 comments

We need this for the block explorer in the UI, so users can search for specific transactions.

@ebuchman @melekes how are the txs being indexed now?

  • by height
  • (with tx_indexer enabled) by hash
  • (with tx_indexer enabled and index_tags set to tagA) by hash and tagA from DeliverTx
curl 'localhost:46657/block_results?height=10'
curl "localhost:46657/tx?hash=0x2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF"
curl "localhost:46657/tx_search?query=\"account.owner='Ivan'\"&prove=true"

https://godoc.org/github.com/tendermint/tendermint/rpc/core

@faboweb The "UID" for a tx is its RipeMD160 hash, 20 bytes.

Just a question for understanding:
If I send 2 same transactions to my self in the same block, wouldn't the hash be the same?

The wallet/client should generate two transactions that have 2 different signatures... each time the wallet signs, it should increment the nonce, which is included in the StdSignature structure.

See https://github.com/cosmos/cosmos-sdk/blob/sdk2/types/signature.go#L8

Thx for the clarification!

The SDK REST endpoint doesn't return neither the hash nor the nonce:

curl http://localhost:8998/tx/coin/DF096FDE8D380FA5B2AD20DB2962C82DDEA1ED9B

Could this endpoint include the hash?

Yes it could. Perhaps @ethanfrey or @mappum can help add this - should be quite straight forward.

Otherwise I can probably get to it in about 12 hours

@faboweb is this done ?

It sadly isn't. I will get to it asap.

  • by height
  • (with tx_indexer enabled) by hash
  • (with tx_indexer enabled and index_tags set to tagA) by hash and tagA from DeliverTx
curl 'localhost:46657/block_results?height=10'
curl "localhost:46657/tx?hash=0x2B8EC32BA2579B3B8606E42C06DE2F7AFA2556EF"
curl "localhost:46657/tx_search?query=\"account.owner='Ivan'\"&prove=true"

https://godoc.org/github.com/tendermint/tendermint/rpc/core

@melekes Can I use the /block_results endpoint to get the tags for searching the txs on gaia-8001? For example, the result of https://gaia-seeds.interblock.io/block_results?height=662474 show the following delivertx.

DeliverTx: [
{
log: "Msg 0: ",
gasWanted: "200000",
gasUsed: "68327",
tags: [
{
key: "YWN0aW9u",
value: "ZGVsZWdhdGU="
},
{
key: "ZGVsZWdhdG9y",
value: "Y29zbW9zYWNjYWRkcjEwNTA1bmw3eWZ0c21lOWprMmdsaGpodGE3dzA0NzV1dmE4N3Bhag=="
},
{
key: "ZGVzdGluYXRpb24tdmFsaWRhdG9y",
value: "Y29zbW9zYWNjYWRkcjEwNTA1bmw3eWZ0c21lOWprMmdsaGpodGE3dzA0NzV1dmE4N3Bhag=="
}
]
}
],

In the tags array, there are key-value pairs. Are they indexed tags? If so, how can they be found using the /subscribe endpoint? Do I have to to decode them before building the query?

Also from the /block endpoint, there are txs data. For example, if you read https://gaia-seeds.interblock.io/block?height=662474, the result has the object

data: {
txs: [
"xAHwYl3uCjySHS5OChR9H0n/xErhvJZWUj95XX3zn19TjBIUfR9J/8RK4byWVlI/eV19859fU4waCgoFc3RlYWsSATISCQoDEgEwEIC1GBp1CibrWumHIQOoUIFNYtxUYnreXHIzrtk8NPEwBDFgEslyij/YdOm71xJGMEQCIBprVXbmumvhAtHc5VoOzrvbho5mAyBMtKpyKobEq4rcAiAuSVT8lq/KVI5RjoQEiob/XwWcEZykyMJoWKbheezZJhjmAyAI"
]
},

Is there a way the tx in the txs array be extracted and decode? I'm looking for the way to track all the txs in the blocks.

Are they indexed tags?

this depends on whenever indexer is configured to index these tags (or all tags).

Do I have to to decode them before building the query?

yes. these are base64 encoded strings

https://play.golang.org/p/wJda6NWSQMi

encTag := "ZGVzdGluYXRpb24tdmFsaWRhdG9y"
tag, _ := base64.StdEncoding.DecodeString(encTag)
fmt.Printf("tag: %q\n", tag)
// -> tag: "original-validator"

Is there a way the tx in the txs array be extracted and decode

same. base64 encoded raw bytes, but only application knows how to decode them (tendermint is not aware of transaction format)

Thank you! It's very clear now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianbrink picture adrianbrink  路  3Comments

fedekunze picture fedekunze  路  3Comments

cwgoes picture cwgoes  路  3Comments

mossid picture mossid  路  3Comments

rigelrozanski picture rigelrozanski  路  3Comments