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

xdr: Enforce asset ordering in xdr pool #3865

Merged
merged 9 commits into from
Sep 2, 2021

Conversation

paulbellamy
Copy link
Contributor

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

Enforce asset ordering in xdr.NewPoolId.

Why

To try to catch potential bugs early.

Known limitations

[TODO or N/A]

Sorry, something went wrong.

xdr/pool_id.go Outdated Show resolved Hide resolved
xdr/pool_id.go Outdated Show resolved Hide resolved
@paulbellamy paulbellamy force-pushed the enforce-asset-ordering-xdr-pool-id branch from b89f700 to 4bb35c8 Compare August 31, 2021 16:24
xdr/pool_id_test.go Outdated Show resolved Hide resolved
txnbuild/asset.go Outdated Show resolved Hide resolved
xdr/pool_id_test.go Show resolved Hide resolved
xdr/asset.go Outdated Show resolved Hide resolved
@paulbellamy paulbellamy force-pushed the enforce-asset-ordering-xdr-pool-id branch from a5fd691 to 6d97293 Compare September 1, 2021 11:55
txnbuild/asset.go Show resolved Hide resolved
if _, ok := max.SetString(maxPrice); !ok {
return LiquidityPoolDeposit{}, errors.Errorf("cannot parse maxPrice: %v", minPrice)
}
maxPrice = max.Inv(max).FloatString(7)
Copy link
Contributor

Choose a reason for hiding this comment

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

Given there can be rounding error after the price inversion I wonder if we should simply return an error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, was debating that as well...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per discussion, this opens a can of worms. Let's just go back to throwing an error if the assets are out-of-order. That is the safest option, matches the JS SDK, and shouldn't happen often IRL, as the assets returned from horizon will be in-order.

@paulbellamy paulbellamy force-pushed the enforce-asset-ordering-xdr-pool-id branch from 9306059 to 3d8cb9e Compare September 2, 2021 15:39
@paulbellamy paulbellamy merged commit 958a010 into amm Sep 2, 2021
@paulbellamy paulbellamy deleted the enforce-asset-ordering-xdr-pool-id branch September 2, 2021 17:14
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.

None yet

6 participants