Repository navigation
[ANCHOR-1319]: Parse a muxed transaction source in the ledger helper - #2095
Open
ceciliaromao wants to merge 4 commits into
Open
ceciliaromao wants to merge 4 commits into
ceciliaromao wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
LedgerClientHelper.parseOperationAndSourceAccountAndMemonow accepts a transaction whose source is a muxed account (M..., CAP-0027), both for a V1 envelope and for the inner transaction of a fee bump. The source is resolved by a newresolveTransactionSourcehelper that switches on theMuxedAccountdiscriminant and returns the baseG...address, the same shaperesolveSourceAccountalready returns for an operation source.getEd25519()only, which isnullfor a muxed source, so it threw aNullPointerException. That exception is not aLedgerDecodeException, so it escapedHorizon.getTransactionandStellarRpc.fromGetTransactionResponse.null, like its other unparseable-envelope cases. The XDR union has no other arm, so this only completes the switch.Context
PUBLISHER_ERRORon the same operation and madenotify_onchain_funds_received/notify_onchain_funds_sentfail for that transaction. This is the fix for a reported security finding.LedgerDecodeExceptionwas ruled out: that path skips the operation and advances the cursor, which would silently drop a legitimate payment. The parser has to support the muxed arm instead.G...address because that is what the rest of the platform expects (from_accountis aG...everywhere, and Horizon reportssource_accountthe same way). Nothing reads the source's muxed id.convert()is a different bug and is not part of this change.Testing
./gradlew test./gradlew :core:test --tests "org.stellar.anchor.ledger.LedgerClientHelperTest": 6 new tests. A muxed V1 source and a muxed fee-bump inner source parse to the baseG..., for muxed ids 0, 1 and 2^64-1. A payment without an operation source is attributed to the baseG..., and a payment with its own operation source keeps it. An unknown key type returnsnullwithout throwing. The existing ed25519 V0, V1 and fee-bump tests are the controls../gradlew :core:test --tests "org.stellar.anchor.ledger.MuxedTransactionSourceTest": 5 new tests that run a real muxed-source payment throughHorizon.getTransaction(V1 and fee bump),StellarRpc.fromGetTransactionResponse(V1 and fee bump) andwaitForTransactionAvailable.NullPointerExceptionondevelopand pass with this change.Documentation
N/A: no documentation change, this is a bug fix.
Known limitations
LedgerTransaction.sourceAccount; only the baseG...is kept.getTransaction, so the fix is covered one layer below, in the real Horizon and RPC parse paths.