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

all: Upgrade to protocol v12 #1776

Merged
merged 9 commits into from
Sep 26, 2019
Merged

all: Upgrade to protocol v12 #1776

merged 9 commits into from
Sep 26, 2019

Conversation

bartekn
Copy link
Contributor

@bartekn bartekn commented Sep 24, 2019

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.

Summary

This commit updates Go monorepo to support Stellar Protocol v12. The new version changes some XDR types and adds a new PathPaymentStrictSend operation (see: CAP-24).

Summary of changes

Below are per package changes added to support v12.

xdr package

  • XDR Go definitions have been regenerated using xdrgen.
  • Added PathPaymentStrictSendResult.DestAmount() helper method.

build package

Because this package is no longer supported the only changes are type name changes that allow the package to be compiled. No support for the new PathPaymentStrictSend operation.

services/horizon and protocols/horizon packages

  • Added a new PathPaymentStrictSend response to operation responses.
  • Added new error codes connected to PathPaymentStrictSend operation in POST /transactions.
  • Changed /payments to include path_payment_strict_send operations.
  • Updated history_trades table schema to allow amounts equal 0 (to support cases where ClaimOfferAtom contains amountSold = 0 and amountBought != 0).
  • Updated ingest package to support ingesting operations, effects and trades that result from path_payment_strict_send operations.

services/compliance package

Support for PathPaymentStrictSend in auth endpoint.

txnbuild package

Added support PathPaymentStrictSend support. Check next section for more information.

Known limitations & issues

  • Even though new operation has been implemented in Horizon's ingest package it has not been tested yet! New test scenarios are required but building them requires changes to scc (and scc requires changes to ruby SDK).
  • PathPaymentStrictSend has been added to txnbuild but there's an ongoing discussion whether we should release it now or after v12 upgrade. See: Update txnbuild to support stellar-core 12 (part 2 of 2) #1773.
  • Horizon schema change skips one number (21 vs 20) as 20 was used in Horizon 0.21.0 and it's not been merged into master yet.

@bartekn bartekn changed the title Upgrade to protocol v12 all: Upgrade to protocol v12 Sep 25, 2019
@bartekn bartekn marked this pull request as ready for review September 25, 2019 13:38
if err != nil {
return NewValidationError("DestMin", err.Error())
}

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to validate pp.Path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point but I think it's outside of scope of this PR (path_payment_strict_send.go is a copy of path_payment.go adjusted for strict send). Tracking in #1786.

@@ -741,10 +761,32 @@ func (is *Session) operationDetails() map[string]interface{} {
is.assetDetails(details, op.SendAsset, "source_")

if c.Transaction().IsSuccessful() {
result := c.OperationResult().MustPathPaymentResult()
result := c.OperationResult().MustPathPaymentStrictReceiveResult()
details["source_amount"] = amount.String(result.SendAmount())
Copy link
Contributor

Choose a reason for hiding this comment

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

if SendAmount() returns 0 if the transaction is not successful so maybe this line can be moved up and replace details["source_amount"] = amount.String(0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed!


if c.Transaction().IsSuccessful() {
result := c.OperationResult().MustPathPaymentStrictSendResult()
details["amount"] = amount.String(result.DestAmount())
Copy link
Contributor

Choose a reason for hiding this comment

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

if DestAmount() returns 0 if the transaction is not successful so maybe this line can be moved up and replace details["amount"] = amount.String(0)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed!

@bartekn bartekn merged commit 50b0a8d into stellar:master Sep 26, 2019
@bartekn bartekn deleted the protocol-v12 branch September 26, 2019 16:22
bartekn added a commit that referenced this pull request Oct 8, 2019
This commit updates Go monorepo to support Stellar Protocol v12. The new
version changes some XDR types and adds a new `PathPaymentStrictSend`
operation (see: CAP-24).

Below are per package changes added to support v12.

* XDR Go definitions have been regenerated using `xdrgen`.
* Added `PathPaymentStrictSendResult.DestAmount()` helper method.

Because this package is no longer supported the only changes are type
name changes that allow the package to be compiled. No support for the
new `PathPaymentStrictSend` operation.

* Added a new `PathPaymentStrictSend` response to operation responses.
* Added new error codes connected to `PathPaymentStrictSend` operation
in `POST /transactions`.
* Changed `/payments` to include `path_payment_strict_send` operations.
* Updated `history_trades` table schema to allow amounts equal `0` (to
support cases where `ClaimOfferAtom` contains `amountSold = 0` and
`amountBought != 0`).
* Updated `ingest` package to support ingesting operations, effects and
trades that result from `path_payment_strict_send` operations.

Support for `PathPaymentStrictSend` in auth endpoint.

Added support `PathPaymentStrictSend` support. Check next section for
more information.

* Even though new operation has been implemented in Horizon's `ingest`
package it has not been tested yet! New test scenarios are required but
building them requires changes to `scc` (and `scc` requires changes to
ruby SDK).
* `PathPaymentStrictSend` has been added to `txnbuild` but there's an
ongoing discussion whether we should release it now or after v12
upgrade. See: #1773.
* Horizon schema change skips one number (`21` vs `20`) as `20` was used
in Horizon 0.21.0 and it's not been merged into master yet.
bartekn added a commit that referenced this pull request Oct 10, 2019
In #1776 we changed code ingesting path payment operations to use helper
methods (`DestAmount()` and `SendAmount()`) without checking if
transaction is successful. The problem with that approach is that to
call helper methods we need result structs fetched using
`c.OperationResult()` however these may not exist if transaction was not
successful or failed with `txFAILED` because for other error codes
`results` slice is empty.

This commit reverts the code in `operationDetails` to check if tx is
successful before using helper methods. We also add a test to catch such
case.
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.

3 participants