Skip to content

Conversation

@gomesalexandre
Copy link
Contributor

@gomesalexandre gomesalexandre commented Dec 23, 2025

Description

... and don't encode.

This PR:

  • moves asset data generation to outputting/serving in /public
  • removes the encoding perf changes from perf: minimise asset data size #8423 - mostly re: generating clean json without encoding/decoding so we get clean, readable files
  • with that being said, does do a bit of size cleanup on the generat(ed|ion) files, removing networkName, explorer, explorerAddressLink, explorerTxLink - we can generate those at runtime in app as they're all the same for a given ChainId.
  • wires-up across the board
  • adds asset-manifest hashes on regen, to ensure cache/busting on new generated files

In effect, this means that:

  • The generated asset data goes from ~5MB to ~15MB but it is now fetched at runtime, not in the bundle. Most importantly it's fetched once for a given asset-manifest version, assuming you have "Disable cache" unticked in network tab obviously (unticked i.e cache enabled is browser default, only devs would have it enabled for testing)
  • LLMs and humans alike can actually understand those files, and work better with them. It's even not unrealistic now to actually monkey patch bits there as needed

Issue (if applicable)

N/A

Risk

High

This PR fundamentally changes how asset data is loaded:

  • Asset data now fetched at runtime instead of bundled
  • AssetService initialization is now async
  • All components wait for AssetLoader before rendering
  • Generation scripts output to new location

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

All asset-related functionality could be affected if asset data fails to load. The entire app depends on asset data being available.

Testing

  • Ensure default trade (swapper spot and limit and new fiat ramps) pair with no cache is sane
  • Ensure app runs fine both with and without "Disable cache" options in network options (i.e full cache nuke, enable/disable, refresh, app should look sane in both cases)
  • Ensure asset data is on par with feat: related bridge assets #11515
  • Do a smoke test of assets (search, spot swapper, limit order, fiat ramps)
  • Do a smoke test of market-data across the board

Engineering

  • Test both with dev and actual build (yarn preview:prod) and ensure no crashes, and assets look good
  • Try and regenerate one more time (without REGEN_ALL) and ensure it still looks good
  • Verify bundle size reduction (~5MB smaller)
  • Check Network tab for asset XHRs
  • Verify asset data is readable JSON (not encoded)

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

This is a foundational change that affects all asset loading. QA should verify:

  • App loads without errors
  • All assets display correctly
  • Trading, staking, and other asset-dependent features work
  • No performance regressions

Screenshots (if applicable)

TODO

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat_poc_regen_public

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Moves asset data generation to outputting/serving in /public, *without* the perf changes from #8423.

In effect, this means that:
- The generated asset data goes from ~5MB to ~15MB *but* it is now fetched at runtime, not in the bundle
- LLMs and humans alike can actually understand those files, and work better with them. It's even not unrealistic now to actually monkey patch bits there as needed

TODO(gomes): Test one of two hard things in software engineering (i.e regardless of "Disable cache" in devtools, regenerated asset data cache should be invalidated on change)

Changes:
- Move generated files to /public/generated/ (served as static assets)
- Remove all encoding/decoding (revert PR #8423 optimizations)
- Output readable, pretty-printed JSON
- AssetService works in both Node.js (generation) and browser (runtime)
- Integrated with feat_bridged_grouping canonical asset handling
- AssetLoader component initializes assets before app renders
- Use existing test mocks from @/test/mocks/assets

Testing:
- Test *both* with dev and actual build (yarn preview:prod) and ensure no crashes, and assets look good
- Try and regenerate one more time (without REGEN_ALL) and ensure it *still* looks good

Risks: High

Screenshots: TODO

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
gomesalexandre and others added 2 commits December 23, 2025 16:10
Moves asset data generation to outputting/serving in /public, *without* the perf changes from #8423.

In effect, this means that:
- The generated asset data goes from ~5MB to ~15MB *but* it is now fetched at runtime, not in the bundle
- LLMs and humans alike can actually understand those files, and work better with them. It's even not unrealistic now to actually monkey patch bits there as needed

TODO(gomes): Test one of two hard things in software engineering (i.e regardless of "Disable cache" in devtools, regenerated asset data cache should be invalidated on change)

Changes:
- Move generated files to /public/generated/ (served as static assets)
- Remove all encoding/decoding (revert PR #8423 optimizations)
- Output readable, pretty-printed JSON
- AssetService works in both Node.js (generation) and browser (runtime)
- Integrated with feat_bridged_grouping canonical asset handling
- AssetLoader component initializes assets before app renders
- Use existing test mocks from @/test/mocks/assets

Testing:
- Test *both* with dev and actual build (yarn preview:prod) and ensure no crashes, and assets look good
- Try and regenerate one more time (without REGEN_ALL) and ensure it *still* looks good

Risks: High

Screenshots: TODO

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Root cause: AssetLoader was running before PersistGate, so:
1. AssetLoader populated 25k assets
2. PersistGate rehydrated and migration cleared them
3. Result: 0 assets in Redux

Fix: AssetLoader now runs AFTER PersistGate completes rehydration.

Also: Use existing test mocks from @/test/mocks/assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
gomesalexandre and others added 9 commits December 23, 2025 16:46
The decodeAssetData function was computing these properties, but we removed it.
Now we compute them manually based on relatedAssetKey:
- isPrimary = relatedAssetKey === null || relatedAssetKey === assetId
- isChainSpecific = relatedAssetKey === null

This fixes asset search showing 0 results (primary assets were all filtered out).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
…ex.json

- encodedAssetData.json → generatedAssetData.json
- encodedRelatedAssetIndex.json → relatedAssetIndex.json

Files stay in /public/generated/ (just filename change, not path change)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
- Add generateManifest() function to compute SHA-256 hashes of asset files
- AssetService fetches asset-manifest.json and uses hashes in query params
- Fetch URLs: /generated/generatedAssetData.json?v=<hash>
- When files change (regen), hashes change, cache is busted
- Update all test mocks to include asset-manifest.json
- Use asset-manifest.json (not manifest.json) to avoid conflict with PWA manifest

Benefits:
- Stable filenames (no renaming on every commit)
- Automatic cache invalidation when content changes
- Works with dev server and production
- Tiny overhead (<1KB manifest file)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

triple-check this, there may be more cleanup needed re: asset-service

Remove networkName, explorer, explorerAddressLink, explorerTxLink from individual assets.
These are chain-level properties (same for all assets on a chain).

Changes:
- Stripped properties from generatedAssetData.json (18MB → 14MB, 22% reduction)
- AssetLoader enriches assets with chain data from getBaseAsset() when upserting to Redux
- Updated asset-manifest.json with new content hash
- Data in Redux store remains identical (enriched at load time)

Benefits:
- 4MB smaller file (faster network transfer)
- Single source of truth for chain metadata (baseAssets.ts)
- Easier maintenance (explorer URL changes only need chain-level updates)
- Cleaner generated data (no duplication)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@gomesalexandre gomesalexandre changed the title feat: don't include related/asset data in bundle feat: don't include asset data in bundle Dec 23, 2025
gomesalexandre and others added 2 commits December 24, 2025 00:52
- Use private properties with public getters instead of 'as any' casts
- Remove unnecessary comment explanations in trade slices
- Simplify comment in generateAssetData.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
return (
<Page>
<Center flexDir='column' height='100vh' backgroundImage={colors.altBg} px={6} _after={after}>
<Center flexDir='column' height='100vh' background={colors.altBg} px={6} _after={after}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Else we'll get this bad boi

Image

…tion

- Global fetch stub in setupVitest.ts (used by all tests)
- Remove duplicated fetch mocks from individual test files
- portals/utils.ts: use getLocalAssetData() helper to reduce diff
- Remove migration 256 (not needed)
- SplashScreen: keep background (not backgroundImage) - handles gradients correctly

Cleanup reduces test code duplication by ~100 lines.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
import Polyglot from 'node-polyglot'

import { descriptions } from './descriptions'
import { localAssetData, relatedAssetIndex, sortedAssetIds } from './localAssetData'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This whole thing was basically useless (ish, is now!) - basically was a wrapper over generated encoded asset data with decoding. Since we don't have encoding anymore, no need for the additional layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should probably be able to clean this up

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.

2 participants