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

Provide TX uids #318

Closed
faboweb opened this issue Jan 4, 2018 · 15 comments · Fixed by #1317
Closed

Provide TX uids #318

faboweb opened this issue Jan 4, 2018 · 15 comments · Fixed by #1317
Assignees

Comments

@faboweb
Copy link
Contributor

faboweb commented Jan 4, 2018

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.

@nylira
Copy link
Contributor

nylira commented Jan 15, 2018

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

@jaekwon
Copy link
Contributor

jaekwon commented Jan 22, 2018

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

@melekes
Copy link
Contributor

melekes commented Jan 22, 2018

  • 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

@jaekwon
Copy link
Contributor

jaekwon commented Jan 22, 2018

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

@faboweb
Copy link
Contributor Author

faboweb commented Jan 22, 2018

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?

@jaekwon
Copy link
Contributor

jaekwon commented Jan 22, 2018

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

@faboweb
Copy link
Contributor Author

faboweb commented Jan 22, 2018

Thx for the clarification!

@faboweb
Copy link
Contributor Author

faboweb commented Jan 22, 2018

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?

@ebuchman
Copy link
Member

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

@ebuchman
Copy link
Member

@faboweb is this done ?

@faboweb
Copy link
Contributor Author

faboweb commented Jun 20, 2018

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

@kwunyeung
Copy link
Contributor

  • 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.

@melekes
Copy link
Contributor

melekes commented Oct 16, 2018

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"

@melekes
Copy link
Contributor

melekes commented Oct 16, 2018

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)

@kwunyeung
Copy link
Contributor

Thank you! It's very clear now.

ParthDesai pushed a commit to ChorusOne/cosmos-sdk that referenced this issue Apr 19, 2021
* Add approximate emit / query log interface
* Fix the syntax linter, ugh
* Call "emitLogEntry"
* Add packets received relay
* Add a bit of an explanation
rootulp referenced this issue in rootulp/cosmos-sdk May 17, 2023
* test: use target height duration in network tests

* wait a factor of the target height duration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants