Skip to content

fix(registry): skip accepts that cannot be stored instead of failing the resource (#1281) - #1282

Open
johnInarti wants to merge 1 commit into
Merit-Systems:mainfrom
johnInarti:fix/storable-accepts-int64
Open

johnInarti wants to merge 1 commit into
Merit-Systems:mainfrom
johnInarti:fix/storable-accepts-int64

Conversation

@johnInarti

Copy link
Copy Markdown

Fixes #1281.

Problem

register-origin and the resource sync fail the whole resource when a single accept cannot be stored:

  1. int64 overflow. Accepts.maxAmountRequired is Prisma BigInt (Postgres bigint, signed 64-bit). An 18-decimal token on Base priced above ~9.22 tokens does not fit; for example a peso stablecoin at 30.34 tokens is 30340000000000000000 atomic units. tx.accepts.upsert throws (Could not convert argument value ... BigInt ... to ArgumentValue) and the resource's perfectly storable USDC accept is lost with it. Reproduced against https://fractalai.net.co: 422 no_valid_resources, 8 of 10 resources failed.
  2. Same (scheme, network) twice. The unique key is resourceId_scheme_network, so when a server advertises USDC and another token on Base, the concurrent upserts race and a later accept can overwrite the server's preferred one.

Change

selectStorableAccepts(accepts) (new, pure, tested) is applied in upsertResource:

  • unsupported networks are skipped, as before (unsupportedAccepts keeps its previous meaning);
  • amounts above int64 are skipped instead of throwing;
  • only the first accept per (scheme, network) is kept, in the order the server advertised;
  • skipped accepts are logged with their reason.

No schema migration. Storing amounts above int64 (e.g. Decimal @db.Decimal(78,0)) is a larger change touching ~116 maxAmountRequired: bigint call sites; this PR only stops one unstorable accept from taking the resource down.

Tests

apps/scan/src/services/db/resources/storable-accepts.test.ts: 18-decimal amount above int64 skipped while USDC is kept, first-per-(scheme, network) wins, unsupported network still skipped, int64 boundary, non-integer strings. vitest run src/services/db/resources/ → 9/9. tsc shows no new errors (the 4 in resource.ts exist on main without a generated Prisma client).

…the resource

register-origin / sync failed the whole resource when one accept could not be stored:
- an 18-decimal token on Base (e.g. a peso stablecoin priced at 30.34 tokens = 30340000000000000000
  atomic units) overflows the int64 maxAmountRequired column and made tx.accepts.upsert throw,
  taking the resource's storable USDC accept down with it;
- several accepts on the same (scheme, network) raced on the unique key resourceId_scheme_network,
  so a later token could overwrite the server's preferred accept (typically USDC).

selectStorableAccepts keeps the advertised order, skips unsupported networks (as before),
skips amounts above int64 and keeps only the first accept per (scheme, network); skipped ones are
logged. Tests cover all three paths and the int64 boundary.

Fixes Merit-Systems#1281
@vercel

vercel Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@johnInarti is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

register-origin fails for 18-decimal stablecoins (int64 overflow on maxAmountRequired) and for arbitrum/worldchain/celo accepts

1 participant