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

protocols/horizon: Change Transaction.AccountSequence to int64 #4409

Merged
merged 6 commits into from
May 27, 2022

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented May 25, 2022

PR Checklist

PR Structure

  • This PR has reasonably narrow scope (if not, break it down into smaller PRs).
  • This PR avoids mixing refactoring changes with feature changes (split into two PRs
    otherwise).
  • This PR's title starts with name of package that is most changed in the PR, ex.
    services/friendbot, or all or doc if the changes are broad or impact many
    packages.

Thoroughness

  • This PR adds tests for the most critical parts of the new functionality or fixes.
  • I've updated any docs (developer docs, .md
    files, etc... affected by this change). Take a look in the docs folder for a given service,
    like this one.

Release planning

  • I've updated the relevant CHANGELOG (here for Horizon) if
    needed with deprecations, added features, breaking changes, and DB schema changes.
  • I've decided if this PR requires a new major/minor version according to
    semver, or if it's mainly a patch change. The PR is targeted at the next
    release branch if it's not a patch change.

What

Change protocols/horizon.Transaction.AccountSequence to int64 from string.

Why

There shouldn't be any extra parsing required in Go since AccountSequence returned by Horizon will be always a valid int64 value. We can make sure the value is rendered as a string to support JS using string tag.

Known limitations

[TODO or N/A]

@bartekn bartekn force-pushed the horizon-accountsequence-int64 branch from 468b91c to 70b9753 Compare May 25, 2022 16:53
@bartekn bartekn marked this pull request as ready for review May 25, 2022 17:44
@bartekn bartekn requested a review from a team May 25, 2022 17:44
@@ -14,11 +14,12 @@ import (
)

func TestNewOperationAllTypesCovered(t *testing.T) {
tx := &history.Transaction{TransactionWithoutLedger: history.TransactionWithoutLedger{AccountSequence: "1"}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it help for consistency of AccountSequence type to also have 'TransactionWithoutLedget.AccountSequence' type int64 also?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sreuland sounds like yes! I didn't do it because I was thikning we store it as string in a db (so changing it would require reingestion or extra code for conversion) but we do actually store it as bigint! Fixed in: 4e38e8d.

Copy link
Contributor

@sreuland sreuland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@@ -511,7 +511,7 @@ type Transaction struct {
Account string `json:"source_account"`
AccountMuxed string `json:"account_muxed,omitempty"`
AccountMuxedID uint64 `json:"account_muxed_id,omitempty,string"`
AccountSequence string `json:"source_account_sequence"`
AccountSequence int64 `json:"source_account_sequence,string"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change to the Go SDK?

Also, we have some other fields like this (that are strings but could be int64s). We should probably do a pass to find them all (this came up briefly during P19).

Copy link
Contributor Author

@bartekn bartekn May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a breaking change to the Go SDK?

Yes, this is a breaking change. However this will probably allow Go SDK users to remove some conversion code. Are we ok with merging this into master?

Also, we have some other fields like this (that are strings but could be int64s). We should probably do a pass to find them all (this came up briefly during P19).

Sounds good. I changed this one because it simplifies the code in Starbridge. I did a quick pass and couldn't find anything else but if there are other instances of this we should definitely change them to ints.

Copy link
Member

@leighmcculloch leighmcculloch May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 We should do this. It moves validation of the response data into the SDK so if the response contained a non-integer string the failure would occur at response parsing rather than later on in application code, so this is a good move and I doubt anyone would be disappointed by it. Thanks for shipping it! Let's do this in all the integer fields we can.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a line to horizonclient CHANGELOG for visibility.

@bartekn bartekn merged commit 6af10a1 into stellar:master May 27, 2022
@bartekn bartekn deleted the horizon-accountsequence-int64 branch May 27, 2022 12:35
bartekn added a commit that referenced this pull request Jun 24, 2022
Change `protocols/horizon/Account.Sequence` to `int64` from `string`.

There shouldn't be any extra parsing required in Go since `Account.Sequence`
returned by Horizon will be always a valid int64 value. We can make sure the
value is rendered as a string to support JS using `string` tag.

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

Successfully merging this pull request may close these issues.

4 participants