Skip to content

perf(scan): skip eth_getLogs factory walk in global LabelProvider#75

Merged
github-actions[bot] merged 1 commit into
mainfrom
perf/scan-label-provider-no-evm-walk
May 12, 2026
Merged

perf(scan): skip eth_getLogs factory walk in global LabelProvider#75
github-actions[bot] merged 1 commit into
mainfrom
perf/scan-label-provider-no-evm-walk

Conversation

@satyakwok
Copy link
Copy Markdown
Member

@satyakwok satyakwok commented May 12, 2026

Summary

Problem: Browser-walked scan v1 home page → 200+ RPC POSTs to rpc.sentrixchain.com within ~30s of cold page load. Source: LabelProvider (root layout, fires on every page mount) calls fetchTokens(network), which fans out to a 117-chunk eth_getLogs walk against TokenFactory v1.1.0 covering ~590K blocks since deploy.

Fix: Split out fetchTokensForLabels = fetchNativeTokens — REST-only, no factory walk. Used by LabelProvider. Pages that actually consume the EVM token list (/tokens, TokenRanking) keep calling the full fetchTokens which still walks.

Why it's safe

  • Native token entries from /tokens REST endpoint (currently empty on mainnet) still feed LabelProvider.
  • Validator names, treasury labels, governance addresses, premine wallets all come from STATIC_LABELS + fetchValidators + fetchAccountsTop — unaffected.
  • EVM token symbols only show as labels on tx-list / address-list rows. Currently scan v1 has 2 factory-deployed tokens (SGC + TECU). Their badges won't appear in tx lists until either (a) a user visits the token detail page (which triggers its own fetch) or (b) the chain /tokens REST endpoint starts returning EVM-factory entries (chain-side indexer follow-up).

Verification

curl https://api.sentrixchain.com/tokens
# { "tokens": [], "total": 0 } — REST endpoint returns empty, so this PR doesn't lose anything that was rendering

Before: home page network panel shows ~200 POSTs to rpc.sentrixchain.com in the first minute (mostly eth_getLogs from the walk).
After: ~10 POSTs (viem block-watch only).

Test plan

  • Open scan.sentrixchain.com/en → confirm no eth_getLogs burst in network panel
  • Open scan.sentrixchain.com/en/tokens → confirm SGC + TECU still render (own useTokens walk)
  • pnpm --filter=@sentriscloud/scan typecheck green (verified locally)

Summary by CodeRabbit

  • Performance Improvements
    • Optimized token label loading by switching to a more efficient data retrieval method, reducing latency and improving responsiveness when accessing token label information throughout the application.

Review Change Stack

LabelProvider sits in the root layout and runs on every page mount. Its
token-fetch was calling fetchTokens(network), which fans out to a 117-chunk
eth_getLogs walk against the TokenFactory v1.1.0 (deploy block → tip in
5000-block windows). That hammered rpc.sentrixchain.com with ~117 POSTs on
every cold page load, even on pages that don't render any token symbols.

Caught while browser-walking scan v1: opening /en kicks off the burst within
the first 30 seconds, idle page-load network panel shows 200+ RPC POSTs.
fetchEvmTokensFromFactory itself caches for 5 min, but the labels role is
"address → name" label resolution where EVM tokens are nice-to-have, not
load-bearing — and the dedicated /tokens page + per-contract pages already
fetch EVM token symbols on their own.

Fix splits out fetchTokensForLabels = fetchNativeTokens (single REST call),
used by LabelProvider only. fetchTokens stays as-is for /tokens and token-
leaderboard which actually need the EVM list.

Native token entries (currently empty on mainnet — /tokens REST returns
[]) plus the hard-coded STATIC_LABELS continue to cover validator,
treasury, ecosystem, premine, and SentrixSafe labels — no visible label
regression on inspection.
@github-actions github-actions Bot enabled auto-merge (squash) May 12, 2026 21:14
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6bd73adb-d6d5-48fb-9021-0e76d0476126

📥 Commits

Reviewing files that changed from the base of the PR and between 348ab67 and a92ca93.

📒 Files selected for processing (2)
  • apps/scan/lib/api.ts
  • apps/scan/lib/labels.tsx

📝 Walkthrough

Walkthrough

This PR optimizes token label resolution by introducing fetchTokensForLabels, a lightweight REST-only variant that replaces the heavier EVM factory log walk. A new export in api.ts aliases fetchTokensForLabels to the existing fetchNativeTokens function. The LabelProvider in labels.tsx is updated to call fetchTokensForLabels instead of fetchTokens during its network effect, reducing overhead while maintaining the same downstream logic for building label entries from token data.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: replacing the heavy eth_getLogs factory walk with a lighter approach in the LabelProvider, which is the core performance optimization.
Description check ✅ Passed The description covers all required template sections with substantial detail: Summary explains the problem and fix clearly, Why it's safe provides important context, Verification demonstrates the improvement, and Test plan provides checkboxes for manual testing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/scan-label-provider-no-evm-walk

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot merged commit c3bde44 into main May 12, 2026
6 checks passed
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