Skip to content

fix: fallback token holders for hot tokens#891

Draft
o-az wants to merge 5 commits intomainfrom
fix/token-holders-query
Draft

fix: fallback token holders for hot tokens#891
o-az wants to merge 5 commits intomainfrom
fix/token-holders-query

Conversation

@o-az
Copy link
Copy Markdown
Member

@o-az o-az commented Apr 28, 2026

Summary

  • avoid expensive full holder aggregation for high-activity tokens
  • add a recent-participant fallback that reads current balanceOf values and sorts positive balances
  • update holder balance aggregation tests for split incoming/outgoing queries

Validation

  • pnpm check:types
  • pnpm vitest run test/tempo-queries.test.ts -t "fetchTokenHolderBalances"
  • pnpm check:env
  • pnpm check:biome

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

Bundle Size Report

Metric Size Δ Change
Total 4.3 MB +69.0 KB (+1.6%)
Gzip 1.2 MB +21.1 KB (+1.7%)
Brotli 1.1 MB +18.5 KB (+1.7%)
Chunk changes (>1KB)
Chunk Change
assets/AbiItem.js (removed) -27.1 KB
assets/tempo-address.js +1.1 KB
assets/_address.js +1.2 KB
assets/TxTransactionRow.js +1.5 KB
assets/token.js +1.6 KB
assets/tempo-queries.js +2.4 KB
assets/schemas.js +7.5 KB
assets/parseAbiItem.js (new) +25.0 KB
assets/wagmi.config.js +27.1 KB
assets/queries.js +27.2 KB

Compared against main branch (baseline from 4/27/2026, 4:02:54 PM)

@github-actions
Copy link
Copy Markdown

Cloudflare Deployments

App Environment Status Preview
explorer devnet [OK] Deployed -
explorer mainnet [OK] Deployed -
explorer testnet [OK] Deployed -
fee-payer devnet [>>] Skipped No changes
fee-payer moderato [>>] Skipped No changes
fee-payer privy [>>] Skipped No changes
og - [>>] Skipped No changes
perf - [>>] Skipped No changes
tokenlist - [>>] Skipped No changes

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ceede74483

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/explorer/src/lib/server/token.ts Outdated
Comment thread apps/explorer/src/lib/server/token.ts Outdated
@o-az
Copy link
Copy Markdown
Member Author

o-az commented Apr 28, 2026

Follow-up pushed in 0024bee.

Addresses Codex review comments:

  • Recent participant lookup failures now retry full holder aggregation before falling back to an empty response.
  • balanceOf failures now throw instead of silently zeroing holders/caching bad data.

Also kept RPC changes local to Explorer: server-side wagmi now uses the proxy RPC URL with key plus the normal RPC URL with key via the existing load balancer/rate limiter; no shared rpc-utils package changes.

@o-az
Copy link
Copy Markdown
Member Author

o-az commented Apr 28, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0024bee189

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/explorer/src/lib/server/token.ts Outdated
Comment on lines +191 to +194
recentParticipants.length >=
HOLDERS_RECENT_PARTICIPANT_FULL_QUERY_THRESHOLD
) {
allHolders = await fetchRecentHolderBalances({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not skip full holder aggregation on activity heuristic

This branch turns the “recent participant” path into the primary path whenever activity is high, so allHolders is built from a small candidate set instead of the full transfer-derived holder set. Because candidates are limited to recent addresses, tokens with many older/inactive holders will return incomplete holder lists and inaccurate totals/pagination metadata even when fetchTokenHolderBalances would succeed, which is a correctness regression rather than a true fallback.

Useful? React with 👍 / 👎.

@o-az
Copy link
Copy Markdown
Member Author

o-az commented Apr 28, 2026

Addressed discussion_r3152152874 in 47987c3. The holders endpoint now tries full transfer-derived aggregation first on cache miss, and only uses the recent-participant balanceOf path if full aggregation fails. That keeps recent participants as a true fallback rather than using activity as a correctness-changing heuristic.

Verified with:

  • pnpm check:types
  • pnpm check:biome
  • pnpm vitest run test/tempo-queries.test.ts -t fetchTokenHolderBalances
  • pnpm check:env

Also rechecked the PathUSD holders URL locally; it still renders holder rows via fallback when full aggregation fails.

@o-az
Copy link
Copy Markdown
Member Author

o-az commented Apr 28, 2026

Also fixed the noisy unverified contract source response in f9d8db4. /api/code now maps upstream 404/unverified source to 204 No Content with a short cache, and the client treats both 204 and legacy 404 as no source (null).

Verified with:

  • pnpm check:types
  • pnpm check:biome
  • curl against the PathUSD URL now returns HTTP 204 instead of 404.

@o-az
Copy link
Copy Markdown
Member Author

o-az commented Apr 28, 2026

Follow-up for PathUSD holder totals pushed in b55a0aa. The fallback path is not an exact holder-count source; it samples recent transfer participants and reads balances because full TIDX aggregation is failing. So the UI should not render 24, 26, or > 26 as a total.

Now the holders response carries totalKnown; when full aggregation fails and we use the recent-participant fallback, the page hides the holder total/count and uses indefinite pagination (1 of …) instead.

Also checked kitty pane 9: it is still showing TIDX 422s for the full holder aggregation (group by to/from) plus the existing workerd cross-request promise warnings.

@o-az o-az marked this pull request as draft April 28, 2026 07:26
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.

1 participant