perf(scan): skip eth_getLogs factory walk in global LabelProvider#75
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR optimizes token label resolution by introducing Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
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) callsfetchTokens(network), which fans out to a 117-chunketh_getLogswalk against TokenFactory v1.1.0 covering ~590K blocks since deploy.Fix: Split out
fetchTokensForLabels = fetchNativeTokens— REST-only, no factory walk. Used byLabelProvider. Pages that actually consume the EVM token list (/tokens,TokenRanking) keep calling the fullfetchTokenswhich still walks.Why it's safe
/tokensREST endpoint (currently empty on mainnet) still feed LabelProvider.STATIC_LABELS+fetchValidators+fetchAccountsTop— unaffected./tokensREST endpoint starts returning EVM-factory entries (chain-side indexer follow-up).Verification
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
scan.sentrixchain.com/en→ confirm no eth_getLogs burst in network panelscan.sentrixchain.com/en/tokens→ confirm SGC + TECU still render (ownuseTokenswalk)pnpm --filter=@sentriscloud/scan typecheckgreen (verified locally)Summary by CodeRabbit