feat: batch-fetch and cache address lookup tables for V0 transactions#565
feat: batch-fetch and cache address lookup tables for V0 transactions#565raushan728 wants to merge 3 commits into
Conversation
Greptile SummaryThis PR replaces the per-ALT
Confidence Score: 5/5The change is safe to merge. All callers have been updated, both code paths deduplicate ALT pubkeys before batch-fetching, error propagation uses The core logic is well-structured: cache hits, RPC misses, and Redis write-back follow the same pattern as existing single-account caching. Deduplication and graceful error handling are present in both the No files require special attention beyond Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Caller as resolve_lookup_table_addresses
participant AltCache as alt_cache (HashMap)
participant GetMulti as CacheUtil::get_multiple_accounts
participant Redis as Redis (mget/set_ex)
participant RPC as Solana RPC
Caller->>AltCache: check for each ALT pubkey
Note over AltCache: misses collected into HashSet
Caller->>GetMulti: batch fetch misses[]
GetMulti->>Redis: mget(keys[])
Redis-->>GetMulti: "Vec<Option<String>> (hits / misses)"
GetMulti->>RPC: get_multiple_accounts(rpc_misses[])
RPC-->>GetMulti: "Vec<Option<Account>>"
GetMulti->>Redis: pipe.set_ex() for each fetched account
GetMulti-->>Caller: "Vec<Account> (in input order)"
Caller->>AltCache: insert(pubkey, addresses) for each miss
Caller-->>Caller: zip lookups with full_address_lists → resolved_addresses
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant Caller as resolve_lookup_table_addresses
participant AltCache as alt_cache (HashMap)
participant GetMulti as CacheUtil::get_multiple_accounts
participant Redis as Redis (mget/set_ex)
participant RPC as Solana RPC
Caller->>AltCache: check for each ALT pubkey
Note over AltCache: misses collected into HashSet
Caller->>GetMulti: batch fetch misses[]
GetMulti->>Redis: mget(keys[])
Redis-->>GetMulti: "Vec<Option<String>> (hits / misses)"
GetMulti->>RPC: get_multiple_accounts(rpc_misses[])
RPC-->>GetMulti: "Vec<Option<Account>>"
GetMulti->>Redis: pipe.set_ex() for each fetched account
GetMulti-->>Caller: "Vec<Account> (in input order)"
Caller->>AltCache: insert(pubkey, addresses) for each miss
Caller-->>Caller: zip lookups with full_address_lists → resolved_addresses
Reviews (2): Last reviewed commit: "feat(bundle): reuse resolved ALTs across..." | Re-trigger Greptile |
30b5abf to
faa046e
Compare
V0 transactions resolved ALTs one at a time via
CacheUtil::get_account, with a TODO comment noting caching was never added. Bundles re-resolved the same ALT for every transaction that referenced it.CacheUtil::get_multiple_accountscache-aware batch fetch using Redismget+ RPCget_multiple_accountsfor missesresolve_lookup_table_addressesnow batches all ALT pubkeys into one call instead of loopingHashMap<Pubkey, Vec<Pubkey>>) across all transactions in the same bundle repeated ALT fetched once per bundle, not once per tx. Single-transaction RPC handlers unaffected (passNone)Note: dropped 2 tests for the Redis cache-hit path needed a live Redis instance, CI doesn't run one, and no existing test in
cache.rsdoes either.