Open webmaster128 opened 3 years ago
Reviving this discussion: tx hash should definitely be made available. There are many good use cases for it. I don't think it makes sense to hide this information on the basis of preventing developers from using it as a source of entropy for randomness.
Which use cases are that?
I used (height, tx_index) in the past which is a shorter way to identify a tx.
Sure thing! I'll do my best to explain in brief. The uses cases I'm exploring involve making authenticated statements in the event log, such that a MITM could not tamper with, say, the emitted TM WebSocket message. The issue with using [sender, block height, tx index] for the AAD (additional authenticated data) is that it does not include the execution's inputs and is not scoped to the chain. Since tx hash includes all TxBody bytes (incl, all execution inputs), using it for AAD would prevent a MITM from making false statements. In other words, the client would be able to verify the authenticity of the information (i.e., that it indeed came from executing the tx described in the TM event message).
Which use cases are that?
I used (height, tx_index) in the past which is a shorter way to identify a tx.
We'd like to see this feature added as well. The use case we have at Axelar is to include the tx hash in an on-chain identifier for a cross-chain message. The identifier is public facing, so using the tx hash is much better for readability, debugging, and indexing instead of the block height and tx index.
FYI we ended up implementing this ourselves on Secret Network: https://github.com/scrtlabs/SecretNetwork/commit/2262b6c1e55a1ddc2784374c25d094afc8eaa9d3 https://github.com/scrtlabs/SecretNetwork/commit/af0fbb4a850c8dc83cdea387b90c599d940ada9a
Pro: gives a block/tx identifier that can easily be used with other tools. Con: people will use it as a weak source of randomness.
In Ehtereum,
blockhash
is available as a global function in Solidity. In https://ethereum.stackexchange.com/questions/2664/is-it-possible-to-get-the-transaction-hash-from-within-a-solidity-function-call people seem to conclude that the transaction hash could be added but is currently not available. There it is also stated that the block hash of the current execution depends on the execution result. Do we have a similar issue in Cosmos?