-
Notifications
You must be signed in to change notification settings - Fork 503
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
Conversation
if err != nil { | ||
return NewValidationError("DestMin", err.Error()) | ||
} | ||
|
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, changed!
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.
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.
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
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
packagexdrgen
.PathPaymentStrictSendResult.DestAmount()
helper method.build
packageBecause 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
andprotocols/horizon
packagesPathPaymentStrictSend
response to operation responses.PathPaymentStrictSend
operation inPOST /transactions
./payments
to includepath_payment_strict_send
operations.history_trades
table schema to allow amounts equal0
(to support cases whereClaimOfferAtom
containsamountSold = 0
andamountBought != 0
).ingest
package to support ingesting operations, effects and trades that result frompath_payment_strict_send
operations.services/compliance
packageSupport for
PathPaymentStrictSend
in auth endpoint.txnbuild
packageAdded support
PathPaymentStrictSend
support. Check next section for more information.Known limitations & issues
ingest
package it has not been tested yet! New test scenarios are required but building them requires changes toscc
(andscc
requires changes to ruby SDK).PathPaymentStrictSend
has been added totxnbuild
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.21
vs20
) as20
was used in Horizon 0.21.0 and it's not been merged into master yet.