Skip to content

PE-9131: Minimize Solana RPC usage in sync and gateway registry - #2165

Closed
vilenarios wants to merge 4 commits into
devfrom
perf/minimize-solana-rpc
Closed

vilenarios wants to merge 4 commits into
devfrom
perf/minimize-solana-rpc

Conversation

@vilenarios

Copy link
Copy Markdown
Collaborator

Summary

Investigation of heavy traffic to ArDrive's QuikNode Solana RPC found two structural sources; this PR eliminates both.

1. Sync no longer sweeps ArNS on every run

Every sync (auto-sync ~5 min, tab-focus restarts, manual) called getAntRecordsForWallet(update: true) — deliberately bypassing the repository's 15-minute cache — walking every owned ArNS name on Solana (several RPC calls per name), plus a post-sync saveAllFilesWithAssignedNames pass. ArDrive currently has no ArNS integration, so this was pure RPC cost with no user-facing effect. Both call sites and the ARNSRepository dependency are removed from SyncRepository. On-demand ArNS lookups elsewhere (upload flows, profile name) are untouched; sync-time integration can return later with the feature.

2. GAR gateway list: fetch at most once ever, refresh only on demand

The AR.IO gateway list was re-fetched from Solana RPC every app session (data-fetch fallback, snapshot validation) and on every open of the gateway settings modal. It's now persisted in local storage:

  • DataGatewayFallback: memory → persisted cache → single SDK fetch (persisted on success). Across sessions the network is hit at most once, ever.
  • Gateway settings serve the cached list; a new "Refresh list" button (new RefreshGateways bloc event) force-fetches and persists — the only path that re-hits the RPC.
  • SnapshotValidationService reads through the same shared cache.
  • Corrupt/missing persisted entries fall back to a normal fetch; fetch failures are cached in memory only (never persisted) so the next session retries.

Expected impact

Steady-state Solana RPC volume drops to ~zero for a signed-in user who isn't using crypto top-ups or explicitly refreshing the gateway list.

Tests

Note: local test execution was unavailable for this branch (WSL→Windows interop broke mid-session); CI is the validation gate for this PR — please wait for green before review.

🤖 Generated with Claude Code

https://claude.ai/code/session_0172nfTRDj7wgnhs44Lg6mxC

vilenarios and others added 3 commits July 9, 2026 13:42
- every sync (auto-sync every ~5 minutes, tab-focus restarts, manual
  syncs) forced a full ArNS sweep on Solana via
  getAntRecordsForWallet(update: true), bypassing the repository's
  15-minute cache; each sweep makes several RPC calls per owned name
- ArDrive currently has no ArNS integration, so the sweep and the
  post-sync saveAllFilesWithAssignedNames pass were pure RPC cost with
  no user-facing effect; both are removed along with the
  ARNSRepository dependency on SyncRepository
- ArNS lookups elsewhere (upload flows, profile name) are untouched and
  fetch on demand; sync-time integration can be reintroduced later if
  the feature returns

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- the AR.IO gateway list was fetched from Solana RPC once per app
  session (data-fetch fallback, snapshot validation) and on every open
  of the gateway settings modal; the registry rarely changes, so this
  was recurring RPC cost for static data
- DataGatewayFallback now persists the list in local storage: memory ->
  persisted cache -> single SDK fetch (persisted on success); across
  sessions the network is hit at most once ever
- gateway settings serve the cached list; an explicit 'Refresh list'
  action (new RefreshGateways event + modal button) force-fetches and
  persists
- SnapshotValidationService reads through the same shared cache
- corrupt or missing persisted entries fall back to a normal fetch;
  fetch failures are cached in memory only (never persisted) so the
  next session retries
- add DataGatewayFallback persistence tests and update gar repository
  tests

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- equatable 2.1.0 (released after the last green dev build) deprecates
  EquatableMixin, which data_table.dart uses; package lockfiles are not
  committed, so CI's per-package pub get floated to 2.1.0 and scr test
  failed on the analyze step for every PR and dev push
- the main app's committed lockfile resolves equatable 2.0.7, where
  Equatable cannot be used as a mixin, so migrating the code instead of
  pinning would break the app build; pin until both contexts can move to
  2.1.x together

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@vilenarios, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 4 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 788e0aa5-c505-4333-a4da-18eb3ed43f5d

📥 Commits

Reviewing files that changed from the base of the PR and between 0860808 and fe3d465.

📒 Files selected for processing (12)
  • lib/gar/domain/repositories/gar_repository.dart
  • lib/gar/presentation/bloc/gar_bloc.dart
  • lib/gar/presentation/bloc/gar_event.dart
  • lib/gar/presentation/widgets/gar_modal.dart
  • lib/main.dart
  • lib/services/arweave/data_gateway_fallback.dart
  • lib/sync/data/snapshot_validation_service.dart
  • lib/sync/domain/repositories/sync_repository.dart
  • packages/ardrive_ui/pubspec.yaml
  • test/gar/domain/repository/gar_repository_test.dart
  • test/services/arweave/data_gateway_fallback_test.dart
  • test/sync/domain/sync_repository_optimization_test.dart
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/minimize-solana-rpc

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.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vilenarios

Copy link
Copy Markdown
Collaborator Author

Consolidated into #2162 so all sync improvements can be tested on one preview build. Branch merged there commit-for-commit.

@vilenarios vilenarios closed this Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit fe3d465):

https://ardrive-web--pr2165-perf-minimize-solana-qch8uf45.web.app

(expires Thu, 16 Jul 2026 18:04:58 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a224ebaee2f0939e7665e7630e7d3d6cd7d0f8b0

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