[ANCHOR-1254]: V30 backfill builds an owner row from two transactions, locking out legacy owners and enabling a co-tenant KYC claim - #1975
Merged
Conversation
* refactor query to broadly select references * add explicit muxed account check in backfill logic
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns V30’s winner selection with V29 to prevent hybrid ownership records.
Changes:
- Selects the same earliest reference as V29.
- Decodes muxed IDs only when that winning reference is muxed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
JiahuiWho
approved these changes
Jul 16, 2026
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
V29__sep31_customer_id_owner.sqlbackfillssep31_customer_id_ownerby picking, per customer id, the earliest historical reference (any caller type) and recording that caller's account and JSONmemofield.V30__backfill_muxed_sep31_customer_id_owner.javathen repairs the memo for muxed callers, since a muxed sub-account id lives in the StrKeyaccountfield, not the JSONmemofield, and SQL alone can't decode it.The bug: V30 selected its own "winning" reference independently — the earliest reference among muxed references only — instead of checking whether the same transaction V29 already chose as the owner happened to be muxed. For a customer id whose earliest reference was a bare, non-muxed caller (so V29 leaves
creator_memonull) but which also has any later muxed reference, V30's independent query found that later reference, decoded its muxed id, and wrote it onto the row V29 built from the earlier, different transaction — producing an owner row combining one caller's account with a different caller's memo. That row matched neither the real owner nor the later caller, so the real owner's own requests failed the ownership check (SepNotAuthorizedException), and a co-tenant sub-account sharing the real owner's client name could pass the check for a customer id it didn't own.Fix: V30 now runs the identical reference-selection query V29 uses (same
refsunion, sameCOALESCE(client_name, account) IS NOT NULLfilter, sameORDER BY customer_id, started_at ASC NULLS LAST, id ASCtie-break) instead of a muxed-only variant, so it always lands on the exact same winning transaction per customer id that V29 already chose. It only decodes and sets a memo when that winning transaction's own account is muxed (startsWith("M")) — never from a different, independently-selected reference.Changes
V30__backfill_muxed_sep31_customer_id_owner.java:findWinningMuxedReferences(muxed-onlyWHEREclause) replaced withfindWinningReferences, an unfiltered-by-muxedness query identical to V29's own winner-selection logic; the muxed check (winningAccount.startsWith("M")) now happens in Java, after selecting the same per-customer-id winner V29 selected, not before.V29__sep31_customer_id_owner.sql: unchanged.Acceptance Criteria
(client_or_account, null)— the earliest transaction's own identity — not a hybrid of two different transactions.verifyOrClaimafter the migration; a co-tenant presenting a different, later muxed sub-account id does not.Context
HackerOne #3866121
Testing
org.stellar.sdk.MuxedAccountclass../gradlew :core:test :platform:test— BUILD SUCCESSFUL.Documentation
N/A
Known limitations
N/A