Skip to content

Conversation

@bmuddha
Copy link
Contributor

@bmuddha bmuddha commented Nov 21, 2025

Summary by CodeRabbit

  • New Features

    • Added RPC endpoints for recent performance samples and vote account queries.
  • Improvements

    • Epoch, slot, and slot-leader responses now reflect live chain state; slot schedule uses a standardized epoch size.
    • Background collector supplies recent performance samples for RPC consumers.
    • CORS handling refined: preflight and responses now include controlled Access‑Control headers (no permissive header emitted).
  • Metrics

    • Global transaction counter introduced and incremented as transactions are processed.
  • Tests

    • Adjusted epoch/slot-related assertions to match dynamic behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

📝 Walkthrough

Walkthrough

Adds runtime transaction counting and a Prometheus TRANSACTION_COUNT metric; makes slot/epoch responses dynamic via a new SLOTS_IN_EPOCH constant; adds get_vote_accounts and a new get_recent_performance_samples handler plus a background perf-sample collector; centralizes CORS header handling and extends HTTP RPC routing; updates server run/handle signatures to spawn the collector; increments transaction metric during processing; and adjusts tests to the new dynamic behavior.

Possibly related PRs

Suggested reviewers

  • thlorenz

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the two main objectives of the pull request: adding missing RPC methods (get_vote_accounts, get_recent_performance_samples, GetRecentPerformanceSamples, GetVoteAccounts) and implementing CORS header management.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
magicblock-aperture/src/server/http/dispatch.rs (2)

96-122: JSON-RPC error responses currently miss CORS headers

dispatch now applies CORS only to the successful Ok(Response<…>) path in process. When a handler or parsing step returns an Err, the unwrap! macro calls ResponseErrorPayload::encode and returns that response without passing through set_access_control_headers, so browser clients will see missing CORS headers on errors.

Consider updating unwrap! so error responses also get CORS:

-        macro_rules! unwrap {
-            ($result:expr, $id: expr) => {
-                match $result {
-                    Ok(r) => r,
-                    Err(error) => {
-                        return Ok(ResponseErrorPayload::encode($id, error));
-                    }
-                }
-            };
-        }
+        macro_rules! unwrap {
+            ($result:expr, $id: expr) => {
+                match $result {
+                    Ok(r) => r,
+                    Err(error) => {
+                        let mut response =
+                            ResponseErrorPayload::encode($id, error);
+                        Self::set_access_control_headers(&mut response);
+                        return Ok(response);
+                    }
+                }
+            };
+        }

This keeps the central CORS behavior while ensuring clients can read error responses.


133-189: CORS application for successful RPC calls and new methods looks good

Applying set_access_control_headers only on Ok(response) from process is appropriate for the success path, and the new methods GetRecentPerformanceSamples and GetVoteAccounts are correctly wired to their handlers. Once the error-path CORS gap is addressed (see earlier comment), the routing + CORS story will be consistent.

You might also consider simplifying result handling by returning early from each arm with headers applied, but that’s purely stylistic.

magicblock-aperture/src/requests/http/mocked.rs (1)

35-44: Doc comment for get_transaction_count is now outdated

The comment still says “currently we don't keep track of transaction count”, but the implementation now calls self.ledger.count_transactions()? and returns the actual count. Please update the comment to reflect the current behavior so it doesn’t mislead future readers.

You may also want to mention that this is still a simplified/mock view if count_transactions has known limitations.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca51651 and 1b2df27.

📒 Files selected for processing (5)
  • magicblock-aperture/src/requests/http/mocked.rs (5 hunks)
  • magicblock-aperture/src/requests/mod.rs (3 hunks)
  • magicblock-aperture/src/requests/payload.rs (1 hunks)
  • magicblock-aperture/src/server/http/dispatch.rs (5 hunks)
  • magicblock-aperture/tests/mocked.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • magicblock-aperture/tests/mocked.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • magicblock-aperture/src/requests/http/mocked.rs
📚 Learning: 2025-10-28T13:15:42.706Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 596
File: magicblock-processor/src/scheduler.rs:1-1
Timestamp: 2025-10-28T13:15:42.706Z
Learning: In magicblock-processor, transaction indexes were always set to 0 even before the changes in PR #596. The proper transaction indexing within slots will be addressed during the planned ledger rewrite.

Applied to files:

  • magicblock-aperture/src/requests/http/mocked.rs
📚 Learning: 2025-10-21T11:00:18.396Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/encoder.rs:176-187
Timestamp: 2025-10-21T11:00:18.396Z
Learning: In the magicblock validator, the current slot is always the root slot. The SlotEncoder in magicblock-aperture/src/encoder.rs correctly sets `root: slot` because there is no lag between current and root slots in this architecture.

Applied to files:

  • magicblock-aperture/src/requests/http/mocked.rs
🧬 Code graph analysis (2)
magicblock-aperture/tests/mocked.rs (1)
magicblock-aperture/tests/setup.rs (1)
  • latest_slot (226-228)
magicblock-aperture/src/requests/http/mocked.rs (2)
magicblock-aperture/src/requests/payload.rs (2)
  • encode_no_context (85-100)
  • encode_no_context (138-148)
magicblock-aperture/src/server/http/dispatch.rs (1)
  • new (65-78)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (6)
magicblock-aperture/src/requests/mod.rs (2)

32-75: New HTTP method variants and as_str mappings look consistent

GetRecentPerformanceSamples and GetVoteAccounts are correctly added to JsonRpcHttpMethod, and their as_str values match the camelCase method names. Using Self::Variant in the matches improves clarity and is functionally equivalent.


93-138: HTTP/WebSocket as_str helpers remain in sync with enum variants

The refactored as_str implementations for both JsonRpcHttpMethod and JsonRpcWsMethod cover all variants, including the newly added HTTP methods, and keep the wire method names aligned with the enums.

magicblock-aperture/tests/mocked.rs (2)

161-167: Epoch info assertion correctly follows dynamic slot behavior

Asserting absolute_slot == env.latest_slot() matches the new get_epoch_info implementation that derives absoluteSlot from the current block height. Keeping epoch == 0 for this test setup is still valid.


179-184: Epoch schedule expectations now match mocked constants

Checking slots_per_epoch == 432_000 and warmup == false is consistent with the new SLOTS_IN_EPOCH constant and the updated get_epoch_schedule mock. This makes the tests better reflect realistic Solana settings.

magicblock-aperture/src/requests/http/mocked.rs (2)

14-20: New constants/imports for epoch and vote/perf data are appropriate

Adding RpcPerfSample, RpcVoteAccountStatus, and SLOTS_IN_EPOCH = 432_000 here matches the new mocked behaviors for epoch info, performance samples, and vote accounts. Keeping these concerns local to the mocked HTTP layer is reasonable.


186-194: Updated get_epoch_schedule behavior is consistent with constants

Returning slotsPerEpoch: SLOTS_IN_EPOCH and warmup: false lines up with the new constant and the tests. The rest of the schedule fields remain simple placeholders, which is acceptable for a mock.

Copy link
Collaborator

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
magicblock-metrics/src/metrics/mod.rs (1)

236-243: Register TRANSACTION_COUNT so it’s exposed via Prometheus

TRANSACTION_COUNT is defined and used but never registered in register(), so it won’t show up in the exported metrics even though it’s incremented and read.

Add it alongside the other transaction-related counters:

     register!(UNDELEGATION_REQUESTED_COUNT);
     register!(UNDELEGATION_COMPLETED_COUNT);
     register!(UNSTUCK_UNDELEGATION_COUNT);
-    register!(FAILED_TRANSACTIONS_COUNT);
+    register!(TRANSACTION_COUNT);
+    register!(FAILED_TRANSACTIONS_COUNT);
     register!(REMOTE_ACCOUNT_PROVIDER_A_COUNT);
     register!(TASK_INFO_FETCHER_A_COUNT);
     register!(TABLE_MANIA_A_COUNT);
     register!(TABLE_MANIA_CLOSED_A_COUNT);

Also applies to: 339-347

magicblock-aperture/src/requests/http/mocked.rs (1)

37-38: Update the outdated comment.

The comment states "currently we don't keep track of transaction count," but the implementation now uses TRANSACTION_COUNT.get() (line 43), making this comment misleading. Additionally, there's a grammar error: "with new the new."

Apply this diff to update the comment:

-    /// Handles the `getTransactionCount` RPC request.
-    /// currently we don't keep track of transaction count,
-    /// but with new the new ledger implementation will
+    /// Handles the `getTransactionCount` RPC request.
+    /// Returns the current transaction count tracked by the TRANSACTION_COUNT metric.
♻️ Duplicate comments (2)
magicblock-aperture/src/requests/http/mocked.rs (2)

20-20: Consider extracting SLOTS_IN_EPOCH to a shared constants module.

The SLOTS_IN_EPOCH constant is module-local but may be needed elsewhere in the codebase. Extracting it to a shared constants module would prevent duplication and ensure consistency across the application.


236-245: Consider adding a test for the vote accounts response structure.

The get_vote_accounts implementation returns empty current and delinquent vectors, which is appropriate for a mocked handler. Adding a test to verify the response structure would guard against accidental API changes.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2df27 and f6389ab.

📒 Files selected for processing (7)
  • magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (1 hunks)
  • magicblock-aperture/src/requests/http/mocked.rs (5 hunks)
  • magicblock-aperture/src/requests/http/mod.rs (1 hunks)
  • magicblock-aperture/src/server/http/mod.rs (2 hunks)
  • magicblock-api/src/magic_validator.rs (2 hunks)
  • magicblock-metrics/src/metrics/mod.rs (1 hunks)
  • magicblock-processor/src/executor/processing.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

  • magicblock-metrics/src/metrics/mod.rs
  • magicblock-processor/src/executor/processing.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • magicblock-metrics/src/metrics/mod.rs
📚 Learning: 2025-11-13T09:38:43.804Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:64-102
Timestamp: 2025-11-13T09:38:43.804Z
Learning: In magicblock-processor's TransactionScheduler (scheduler/mod.rs line 59), the executor count is clamped to MAX_SVM_EXECUTORS (63) at initialization time, and executor IDs are assigned sequentially from 0 to count-1. This architectural guarantee ensures that executor IDs used in the bitmask-based AccountLock (scheduler/locks.rs) will always be within valid bounds for bit shifting operations, making runtime bounds checks unnecessary.

Applied to files:

  • magicblock-processor/src/executor/processing.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-10-28T13:15:42.706Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 596
File: magicblock-processor/src/scheduler.rs:1-1
Timestamp: 2025-10-28T13:15:42.706Z
Learning: In magicblock-processor, transaction indexes were always set to 0 even before the changes in PR #596. The proper transaction indexing within slots will be addressed during the planned ledger rewrite.

Applied to files:

  • magicblock-processor/src/executor/processing.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-04T10:53:50.922Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:110-122
Timestamp: 2025-11-04T10:53:50.922Z
Learning: In magicblock-processor, the TransactionScheduler runs in a single, dedicated thread and will always remain single-threaded. The `next_transaction_id()` function in scheduler/locks.rs uses `unsafe static mut` which is safe given this architectural guarantee.

Applied to files:

  • magicblock-processor/src/executor/processing.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • magicblock-processor/src/executor/processing.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-12T09:46:27.553Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: magicblock-task-scheduler/src/db.rs:26-0
Timestamp: 2025-11-12T09:46:27.553Z
Learning: In magicblock-task-scheduler, task parameter validation (including ensuring iterations > 0 and enforcing minimum execution intervals) is performed in the Magic program (on-chain) before ScheduleTaskRequest instances reach the scheduler service. The From<&ScheduleTaskRequest> conversion in db.rs does not need additional validation because inputs are already validated at the program level.

Applied to files:

  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

  • magicblock-api/src/magic_validator.rs
  • magicblock-aperture/src/requests/http/mocked.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-aperture/src/requests/http/mocked.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

  • magicblock-aperture/src/requests/http/mocked.rs
🧬 Code graph analysis (4)
magicblock-metrics/src/metrics/mod.rs (1)
magicblock-aperture/src/state/subscriptions.rs (2)
  • new (342-355)
  • new (410-413)
magicblock-aperture/src/requests/http/mod.rs (1)
magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (1)
  • get_recent_performance_samples (28-49)
magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (2)
magicblock-aperture/src/requests/mod.rs (1)
  • params (22-26)
magicblock-aperture/src/state/blocks.rs (1)
  • block_height (95-97)
magicblock-aperture/src/requests/http/mocked.rs (2)
magicblock-aperture/src/requests/payload.rs (2)
  • encode_no_context (85-100)
  • encode_no_context (138-148)
magicblock-aperture/src/server/http/dispatch.rs (1)
  • new (65-78)
🪛 GitHub Actions: Run CI - Lint
magicblock-aperture/src/requests/http/get_recent_performance_samples.rs

[error] 35-35: Clippy: redundant closure. Replace get_or_init(|| TreeIndex::default()) with TreeIndex::default.


[error] 62-62: Clippy: redundant closure. Replace get_or_init(|| TreeIndex::default()) with TreeIndex::default.


[error] 66-66: Clippy: casting to the same type is unnecessary (unnecessary_cast). Remove 'as u64' in 'count.saturating_sub(last_count) as u64'.


[error] 1-1: Build failed: could not compile due to previous clippy errors in the same file.

🔇 Additional comments (6)
magicblock-processor/src/executor/processing.rs (1)

12-14: Clarify whether TRANSACTION_COUNT should include load failures and replays

TRANSACTION_COUNT.inc() is called before you know if process succeeded and regardless of is_replay, so the counter will include:

  • Transactions that failed during load (Err branch), and
  • Replayed transactions (is_replay == true).

Given the description “Total number of executed transactions” and its use in performance sampling, it’d be good to confirm that this broader definition is intentional. If you only want successfully processed, non‑replay traffic, you probably want to move the increment into the Ok(processed) branch and optionally gate it on !is_replay.

Also applies to: 54-72

magicblock-api/src/magic_validator.rs (1)

51-52: Check interaction of TRANSACTION_COUNT seeding with ledger replay

Here you seed TRANSACTION_COUNT with ledger.count_transactions()? and later, on startup, you may replay the ledger via maybe_process_ledger(). If ledger replay flows through TransactionExecutor::execute (which also calls TRANSACTION_COUNT.inc()), historical transactions could be counted twice (once via inc_by, once during replay).

If the goal is “total transactions ever seen” including replays, this is fine; otherwise you may want to:

  • Either avoid seeding and rely purely on execution‑time increments, or
  • Ensure replay paths don’t bump TRANSACTION_COUNT.

Also applies to: 275-293

magicblock-aperture/src/server/http/mod.rs (1)

67-87: HTTP server lifecycle + perf-samples collector wiring looks sound

Taking self by value in run and spawning dispatcher.run_perf_samples_collector(cancel.clone()) is a clean way to attach the collector to the same cancellation flow as the listener. The updated handle(&self, ...) keeps per‑connection shutdown semantics unchanged and avoids unnecessary interior mutability.

Also applies to: 93-127

magicblock-aperture/src/requests/http/mod.rs (1)

273-273: LGTM! Module declaration is consistent with existing patterns.

The new get_recent_performance_samples module follows the naming conventions and is properly placed among other HTTP request handler modules.

magicblock-aperture/src/requests/http/mocked.rs (2)

168-177: Dynamic epoch calculations are correct and well-implemented.

The epoch-related fields are now properly derived from the current slot using SLOTS_IN_EPOCH, and transactionCount is sourced from the ledger. The modulo and division operations correctly compute epoch and slotIndex.


191-192: Epoch schedule values are consistent with epoch info calculations.

Using SLOTS_IN_EPOCH for slotsPerEpoch and setting warmup: false aligns with the simplified epoch model used throughout this mocked implementation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d803a1 and 56fe05b.

📒 Files selected for processing (1)
  • magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • magicblock-aperture/src/requests/http/get_recent_performance_samples.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-aperture/src/requests/http/get_recent_performance_samples.rs
🧬 Code graph analysis (1)
magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (2)
magicblock-aperture/src/requests/mod.rs (1)
  • params (22-26)
magicblock-aperture/src/state/blocks.rs (1)
  • block_height (95-97)
🔇 Additional comments (4)
magicblock-aperture/src/requests/http/get_recent_performance_samples.rs (4)

1-13: LGTM!

Imports are well-organized and all dependencies are necessary for the functionality.


15-25: LGTM!

Constants are well-documented with clear rationale. The 25% buffer in ESTIMATED_SLOTS_PER_SAMPLE provides safety margin for the pruning logic.


27-34: Past clippy issues have been resolved.

The code correctly uses TreeIndex::default without redundant closures (lines 47, 84). The Reverse<Slot> key ordering ensures newest samples are returned first, which aligns with RPC expectations. The Sample struct is appropriately simple.


37-62: LGTM!

The handler correctly:

  • Parses and validates the count parameter
  • Caps requests at the maximum history size to prevent resource abuse
  • Uses Guard for safe concurrent reads
  • Returns samples in newest-first order (Reverse key ordering)
  • Sets num_non_vote_transactions to None (not tracked separately, which is acceptable)

@bmuddha bmuddha merged commit 6ce4c8a into master Nov 22, 2025
18 checks passed
@bmuddha bmuddha deleted the bmuddha/feat/add-missing-rpc-methods branch November 22, 2025 12:34
thlorenz added a commit that referenced this pull request Nov 22, 2025
…xec-buffer-fetch

* origin/master:
  release: v3.0.0 (#673)
  feat: add missing rpc methods and CORS headers (#663)
thlorenz added a commit that referenced this pull request Nov 22, 2025
…-coderabbit-ai-agent-prompts

* origin/master:
  release: v3.0.0 (#673)
  feat: add missing rpc methods and CORS headers (#663)
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