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

TransactionId toString not returning the same value as the mirror nodes #1564

Closed
SamCullin opened this issue Apr 20, 2023 · 2 comments · Fixed by #1573
Closed

TransactionId toString not returning the same value as the mirror nodes #1564

SamCullin opened this issue Apr 20, 2023 · 2 comments · Fixed by #1573
Assignees
Labels
bug Something isn't working
Milestone

Comments

@SamCullin
Copy link

SamCullin commented Apr 20, 2023

Description

We are running CONSENSUSSUBMITMESSAGE transactions then we then query from the mirror nodes to find out the message sequence number. However, we randomly found that some messages could not be found. After some digging, we found that the TransactionId.toString() function was returning a timestamp string that did not match the values returned by the mirror node. This made searching for the generated message impossible without creating a custom toString for the TransactionIds.

This only happened when the transaction's nanoseconds begin with a 0.

Example transaction:
https://testnet.mirrornode.hedera.com/api/v1/transactions/0.0.2180436-1681876267-054802581

Example Messages:
https://testnet.mirrornode.hedera.com/api/v1/topics/0.0.4250176/messages?limit=100&order=desc&timestamp=gte%3A1681876267.054802581
Sequence number: 5

Looks like the culprit is this line:
https://github.com/hashgraph/hedera-sdk-js/blob/develop/src/transaction/TransactionId.js#L165
The nanoseconds need to be left padded with 0s for 9 chars

Steps to reproduce

const transactionId_str = '0.0.4163533@1681876267.054802581'

const transactionId_class = TransactionId.fromString(transactionId_str);

const transactionId_str2 = transactionId_class.toString();

let working = transactionId_str == transactionId_str2;

console.log(working);

Additional context

No response

Hedera network

mainnet, testnet, previewnet, other

Version

v2.23.0

Operating system

Linux

@SamCullin SamCullin added the bug Something isn't working label Apr 20, 2023
@ochikov
Copy link
Contributor

ochikov commented Apr 21, 2023

Hello @SamCullin and thank you for your issue. We are going to schedule it for fixing for our next release. Will keep you updated.

@Neurone
Copy link
Contributor

Neurone commented Apr 24, 2023

Padding to 9 chars in the SDK seems a good idea.

As a side note, you can retrieve the sequence number of the message directly using the consensus timestamp instead of searching for the TransacionId, in your example it would be https://testnet.mirrornode.hedera.com/api/v1/topics/messages/1681876277.308591360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants