-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Wrong TxHash sporadically calculated by TransactionUtil
class
#353
Comments
Some additional info. I've tested the This suggests that the To support this hypothesis there is also another thing I've observed, when I submit a tx, I also print the hash, and sporadically, I get:
I.e. for a transaction I craft in the code, the hash calculated might differ from the one returned by the code. While I write this I also realise that "some things" might be "reordered". Like for instance, inputs get reordered lexicographycally. Inability to reliably compute a tx hash for a transaction, prevents code from creating chained transactions. |
@nemo83 There's a known issue where deserializing and serializing a transaction using different tools can result in varying byte sequences. CCL employs canonical ordering (e.g. in maps) during serialization. Therefore, if you serialize, deserialize, and then serialize a transaction created by CCL, you will consistently obtain the same result. However, this may not hold true for transactions generated by other tools that do not adhere to canonical ordering. But, both types of transactions are valid during execution in node. This is why it's advisable to avoid fully deserializing and serializing a transaction when calculating its Tx hash. In the first method, However, if you're using a transaction built by an external tool or an already executed transaction to obtain the Tx hash, it's better to use This method should be correct most of the time, but we've encountered issues with only few transactions on the mainnet when using this approach with Yaci. So in Yaci, we avoid deserializing to DataItem altogether. The parser simply extracts the transaction body bytes from the full transaction bytes to create the hash. I think we should update |
@nemo83 Can you please verify the fix with your use case ? You can take the code from the below branch. Thanks https://github.com/bloxbean/cardano-client-lib/tree/fix_353_main |
Changes look good! Thank you |
fix: #353 Directly extract tx body bytes from tx bytes
There seems to be an issue that sporadically manifest in the method:
TransactionUtil.getTxHash(Transaction transaction)
From time to time a wrong hash is created.
The text was updated successfully, but these errors were encountered: