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: SEP 10 challenge builder #1468

Merged
merged 9 commits into from
Jul 16, 2019

Conversation

ire-and-curses
Copy link
Member

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

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.

Summary

Goal and scope

This PR addresses #1466.

Summary of changes

A new factory method txnbuild.BuildChallengeTx() returns a SEP 10 compatible "challenge" transaction.

Known limitations & issues

This is almost finished, but not quite. It still needs testing, and the envelope currently being produced appears to be invalid according to Stellar Laboratory.

Needs adding to the Changelog. An example of use should be added to the docs.

The code will need to be reworked in v2.0. This is indicated by Action needed tags.

What shouldn't be reviewed

All to be reviewed.

@ire-and-curses ire-and-curses added the txnbuild 2nd-generation transaction build library for Go SDK label Jul 2, 2019
@ire-and-curses ire-and-curses requested review from bartekn and poliha July 2, 2019 23:24
@poliha poliha changed the base branch from master to release-horizonclient-v1.3.0 July 3, 2019 13:51
@poliha poliha changed the base branch from release-horizonclient-v1.3.0 to master July 3, 2019 13:55
@poliha poliha marked this pull request as ready for review July 3, 2019 13:56
Copy link
Member Author

@ire-and-curses ire-and-curses left a comment

Choose a reason for hiding this comment

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

I can't formally review this since I authored the PR :) Some questions below.

txnbuild/transaction.go Outdated Show resolved Hide resolved
txTimebound := NewInfiniteTimeout()

if timebound > 0 {
txTimebound = NewTimebounds(time.Now().UTC().Unix(), time.Now().UTC().Unix()+timebound)
Copy link
Member Author

Choose a reason for hiding this comment

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

can use the helper method NewTimeout() here instead

Copy link
Contributor

Choose a reason for hiding this comment

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

Just following the spec here. The timebound should be {min: now(), max: now() + 300 }.
NewTimeout gives {min: 0, max: now() + 300 }.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, that's annoying. Ok, makes sense. Can we make just one call to Now and store in a temporary variable? That will guarantee that the timebound is always the right length.

txnbuild/transaction.go Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
txnbuild/transaction.go Outdated Show resolved Hide resolved
@poliha
Copy link
Contributor

poliha commented Jul 4, 2019

@bartekn good catch for the network passphrase. We should probably hold off on this until we get more information on that. I see that you opened an issue for it, will track there.

@tomquisel
Copy link
Contributor

@poliha this has been clarified in SEP-10 so I think this PR is unblocked.

Copy link
Contributor

@bartekn bartekn left a comment

Choose a reason for hiding this comment

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

LGTM! Just two minor things.

}

// generateRandomString creates a base-64 encoded, cryptographically secure random string of `n` bytes.
func generateRandomString(n int) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this function return []byte? You need to hex decode this in BuildChallengeTx.

// tx envelope returned here is ignored because it will be different for each run and cause tests to fail
_, err := BuildChallengeTx(serverSignerSeed, clientAccountID, anchorName,
network.TestNetworkPassphrase, timebound)
check(err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a simple sanity check (if tx contains manage_data operation with a correct name) would be great to have.

@tomquisel
Copy link
Contributor

Shouldn't this be merged into the next minor release branch since it adds a feature? No point reverting it this time, but I just wanted to double check that my understanding is right.

@poliha
Copy link
Contributor

poliha commented Jul 16, 2019

@tomquisel Yes that would have been the case but we don't have the next minor release branch yet because we just pushed put v1.3. We will base the next release branch off master so this will be in there for sure.

@abuiles
Copy link
Contributor

abuiles commented Jul 22, 2019

Implementation for the js-sdk here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
txnbuild 2nd-generation transaction build library for Go SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants