Skip to content

feat(rpc): expose remote account claim counts - #1500

Merged
GabrielePicco merged 12 commits into
masterfrom
thlorenz/rate-limit
Jul 30, 2026
Merged

feat(rpc): expose remote account claim counts#1500
GabrielePicco merged 12 commits into
masterfrom
thlorenz/rate-limit

Conversation

@thlorenz

@thlorenz thlorenz commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add X-MB-Remote-Account-Claims to JSON-RPC responses, reporting the number of unique remote
accounts claimed while serving a request.

Details

  • Propagate request-scoped claim accounting through account-read, transaction, and simulation
    paths.
  • Count only direct user-requested remote claims owned by the current fetch; exclude bank hits,
    duplicates, waiters, companion fetches, and internal/background fetches.
  • Emit the header on successful, error, and batch JSON-RPC responses. Requests with no remote
    claims report 0.
  • Add Aperture response-header coverage and Chainlink ownership/counting tests, including
    positive coverage in test_remote_account_claims_count_owned_unique_requested_pubkeys.
  • Made AccountFetchContext cloneable rather than Copy: it owns an Arc<AtomicU64>, and the remaining clones are required for async ownership and shared request accounting.

Summary by CodeRabbit

  • New Features

    • Added the X-MB-Remote-Account-Claims response header to account-related RPC requests, including batch responses.
    • The header reports the number of remote account claims made while processing each request.
  • Bug Fixes

    • Improved account-fetch tracking across account reads, transaction submission, and transaction simulation.
    • Ensured claim counts are reported consistently for successful and error responses.
  • Tests

    • Added coverage for account, balance, token, delegation, transaction, simulation, and batch RPC responses.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

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

Next review available in: 34 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b1bd1e3-6d0c-4585-b64a-a2a956d160d9

📥 Commits

Reviewing files that changed from the base of the PR and between e7a3219 and 7708b73.

📒 Files selected for processing (23)
  • magicblock-aperture/src/requests/http/get_account_info.rs
  • magicblock-aperture/src/requests/http/get_balance.rs
  • magicblock-aperture/src/requests/http/get_delegation_status.rs
  • magicblock-aperture/src/requests/http/get_multiple_accounts.rs
  • magicblock-aperture/src/requests/http/get_token_account_balance.rs
  • magicblock-aperture/src/requests/http/mod.rs
  • magicblock-aperture/src/requests/http/send_transaction.rs
  • magicblock-aperture/src/requests/http/simulate_transaction.rs
  • magicblock-aperture/src/server/http/dispatch.rs
  • magicblock-aperture/tests/accounts.rs
  • magicblock-aperture/tests/batches.rs
  • magicblock-aperture/tests/setup.rs
  • magicblock-aperture/tests/transactions.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/ata_projection.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/pending_operation.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/pipeline.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/program_loader.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/tests.rs
  • magicblock-chainlink/src/chainlink/mod.rs
  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • magicblock-chainlink/src/remote_account_provider/tests.rs
  • magicblock-metrics/src/metrics/types.rs
📝 Walkthrough

Walkthrough

The change adds shared atomic remote-account claim tracking to AccountFetchContext, propagates fetch contexts through Chainlink and HTTP account-loading paths, and exposes the resulting count through the X-MB-Remote-Account-Claims response header. HTTP dispatch handles single, batch, success, and error responses. Chainlink async workflows clone contexts where needed, and tests cover account, transaction, batch, and claim-counting behavior.

Suggested reviewers: bmuddha, gabrielepicco

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch thlorenz/rate-limit

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.

@thlorenz
thlorenz requested a review from GabrielePicco July 28, 2026 14:16

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-aperture/src/requests/http/mod.rs`:
- Around line 239-245: Remove the redundant
read_accounts_with_ensure_with_context method and update its sole caller in
get_multiple_accounts.rs to invoke read_accounts_with_ensure directly, passing
the existing fetch_context unchanged.

In `@magicblock-aperture/src/requests/http/send_transaction.rs`:
- Around line 49-55: Extract the duplicated SendTransaction AccountFetchContext
construction into a shared helper such as send_transaction_context alongside
rpc_get_account_context and rpc_get_multiple_accounts_context in mod.rs. Update
magicblock-aperture/src/requests/http/send_transaction.rs:49-55 and
magicblock-aperture/src/requests/http/simulate_transaction.rs:58-66 to call the
helper with signature and remote_account_claims, preserving the existing
entrypoint and requested-account values.

In `@magicblock-aperture/tests/accounts.rs`:
- Around line 10-21: The remote account claims header helper is duplicated
across three integration test files. Add or reuse the shared
`REMOTE_ACCOUNT_CLAIMS_HEADER` and `remote_account_claims_header()` definitions
in `tests/setup.rs`, remove the local copies, and import the shared helper in
`magicblock-aperture/tests/accounts.rs` lines 10-21,
`magicblock-aperture/tests/batches.rs` lines 4-15, and
`magicblock-aperture/tests/transactions.rs` lines 19-30.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 17da7a60-87c2-4d60-a763-498db8521f37

📥 Commits

Reviewing files that changed from the base of the PR and between 26e5844 and e7a3219.

📒 Files selected for processing (22)
  • magicblock-aperture/src/requests/http/get_account_info.rs
  • magicblock-aperture/src/requests/http/get_balance.rs
  • magicblock-aperture/src/requests/http/get_delegation_status.rs
  • magicblock-aperture/src/requests/http/get_multiple_accounts.rs
  • magicblock-aperture/src/requests/http/get_token_account_balance.rs
  • magicblock-aperture/src/requests/http/mod.rs
  • magicblock-aperture/src/requests/http/send_transaction.rs
  • magicblock-aperture/src/requests/http/simulate_transaction.rs
  • magicblock-aperture/src/server/http/dispatch.rs
  • magicblock-aperture/tests/accounts.rs
  • magicblock-aperture/tests/batches.rs
  • magicblock-aperture/tests/transactions.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/ata_projection.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/mod.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/pending_operation.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/pipeline.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/program_loader.rs
  • magicblock-chainlink/src/chainlink/fetch_cloner/tests.rs
  • magicblock-chainlink/src/chainlink/mod.rs
  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • magicblock-chainlink/src/remote_account_provider/tests.rs
  • magicblock-metrics/src/metrics/types.rs

Comment thread magicblock-aperture/src/requests/http/mod.rs Outdated
Comment thread magicblock-aperture/src/requests/http/send_transaction.rs Outdated
Comment thread magicblock-aperture/tests/accounts.rs Outdated
@thlorenz
thlorenz requested a review from bzawisto July 28, 2026 14:52
@thlorenz
thlorenz marked this pull request as ready for review July 28, 2026 14:52
@GabrielePicco
GabrielePicco merged commit 3bbd376 into master Jul 30, 2026
36 checks passed
@GabrielePicco
GabrielePicco deleted the thlorenz/rate-limit branch July 30, 2026 13:14
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.

3 participants