-
Notifications
You must be signed in to change notification settings - Fork 501
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: Reenable Multiplexed strkeys (SEP23 M-addresses) behind flags #3527
txnbuild: Reenable Multiplexed strkeys (SEP23 M-addresses) behind flags #3527
Conversation
@tamirms Operation-tests (which are cooking) and #3527 (comment) aside, this is ready for review. PTAL while I am on it so that we can reach the release quicker. Same for @bartekn (but I know he is off today :) ). |
result, ok := xdrOp.Body.GetPathPaymentStrictReceiveOp() | ||
if !ok { | ||
return errors.New("error parsing path_payment operation from xdr") | ||
} | ||
|
||
pp.SourceAccount = accountFromXDR(xdrOp.SourceAccount) | ||
pp.SourceAccount = accountFromXDR(xdrOp.SourceAccount, withMuxedAccounts) | ||
if withMuxedAccounts { |
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.
I think accountFromXDR can be used to assign to pp.Destination
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.
Not really, because accountFromXDR()
accepts nil
values.
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.
Really exciting to see this rolling.
I left comments about a couple things I think we should change (❗).
If you're open, I also left some suggestions (💡) that are to do with how the API is changing for the user, and how I think we could make the API is easier to understand.
ed74412
to
0a6beda
Compare
@@ -13,10 +13,14 @@ type AccountMerge struct { | |||
} | |||
|
|||
// BuildXDR for AccountMerge returns a fully configured XDR Operation. | |||
func (am *AccountMerge) BuildXDR() (xdr.Operation, error) { | |||
func (am *AccountMerge) BuildXDR(withMuxedAccounts bool) (xdr.Operation, 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.
Nit: I know this PR has been reviewed multiple times but I have one (simple) idea how to improve the API. Passing bool value to methods can be misleading (user need to check the description of the method to understand what is the param). We can create additional extra methods for each method accepting withMuxedAccounts
. BuildXDR
as an example:
- Change
BuildXDR(withMuxedAccounts bool) (xdr.Operation, error)
tobuildXDR(withMuxedAccounts bool) (xdr.Operation, error)
BuildXDR()
stays in a form before this PR. CallsbuildXDR(false)
internally.- A new
BuildXDRWithMuxedAccounts()
is added and callsbuildXDR(true)
internally.
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.
@bartekn that's exactly what I implemented originally and I discarded after the design discussion. Please see 27a79c6#diff-0ef2e7d165d2f196939c937afadef91206823b0671f32120b265843fd291332aR15 and the issue body edit history (which originally presented the same design you suggested, symbol-naming aside).
We should be more cohesive when discussing designs (but that's for a retro discussion). The purpose of creating an early draft a week ago was exactly avoiding this type of situation.
I personally think this needs to go out (it's already late) but if @ire-and-curses thinks it's worth another rewrite, I will cave in and restore my original design.
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.
@ire-and-curses In order to get more context on what happened:
- I originally proposed what @bartekn is proposing now (you can go through the edit history of the issue body and see it).
- @tamirms suggested using an internal boolean (appended to each operation struct) at txnbuild: Reenable Multiplexed strkeys (SEP23 M-addresses) behind flags #3527 (comment)
- We discarded it at txnbuild: Reenable Multiplexed strkeys (SEP23 M-addresses) behind flags #3527 (comment) and went for the design as it is now.
- I proceed to implement the design for all the operations.
- @leighmcculloch proposed yet another design modification at txnbuild: Reenable Multiplexed strkeys (SEP23 M-addresses) behind flags #3527 (comment) which I discarded.
- @bartekn suggests my original design.
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.
- Profit??!!
Let's discuss in team meeting today. I really want to get this out.
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.
We decided offline to keep it as it is. Thanks for the suggestion though @bartekn
Feature summary: - Operations updated to support muxed accounts: * Operation.sourceAccount * Payment.destination * PathPaymentStrictReceive.destination * PathPaymentStrictSend.destination * AccountMerge.destination * Transaction.sourceAccount - M... addresses can be converted to & from their XDR representation easily - Muxed accounts can be created & managed efficiently w/ helpers (MuxedAccount) - Feature is hidden behind an opt-in flag (`withMuxing` boolean) Limitations: - The final missing implementation detail is adapting `FeeBumpTransaction.feeSource` to accept an M-address, but this will not (and _should not_) be a part of this pull request because it involves a breaking change. Currently, `TransactionBuilder.buildFeeBumpTransaction` takes `feeSource` typed to `Keypair`, which doesn't support M-addresses. Either Keypair will need to support M-addresses (unlikely, as this breaks abstraction barriers) or the type will need to change (likely), so this will be part of a breaking 6.0 release. See #422. More reading: - CAP-27 (muxed account XDR), - SEP-23 (M-addresses), - stellar/stellar-protocol#617 (rollout plan) - stellar/go#3527 (Go SDK reference impl.)
Feature summary: - Operations updated to support muxed accounts: * Operation.sourceAccount * Payment.destination * PathPaymentStrictReceive.destination * PathPaymentStrictSend.destination * AccountMerge.destination * Transaction.sourceAccount - M... addresses can be converted to & from their XDR representation easily - Muxed accounts can be created & managed efficiently w/ helpers (MuxedAccount) - Feature is hidden behind an opt-in flag (`withMuxing` boolean) Limitations: - The final missing implementation detail is adapting `FeeBumpTransaction.feeSource` to accept an M-address, but this will not (and _should not_) be a part of this pull request because it involves a breaking change. Currently, `TransactionBuilder.buildFeeBumpTransaction` takes `feeSource` typed to `Keypair`, which doesn't support M-addresses. Either Keypair will need to support M-addresses (unlikely, as this breaks abstraction barriers) or the type will need to change (likely), so this will be part of a breaking 6.0 release. See #422. More reading: - CAP-27 (muxed account XDR), - SEP-23 (M-addresses), - stellar/stellar-protocol#617 (rollout plan) - stellar/go#3527 (Go SDK reference impl.)
Fixes #3490
This is
an initial RFC drafta PR to re-introduce Multiplexed addresses in txnbuild, considering all the requirements from #3490 .My main criteria for this proposal has been that no user should be enabling M-addresss unknowingly, either for new or existing code. For that reason:
Key changes:
txnbuild.Operation
interface now adds awithMuxedAccount
parameter to most of its methods:For now, onlytxnbuild.AccountMerge
supports the extended interface.NewTransaction()
,TransactionFromXDR()
andNewFeeBumpTransaction()
now accept an option to enable SEP23, while keeping backwards compatibilityTODO:
SEP23
-methods in all operationsAdd support forWe agreed offline not to do it.SEP23
in the theSEP10
functions (BuildChallengeTx()
,ReadChallengeTx()
...). I am not even sure we should, TBH (I would appreciate feedback on this).