Skip to content

Cache asset movement providers by id (300ms -> 30ms during parallel requests)#394

Merged
ezraripps merged 5 commits into
mainfrom
feature/cache-asset-movement-providers-by-id
Jul 9, 2026
Merged

Cache asset movement providers by id (300ms -> 30ms during parallel requests)#394
ezraripps merged 5 commits into
mainfrom
feature/cache-asset-movement-providers-by-id

Conversation

@ezraripps

@ezraripps ezraripps commented Jul 9, 2026

Copy link
Copy Markdown
Member

There were issues with caching providers/metadata during parallel requests. This was causing performance issues on the browser. This PR fixes that, and adds some other optimizations to resolving the chaining graph. All previous tests pass.


Note

Medium Risk
Touches core asset-movement provider resolution and reachability BFS used for transfer routing; caching and graph traversal changes could affect correctness under concurrency or edge-case graph shapes, though behavior is intended to be equivalent with better performance.

Overview
Improves anchor chaining performance when many parallel browser requests resolve the same asset-movement providers and walk the transfer graph.

Asset movement providers: getAssetMovementProviderById now caches in-flight promises per provider ID (not just resolved providers), so concurrent callers share one fetch; failed lookups are evicted so retries work. getAssetMovementProvidersForAsset builds a lazy index of provider IDs by asset+location from graph nodes instead of scanning every node on each lookup, then resolves providers in parallel.

EVM asset keys: Optional EVMChecksumCache on checksumEVMAsset, normalizeChainAssetCasing, and convertAssetSearchInputToCanonical avoids repeat EIP-55 work; AnchorGraph and Resolver each hold a shared map for metadata canonicalization and #assetLocationKey (with a WeakMap cache on location key objects).

Graph resolveAssets: Drops always-built prev/next adjacency; BFS builds rail-key neighbor buckets only when from/to filters are set, uses an index-based queue instead of queue.shift(), and walks neighbors via those buckets while preserving same-provider FX skip rules.

Reviewed by Cursor Bugbot for commit 17aa786. Bugbot is set up for automated code reviews on this repo. Configure here.

@ezraripps ezraripps self-assigned this Jul 9, 2026
@ezraripps ezraripps mentioned this pull request Jul 9, 2026
@ezraripps ezraripps requested a review from sephynox July 9, 2026 20:28
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@ezraripps ezraripps merged commit 2fb7e75 into main Jul 9, 2026
4 checks passed
@ezraripps ezraripps deleted the feature/cache-asset-movement-providers-by-id branch July 9, 2026 20:34
ezraripps added a commit that referenced this pull request Jul 9, 2026
Includes changes from:
 - #394

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Only manifest version fields change with no runtime or dependency
updates in the diff.
> 
> **Overview**
> Bumps **`@keetanetwork/anchor`** from **0.0.84** to **0.0.85** in
`package.json` and the root entry in `package-lock.json`. No dependency
or source changes appear in this diff; it is a version-only release cut
(PR description notes inclusion of **#394** elsewhere).
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
78305e3. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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