feat(anchors): validate canonical asset-issuer per anchor (USDC issuer match)#614
Open
Olorunfemi20 wants to merge 1 commit into
Open
feat(anchors): validate canonical asset-issuer per anchor (USDC issuer match)#614Olorunfemi20 wants to merge 1 commit into
Olorunfemi20 wants to merge 1 commit into
Conversation
Guard against look-alike assets that reuse a trusted code (e.g. "USDC") under an impostor issuer by checking each anchor's advertised issuer against the canonical one it is registered to settle. - lib/stellar/anchors.ts: add validateAnchorAssetIssuer(), a pure comparison of an anchor's registered assetIssuer against the issuer it advertises for the same code in its resolved stellar.toml CURRENCIES. Wire a non-fatal warning into discoverAnchorsForCorridor for mismatches. - scripts/validate-anchors.mjs: parse [[CURRENCIES]] from each probed toml, resolve the expected issuer (inline literal or USDC_ISSUER from env), and flag mismatches with a ::warning:: in the nightly run without touching the degraded health ledger. Closes ezedike-evan#489
|
@Olorunfemi20 is attempting to deploy a commit to the ezedikeevan's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Olorunfemi20 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
ezedike-evan
left a comment
Owner
There was a problem hiding this comment.
CI workflows haven't triggered for this PR yet. Please push an empty commit or close and reopen to re-trigger GitHub Actions and wait for check (node 20) and check (node 22) to go green before this can merge.
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.
Summary
Validates that each anchor settles the canonical asset issuer it is registered to, rather than a look-alike asset that merely reuses a trusted code such as
USDCunder an impostor issuer. Implements B056.The anchor registry (
constants/anchors.ts) records each anchor's canonicalassetIssuer(USDC anchors useUSDC_ISSUER). This change compares that canonical issuer against the issuer the anchor actually advertises for the same asset code in its resolvedstellar.toml[[CURRENCIES]], and flags any mismatch.Changes
lib/stellar/anchors.tsvalidateAnchorAssetIssuer(anchor, currencies)— a pure, synchronous comparison returningmatch/mismatch/missingplus the expected and advertised issuers. Exported (withAnchorIssuerStatus/AnchorIssuerValidation) for reuse by the app, the nightly validator, and tests.discoverAnchorsForCorridor: a resolved anchor advertising a look-alike issuer is logged loudly but not dropped, since the registry's canonical issuer still governs downstream SEP-38 identifiers. Only a truemismatchwarns; amissingissuer does not.scripts/validate-anchors.mjsparseAnchorsnow also extractsassetCodeandassetIssuer(inline literal or aUSDC_ISSUERreference) from the registry source.parseCurrencies,resolveExpectedIssuer, andvalidateIssuerhelpers (dependency-free TOML scanning, mirroring the lib logic).::warning::listing any anchors that advertise a look-alike issuer. This is kept entirely separate from the degraded health ledger.Acceptance criteria
Met:
validateIssuer/validateAnchorAssetIssuerreturnmismatchwhen an anchor advertises a different issuer for its asset code, and the script surfaces it as a::warning::. A missing or absent issuer is reported distinctly (missing/unverifiable) and is not treated as a false positive.Testing
tests/anchors-issuer.spec.ts— unit tests forvalidateAnchorAssetIssuer(match / mismatch / missing / other-code isolation).tests/validate-anchors.spec.mjs— added coverage forparseAnchorsasset fields,parseCurrencies,resolveExpectedIssuer, andvalidateIssuer.npm run typecheck,eslint --max-warnings 0, andprettier --checkpass on the changed files.MATCHagainst their canonical issuers; anchors that publish no USDC currency reportMISSING(correctly, not a mismatch).Closes #489