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

Sequence JSON return types are inconsistent across methods #1081

Closed
ElliotFriend opened this issue Nov 14, 2023 · 4 comments · Fixed by #1097
Closed

Sequence JSON return types are inconsistent across methods #1081

ElliotFriend opened this issue Nov 14, 2023 · 4 comments · Fixed by #1097
Assignees
Labels
bug Something isn't working

Comments

@ElliotFriend
Copy link
Contributor

I've noticed that the ledger sequence number isn't always returned as the same type in some of the Soroban-RPC methods. The getLatestLedger method returns the sequence as a uint32. Elsewhere when a ledger's sequence number is returned, it's stringified in the JSON response.

I could've sworn I noticed this same kind of thing with a protocolVersion field in two of the methods, but I'm not finding it now. I might've just been conflating some things in my head.

@ElliotFriend ElliotFriend added the bug Something isn't working label Nov 14, 2023
@ElliotFriend
Copy link
Contributor Author

For some additional details and context, here are all the occurrences I can find of a ledger sequence number in the methods, and how it's returned

method name return name struct type json type
getLatestLedger sequence uint32 n/a
getLedgerEntries lastModifiedLedgerSeq int64 string
getLedgerEntries liveUntilLedgerSeq *uint32 string
getLedgerEntries latestLedger int64 string
getEvents ledger int32 string
getTransaction latestLedger int64 string
getTransaction oldestLedger int64 string
getTransaction ledger int64 string
sendTransaction latestLedger int64 string
simulateTransaction latestLedger int64 string

Seems like it's only returned as a number in the getLatestLedger method. I am curious if there's a significance or reasoning behind the use of int64 vs. uint32 vs. int32 vs. *uint32 in the structs, though? Maybe that's just how the data is retrieved from stellar core?

@leighmcculloch
Copy link
Member

Ledger sequences are uint32 in the xdr, so I don't think we need to be communicating the sequence as a int64 or as a string. It looks like most of the fields need updating.

See:
https://github.com/stellar/stellar-xdr/blob/6a620d160aab22609c982d54578ff6a63bfcdc01/Stellar-ledger.x#L82

@ElliotFriend
Copy link
Contributor Author

Looks like there's also some discrepancies between ledger close time representations. latestLedgerCloseTime, oldestLedgerCloseTime, and createdAt in the getTransaction method return a unix timestamp (1699997993); same with latestLedgerCloseTime in the sendTransaction method. However, in the getEvents method, ledgerClosedAt is returned as an ISO-8601 timestamp (2023-11-14T02:42:23Z)

@mollykarcher mollykarcher moved this from Backlog to Next Sprint Proposal in Platform Scrum Nov 15, 2023
@mollykarcher
Copy link
Contributor

The change to getLatestLedger will be breaking for downstream systems, so we'll need to make sure to alert downstream SDK providers about this (possibly just a comment on the existing issues we sent out)

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
Status: Done
4 participants