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

Expose block hash and tx hash #1086

Open
webmaster128 opened this issue Sep 9, 2021 · 5 comments
Open

Expose block hash and tx hash #1086

webmaster128 opened this issue Sep 9, 2021 · 5 comments
Labels

Comments

@webmaster128
Copy link
Member

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?

@blake-regalia
Copy link

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.

@webmaster128
Copy link
Member Author

Which use cases are that?

I used (height, tx_index) in the past which is a shorter way to identify a tx.

@blake-regalia
Copy link

blake-regalia commented Jun 15, 2023

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

@milapsheth
Copy link

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.

@blake-regalia
Copy link

FYI we ended up implementing this ourselves on Secret Network:
scrtlabs/SecretNetwork@2262b6c
scrtlabs/SecretNetwork@af0fbb4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants