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

txnbuild: add muxed account & memo support to SEP-10 utility functions #4746

Merged
merged 23 commits into from
Jan 30, 2023

Conversation

JakeUrban
Copy link
Contributor

@JakeUrban JakeUrban commented Jan 24, 2023

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

resolves #3937

Adds support for muxed accounts to be specified as client account IDs and memos to be added to challenge transactions. This is a breaking change.

Why

SEP-10 was modified to support users of shared Stellar accounts. The two approaches to identifying users of a shared account, in the context of SEP-10, is by assigning each user a muxed account address or an integer memo.

Outstanding Questions

The Python SDK moved away from returning mutliple values from the BuildChallengeTx() and ReadChallengeTx() equivalent functions and instead introduced a ChallengeTransaction container object for all the relevant values. We could use this same approach in the Go SDK instead of adding an additional value to the existing set.

@JakeUrban JakeUrban changed the title add memo to BuildChallengeTx params and ReadChallengeTx return value add muxed account & memo support to SEP-10 utility functions Jan 24, 2023
@JakeUrban JakeUrban changed the title add muxed account & memo support to SEP-10 utility functions Add muxed account & memo support to SEP-10 utility functions Jan 24, 2023
@JakeUrban JakeUrban changed the title Add muxed account & memo support to SEP-10 utility functions txnbuild: add muxed account & memo support to SEP-10 utility functions Jan 25, 2023
@JakeUrban JakeUrban marked this pull request as ready for review January 25, 2023 17:06
@leighmcculloch leighmcculloch requested a review from a team January 25, 2023 17:26
Copy link
Contributor

@tsachiherman tsachiherman left a comment

Choose a reason for hiding this comment

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

Overall, I think that it looks good, but I do have few comments that would improve the code quality and readability.

@JakeUrban
Copy link
Contributor Author

Thanks @tsachiherman,

Independently from your comments, what do you think about the approach described in the "Outstanding Questions" section of the description? Should we stick we adding another return value or use a ChallengeTransaction struct?

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Thanks for expanding support for memos and muxeds in the SDK and also updating the webauth server too, this has been lacking for a while.

I left some comments inline.

txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
exp/services/webauth/internal/serve/challenge.go Outdated Show resolved Hide resolved
exp/services/webauth/internal/serve/token.go Outdated Show resolved Hide resolved
exp/services/webauth/internal/serve/token.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
@leighmcculloch
Copy link
Member

leighmcculloch commented Jan 25, 2023

The Python SDK moved away from returning mutliple values from the BuildChallengeTx() and ReadChallengeTx() equivalent functions and instead introduced a ChallengeTransaction container object for all the relevant values. We could use this same approach in the Go SDK instead of adding an additional value to the existing set.

I think a refactor like that should take place as an independent change either ahead of or after this change. I'd avoid making the change in the same pull request because it's really easy for the complexity of the diff to expand to the point where we miss subtle changes in the logic of these sensitive functions.

That aside, there are pros and cons.

I generally prefer a struct and I think it is more ergonomic. A side-effect of returning a struct is that each time we add a new field existing software will continue to work unchanged. This side-effect is usually a good thing because for most software consumers of values only need to be aware of a partial set of data contained in the value.

However, in the case of authentication it is usually important for the consumer of a value to be aware of the entire value. So for this code, while it is less ergonomic, I think the many return values actually play a beneficial role.

Co-authored-by: Leigh McCulloch <[email protected]>
@JakeUrban
Copy link
Contributor Author

Ok, thanks Leigh. We'll keep the use of multiple return values here.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

One comment outstanding above:

I think that there should be some tests added to the webauth service. There's a new parameter that's accepted, and new logic being added there.

For example:

Screenshot 2023-01-25 at 3 33 04 PM

Screenshot 2023-01-25 at 3 34 09 PM

@leighmcculloch
Copy link
Member

I noticed another couple spots without coverage that seem important:

Screenshot 2023-01-26 at 11 13 47 AM

Screenshot 2023-01-26 at 11 14 06 AM

I think this is an area that was previously untested, but given we're adding some more complexity to whether an account is valid or not, I think it's probably worth adding tests for both cases.

@JakeUrban
Copy link
Contributor Author

The 2nd check in first screenshot, where it errors if a memo and muxed account are provided, is tested. But I'll add tests for the 2 other checks.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻

exp/services/webauth/internal/serve/token.go Outdated Show resolved Hide resolved
@JakeUrban JakeUrban merged commit 295e520 into master Jan 30, 2023
@JakeUrban JakeUrban deleted the sep10-muxed-account-support branch January 30, 2023 18:57
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.

SEP-10: muxed account and memo support
3 participants