Skip to content

Conversation

@Dodecahedr0x
Copy link
Contributor

@Dodecahedr0x Dodecahedr0x commented Dec 4, 2025

Fixes #722

Replaces the transaction executor with a regular RPC to send crank transactions.

Higher dimensional spaghetti as Babur calls it

Summary by CodeRabbit

  • New Features

    • Network configuration exposes ready-to-use HTTP and WebSocket connection URLs that normalize unspecified addresses.
  • Refactor

    • Task scheduler now sends transactions via RPC, uses a unified result type for errors, and database records include created_at/updated_at timestamps.
    • Dependencies and error shapes adjusted for scheduler and RPC usage.
  • Chores

    • Integration test suite removed.
    • CPI payload commit frequency set to zero.

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

@github-actions
Copy link

github-actions bot commented Dec 4, 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 Dec 4, 2025

📝 Walkthrough

Walkthrough

This PR refactors task-scheduler integration and APIs: TaskSchedulerService::new signature now accepts an RPC URL and additional runtime args, replacing the TransactionSchedulerHandle with RpcClient usage for sending transactions; TaskSchedulerService and related methods now return TaskSchedulerResult. The scheduler crate's Cargo.toml swaps Solana dependencies (introduces solana-rpc-client, removes pubsub and others) and removes the integration test suite. SchedulerDatabase adds created_at/updated_at columns and public methods now return TaskSchedulerResult. BindAddress helpers for HTTP/websocket URLs were added and a test CPI argument was changed to 0.

Possibly related PRs

Suggested reviewers

  • GabrielePicco
  • thlorenz
  • bmuddha

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully replaces the task executor with an RPC client to send crank transactions through Chainlink, directly addressing issue #722's requirement to prevent account loss and eviction.
Out of Scope Changes check ✅ Passed All changes are directly related to replacing the transaction scheduler with an RPC client for Chainlink integration and supporting refactoring of error handling and database layers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dode/schedule-with-rpc

📜 Recent 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 d0f7dec and f4cd087.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • magicblock-api/src/magic_validator.rs (1 hunks)
  • magicblock-config/src/types/network.rs (1 hunks)
  • magicblock-task-scheduler/Cargo.toml (1 hunks)
  • magicblock-task-scheduler/src/db.rs (13 hunks)
  • magicblock-task-scheduler/src/errors.rs (1 hunks)
  • magicblock-task-scheduler/src/service.rs (9 hunks)
  • magicblock-task-scheduler/tests/service.rs (0 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • magicblock-task-scheduler/tests/service.rs
🧰 Additional context used
🧠 Learnings (22)
📓 Common learnings
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.
📚 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-config/src/types/network.rs
  • magicblock-task-scheduler/src/service.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-task-scheduler/Cargo.toml
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • magicblock-config/src/types/network.rs
  • magicblock-task-scheduler/src/service.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-config/src/types/network.rs
  • magicblock-task-scheduler/src/errors.rs
  • magicblock-task-scheduler/src/service.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-task-scheduler/src/errors.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.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-task-scheduler/src/service.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-task-scheduler/Cargo.toml
📚 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-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-task-scheduler/src/service.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-task-scheduler/src/service.rs
  • magicblock-task-scheduler/Cargo.toml
  • magicblock-api/src/magic_validator.rs
📚 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-task-scheduler/src/service.rs
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/Cargo.toml
📚 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-task-scheduler/src/service.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.rs
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-10-21T13:06:38.900Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/http/get_program_accounts.rs:17-25
Timestamp: 2025-10-21T13:06:38.900Z
Learning: The magicblock validator does not support ledger forking, so commitment-based state queries (processed/confirmed/finalized) are not applicable. RPC methods can safely ignore commitment and minContextSlot parameters from Solana RPC config objects.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-04T13:22:38.811Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-aperture/src/requests/http/get_fee_for_message.rs:25-31
Timestamp: 2025-11-04T13:22:38.811Z
Learning: In magicblock-aperture, request size validation (including limits on message size) is enforced at the request ingestion layer, before handlers like get_fee_for_message are invoked. Therefore, handlers do not need additional size guards on decoded data.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
🧬 Code graph analysis (1)
magicblock-task-scheduler/src/service.rs (1)
magicblock-core/src/link.rs (1)
  • link (60-89)
🔇 Additional comments (9)
magicblock-task-scheduler/Cargo.toml (1)

23-23: Dependency change aligns with RPC-based refactor.

The addition of solana-rpc-client and removal of solana-pubsub-client aligns with the PR objective to route crank transactions through a regular RPC client for Chainlink integration.

magicblock-config/src/types/network.rs (1)

24-46: LGTM: Correctly normalizes bind addresses to connectable endpoints.

The as_connect_addr helper properly handles the case where bind addresses are unspecified (0.0.0.0 or ::), converting them to localhost for client-side URL construction. This prevents invalid URLs like http://0.0.0.0:8899 from being used by RpcClient.

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

285-295: LGTM: TaskSchedulerService initialization updated for RPC-based flow.

The change correctly passes config.listen.http() (which now properly normalizes bind addresses to connectable URLs) and additional required parameters. The .take().expect() is safe since tasks_service is guaranteed to be initialized by link() before this point.

magicblock-task-scheduler/src/errors.rs (1)

5-21: LGTM: Error enum simplified for RPC-based flow.

The removal of Pubsub, Transaction, and context-related variants aligns with the shift away from the pubsub/tx-scheduler pattern. Boxing ClientError in the Rpc variant is appropriate given its size.

magicblock-task-scheduler/src/service.rs (2)

33-50: Core refactor: Transaction submission now goes through RPC client.

The replacement of tx_scheduler with rpc_client achieves the PR objective—crank transactions now route through a regular RPC endpoint, enabling Chainlink to properly clone missing accounts. The struct fields are appropriate for the new flow.


301-328: Transaction submission now uses RPC client directly.

The process_transaction method correctly uses rpc_client.send_transaction(&tx) and returns the signature from the RPC response. The error is properly boxed to match the updated TaskSchedulerError::Rpc variant.

magicblock-task-scheduler/src/db.rs (3)

72-84: Good addition of audit timestamps.

Adding created_at and updated_at columns improves traceability for task lifecycle tracking.


135-152: LGTM!

The method correctly updates updated_at when modifying execution state.


201-239: LGTM!

The query and error handling logic is correct. Using InvalidParameterName for mapping deserialization errors is acceptable given rusqlite's error type constraints.


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: 1

Caution

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

⚠️ Outside diff range comments (1)
magicblock-api/src/magic_validator.rs (1)

287-297: RpcClient wiring correctly routes through JSON-RPC for Chainlink, but relies on non-wildcard listen addresses

Switching TaskSchedulerService::new to use RpcClient::new(config.listen.http()) correctly sends crank transactions through the node's JSON-RPC stack (and therefore through Chainlink) instead of hitting TransactionScheduler directly, aligning with #722.

However, the current BindAddress::http() method does not normalize unspecified addresses. If config.listen is configured as a wildcard bind (e.g. 0.0.0.0:8899 or [::]:8899), the RpcClient will receive an invalid endpoint like http://0.0.0.0:8899, causing transaction sends to fail. The default configuration uses 127.0.0.1:8899, which is safe.

To make this fully robust for wildcard configurations, either add normalization to BindAddress::http() to convert unspecified IPs to loopback, or document that listen must be a reachable address (not a wildcard bind).

📜 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 a69df0b and ada25b6.

📒 Files selected for processing (2)
  • magicblock-api/src/magic_validator.rs (1 hunks)
  • magicblock-config/src/types/network.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
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.
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.
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.
📚 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-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-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
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • magicblock-api/src/magic_validator.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-api/src/magic_validator.rs

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 ada25b6 and f4301d7.

📒 Files selected for processing (2)
  • .gitignore (1 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
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.
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.
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.
🔇 Additional comments (1)
.gitignore (1)

22-22: Appropriate addition to .gitignore for test artifacts.

The new entry magicblock-test-storage/ correctly ignores test-generated storage artifacts and aligns with the removal of the task-scheduler integration test suite. The placement within the Ledger section is consistent with related test ledger ignores.

Copy link
Contributor

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

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

Not sure I understand where the actual requests are taking place 🤔

Comment on lines 27 to 29
solana-sdk = { workspace = true }
solana-svm = { workspace = true }
solana-timings = { workspace = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

But why those dependencies are needed here? Also please use specific solana subcrates instead of sdk, unless you have to import too many of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in c231e0b, not sure where that was coming from...

@Dodecahedr0x
Copy link
Contributor Author

@bmuddha the request is done here

Copy link
Contributor

@taco-paco taco-paco left a comment

Choose a reason for hiding this comment

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

LGTM! Step in the right direction. Hope one day we will stop using channels instead of function calls as well!

Minor comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this removed? Will there be a replacement for removed tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been removed because the unit tests used test-kit, which does not provide the RPC the service depends on. Integration tests for the service are still functional

&task_scheduler_db_path,
&config.task_scheduler,
dispatch.transaction_scheduler.clone(),
RpcClient::new(config.listen.http()),
Copy link
Contributor

Choose a reason for hiding this comment

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

RpcClient::new(config.listen.http()) is exposing internal details of TaskSchedulerService.

This could be

TaskSchedulerService::new(
            &task_scheduler_db_path,
            &config,
            ...
)

or just passing config.listen separately

Copy link
Contributor Author

@Dodecahedr0x Dodecahedr0x Dec 8, 2025

Choose a reason for hiding this comment

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

Fixed in 1bb3bb5

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 (3)
magicblock-account-cloner/src/lib.rs (1)

106-149: Hotfix fully disables frequency-based commits; consider making this explicit

The guard Some(commit_frequency_ms) if commit_frequency_ms > 0 && false makes the scheduling branch unreachable, so commit_frequency_ms is effectively ignored and only modify_ix is ever sent. That matches the “do not schedule frequency commits” hotfix comment but is quite implicit.

Consider either:

  • Gating the scheduling branch behind a clearly named constant/config flag (e.g. ENABLE_FREQUENCY_COMMITS: bool) instead of && false, and/or
  • Emitting at least a debug/warn log when commit_frequency_ms is Some(>0) to make it obvious that periodic commits are currently disabled.

This keeps the hotfix behavior while making it more self-documenting and easier to flip later.

magicblock-chainlink/src/submux/subscription_task.rs (1)

14-90: SubscribeProgram handling mirrors Subscribe; consider adding targeted tests

The new SubscribeProgram(Pubkey, usize) variant is wired consistently:

  • op_name, required_confirmations, and the zero-confirmations validation treat it identically to Subscribe.
  • Dispatch correctly calls client.subscribe_program(program_id).await.

Functionally this looks sound. To guard regressions, it would be useful to add a couple of small unit tests (similar to the existing Subscribe tests) that exercise:

  • A successful SubscribeProgram across one or more clients, and
  • The zero-confirmations error path for SubscribeProgram.

That would ensure the new variant stays behaviorally aligned with Subscribe as the API evolves.

magicblock-task-scheduler/src/service.rs (1)

194-223: Note: Transaction execution result is not verified.

The TODO comment at lines 197-201 correctly identifies that the transaction outcome isn't verified after send_transaction. Since the PR objective is to ensure accounts get cloned via Chainlink, consider whether transaction failures should be handled more proactively (e.g., by polling for confirmation or using send_and_confirm_transaction).

Would you like me to suggest an implementation using send_and_confirm_transaction or a separate confirmation polling task?

♻️ Duplicate comments (1)
magicblock-api/src/magic_validator.rs (1)

287-297: Consider encapsulating RpcClient construction inside TaskSchedulerService.

Creating RpcClient::new(config.listen.http()) here exposes internal details of TaskSchedulerService. Consider passing &config.listen (or config.listen.http()) to the service and letting it construct the RpcClient internally.

 let task_scheduler = TaskSchedulerService::new(
     &task_scheduler_db_path,
     &config.task_scheduler,
-    RpcClient::new(config.listen.http()),
+    config.listen.http(),
     dispatch
         .tasks_service
         .take()

This would require updating TaskSchedulerService::new signature to accept the URL and construct the client internally.

📜 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 fbbf688 and a9e65c2.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/programs/noop/noop.so is excluded by !**/*.so
📒 Files selected for processing (39)
  • .github/actions/setup-build-env/action.yml (1 hunks)
  • Cargo.toml (1 hunks)
  • config.example.toml (1 hunks)
  • magicblock-account-cloner/src/lib.rs (1 hunks)
  • magicblock-aperture/src/tests.rs (2 hunks)
  • magicblock-aperture/tests/setup.rs (2 hunks)
  • magicblock-api/src/magic_validator.rs (3 hunks)
  • magicblock-chainlink/src/chainlink/config.rs (2 hunks)
  • magicblock-chainlink/src/chainlink/mod.rs (7 hunks)
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs (17 hunks)
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs (6 hunks)
  • magicblock-chainlink/src/remote_account_provider/config.rs (5 hunks)
  • magicblock-chainlink/src/remote_account_provider/mod.rs (1 hunks)
  • magicblock-chainlink/src/submux/mod.rs (10 hunks)
  • magicblock-chainlink/src/submux/subscription_task.rs (5 hunks)
  • magicblock-chainlink/tests/utils/test_context.rs (2 hunks)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1 hunks)
  • magicblock-config/src/config/chain.rs (2 hunks)
  • magicblock-ledger/Cargo.toml (1 hunks)
  • magicblock-magic-program-api/src/instruction.rs (1 hunks)
  • magicblock-processor/src/executor/mod.rs (1 hunks)
  • magicblock-processor/src/scheduler.rs (1 hunks)
  • magicblock-task-scheduler/src/service.rs (9 hunks)
  • programs/magicblock/src/magicblock_processor.rs (1 hunks)
  • programs/magicblock/src/schedule_task/process_schedule_task.rs (1 hunks)
  • programs/magicblock/src/test_utils/mod.rs (0 hunks)
  • programs/magicblock/src/utils/instruction_utils.rs (1 hunks)
  • test-integration/configs/schedule-task.devnet.toml (0 hunks)
  • test-integration/test-chainlink/src/ixtest_context.rs (2 hunks)
  • test-integration/test-chainlink/src/test_context.rs (2 hunks)
  • test-integration/test-task-scheduler/src/lib.rs (1 hunks)
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (2 hunks)
  • test-kit/src/lib.rs (0 hunks)
💤 Files with no reviewable changes (3)
  • programs/magicblock/src/test_utils/mod.rs
  • test-integration/configs/schedule-task.devnet.toml
  • test-kit/src/lib.rs
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
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.
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • magicblock-chainlink/src/chainlink/config.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • magicblock-aperture/src/tests.rs
  • magicblock-api/src/magic_validator.rs
  • magicblock-chainlink/src/submux/subscription_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • magicblock-config/src/config/chain.rs
  • magicblock-chainlink/tests/utils/test_context.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
  • magicblock-aperture/tests/setup.rs
  • test-integration/test-chainlink/src/test_context.rs
  • magicblock-chainlink/src/chainlink/mod.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
  • magicblock-chainlink/src/submux/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/config.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-chainlink/src/chainlink/config.rs
  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • magicblock-chainlink/src/submux/subscription_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • magicblock-aperture/tests/setup.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
  • magicblock-chainlink/src/submux/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/config.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.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:

  • programs/magicblock/src/schedule_task/process_schedule_task.rs
  • magicblock-api/src/magic_validator.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-account-cloner/src/lib.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • programs/magicblock/src/schedule_task/process_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • magicblock-aperture/src/tests.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
  • test-integration/test-chainlink/src/ixtest_context.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • magicblock-chainlink/src/submux/subscription_task.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • magicblock-chainlink/src/submux/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/config.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-chainlink/src/remote_account_provider/mod.rs
  • magicblock-chainlink/src/submux/subscription_task.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • magicblock-chainlink/src/submux/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/config.rs
📚 Learning: 2025-10-26T16:53:29.820Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: magicblock-chainlink/src/remote_account_provider/mod.rs:134-0
Timestamp: 2025-10-26T16:53:29.820Z
Learning: In magicblock-chainlink/src/remote_account_provider/mod.rs, the `Endpoint::separate_pubsub_url_and_api_key()` method uses `split_once("?api-key=")` because the api-key parameter is always the only query parameter right after `?`. No additional query parameter parsing is needed for this use case.

Applied to files:

  • magicblock-chainlink/src/remote_account_provider/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • magicblock-chainlink/src/remote_account_provider/config.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-chainlink/src/remote_account_provider/mod.rs
  • magicblock-api/src/magic_validator.rs
  • magicblock-chainlink/src/submux/subscription_task.rs
  • magicblock-config/src/config/chain.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs
  • magicblock-chainlink/src/submux/mod.rs
  • magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs
  • magicblock-chainlink/src/remote_account_provider/config.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:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
  • magicblock-task-scheduler/src/service.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
  • magicblock-account-cloner/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • magicblock-api/src/magic_validator.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
  • magicblock-task-scheduler/src/service.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/scheduler.rs
  • magicblock-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.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-processor/src/scheduler.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/scheduler.rs
  • magicblock-task-scheduler/src/service.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/scheduler.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/scheduler.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • Cargo.toml
  • magicblock-ledger/Cargo.toml
  • magicblock-api/src/magic_validator.rs
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.

Applied to files:

  • magicblock-api/src/magic_validator.rs
📚 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-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
🧬 Code graph analysis (13)
programs/magicblock/src/schedule_task/process_schedule_task.rs (2)
programs/magicblock/src/test_utils/mod.rs (1)
  • process_instruction (42-59)
programs/magicblock/src/utils/instruction_utils.rs (1)
  • noop_instruction (285-291)
magicblock-chainlink/src/remote_account_provider/mod.rs (1)
magicblock-chainlink/src/remote_account_provider/config.rs (1)
  • program_subs (74-76)
test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (3)
test-integration/test-task-scheduler/src/lib.rs (1)
  • create_delegated_counter (75-124)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
test-integration/test-task-scheduler/tests/test_reschedule_task.rs (3)
test-integration/test-task-scheduler/src/lib.rs (1)
  • create_delegated_counter (75-124)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
magicblock-api/src/magic_validator.rs (3)
magicblock-task-scheduler/src/service.rs (1)
  • new (64-97)
magicblock-chainlink/src/chainlink/config.rs (2)
  • new (12-17)
  • default_with_lifecycle_mode (19-27)
magicblock-api/src/domain_registry_manager.rs (1)
  • new (28-35)
magicblock-chainlink/src/submux/subscription_task.rs (1)
magicblock-version/src/lib.rs (1)
  • client (42-44)
test-integration/test-task-scheduler/tests/test_schedule_error.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
test-integration/test-task-scheduler/tests/test_schedule_task.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs (1)
magicblock-chainlink/src/submux/mod.rs (1)
  • subscribe_program (641-662)
test-integration/test-chainlink/src/ixtest_context.rs (4)
magicblock-api/src/magic_validator.rs (1)
  • config (367-374)
magicblock-chainlink/src/remote_account_provider/config.rs (1)
  • default (80-88)
magicblock-chainlink/src/remote_account_provider/mod.rs (1)
  • default (125-131)
magicblock-config/src/config/chain.rs (1)
  • default (20-24)
magicblock-chainlink/src/submux/mod.rs (2)
magicblock-chainlink/src/remote_account_provider/config.rs (2)
  • program_subs (74-76)
  • default (80-88)
magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs (3)
  • subscribe_program (154-157)
  • subscribe_program (254-270)
  • subscribe_program (455-469)
magicblock-task-scheduler/src/service.rs (1)
programs/magicblock/src/utils/instruction_utils.rs (1)
  • noop_instruction (285-291)
test-integration/test-task-scheduler/tests/test_scheduled_commits.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
🔇 Additional comments (63)
.github/actions/setup-build-env/action.yml (1)

30-37: LGTM—verify that libclang-dev is actually required.

The syntax and structure are correct: the multi-line script format, apt-get update before install, and the -y flag are all appropriate for CI. However, ensure that libclang-dev is genuinely needed by the updated codebase. If adding it here is a response to build failures in the wider PR changes (e.g., due to new dependencies introduced by RPC client integration), that context should be documented in the PR description or commit message.

magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)

9-9: LGTM! Good cleanup of unused import.

The removal of the unused error import is appropriate since only warn! is used in this file.

magicblock-processor/src/scheduler.rs (1)

143-152: LGTM! Good consolidation of cache operations under a single lock scope.

The refactor correctly:

  1. Acquires the write lock once instead of potentially multiple times.
  2. Adds necessary prune() cleanup to prevent cache corruption from duplicate entries.
  3. Ensures atomicity between pruning and updating latest_root_slot.

The comment explaining why pruning is important is helpful for future maintainers.

test-integration/test-task-scheduler/src/lib.rs (1)

29-29: LGTM: Import cleanup aligns with removal of NOOP utilities.

The import adjustments correctly reflect the removal of NOOP_PROGRAM_ID and send_noop_tx, keeping only the necessary items for the remaining test helpers.

test-integration/test-task-scheduler/tests/test_schedule_error.rs (1)

31-32: LGTM: Cleaner blockhash retrieval.

Replacing the noop transaction workaround with direct blockhash retrieval via ctx.try_get_latest_blockhash_ephem() is more straightforward and aligns with the PR's shift to using the RPC client through Chainlink.

test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (1)

35-36: LGTM: Consistent refactoring.

The blockhash retrieval update matches the pattern applied across all test files.

test-integration/test-task-scheduler/tests/test_reschedule_task.rs (1)

30-31: LGTM: Consistent refactoring.

test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs (1)

30-31: LGTM: Consistent refactoring.

test-integration/test-task-scheduler/tests/test_schedule_task.rs (1)

30-31: LGTM: Consistent refactoring.

test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs (1)

25-26: LGTM: Consistent refactoring.

test-integration/test-task-scheduler/tests/test_scheduled_commits.rs (2)

25-26: LGTM: Consistent blockhash retrieval refactoring.


13-13: Clarify why this test is ignored.

The #[ignore] attribute was added without explanation. Is this test temporarily disabled due to the RPC client changes, or is there a known issue that needs to be addressed separately?

Please clarify:

  1. Why is this test now ignored?
  2. Is this temporary or permanent?
  3. If temporary, is there a tracking issue?
programs/magicblock/src/magicblock_processor.rs (1)

80-80: LGTM!

The Noop instruction handler correctly returns success without performing any operations, which is the expected behavior for a no-op instruction.

programs/magicblock/src/schedule_task/process_schedule_task.rs (1)

157-163: LGTM! Clean test refactoring.

The migration from using an external NOOP_PROGRAM_ID to the internal Noop instruction via InstructionUtils::noop_instruction(0) improves test self-containment and removes an external dependency.

programs/magicblock/src/utils/instruction_utils.rs (1)

282-291: LGTM!

The helper function correctly constructs a Noop instruction with the MagicBlock program ID and empty account metadata, following the same pattern as other instruction helpers in this module.

magicblock-ledger/Cargo.toml (1)

33-33: Rocksdb dependency correctly aligned with workspace.

The switch to { workspace = true, default-features = false, features = ["lz4"] } properly references the newly introduced workspace rocksdb dependency and maintains feature consistency. This refactoring follows best practices for workspace dependency management.

Cargo.toml (2)

195-212: Resolve RocksDB version mismatch between workspace dependency and git patch.

The workspace declares rocksdb = "0.22.0" but the patch references git revision d4e9e16, which is part of v0.23.0 (not v0.22.0). This version mismatch will cause Cargo to apply code from a different minor version than declared, risking compatibility issues and unexpected behavior. Either update the workspace version to 0.23.0 or use a git revision that corresponds to the 0.22.0 release.

⛔ Skipped due to learnings
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

190-193: Remove this comment - solana-svm revision verification is not applicable to RPC client changes.

The solana-svm dependency is used in magicblock-processor for transaction execution, not in the RPC aperture layer. RPC methods like sendTransaction and simulateTransaction interact with the transaction scheduler at a higher level and don't directly depend on solana-svm. Unless this PR modifies transaction processing logic in magicblock-processor, the solana-svm revision change does not require verification for RPC client compatibility.

Likely an incorrect or invalid review comment.

magicblock-processor/src/executor/mod.rs (1)

242-252: Confirm ForkGraph::relationship argument semantics and forkless assumption

This linear implementation looks correct under the stated assumption of a strictly forkless, monotonically increasing slot sequence: earlier slots as ancestors, later as descendants, equal as Equal. It’s also a clear improvement over always returning Unrelated.

Two things are worth explicitly double‑checking against the current Solana ForkGraph usage:

  • That relationship(a, b) is indeed defined as “relationship of the block at a relative to the block at b”, so a < b => Ancestor matches the expected direction.
  • That no call sites rely on Unrelated/Unknown being returned (since this implementation will never produce them), especially in any program‑cache invalidation or eviction paths.

If both hold and the environment truly guarantees no forks, this implementation is good as‑is.

magicblock-aperture/tests/setup.rs (1)

20-67: ChainLinkConfig wiring in test setup looks correct

Using ChainLinkConfig::default() and passing &ChainLinkConfig into ChainlinkImpl::try_new matches the new config-driven API and keeps tests aligned with defaults. No issues spotted.

config.example.toml (1)

182-185: New remove-confined-accounts option is consistent with existing config style

Field name, default, and MBV_CHAINLINK__REMOVE_CONFINED_ACCOUNTS env var follow the established conventions in this file; no issues from the example-config perspective.

magicblock-aperture/src/tests.rs (1)

11-52: ChainLinkConfig usage in aperture tests aligns with new API

Importing ChainLinkConfig and passing a local &ChainLinkConfig::default() into ChainlinkImpl::try_new is a clean adaptation to the new signature and keeps tests using default chainlink behavior.

magicblock-chainlink/src/remote_account_provider/mod.rs (1)

381-405: Program subscriptions from config are eagerly established; verify desired failure semantics

Hooking config.program_subs() into SubMuxClient at startup and logging the list is good, and calling subscribe_program here respects the SubMux “remember program_subs and resubscribe on reconnect” pattern.

Because of the ?, if any subscribe_program call fails hard (i.e., doesn’t reach the required confirmations across all clients), try_new_from_urls returns an error and the RemoteAccountProvider isn’t constructed. That’s a reasonable “fail-fast” choice if configured program subscriptions are mandatory, but it does mean transient issues on those subscriptions will prevent chainlink from starting.

Please double-check that this strict behavior is intended; if program subscriptions are meant to be best-effort, you might instead want to log failures and proceed, relying on the reconnection logic to heal later.

Based on learnings, this keeps SubMux’s program_subs-based reconnection behavior intact.

magicblock-chainlink/src/chainlink/config.rs (1)

5-27: remove_confined_accounts field is correctly added and defaulted

Adding pub remove_confined_accounts: bool and initializing it to false in both new and default_with_lifecycle_mode keeps defaults consistent with the derived Default and avoids surprising behavior changes unless explicitly configured.

test-integration/test-chainlink/src/test_context.rs (1)

26-129: Test context’s ChainLinkConfig usage matches the new Chainlink::try_new signature

Importing ChainLinkConfig and passing &ChainLinkConfig::default() into Chainlink::try_new correctly adapts the test harness to the new API while keeping behavior on defaults; the separate lifecycle_mode fed into RemoteAccountProviderConfig remains unchanged and appropriate for these tests.

magicblock-chainlink/tests/utils/test_context.rs (1)

110-117: LGTM!

The Chainlink::try_new call now correctly passes &ChainLinkConfig::default() to align with the updated constructor signature that accepts a config reference.

magicblock-config/src/config/chain.rs (1)

44-58: LGTM!

The addition of serde(default) enables graceful deserialization when fields are missing from config files. The new remove_confined_accounts field is well-documented and defaults to false (via Default derive), which is a safe default for this feature flag.

test-integration/test-chainlink/src/ixtest_context.rs (2)

26-26: LGTM!

Import correctly includes both ChainLinkConfig and LifecycleMode, both of which are used in this file.


143-150: LGTM!

The Chainlink::try_new call correctly uses &ChainLinkConfig::default() to match the updated constructor signature.

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

385-389: LGTM with minor observation.

The propagation of remove_confined_accounts from config.chainlink to chainlink_config is correct. Consider whether future fields should follow the same pattern or if a more systematic approach (e.g., deriving from the same config source) would be cleaner.


394-404: LGTM!

The ChainlinkImpl::try_new_from_endpoints call correctly passes &config.chainlink as the final argument, aligning with the updated constructor signature.

magicblock-chainlink/src/remote_account_provider/config.rs (5)

1-4: LGTM!

Imports for HashSet and Pubkey are correctly added to support the new program_subs field.


14-23: LGTM!

The new program_subs field is well-documented as a backup subscription mechanism for program accounts. The documentation clearly explains its purpose.


47-52: LGTM!

Using ..Default::default() in try_new_with_metrics ensures forward compatibility when new fields are added to the struct.


73-76: LGTM!

The accessor returns a reference to the HashSet, which is appropriate for read-only access.


79-88: LGTM!

The default implementation correctly initializes program_subs with dlp::id() (the delegation program), which is a sensible default for the subscription backup mechanism.

magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs (6)

17-20: LGTM!

Imports correctly added for the new program subscription types: RpcProgramAccountsConfig and RpcKeyedAccount.


39-42: LGTM!

The ProgramSubscribeResult type alias mirrors the existing SubscribeResult pattern, maintaining consistency in the codebase.


154-157: LGTM!

The subscribe_program method is correctly added to the ChainPubsubClient trait with a consistent signature pattern.


254-270: LGTM!

The subscribe_program implementation correctly:

  1. Uses the actor message pattern consistent with subscribe
  2. Sends ChainPubsubActorMessage::ProgramSubscribe
  3. Includes appropriate error logging with inspect_err

455-469: LGTM!

The mock implementation correctly:

  1. Checks connection state before allowing subscription
  2. Returns appropriate error when disconnected
  3. Documents that program subscriptions don't track individual accounts in the mock

89-110: Unsafe lifetime extension consistently applied across subscription methods.

Both account_subscribe (lines 80–85) and program_subscribe (lines 103–108) use identical unsafe transmute patterns to extend stream lifetimes to 'static. The safety comments are consistent and correctly document the reasoning: the stream depends on the client instance, which is only dropped when the connection terminates, at which point the stream is discarded regardless.

magicblock-chainlink/src/chainlink/mod.rs (4)

13-13: LGTM!

Import addition for ChainLinkConfig is correctly placed and aligns with the config-based parameter refactoring.


65-68: LGTM!

The remove_confined_accounts field is well-documented and correctly typed. The blank line before the doc comment improves readability.


73-99: LGTM - Config-based initialization is cleaner.

The signature change from individual parameters to &ChainLinkConfig improves API ergonomics and extensibility. Field initialization from config is straightforward.


102-151: LGTM!

The try_new_from_endpoints signature update correctly propagates chainlink_config to the inner try_new call, maintaining consistency across the initialization paths.

magicblock-chainlink/src/submux/mod.rs (5)

140-142: LGTM!

The program_subs field correctly uses Arc<Mutex<HashSet<Pubkey>>> for thread-safe sharing across reconnection tasks, consistent with the existing subscriptions pattern.


205-228: LGTM!

Initialization and propagation of program_subs through the reconnector spawn path is correctly wired. The clone before passing to spawn ensures each task has its own Arc reference.


240-268: LGTM!

The spawn_reconnectors function correctly clones program_subs for each client's reconnection task, ensuring the shared state is accessible during reconnection attempts.


641-662: LGTM - Resilient subscription pattern correctly implemented.

The subscribe_program method correctly adds to program_subs before attempting the subscription, ensuring reconnection logic will retry failed subscriptions. This aligns with the established pattern per project learnings.

The warn! log level for existing subscriptions is appropriate as it indicates a potential logic issue in the caller without being an error.


330-343: Consider whether program resubscription failure should abort the entire reconnect.

Currently, if any single program subscription fails during reconnect, the entire reconnect is considered failed and will be retried. This is conservative but may cause unnecessary retry loops if a single program consistently fails to subscribe while others succeed.

Consider whether partial success (logging the failure but continuing with other programs) would be more resilient, similar to how account subscription failures are handled in some systems.

⛔ Skipped due to learnings
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
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.
magicblock-task-scheduler/src/service.rs (5)

10-21: LGTM!

Import reorganization correctly brings in RpcClient from solana_rpc_client::nonblocking and splits SDK types into their respective crates (solana_instruction, solana_message, etc.).


33-50: LGTM!

The struct field change from tx_scheduler: TransactionSchedulerHandle to rpc_client: RpcClient correctly reflects the architectural shift to using RPC for transaction submission.


52-55: LGTM!

Boxing TaskSchedulerError in Recoverable is appropriate since RPC client errors can be large, and this avoids bloating the enum variant size.


64-97: LGTM!

Constructor correctly accepts RpcClient and returns TaskSchedulerResult<Self>. The initialization path remains unchanged except for the field name.


301-329: The error type compatibility is correctly implemented. TaskSchedulerError has an Rpc variant that accepts Box<solana_rpc_client_api::client_error::Error> with the #[from] attribute, which auto-generates the From implementation. The map_err(Box::new) call properly converts ClientError to Box<ClientError>, which is then automatically converted to TaskSchedulerError::Rpc.

magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs (7)

14-17: LGTM!

Import additions for RpcProgramAccountsConfig and Response alias are correctly placed for the new program subscription functionality.


84-86: LGTM!

The program_subs field mirrors the subscriptions field structure, maintaining consistency in how account and program subscriptions are tracked.


101-125: LGTM - Well-documented message variants.

The ProgramSubscribe variant is well-documented with the important note that only updates for accounts also in subscriptions will be forwarded. This documents the intentional filtering behavior.


176-192: LGTM!

Shutdown correctly drains both subscriptions and program_subs using iterator chaining, ensuring all subscription tasks are cancelled cleanly.


522-653: LGTM - Program subscription implementation is well-structured.

The add_program_sub function correctly:

  1. Checks for existing subscriptions to avoid duplicates
  2. Inserts cancellation token before async subscription to prevent race conditions
  3. Filters updates to only forward accounts that are also directly subscribed (lines 609)
  4. Handles EOF by signaling connection issues
  5. Cleans up with timeout on unsubscribe

The filtering at line 609 implements the documented behavior from the enum variant comment.


712-732: Good refactoring - DRY improvement for subscription draining.

The drain_subscriptions helper function reduces code duplication and makes the abort logic cleaner. The function correctly:

  1. Takes ownership of all subscriptions via std::mem::take
  2. Cancels each subscription's token
  3. Logs the count of cancelled subscriptions

604-620: Potential performance concern with lock acquisition in hot path.

The subs.lock() call inside the update loop (line 609) acquires a mutex lock for every program account update. If the program has many accounts with frequent updates, this could become a bottleneck.

Consider caching the subscribed accounts set periodically or using a read-optimized concurrent data structure if performance becomes an issue.

⛔ Skipped due to learnings
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.
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-accounts-db/src/lib.rs:63-72
Timestamp: 2025-10-21T10:34:59.140Z
Learning: In magicblock-validator, the AccountsDb "stop-the-world" synchronizer is managed at the processor/executor level, not at the AccountsDb API level. Transaction executors in magicblock-processor hold a read lock (sync.read()) for the duration of each slot and release it only at slot boundaries, ensuring all account writes happen under the read lock. Snapshot operations acquire a write lock, blocking until all executors release their read locks. This pattern ensures mutual exclusion between writes and snapshots without requiring read guards in AccountsDb write APIs.
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.

@Dodecahedr0x Dodecahedr0x force-pushed the dode/schedule-with-rpc branch from d880a89 to ff66c7b Compare December 8, 2025 08:34
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: 4

Caution

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

⚠️ Outside diff range comments (1)
magicblock-task-scheduler/src/service.rs (1)

33-50: RpcClient injection into TaskSchedulerService looks good; consider refreshing surrounding comments

The new rpc_client: RpcClient field and corresponding constructor parameter cleanly decouple the scheduler from the old executor and align with the “send crank txs via RPC” objective. Struct initialization in new is consistent and there are no ownership/lifetime issues.

Two small follow‑ups for clarity:

  • Line 38: scheduled_tasks’s doc string still mentions “transaction executor”, which is no longer accurate with the new wiring.
  • Lines 57‑60: the SAFETY comment still refers to TransactionSchedulerHandle; updating it to mention RpcClient (and dropping obsolete types) will keep the unsafe justification in sync with the actual fields.

Also applies to: 64-71, 87-90

♻️ Duplicate comments (1)
magicblock-magic-program-api/src/instruction.rs (1)

103-105: Clarify the semantics of the Noop(u64) payload

Noop(u64) is now part of the public instruction API, but the doc comment doesn’t explain what the u64 represents or whether it’s ignored by the processor (currently matched as Noop(_)). Expanding the docs will help callers understand if this is simply a nonce/unique identifier or reserved for future use.

You could apply something along these lines:

-    /// Noop instruction
-    Noop(u64),
+    /// Noop instruction (no operation).
+    ///
+    /// The `u64` payload is not interpreted by the program and can be used
+    /// by callers as a nonce/unique identifier (e.g. for tests or tx hashing).
+    /// It is currently ignored during execution.
+    Noop(u64),
📜 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 a9e65c2 and ff66c7b.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/programs/noop/noop.so is excluded by !**/*.so
📒 Files selected for processing (22)
  • .github/actions/setup-build-env/action.yml (1 hunks)
  • Cargo.toml (1 hunks)
  • magicblock-account-cloner/src/lib.rs (1 hunks)
  • magicblock-ledger/Cargo.toml (1 hunks)
  • magicblock-magic-program-api/src/instruction.rs (1 hunks)
  • magicblock-processor/src/executor/mod.rs (1 hunks)
  • magicblock-processor/src/scheduler.rs (1 hunks)
  • magicblock-task-scheduler/src/service.rs (9 hunks)
  • programs/magicblock/src/magicblock_processor.rs (1 hunks)
  • programs/magicblock/src/schedule_task/process_schedule_task.rs (1 hunks)
  • programs/magicblock/src/test_utils/mod.rs (0 hunks)
  • programs/magicblock/src/utils/instruction_utils.rs (1 hunks)
  • test-integration/configs/schedule-task.devnet.toml (0 hunks)
  • test-integration/test-task-scheduler/src/lib.rs (1 hunks)
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs (2 hunks)
  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (2 hunks)
  • test-kit/src/lib.rs (0 hunks)
💤 Files with no reviewable changes (3)
  • test-kit/src/lib.rs
  • programs/magicblock/src/test_utils/mod.rs
  • test-integration/configs/schedule-task.devnet.toml
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
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.
📚 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:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
  • magicblock-task-scheduler/src/service.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • programs/magicblock/src/schedule_task/process_schedule_task.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
  • magicblock-account-cloner/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.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:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • test-integration/test-task-scheduler/tests/test_scheduled_commits.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs
  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.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:

  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • programs/magicblock/src/schedule_task/process_schedule_task.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-account-cloner/src/lib.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • test-integration/test-task-scheduler/tests/test_schedule_error.rs
  • test-integration/test-task-scheduler/src/lib.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task.rs
  • test-integration/test-task-scheduler/tests/test_reschedule_task.rs
  • magicblock-task-scheduler/src/service.rs
  • test-integration/test-task-scheduler/tests/test_schedule_task_signed.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/scheduler.rs
  • magicblock-task-scheduler/src/service.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-processor/src/scheduler.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/scheduler.rs
  • magicblock-task-scheduler/src/service.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/scheduler.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/scheduler.rs
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • magicblock-ledger/Cargo.toml
  • Cargo.toml
📚 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-task-scheduler/src/service.rs
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • Cargo.toml
🧬 Code graph analysis (8)
test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
test-integration/test-task-scheduler/tests/test_schedule_error.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
programs/magicblock/src/schedule_task/process_schedule_task.rs (2)
programs/magicblock/src/test_utils/mod.rs (1)
  • process_instruction (42-59)
programs/magicblock/src/utils/instruction_utils.rs (1)
  • noop_instruction (285-291)
test-integration/test-task-scheduler/tests/test_schedule_task.rs (3)
test-integration/test-task-scheduler/src/lib.rs (1)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs (2)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
test-integration/test-task-scheduler/tests/test_reschedule_task.rs (2)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
magicblock-task-scheduler/src/service.rs (2)
programs/magicblock/src/validator.rs (2)
  • validator_authority (26-33)
  • validator_authority_id (35-42)
programs/magicblock/src/utils/instruction_utils.rs (1)
  • noop_instruction (285-291)
test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs (3)
test-integration/test-task-scheduler/src/lib.rs (2)
  • create_delegated_counter (75-124)
  • setup_validator (35-73)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
  • ephem_blockhash (282-284)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_get_latest_blockhash_ephem (1085-1087)
🔇 Additional comments (19)
.github/actions/setup-build-env/action.yml (1)

30-37: The addition of libclang-dev is necessary and correctly placed.

RocksDB is a workspace dependency that uses rocksdb-sys for C bindings, which requires libclang-dev headers to compile successfully. The Cargo.toml explicitly references rocksdb-sys and includes a comment about build compatibility. This dependency addition aligns with the recent RocksDB patch (0.23.0) and is not optional—it's required for the build to succeed on Linux.

magicblock-ledger/Cargo.toml (1)

33-33: No issues found with rocksdb workspace dependency reference.

The rocksdb dependency in magicblock-ledger correctly uses workspace = true. The root Cargo.toml intentionally overrides the workspace.dependencies.rocksdb with a git source (parent commit d4e9e16 of rocksdb 0.23.0) to resolve Solana version conflicts. This override is documented and marked for removal once Solana is upgraded to 2.3. The inline features declaration in magicblock-ledger matches the workspace configuration.

Cargo.toml (2)

190-193: Verify solana-svm revision 3e9456ec4 for compatibility and stability.

The solana-svm revision has been updated to 3e9456ec4, which is currently associated with PR 10 in the magicblock-svm repository. Confirm that this commit is stable and does not introduce breaking changes to the magicblock-svm fork or dependent crates in the workspace.


195-212: Rocksdb version mismatch is intentional but pending resolution.

The workspace declares rocksdb 0.22.0 but patches it to git rev d4e9e16 (a parent commit of 0.23.0) specifically to avoid linker conflicts with solana dependencies. Only magicblock-ledger directly uses rocksdb in the workspace, and it correctly inherits the lz4 feature from the workspace dependency.

The configuration is documented and intentional. However, the TODO to remove this patch upon solana 2.3 upgrade should reference a tracked issue or sprint plan for visibility and accountability.

magicblock-processor/src/executor/mod.rs (1)

242-252: Clarify ForkGraph::relationship direction and forkless assumption

The linear ordering (a < bAncestor, a > bDescendant, a == bEqual) looks sensible for a forkless chain, but correctness depends on how ForkGraph::relationship(a, b) defines the relation (i.e., “relation of a to b” vs the inverse). Please double‑check this against solana_program_runtime::loaded_programs::ForkGraph/BlockRelation docs and confirm that:

  • the direction (a vs b) matches Solana’s expectation, and
  • assuming a strictly linear, forkless slot sequence is acceptable for all current uses of SimpleForkGraph (e.g., no future support for reorgs/forks relying on this).
programs/magicblock/src/magicblock_processor.rs (1)

35-81: Noop arm correctly wired as a pure no-op

The new Noop(_) => Ok(()) arm cleanly handles the added enum variant without touching accounts or altering existing flows. This is a safe, backwards-compatible extension of the instruction dispatcher.

programs/magicblock/src/schedule_task/process_schedule_task.rs (1)

155-164: Tests now use shared Noop helper with unchanged semantics

Switching create_simple_ix to InstructionUtils::noop_instruction(0) preserves the “no accounts, no signers” behavior of the simple test instruction while centralizing Noop construction. This keeps the schedule‑task tests aligned with the on‑chain validation invariants (interval, iterations, non‑empty instructions) that the scheduler service relies on.

Based on learnings, this keeps validation where it belongs in the Magic program.

programs/magicblock/src/utils/instruction_utils.rs (1)

282-291: Noop helper is correctly scoped and implemented

InstructionUtils::noop_instruction cleanly wraps MagicBlockInstruction::Noop(data) with the program’s ID and no account metas, providing a single canonical way to build MagicBlock no-op instructions for tests and callers.

test-integration/test-task-scheduler/tests/test_schedule_error.rs (1)

12-12: Use ephem blockhash helper instead of NOOP helper

Importing setup_validator/create_delegated_counter and switching to ctx.try_get_latest_blockhash_ephem() is consistent with the new pattern across tests and removes the NOOP dependency without changing the test’s semantics.

Also applies to: 31-32

test-integration/test-task-scheduler/src/lib.rs (1)

29-30: solana_sdk import now matches actual usage

Trimming the solana_sdk import list down to the types used in this module is correct and keeps the dependency surface clean.

test-integration/test-task-scheduler/tests/test_unauthorized_reschedule.rs (1)

11-11: Align unauthorized-reschedule test with shared helpers and ephem blockhash API

Using setup_validator/create_delegated_counter plus ctx.try_get_latest_blockhash_ephem() standardizes setup and ephem blockhash retrieval across the suite while preserving the unauthorized-reschedule behavior being asserted here.

Also applies to: 35-36

test-integration/test-task-scheduler/tests/test_cancel_ongoing_task.rs (1)

12-12: Switch cancel-ongoing-task test to ctx.try_get_latest_blockhash_ephem

The new import and use of ctx.try_get_latest_blockhash_ephem() remove the NOOP transaction dependency while keeping the test’s scheduling and cancellation behavior intact.

Also applies to: 30-31

test-integration/test-task-scheduler/tests/test_reschedule_task.rs (1)

12-12: Use shared helpers and ephem blockhash helper in reschedule test

The refactor to setup_validator/create_delegated_counter and ctx.try_get_latest_blockhash_ephem() simplifies setup and keeps the reschedule assertions unchanged.

Also applies to: 30-31

test-integration/test-task-scheduler/tests/test_schedule_task_signed.rs (1)

10-10: Standardize signed-schedule test on ephem blockhash helper

Using setup_validator/create_delegated_counter and ctx.try_get_latest_blockhash_ephem() matches the rest of the suite and doesn’t change the expected MissingRequiredSignature behavior.

Also applies to: 25-26

test-integration/test-task-scheduler/tests/test_schedule_task.rs (1)

12-12: Migrate schedule-task test to shared setup and ephem blockhash API

The new helper import and ctx.try_get_latest_blockhash_ephem() usage are consistent with other tests and keep the end-to-end scheduling/cancellation and DB checks intact.

Also applies to: 30-31

test-integration/test-task-scheduler/tests/test_scheduled_commits.rs (1)

10-10: Use shared helpers and ephem blockhash helper in scheduled-commits test

The import update and ctx.try_get_latest_blockhash_ephem() call are consistent with the rest of the suite and keep the test logic straightforward.

Also applies to: 25-26

magicblock-processor/src/scheduler.rs (1)

142-152: Verify prune second parameter and confirm latest_root_slot redundancy

The locking consolidation is good, but the hardcoded 0 passed to cache.prune(root, 0) needs verification. LatestBlock contains clock: Clock, which has an epoch field — you likely need to pass self.latest_block.load().clock.epoch instead of 0 as the second argument to match the actual epoch of the block being processed.

Additionally, check your local solana-program-runtime v2.2.1 to confirm whether ProgramCache::prune updates latest_root_slot internally. If it does, the explicit cache.latest_root_slot = root; assignment is redundant. If not, add a comment explaining why the manual assignment is necessary to prevent future cleanup.

magicblock-task-scheduler/src/service.rs (2)

52-55: Boxing recoverable errors is reasonable and run‑loop handling remains consistent

Changing ProcessingOutcome::Recoverable to carry Box<TaskSchedulerError> and wrapping errors in process_request preserves the previous control flow while avoiding copies of potentially large error values. The run loop’s match on ProcessingOutcome still cleanly distinguishes recoverable vs fatal paths.

No functional issues spotted here.

Also applies to: 123-165, 260-283


301-321: Noop prefix for transaction uniqueness with AtomicU64 is sound

Using InstructionUtils::noop_instruction(self.tx_counter.fetch_add(1, Ordering::Relaxed)) to prepend a unique noop instruction achieves per‑tx uniqueness without affecting task instructions. Given the scheduler is confined to a single Tokio task (per the SAFETY comment), AtomicU64 with relaxed ordering is sufficient here.

@Dodecahedr0x Dodecahedr0x force-pushed the dode/schedule-with-rpc branch from ff66c7b to 1bb3bb5 Compare December 8, 2025 08:52
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

Caution

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

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

279-297: Consider passing a higher‑level config handle instead of a raw RPC URL String

TaskSchedulerService::new now takes config.listen.http() as a String, which leaks knowledge of how the validator constructs its local RPC endpoint into the scheduler API. Long‑term, you might want to pass either config.listen (BindAddress) or a small TaskSchedulerRpcConfig struct and let the scheduler decide how to materialize the client URL, to reduce coupling between layers.

magicblock-task-scheduler/src/service.rs (1)

57-62: Update unsafe Send/Sync comment to reflect current fields

The safety comment still names TransactionSchedulerHandle, but the struct now holds an RpcClient instead. For future maintainers reviewing the unsafe Send/Sync impls, please update the comment to list the current fields (including RpcClient) so the justification matches the actual struct layout.

♻️ Duplicate comments (1)
magicblock-task-scheduler/src/service.rs (1)

301-329: Use the Signature returned by RpcClient::send_transaction and make RPC error mapping explicit

process_transaction derives the signature from tx.signatures[0] and ignores the Signature returned by send_transaction, while relying on map_err(Box::new)? plus the #[from] Box<...::Error> on TaskSchedulerError::Rpc. This duplicates the source of truth for the signature and hides the error mapping behind an extra boxing step.

You can simplify and make this clearer by using the returned signature and constructing the error variant directly:

-        let sig = tx.signatures[0];
-        self.rpc_client
-            .send_transaction(&tx)
-            .await
-            .map_err(Box::new)?;
-        Ok(sig)
+        self.rpc_client
+            .send_transaction(&tx)
+            .await
+            .map_err(|e| TaskSchedulerError::Rpc(Box::new(e)))

This uses the actual RPC response signature and documents the error conversion in one place.

📜 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 ff66c7b and 1bb3bb5.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • magicblock-api/src/magic_validator.rs (1 hunks)
  • magicblock-config/src/types/network.rs (1 hunks)
  • magicblock-task-scheduler/Cargo.toml (1 hunks)
  • magicblock-task-scheduler/src/db.rs (13 hunks)
  • magicblock-task-scheduler/src/errors.rs (1 hunks)
  • magicblock-task-scheduler/src/service.rs (8 hunks)
  • magicblock-task-scheduler/tests/service.rs (0 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • magicblock-task-scheduler/tests/service.rs
🧰 Additional context used
🧠 Learnings (20)
📓 Common learnings
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.
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.
📚 Learning: 2025-11-24T14:21:00.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: Cargo.toml:58-58
Timestamp: 2025-11-24T14:21:00.996Z
Learning: In the magicblock-validator codebase, magicblock-api/Cargo.toml intentionally uses borsh = "1.5.3" (instead of the workspace version 0.10.4) because it needs to deserialize types from the magic-domain-program external dependency, which requires borsh 1.5.x compatibility. This is an intentional exception for interoperability with the magic domain program.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 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-task-scheduler/Cargo.toml
  • magicblock-task-scheduler/src/errors.rs
  • magicblock-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.rs
📚 Learning: 2025-11-07T18:19:48.996Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 614
File: test-integration/programs/schedulecommit/Cargo.toml:19-20
Timestamp: 2025-11-07T18:19:48.996Z
Learning: In Solana programs (crates depending on solana-program), the empty feature flags `custom-heap = []` and `custom-panic = []` are standard declarations required to avoid compiler warnings. These should not be flagged as unused features in Cargo.toml files for Solana program crates.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-24T08:45:11.164Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 675
File: Cargo.toml:145-145
Timestamp: 2025-11-24T08:45:11.164Z
Learning: The reqwest dependency version 0.11 is intentionally used in the magicblock-validator project to maintain compatibility with the Solana client dependencies.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 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-task-scheduler/Cargo.toml
📚 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-task-scheduler/Cargo.toml
  • magicblock-config/src/types/network.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-task-scheduler/src/service.rs
📚 Learning: 2025-10-21T13:06:38.900Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/http/get_program_accounts.rs:17-25
Timestamp: 2025-10-21T13:06:38.900Z
Learning: The magicblock validator does not support ledger forking, so commitment-based state queries (processed/confirmed/finalized) are not applicable. RPC methods can safely ignore commitment and minContextSlot parameters from Solana RPC config objects.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-task-scheduler/src/service.rs
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-11-04T13:22:38.811Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-aperture/src/requests/http/get_fee_for_message.rs:25-31
Timestamp: 2025-11-04T13:22:38.811Z
Learning: In magicblock-aperture, request size validation (including limits on message size) is enforced at the request ingestion layer, before handlers like get_fee_for_message are invoked. Therefore, handlers do not need additional size guards on decoded data.

Applied to files:

  • magicblock-task-scheduler/Cargo.toml
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • magicblock-config/src/types/network.rs
  • magicblock-task-scheduler/src/service.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-config/src/types/network.rs
  • magicblock-task-scheduler/src/errors.rs
  • magicblock-task-scheduler/src/service.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-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • magicblock-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.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-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
  • magicblock-task-scheduler/src/db.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-api/src/magic_validator.rs
  • magicblock-task-scheduler/src/service.rs
📚 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-task-scheduler/src/service.rs
🧬 Code graph analysis (3)
magicblock-task-scheduler/src/errors.rs (3)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (3)
  • from (499-501)
  • from (534-538)
  • from (560-562)
magicblock-api/src/errors.rs (6)
  • from (104-106)
  • from (110-112)
  • from (116-118)
  • from (122-124)
  • from (130-134)
  • from (138-140)
magicblock-chainlink/src/remote_account_provider/errors.rs (1)
  • from (95-97)
magicblock-task-scheduler/src/service.rs (1)
magicblock-core/src/link.rs (1)
  • link (60-89)
magicblock-task-scheduler/src/db.rs (1)
magicblock-task-scheduler/src/service.rs (1)
  • new (64-97)
🔇 Additional comments (1)
magicblock-task-scheduler/src/db.rs (1)

68-85: Adding created_at/updated_at without migration will break existing scheduler databases

The tasks table now includes created_at and updated_at as INTEGER NOT NULL, and insert_task unconditionally inserts into these columns. However, CREATE TABLE IF NOT EXISTS does not alter an existing table, so any pre-existing task_scheduler.sqlite created before this change will not have those columns. On upgrade, INSERT OR REPLACE INTO tasks (...) will fail with "no such column: created_at/updated_at", breaking task scheduling (and possibly validator startup).

You'll need either:

  • a schema migration path (e.g., detect missing columns and ALTER TABLE to add them with sensible defaults), or
  • a deliberate reset strategy (e.g., force config.task_scheduler.reset = true for this release and clearly document that tasks DB will be wiped).

Right now this is a silent migration hazard.

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

Caution

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

⚠️ Outside diff range comments (2)
magicblock-task-scheduler/src/service.rs (2)

194-223: Consider retry logic for transient RPC failures.

The current implementation removes and logs failed tasks (lines 270-271), which is reasonable. However, for improved resilience, consider distinguishing between transient network errors (which could be retried) versus permanent failures (invalid transaction). This could be implemented by:

  1. Inspecting the error type from send_transaction
  2. Implementing a bounded retry with backoff for retriable errors
  3. Only marking the task as failed after retry exhaustion

This is optional and depends on the reliability requirements for scheduled tasks.


57-62: Update the safety comment to reflect the actual struct fields and verify necessity of unsafe impls.

The safety comment lists TransactionSchedulerHandle (line 58) which is not a field in the struct, and omits RpcClient which is. Update the comment to accurately list: SchedulerDatabase, RpcClient, ScheduledTasksRx, LatestBlock, DelayQueue, HashMap, AtomicU64, CancellationToken. If all these fields are confirmed to be Send+Sync, consider whether the unsafe impls can be removed and let the compiler auto-derive these traits, or document the specific reason they remain necessary.

📜 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 1bb3bb5 and d0f7dec.

📒 Files selected for processing (1)
  • magicblock-task-scheduler/src/service.rs (8 hunks)
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
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.
📚 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-task-scheduler/src/service.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-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • magicblock-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • magicblock-task-scheduler/src/service.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-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 Learning: 2025-12-01T16:02:05.367Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 703
File: magicblock-chainlink/src/submux/mod.rs:652-654
Timestamp: 2025-12-01T16:02:05.367Z
Learning: In magicblock-chainlink/src/submux/mod.rs, the subscribe_program method intentionally adds program_id to program_subs before attempting the subscription. This ensures that even if the initial subscription fails or only partially succeeds across clients, the reconnection logic will retry the subscription. This is a deliberate design pattern for resilience in the multi-client architecture and should not be "fixed" to remove entries on failure.

Applied to files:

  • magicblock-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 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-task-scheduler/src/service.rs
📚 Learning: 2025-11-20T08:57:07.217Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 650
File: magicblock-chainlink/src/submux/subscription_task.rs:13-99
Timestamp: 2025-11-20T08:57:07.217Z
Learning: In the magicblock-validator repository, avoid posting review comments that merely confirm code is correct or matches intended behavior without providing actionable feedback, suggestions for improvement, or identifying potential issues. Such confirmatory comments are considered unhelpful noise by the maintainers.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
📚 Learning: 2025-11-21T11:03:26.756Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 664
File: magicblock-chainlink/src/testing/mod.rs:342-370
Timestamp: 2025-11-21T11:03:26.756Z
Learning: In the magicblock-validator codebase, avoid leaving review comments that merely acknowledge code is correct or well-structured when there is no actionable suggestion, improvement, or issue to flag. Only comment when there is something specific to recommend, fix, or clarify.

Applied to files:

  • magicblock-task-scheduler/src/service.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-task-scheduler/src/service.rs
📚 Learning: 2025-11-20T17:25:23.444Z
Learnt from: JMirval
Repo: magicblock-labs/magicblock-validator PR: 656
File: programs/guinea/src/lib.rs:33-33
Timestamp: 2025-11-20T17:25:23.444Z
Learning: In the magicblock-validator codebase, task IDs (task_id) are i64 values that can be negative. The task scheduler is designed to handle any i64 value including negative task IDs. Task IDs are randomly generated using rand::random() which produces values across the full i64 range. No validation is needed to restrict task IDs to positive values.

Applied to files:

  • magicblock-task-scheduler/src/service.rs
🧬 Code graph analysis (1)
magicblock-task-scheduler/src/service.rs (1)
magicblock-core/src/link.rs (1)
  • link (60-89)
🔇 Additional comments (4)
magicblock-task-scheduler/src/service.rs (4)

17-21: LGTM!

Import changes correctly switch to granular Solana crates and use the nonblocking RpcClient for async transaction submission.


36-37: LGTM!

Field replacement and error boxing changes align with the PR objective to route transactions through RPC for proper Chainlink integration.

Also applies to: 54-54


141-141: LGTM!

Error boxing is consistent in both branches and matches the updated ProcessingOutcome::Recoverable(Box<TaskSchedulerError>) signature.

Also applies to: 159-159


323-327: LGTM!

The implementation correctly uses the signature returned by send_transaction and properly boxes the error for conversion.

@Dodecahedr0x Dodecahedr0x force-pushed the dode/schedule-with-rpc branch from d0f7dec to f4cd087 Compare December 8, 2025 10:48
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.

fix: task scheduler not using chainlink prevents cloning missing accounts

4 participants