Skip to content

feat: Add support for CommitDiff to efficiently commit small changes in large delegated accounts#575

Merged
snawaz merged 13 commits intomasterfrom
snawaz/commit-diff
Dec 24, 2025
Merged

feat: Add support for CommitDiff to efficiently commit small changes in large delegated accounts#575
snawaz merged 13 commits intomasterfrom
snawaz/commit-diff

Conversation

@snawaz
Copy link
Contributor

@snawaz snawaz commented Oct 15, 2025

This PR does the following things:

  • Adds support for CommitDiff. So now when a commit is scheduled, it triggers either CommitState or CommitDiff in the delegation-program, depending on the account size and the COMMIT_STATE_SIZE_THRESHOLD.
    • CommitDiff is effectively an optimization that reduces the amount of data transferred when committing small changes in large accounts, which improves performance and reduces costs.
    • The diff is sent over args, not buffer account.
  • Adds test using a large OrderBook account (10 KB). I initially wanted to try a few MB, but realized currently that’s not possible yet.
    • After 13 book updates , CommitDiff was invoked (in the delegation-program) with only diff len = 286 whereas data len = 10240 (see first screenshot).
    • When there’s no diff, CommitDiff still runs with diff len = 8 (encoding the size of account on ER and the number of offset-pairs), and logs a warning (see second screenshot).
    • In the zero-diff case, we could optimize for an early return, though currently it seems we cannot.. since Finalize and Undelegate still depend on Commit running fully.

Update dlp.so

Updated test-integration/schedulecommit/elfs/dlp.so to use latest version of DLP with CommitDiff ix.

Changes in the existing tests.

Two kinds of changes:

  • Since it is CommitTask which decides the exact DLP instruction CommitState or CommitDiff, and many tests which earlier used to get executed as BufferTask, will now be executed as ArgsTask because large accounts with small changes can be executed as ArgsTask as long as the transaction size stays within limit. So made the related changes in the tests.

  • For some tests, I made the following change:

    -#[tokio::test]
    +#[tokio::test(flavor = "multi_thread", worker_threads = 2)]

    It is because now CommitTask::new() uses blocking RpcClient to fetch account from the base chain, so the tests fail because they run in a single-threaded environment, giving this error:

    can call blocking only when running on the multi-threaded runtime

    Using multi_thread with 2 threads makes the tests work again.

Screenshots

image image

Summary by CodeRabbit

  • New Features

    • Order-book support: init/grow/update/delegate order-book accounts, schedule diffs/commits, and new OrderBook types/APIs.
    • Commit-diff and size-aware strategy: threshold-based selection, optional base-account fetching, and parallel base-account retrieval.
    • Selectable user-seed modes to choose delegation/init behavior (OrderBook vs default).
    • TaskBuilderImpl and task-creation API to produce size-aware commit tasks.
  • Tests

    • Expanded integration/unit tests covering order-book flows, diff/size boundaries, strategies, and concurrent task creation.
  • Chores

    • Workspace dependency updates and new test dependencies.

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

Copy link
Contributor Author

snawaz commented Oct 15, 2025

@snawaz snawaz force-pushed the snawaz/commit-diff branch 6 times, most recently from 249b1aa to 2f0555f Compare October 23, 2025 15:45
@snawaz snawaz force-pushed the snawaz/commit-diff branch 2 times, most recently from 0151da0 to 5c25e73 Compare October 27, 2025 06:13
@snawaz snawaz changed the title Add ScheduleCommitDiffAndUndelegate Add MagicBlockInstruction::ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts Oct 27, 2025
@snawaz snawaz changed the title Add MagicBlockInstruction::ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts Add ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts Oct 27, 2025
@snawaz snawaz force-pushed the snawaz/commit-diff branch 2 times, most recently from 2ae750b to 725f72c Compare October 27, 2025 09:45
@github-actions
Copy link

github-actions bot commented Oct 27, 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.

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 725f72c to e5c5e15 Compare October 27, 2025 16:55
@snawaz snawaz changed the title Add ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts featAdd ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts Oct 27, 2025
@snawaz snawaz changed the title featAdd ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts feat: Add ScheduleCommitDiffAndUndelegate to efficiently commit changes in delegated accounts Oct 27, 2025
@snawaz snawaz marked this pull request as ready for review October 28, 2025 14: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: 29

Caution

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

⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)

229-237: reset_commit_id ignores CommitDiff—update both variants.

Commit IDs must update for Commit and CommitDiff.

Apply:

-        let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-            log::error!("reset_commit_id");
-            return;
-        };
-
-        commit_task.commit_id = commit_id;
+        match &mut self.task_type {
+            ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+                task.commit_id = commit_id;
+            }
+            _ => {}
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1dfd59 and e5c5e15.

⛔ 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 (28)
  • Cargo.toml (1 hunks)
  • magicblock-accounts/src/scheduled_commits_processor.rs (3 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (6 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (1 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (3 hunks)
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1 hunks)
  • magicblock-magic-program-api/src/instruction.rs (1 hunks)
  • magicblock-rpc-client/src/lib.rs (1 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (7 hunks)
  • programs/magicblock/src/magicblock_processor.rs (4 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs (5 hunks)
  • test-integration/Cargo.toml (2 hunks)
  • test-integration/programs/schedulecommit-security/src/lib.rs (2 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (5 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (9 hunks)
  • test-integration/programs/schedulecommit/src/order_book.rs (1 hunks)
  • test-integration/programs/schedulecommit/src/utils/mod.rs (3 hunks)
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs (6 hunks)
  • test-integration/schedulecommit/client/src/verify.rs (2 hunks)
  • test-integration/schedulecommit/test-scenarios/Cargo.toml (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1 hunks)
  • test-integration/test-ledger-restore/tests/08_commit_update.rs (2 hunks)
  • test-integration/test-tools/src/integration_test_context.rs (2 hunks)
  • test-integration/test-tools/src/scheduled_commits.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
PR: magicblock-labs/magicblock-validator#585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (15)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
  • setup_validator_with_local_remote (97-119)
test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (3)
test-integration/programs/schedulecommit/src/api.rs (1)
  • schedule_commit_with_payer_cpi_instruction (214-232)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • assert_two_committees_were_committed (68-91)
  • get_context_with_delegated_committees (16-35)
  • assert_feepayer_was_committed (94-113)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_commit_result_from_logs (7-14)
test-integration/programs/schedulecommit-security/src/lib.rs (1)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • create_schedule_commit_ix (41-66)
magicblock-committor-service/src/tasks/args_task.rs (4)
magicblock-committor-service/src/tasks/mod.rs (2)
  • instruction (66-66)
  • instruction (249-255)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • instruction (65-86)
  • new (37-45)
magicblock-committor-service/src/config.rs (1)
  • local (29-35)
magicblock-accounts/src/scheduled_commits_processor.rs (2)
  • new (66-90)
  • new (420-436)
programs/magicblock/src/magicblock_processor.rs (3)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • instruction (58-160)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
  • process_schedule_commit (34-259)
magicblock-committor-program/src/state/changeset.rs (1)
  • request_undelegation (230-232)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)
test-integration/programs/schedulecommit/src/api.rs (4)
  • schedule_commit_and_undelegate_cpi_instruction (234-252)
  • schedule_commit_and_undelegate_cpi_with_mod_after_instruction (287-311)
  • schedule_commit_diff_instruction_for_order_book (193-212)
  • update_order_book_instruction (175-191)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
  • assert_one_committee_account_was_undelegated_on_chain (190-196)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • committees (205-209)
  • ephem_blockhash (322-324)
  • ephem_client (318-320)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
test-integration/programs/schedulecommit/src/api.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (85-94)
test-integration/programs/flexi-counter/src/state.rs (1)
  • pda (32-35)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (145-146)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-accounts/src/scheduled_commits_processor.rs (2)
  • new (66-90)
  • new (420-436)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (49-54)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-106)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (85-94)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
  • base_intent (544-549)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
  • init_order_book_instruction (36-54)
  • init_payer_escrow (77-98)
  • init_account_instruction (16-34)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (145-146)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
  • get_context_with_delegated_committees (16-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: run_make_ci_format
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (34)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)

55-55: LGTM! Correctly updated to match new function signature.

Both call sites properly destructure the new 3-tuple return value. The _tmpdir binding is necessary to keep the TempDir alive throughout the function scope, preventing premature cleanup of the temporary directory while the validator is still using it.

Also applies to: 170-170

test-integration/programs/schedulecommit/src/utils/mod.rs (2)

53-53: LGTM: Type alignment with Solana API.

Changing size to u64 aligns with Solana's system_instruction::allocate API, which expects a u64 parameter. This improves type consistency and eliminates the need for type conversions downstream.


70-90: LGTM: Clean implementation with helpful debugging.

The changes correctly handle the type conversion:

  • Line 71: The cast to usize is necessary for Rent::minimum_balance and is safe given Solana's practical account size limits.
  • Lines 75-80: The debug log provides useful visibility into lamport requirements during account allocation.
  • Line 90: Passing size directly as u64 to system_instruction::allocate is cleaner and aligns with the API signature.
test-integration/programs/schedulecommit-security/src/lib.rs (2)

2-2: LGTM: Import addition is correct.

The CommitPolicy import is necessary for the API change on line 149.


143-150: No action required—the two CPI paths use intentionally different APIs.

The review comment's concern about consistency is based on a false premise. The code uses two fundamentally different functions from different modules:

  • Path 1 (schedule_commit_cpi_instruction): A local program API wrapper with a fixed, simplified interface
  • Path 2 (create_schedule_commit_ix): An external SDK function with extended configuration options including CommitPolicy

These are not parallel implementations requiring symmetry. The schedule_commit_cpi_instruction function does not support CommitPolicy by design—it wraps commit scheduling with hardcoded policy defaults. Adding CommitPolicy::UseFullBytes to create_schedule_commit_ix is the correct change and requires no corresponding update to schedule_commit_cpi_instruction.

Likely an incorrect or invalid review comment.

test-integration/test-tools/src/integration_test_context.rs (1)

167-171: Transaction version configuration is correct and environment-aware.

The conditional logic properly handles two distinct RPC endpoints:

  • Chain (Solana devnet): max_supported_transaction_version: Some(0) with 50 retries to handle devnet's known quirk of sometimes returning version responses instead of transaction metadata (noted at line 160-161).
  • Ephemeral (local validator): None to use default behavior on a controlled, local environment without such quirks.

Git history confirms this change is part of the current PR (commit 4c75d78). The code is correctly differentiated for each environment. No changes needed.

test-integration/test-tools/src/scheduled_commits.rs (1)

182-213: LGTM! Clear hierarchical naming for log variables.

The renaming from ephem_logs/chain_logs to ephem_logs_l1/ephem_logs_l2 improves clarity by establishing a consistent naming convention that reflects the two-level log retrieval hierarchy.

magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1)

29-33: LGTM: CommitDiff included in strategy persistence.

Cleanly broadens Commit to CommitDiff without changing strategy semantics.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)

224-230: Diff-aware commit routing is correct; keep logs concise.

Choosing StandaloneDiff when request_diff is true is right. Consider demoting the "StandaloneDiff" ic_msg to debug in production builds to reduce log noise.

Also applies to: 233-238


29-32: All call sites properly initialize request_diff—no corrections needed.

Verification confirms that every process_schedule_commit() invocation explicitly sets both request_undelegation and request_diff fields. All three instruction paths (ScheduleCommit, ScheduleCommitAndUndelegate, ScheduleCommitDiffAndUndelegate) pass values for request_diff, with ScheduleCommitDiffAndUndelegate correctly setting it to true to trigger the CommitType::StandaloneDiff path. No uninitialized defaults are used, and no silent routing to full-state commits can occur.

programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs (1)

29-30: LGTM: commit_diff added end-to-end with safe logging.

Field is carried into printable form and logged only as a flag. Tests initialize the new field.

Also applies to: 44-45, 71-73, 215-217, 254-255

magicblock-committor-service/src/tasks/args_task.rs (1)

197-205: Calibrate compute units for CommitDiff based on diff size.

Fixed 65_000 may be inaccurate. Once diff is precomputed, scale CU by diff length/segments or add headroom to avoid CU errors.

Based on learnings

programs/magicblock/src/magicblock_processor.rs (3)

2-2: LGTM: import added is correct.


51-54: ScheduleCommit: explicit request_diff=false is correct.


90-99: New ScheduleCommitDiffAndUndelegate path correctly flips request_diff=true.

magicblock-committor-service/src/tasks/task_builder.rs (1)

96-105: Per-account Commit vs CommitDiff task selection is correct.

programs/magicblock/src/magic_scheduled_base_intent.rs (6)

104-107: ScheduledBaseIntent::is_commit_diff added — OK.


155-164: MagicBaseIntent::is_commit_diff added — OK.


448-454: CommitType::is_commit_diff implementation — OK.


456-463: Getters updated for StandaloneDiff — OK.

Also applies to: 465-473


475-487: is_empty handles StandaloneDiff — OK.


317-323: StandaloneDiff variant already exists and is actively used in the codebase.

The review's concern assumes StandaloneDiff is a new addition that will shift bincode discriminants. However, the variant is already present in process_schedule_commit.rs (lines 225–226), indicating it exists before this PR or is not new.

If StandaloneDiff was already committed to the codebase:

  • The bincode discriminant shift already happened (or never was a concern).
  • The review comment's warning is outdated or misguided.

If the snippet shows the final state (post-changes) and StandaloneDiff was genuinely added in this PR:

  • Verify the diff shows it was inserted between existing variants (which would shift discriminants).
  • If it was appended after existing variants, discriminants remain stable and no migration is needed.

Critical finding: No backwards compatibility tests, no versioning code, and no serde external tagging exist. If persisted state truly exists and the variant order changed, this is a risk. However, the evidence suggests StandaloneDiff is not new.

Action for developer: Confirm in the PR diff that you are not reordering existing enum variants. If appending new variants after existing ones, bincode compatibility is safe. If inserting between existing variants, migration is required.

test-integration/schedulecommit/test-scenarios/Cargo.toml (1)

19-20: LGTM!

The addition of rand and borsh as workspace dev-dependencies appropriately supports the new order-book test scenarios introduced in this PR.

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

30-31: LGTM!

The addition of deterministic seed b"magic_schedule_commit" improves test reproducibility by ensuring consistent PDA derivation across test runs.

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)

16-35: LGTM!

The seed parameter enables deterministic test context initialization, and explicitly driving the init_committees and delegate_committees workflow steps with debug logging improves test clarity and observability.


41-47: LGTM!

Making assert_one_committee_was_committed generic over type T with appropriate trait bounds enables reuse across different account types (MainAccount, OrderBookOwned, etc.) while maintaining type safety.

test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (2)

23-80: LGTM!

The test properly validates that attempting to commit a fee payer without escrowing lamports fails with the expected "DoesNotHaveEscrowAccount" error. The test structure and assertions are appropriate.


83-135: LGTM!

The test correctly validates the happy path where fee payer commits succeed when lamports are properly escrowed. The verification flow and assertions comprehensively check that both committees and the fee payer were committed and synchronized.

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)

55-56: LGTM!

The addition of deterministic seed b"magic_schedule_commit" ensures reproducible test behavior across runs.


110-164: LGTM!

The commit_and_undelegate_order_book_account helper follows the established pattern of other commit helpers in this file, properly constructing the update and schedule-commit-diff instructions sequence.


244-312: Excellent reproducibility design for randomized testing.

The test demonstrates best practices for randomized testing:

  • Prints the RNG seed for reproducibility
  • Includes the seed in assertion failure messages
  • Uses seeded RNG (StdRng) for deterministic behavior given a seed

This allows failures to be reproduced by rerunning with the printed seed value.

One optional enhancement: consider adding a way to override the seed via environment variable for easier failure reproduction:

let rng_seed = std::env::var("TEST_RNG_SEED")
    .ok()
    .and_then(|s| s.parse::<u64>().ok())
    .unwrap_or_else(|| OsRng.next_u64());
test-integration/programs/schedulecommit/src/lib.rs (1)

561-571: Use commit_diff for undelegate path; this looks correct.

The diff-based commit is invoked when undelegate is true; good alignment with the new optimization.

Please confirm tests cover both diff and full-commit paths (with/without undelegate).

test-integration/programs/schedulecommit/src/order_book.rs (1)

101-116: Bounds/capacity logic is good; but relies on header being valid.

Once header init is fixed in process_init_order_book, these helpers are fine for basic growth semantics.

Ensure tests cover:

  • Non-zero existing asks/bids followed by additional inserts (to exercise prefix/suffix behavior).
  • Capacity exhaustion returning None.

Also applies to: 118-138, 163-184

test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)

260-267: Seed semantics are correct and consistently applied across the codebase.

The verification shows that delegate_account_cpi_instruction() explicitly branches on two supported canonical seeds:

  • b"magic_schedule_commit"ScheduleCommitInstruction::DelegateCpi
  • b"order_book"ScheduleCommitInstruction::DelegateOrderBook

All test utilities and callers supply only these supported seeds. The delegate_committees() function at lines 260-267 correctly passes &self.user_seed, and all constructors receive only canonical seeds from test callers. PDA derivation and instruction creation use consistent seed semantics.

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

♻️ Duplicate comments (22)
magicblock-rpc-client/src/lib.rs (1)

430-430: Redundant error prefix persists in log message.

The error! macro already includes ERROR level in its output. The explicit "> ERROR:" prefix creates redundancy and reduces log readability.

Apply this diff to remove the redundant prefix:

-            error!("> ERROR: {:?}", err);
+            error!("{:?}", err);

Or add context instead:

-            error!("> ERROR: {:?}", err);
+            error!("Transaction processed status failed: {:?}", err);
test-integration/test-tools/src/scheduled_commits.rs (2)

198-210: Verbose debug output concern still applies.

The past review comment regarding verbose debug output from println! with {:#?} formatting remains applicable to these new debug statements. Consider making the debug output conditional or using a more compact format.


233-235: Unnecessary clone() on Copy type.

The past review comment regarding the redundant .clone() call on Signature (which implements Copy) remains applicable. Use *sig instead of sig.clone().

test-integration/test-tools/src/integration_test_context.rs (1)

157-158: Format the panic message with label.

The panic still prints the literal rpc_client for [{}] does not exist, so the label never appears when this trips. Please inject label into the message.

-        let rpc_client =
-            rpc_client.expect("rpc_client for [{}] does not exist");
+        let rpc_client = rpc_client.unwrap_or_else(|| {
+            panic!("rpc_client for [{}] does not exist", label)
+        });
test-integration/schedulecommit/client/src/verify.rs (1)

16-23: Code duplication: consider the generic implementation suggested in the previous review.

This function duplicates fetch_and_verify_commit_result_from_logs except for the type parameter. A generic implementation with T: borsh::BorshDeserialize would eliminate this duplication.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)

115-118: PDA derivation must match program-side seeds.

The PDA is derived using an arbitrary user_seed, which may not match the on-chain program's expected seeds (e.g., [b"order_book", book_manager] or [b"magic_schedule_commit", player]). This mismatch will cause transaction failures.


170-203: Validate user_seed explicitly to prevent silent misconfiguration.

The implicit else branch will execute for any user_seed that isn't b"magic_schedule_commit", including invalid values. Add explicit validation to fail fast with a clear error when an unsupported seed is provided.

test-integration/programs/schedulecommit/src/api.rs (1)

106-109: Derive delegated PDA with canonical seeds to match on-chain expectations.

The PDA is derived using an arbitrary user_seed, but the on-chain program expects fixed seeds like [b"magic_schedule_commit", player] or [b"order_book", book_manager]. This mismatch will cause the delegated_account to not match program-side expectations.

Cargo.toml (1)

112-112: CI/CD will fail: local path dependency not available.

The path ../delegation-program does not exist in the repository or CI environments, causing all builds to fail. Either:

  • Revert to a git-based dependency (consistent with the learning about using git branch references)
  • Make delegation-program a workspace member at the correct path
  • Update CI workflows to checkout the dependency

Verify the intended dependency resolution strategy:

#!/bin/bash
# Check if the delegation-program path exists
if [ -d "../delegation-program" ]; then
    echo "✓ Path exists locally"
    ls -la ../delegation-program/
else
    echo "✗ Path ../delegation-program does not exist"
fi

# Check for any git submodule configuration
echo ""
echo "=== Git submodules ==="
git submodule status 2>/dev/null || echo "No submodules configured"

# Check recent commits for this dependency change
echo ""
echo "=== Recent changes to delegation-program dependency ==="
git log -n 5 --oneline --all -- Cargo.toml | head -10
test-integration/Cargo.toml (1)

40-40: Critical: Local path dependencies will break CI builds.

This issue has already been flagged in previous review comments. The local paths ../../ephemeral-rollups-sdk/rust/sdk and ../../delegation-program do not exist in the CI environment and will cause build failures.

Also applies to: 60-60

test-integration/programs/schedulecommit/src/lib.rs (4)

302-309: Zero the order-book header immediately after allocation.

OrderBook::new reads bids_len/asks_len straight from account data. Leaving those bytes uninitialized means random counts, which makes the next borrow calculate bogus slices and can walk past the buffer. Please clear the header bytes right after allocation (e.g. borrow data, zero the first size_of::<OrderBookHeader>() bytes).

Apply this diff:

     allocate_account_and_assign_owner(AllocateAndAssignAccountArgs {
         payer_info: payer,
         account_info: order_book,
         owner: &crate::ID,
         signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]],
         size: 10 * 1024,
     })?;
 
+    {
+        let mut data = order_book.try_borrow_mut_data()?;
+        let header_len = core::mem::size_of::<OrderBookHeader>();
+        if data.len() < header_len {
+            return Err(ProgramError::AccountDataTooSmall);
+        }
+        for byte in &mut data[..header_len] {
+            *byte = 0;
+        }
+    }
+
     Ok(())

329-334: Fix the PDA assertion message.

The diagnostic still prints payer.key, so a failing check points at the wrong seed. Swap it for book_manager.key as previously requested.

Apply this diff:

     assert_keys_equal(order_book.key, &pda, || {
         format!(
             "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            order_book.key, book_manager.key
         )
     })?;

398-403: Update the log label.

This path is mutating an existing order book, not initializing one. Please change the msg! to say “Update order book” (or equivalent) so logs stay accurate.


424-451: Use the right error kind and require the payer to sign.

When the accounts slice is the wrong length you must emit ProgramError::NotEnoughAccountKeys; MissingRequiredSignature is misleading. More importantly, we still never verify payer.is_signer, so the CPI can run with an unsigned funder. Add assert_is_signer(payer, "payer")? before the CPI.

Apply this diff:

     let [payer, order_book_account, magic_context, magic_program] = accounts
     else {
-        return Err(ProgramError::MissingRequiredSignature);
+        return Err(ProgramError::NotEnoughAccountKeys);
     };
 
+    assert_is_signer(payer, "payer")?;
+
     commit_diff_and_undelegate_accounts(
         payer,
         vec![order_book_account],
         magic_context,
         magic_program,
test-integration/programs/schedulecommit/src/order_book.rs (3)

45-55: deserialize still aliases immutable data mutably (UB).

slice::from_raw_parts_mut on book_bytes forges a &mut [u8] from shared data, violating Rust’s aliasing rules and instantly triggering undefined behaviour. Please replace this with a safe path—e.g. copy into an owned buffer or implement a parser that reads header/levels straight from the immutable slice.


85-93: OrderBook::new assumes alignment that account data does not guarantee.

Casting header_bytes.as_ptr() to *mut OrderBookHeader (and the level pointer to *mut OrderLevel) requires 4/8‑byte alignment, but Solana account data is byte-aligned. The moment you dereference those pointers you trigger UB. Rework this to treat the buffer as raw bytes and read/write fields with from_le_bytes/to_le_bytes instead of typed references.


140-178: Typed slices over account data remain unsafe.

slice::from_raw_parts(_ as *mut OrderLevel, ...) for bids/asks/buffer helpers creates slices of OrderLevel out of unaligned memory. That’s the same UB called out earlier. Please keep the backing store as [u8], then decode/encode each OrderLevel by copying 16 bytes into a local array and using u64::from_le_bytes / u64::to_le_bytes.

magicblock-magic-program-api/src/instruction.rs (1)

111-111: Add documentation for ScheduleCommitDiffAndUndelegate.

This issue was already identified in a previous review. The variant lacks documentation while all sibling variants include doc comments describing the instruction purpose and account references.

magicblock-committor-service/src/tasks/args_task.rs (3)

75-103: Stop hard-coding the RPC endpoint in CommitDiff.

ChainConfig::local(ComputeBudgetConfig::new(1_000_000)) forces every CommitDiff task to dial http://localhost:7799 with Processed commitment and re-create an RPC client each time instruction() is called. In production that URI does not exist, so we immediately fall back to commit_state and never ship a diff; plus every call repeats the network fetch we already warned about. Inject the real ChainConfig/RpcClient from the service (or precompute/cache the diff during task construction) so instruction() stays pure and uses the configured endpoint. Prior feedback on this remains unresolved.


115-116: Do not log raw diff payloads.

Dumping the entire diff at warn level leaks account data and explodes log volume. Log only bounded metadata (e.g., commit_id, pubkey, diff length) instead.

-                log::warn!("DIFF computed: {:?}", args.diff);
+                log::debug!(
+                    "commit_diff computed: commit_id={} pubkey={} len={}",
+                    value.commit_id,
+                    value.committed_account.pubkey,
+                    args.diff.len()
+                );

171-173: Remove the CommitDiff panic in optimize().

optimize() is part of the normal pipeline; panicking here will abort the worker whenever a CommitDiff task flows through. Return Err(self) (mirroring the other variants) so the caller can fall back cleanly.

-            ArgsTaskType::CommitDiff(_) => {
-                panic!("ArgsTaskType::CommitDiff not handled")
-            }
+            ArgsTaskType::CommitDiff(_) => Err(self),
programs/magicblock/src/magicblock_processor.rs (1)

38-38: Avoid logging entire MagicBlockInstruction payloads.

ic_msg!(..., "{:?}", instruction) dumps the full enum—including the diff bytes you just added—on every invocation. That inflates CU cost and spams logs, an issue we already called out earlier. Drop the log or gate it behind a debug-only feature flag so mainnet builds don’t emit the payload.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5c5e15 and 693af7f.

⛔ 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 (28)
  • Cargo.toml (1 hunks)
  • magicblock-accounts/src/scheduled_commits_processor.rs (3 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (6 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (1 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (3 hunks)
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1 hunks)
  • magicblock-magic-program-api/src/instruction.rs (1 hunks)
  • magicblock-rpc-client/src/lib.rs (1 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (7 hunks)
  • programs/magicblock/src/magicblock_processor.rs (4 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs (5 hunks)
  • test-integration/Cargo.toml (2 hunks)
  • test-integration/programs/schedulecommit-security/src/lib.rs (2 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (5 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (9 hunks)
  • test-integration/programs/schedulecommit/src/order_book.rs (1 hunks)
  • test-integration/programs/schedulecommit/src/utils/mod.rs (3 hunks)
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs (6 hunks)
  • test-integration/schedulecommit/client/src/verify.rs (2 hunks)
  • test-integration/schedulecommit/test-scenarios/Cargo.toml (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1 hunks)
  • test-integration/test-ledger-restore/tests/08_commit_update.rs (2 hunks)
  • test-integration/test-tools/src/integration_test_context.rs (2 hunks)
  • test-integration/test-tools/src/scheduled_commits.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 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-tools/src/integration_test_context.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.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:

  • test-integration/Cargo.toml
  • Cargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (15)
test-integration/programs/schedulecommit-security/src/lib.rs (1)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • create_schedule_commit_ix (41-66)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (49-54)
magicblock-accounts/src/scheduled_commits_processor.rs (2)
  • new (66-90)
  • new (420-436)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
  • base_intent (544-549)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (145-146)
programs/magicblock/src/magicblock_processor.rs (3)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • instruction (58-160)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
  • process_schedule_commit (34-259)
magicblock-committor-program/src/state/changeset.rs (1)
  • request_undelegation (230-232)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
  • get_context_with_delegated_committees (16-35)
magicblock-committor-service/src/tasks/args_task.rs (3)
magicblock-committor-service/src/tasks/mod.rs (2)
  • instruction (66-66)
  • instruction (249-255)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • instruction (65-86)
magicblock-committor-service/src/config.rs (1)
  • local (29-35)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (145-146)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
  • init_order_book_instruction (36-54)
  • init_payer_escrow (77-98)
  • init_account_instruction (16-34)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_new (113-115)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
  • setup_validator_with_local_remote (97-119)
test-integration/programs/schedulecommit/src/api.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (85-94)
test-integration/programs/flexi-counter/src/state.rs (1)
  • pda (32-35)
test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (4)
test-integration/test-runner/bin/run_tests.rs (1)
  • run_test (777-796)
test-integration/programs/schedulecommit/src/api.rs (1)
  • schedule_commit_with_payer_cpi_instruction (214-232)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (4)
  • assert_two_committees_synchronized_count (139-169)
  • assert_two_committees_were_committed (68-91)
  • get_context_with_delegated_committees (16-35)
  • assert_feepayer_was_committed (94-113)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_commit_result_from_logs (7-14)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-106)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (85-94)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)
test-integration/programs/schedulecommit/src/api.rs (3)
  • schedule_commit_and_undelegate_cpi_with_mod_after_instruction (287-311)
  • schedule_commit_diff_instruction_for_order_book (193-212)
  • update_order_book_instruction (175-191)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
  • assert_one_committee_account_was_undelegated_on_chain (190-196)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • committees (205-209)
  • ephem_blockhash (322-324)
  • ephem_client (318-320)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (20)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)

49-55: LGTM: Type alignment with Solana API.

Changing size from usize to u64 correctly aligns with Solana's system_instruction::allocate signature, which expects space: u64.


75-79: LGTM: Helpful debug logging.

The added logging for lamport requirements and payer balance aids in troubleshooting account allocation issues during testing.


90-90: Critical fix: Correct system_instruction::allocate signature.

The updated call now correctly provides both required arguments (pubkey and space) to system_instruction::allocate. The previous implementation appears to have been missing the pubkey argument, which would not match the function signature: pub fn allocate(pubkey: &Pubkey, space: u64) -> Instruction.

test-integration/test-tools/src/scheduled_commits.rs (1)

182-213: Variable renaming improves clarity.

The renaming of log variables to ephem_logs_l1 and ephem_logs_l2 clearly distinguishes the two-level log fetching process, and the updated error context at line 206 now correctly references the first-level logs. These changes enhance code readability.

test-integration/programs/schedulecommit-security/src/lib.rs (2)

2-2: LGTM!

The CommitPolicy import is correctly added to support the new argument at line 149.


143-150: Ignore this review comment. The original comment incorrectly assumes that schedule_commit_cpi_instruction and create_schedule_commit_ix should be consistent, but they are two distinct functions from different crates with different purposes:

  • schedule_commit_cpi_instruction (from program_schedulecommit::api) is a local CPI helper that does not accept a CommitPolicy parameter
  • create_schedule_commit_ix (from ephemeral_rollups_sdk::ephem) is an SDK function that accepts CommitPolicy as a parameter

The two functions have intentionally different signatures. There is no test inconsistency to address.

Likely an incorrect or invalid review comment.

test-integration/test-ledger-restore/tests/08_commit_update.rs (1)

55-61: No issues found—code is correct as written.

The TempDir returned by setup_validator_with_local_remote is created specifically for temporary config storage during validator initialization (written in start_magicblock_validator_with_config_struct at line 225: fs::write(&config_path, config_toml)). After the validator process is spawned, this directory is no longer needed and is safely dropped. The actual ledger directory is managed separately by the main _tmpdir at line 42 of the test, which persists for the entire test duration. The binding to _tmpdir with an underscore prefix correctly signals that this return value is intentionally unused beyond validator initialization.

test-integration/programs/schedulecommit/src/api.rs (3)

36-54: LGTM!

The init_order_book_instruction follows the standard instruction builder pattern with appropriate account metadata.


56-75: LGTM!

The grow_order_book_instruction correctly constructs the instruction with the additional_space parameter.


175-212: LGTM!

Both update_order_book_instruction and schedule_commit_diff_instruction_for_order_book follow correct instruction builder patterns with appropriate account metadata.

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

30-31: LGTM! Deterministic seed ensures reproducible test contexts.

The hard-coded seed b"magic_schedule_commit" provides deterministic PDA derivation and context initialization, which improves test reliability and debugging.

Also applies to: 84-85

test-integration/schedulecommit/test-scenarios/tests/03_commits_fee_payer.rs (2)

82-135: LGTM! Fee payer escrow test properly verifies expected behavior.

The test correctly verifies that with proper escrow setup, the fee payer commit succeeds and all expected assertions pass.


34-41: Fix struct field destructuring: payer_ephem field and ephem_blockhash retrieval.

The code attempts to destructure non-existent struct fields:

  • Line 35: payer field doesn't exist in ScheduleCommitTestContextFields — should be payer_ephem: payer
  • Line 39: ephem_blockhash is not a struct field — must be fetched separately via ephem_client.get_latest_blockhash().unwrap()
  • Lines 58, 112: Remove dereference (*) from ephem_blockhash once corrected

See 01_commits.rs (lines 34, 54) for the correct pattern.

Also applies to: 88-95, 112

⛔ Skipped due to learnings
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
programs/magicblock/src/magic_scheduled_base_intent.rs (3)

104-106: LGTM!

The is_commit_diff() method correctly delegates to the base intent, following the same pattern as the existing is_undelegate() method.


155-163: LGTM!

The is_commit_diff() method correctly handles all MagicBaseIntent variants, properly delegating to the underlying CommitType for both Commit and CommitAndUndelegate cases.


458-458: LGTM!

The accessor methods correctly handle the new StandaloneDiff variant, treating it identically to Standalone since both contain Vec<CommittedAccount>.

Also applies to: 468-468, 480-482

magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (2)

29-33: LGTM!

The match correctly handles both Commit and CommitDiff variants identically, as both contain CommitTask and should be persisted the same way.


59-59: ****

The review comment is incorrect. BufferTaskType intentionally has only a single Commit variant because it represents buffer-based commit operations. CommitDiff is a separate task variant that belongs exclusively to ArgsTaskType and is handled through a different code path.

Evidence:

  • ArgsTaskType includes CommitDiff(CommitTask), but BufferTaskType does not
  • ArgsTaskType::CommitDiff explicitly panics with "ArgsTaskType::CommitDiff not handled" when attempting conversion, indicating CommitDiff is intentionally not converted to BufferTask
  • The refutable pattern at line 59 is safe because BufferTaskType can only ever contain a single variant

No code changes are needed; the refutable pattern is correct as implemented.

Likely an incorrect or invalid review comment.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)

31-31: LGTM!

The request_diff field addition cleanly extends the options structure to control diff-based commit scheduling.


231-238: LGTM!

The commit_action is correctly used in both the undelegation and non-undelegation paths, enabling diff-based commits for both scenarios while preserving existing semantics.

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 693af7f to 99f2e8f Compare October 31, 2025 14:19
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

♻️ Duplicate comments (8)
test-integration/Cargo.toml (1)

40-40: ⚠️ Path dependency concerns from prior review remain unresolved.

The migration from git-based to local path dependencies for ephemeral-rollups-sdk and magicblock-delegation-program still poses the same critical CI/CD risks flagged in the previous review: these paths do not exist in the repository, CI workflows do not clone them, and builds will fail in CI/CD and for contributors without manual setup.

The prior review's recommendations still apply:

  1. Update CI to clone both external repositories, OR
  2. Switch back to git-based references, OR
  3. Add clear setup documentation with exact clone commands and relative paths

Also applies to: 60-60

magicblock-committor-service/src/tasks/args_task.rs (2)

228-234: reset_commit_id must handle CommitDiff variant.

The current implementation only updates the commit_id for Commit tasks and silently returns for CommitDiff. When a CommitDiff task is recycled, the stale commit_id will remain, causing desynced submissions.

Apply this fix to handle both variants:

 fn reset_commit_id(&mut self, commit_id: u64) {
-    // TODO (snawaz): handle CommitDiff as well? what is it about?
-    let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-        return;
-    };
-
-    commit_task.commit_id = commit_id;
+    match &mut self.task_type {
+        ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+            task.commit_id = commit_id;
+        }
+        _ => {
+            // Only Commit and CommitDiff tasks have commit_id
+        }
+    }
 }

74-122: Network I/O inside instruction() remains a major concern.

The instruction() method performs RPC calls and diff computation on every invocation, which is expensive and risky:

  • instruction() may be called multiple times (e.g., via involved_accounts), multiplying RPC calls
  • TOCTOU: base-chain account can change between diff calculation and transaction submission
  • Coupling to network hinders testing and determinism

Per previous discussion, this is acknowledged as temporary and will be addressed in subsequent PRs. Consider tracking this technical debt.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

224-228: Consider enhancing observability as previously suggested.

The conditional logic correctly selects the commit type based on request_diff. However, a past review comment suggests improving the log messages to include the number of committed accounts and the flag value for better operational visibility.

test-integration/programs/schedulecommit/src/order_book.rs (2)

99-119: Unaligned typed reference to OrderBookHeader remains a critical issue.

Line 114 creates a typed reference &mut OrderBookHeader via raw pointer cast. While alignment is asserted at runtime (lines 102-110), Solana account data does not guarantee alignment for arbitrary types. This is undefined behavior if the account data is not aligned to align_of::<OrderBookHeader>().

The assertion will catch misalignment at runtime, but the proper fix is to avoid typed references entirely. Consider reading/writing the header fields as raw bytes using little-endian encoding.


165-178: Typed slices over potentially unaligned memory (OrderLevel).

Lines 166 and 173-174 use slice::from_raw_parts to create typed slices of OrderLevel (which contains u64 fields requiring 8-byte alignment). Account data alignment is not guaranteed by Solana, leading to undefined behavior on read.

Per previous review: store levels as raw bytes and provide accessors that read/write fields via u64::from_le_bytes/to_le_bytes, or use a packed representation without taking references to fields.

test-integration/programs/schedulecommit/src/lib.rs (2)

280-311: Critical: OrderBook header is never initialized.

After allocate_account_and_assign_owner returns (line 308), the account data contains uninitialized memory. Subsequent calls to OrderBook::new will read uninitialized bids_len and asks_len values, causing undefined behavior.

Apply this fix immediately after allocation:

     allocate_account_and_assign_owner(AllocateAndAssignAccountArgs {
         payer_info: payer,
         account_info: order_book,
         owner: &crate::ID,
         signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]],
         size: 10 * 1024,
     })?;
 
+    // Initialize header to zero
+    let mut data = order_book.try_borrow_mut_data()?;
+    let header_size = core::mem::size_of::<OrderBookHeader>();
+    for b in &mut data[..header_size] {
+        *b = 0;
+    }
 
     Ok(())

329-334: Incorrect identifier in PDA assertion error message.

Line 332 incorrectly references payer.key in the error message, which should be book_manager.key to accurately reflect the PDA derivation.

Apply this fix:

     assert_keys_equal(order_book.key, &pda, || {
         format!(
             "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            order_book.key, book_manager.key
         )
     })?;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 693af7f and 99f2e8f.

⛔ 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-committor-service/src/tasks/args_task.rs (6 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (7 hunks)
  • programs/magicblock/src/magicblock_processor.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • test-integration/Cargo.toml (4 hunks)
  • test-integration/programs/schedulecommit/Cargo.toml (1 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (9 hunks)
  • test-integration/programs/schedulecommit/src/order_book.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 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-committor-service/src/tasks/args_task.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (5)
magicblock-committor-service/src/tasks/args_task.rs (3)
magicblock-committor-service/src/tasks/mod.rs (2)
  • instruction (66-66)
  • instruction (249-255)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • instruction (65-86)
magicblock-committor-service/src/config.rs (1)
  • local (29-35)
programs/magicblock/src/magicblock_processor.rs (1)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
  • process_schedule_commit (34-258)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
  • base_intent (544-549)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-106)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (99-119)
🔇 Additional comments (11)
test-integration/Cargo.toml (1)

72-72: Now let me check the codebase for actual usage of these dependencies to confirm they are necessary:

Based on my verification, I can now generate the rewritten review comment:


Both dependencies are compatible with Solana 2.2 and appropriate for this PR.

rkyv 0.7.45 supports no_std and no_alloc configurations, making it suitable for Solana on-chain programs. It supports no-std builds for targets without a standard library and no-alloc builds for targets where allocations cannot be made. The Solana VM guarantees that account data is byte-aligned to a multiple of 8, which enables rkyv's zero-copy deserialization to function safely on account data. static_assertions 1.1.0 is a stable, widely-adopted crate (225,914,390 downloads all time) providing compile-time assertion macros useful for validating account structure layouts and sizes—a common pattern in Solana programs.

No further verification needed.

test-integration/programs/schedulecommit/Cargo.toml (1)

11-12: LGTM! Dependencies properly support order book implementation.

The additions of rkyv and static_assertions are well-utilized in order_book.rs for alignment guarantees and compile-time size/alignment checks.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

31-31: LGTM! New field enables diff-based commit path.

The request_diff flag properly controls whether to use CommitType::StandaloneDiff or CommitType::Standalone, enabling the optimization for large accounts with small changes.

programs/magicblock/src/magicblock_processor.rs (2)

44-59: LGTM! Existing instructions properly default to non-diff path.

Both ScheduleCommit and ScheduleCommitAndUndelegate correctly set request_diff: false to maintain existing behavior.


85-92: LGTM! New instruction variant correctly enables diff-based commit with undelegation.

The ScheduleCommitDiffAndUndelegate instruction properly sets both request_undelegation: true and request_diff: true, mirroring ScheduleCommitAndUndelegate behavior while enabling the diff optimization.

test-integration/programs/schedulecommit/src/order_book.rs (1)

48-75: LGTM! Mutable aliasing UB resolved with aligned copy.

The implementation now safely copies the input buffer into rkyv::AlignedVec before creating mutable references, avoiding the undefined behavior from the previous approach. The comment clearly explains the rationale.

magicblock-committor-service/src/tasks/args_task.rs (2)

171-172: LGTM! CommitDiff correctly returns Err(self) in optimize().

Returning Err(self) for CommitDiff is correct since the diff is already optimized by design—it sends only the differences rather than full account data. Converting to BufferTask would be counterproductive.

Per previous discussion, this is the correct semantic since CommitDiff is already using the most efficient data transfer strategy.


196-203: LGTM! Compute units appropriately set for CommitDiff.

The 65,000 compute units for CommitDiff (vs 70,000 for Commit) reflects the reduced work from transmitting only the diff. This aligns with the test observation showing lower CU usage.

Based on learnings: these are compute units per task, and transactions may comprise multiple tasks.

test-integration/programs/schedulecommit/src/lib.rs (3)

203-203: LGTM! Type change to u64 is appropriate.

Changing MainAccount::SIZE from usize to u64 aligns with the size parameter type in allocate_account_and_assign_owner (line 255) and Solana's account size conventions.


398-414: LGTM! Log message and signer check are correct.

Line 402 now uses the accurate log message "Update orderbook", and line 407 properly validates that the payer is a signer before allowing the update.


419-439: LGTM! Handler correctly uses diff-based commit with undelegation.

The implementation properly:

  • Returns NotEnoughAccountKeys when accounts are missing (line 426)
  • Validates payer is a signer (line 429)
  • Invokes commit_diff_and_undelegate_accounts for the optimized diff path (line 431)

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 99f2e8f to 7eaaa13 Compare October 31, 2025 14:50
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-committor-service/src/tasks/args_task.rs (1)

228-235: Critical: reset_commit_id silently ignores CommitDiff tasks.

When a CommitDiff task is recycled, the current code silently returns without updating its commit_id (line 230-232), leaving stale IDs that will cause:

  • Desynchronization with actual commit state
  • Failed submissions with wrong nonce
  • Data integrity issues

A past review correctly identified this issue.

Apply this fix to handle both Commit and CommitDiff:

     fn reset_commit_id(&mut self, commit_id: u64) {
-        // TODO (snawaz): handle CommitDiff as well? what is it about?
-        let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-            return;
-        };
-
-        commit_task.commit_id = commit_id;
+        match &mut self.task_type {
+            ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+                task.commit_id = commit_id;
+            }
+            _ => {
+                // Other task types don't have commit_id
+            }
+        }
     }
♻️ Duplicate comments (7)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)

389-446: CRITICAL: try_from_args cannot construct StandaloneDiff.

The try_from_args method only handles CommitTypeArgs::Standalone and CommitTypeArgs::WithBaseActions, but does not handle CommitTypeArgs::StandaloneDiff. This means:

  1. Code paths using try_from_args (e.g., process_schedule_base_intent) cannot construct CommitType::StandaloneDiff
  2. Only process_schedule_commit can create it programmatically
  3. Any attempt to deserialize CommitTypeArgs::StandaloneDiff from instruction data will fail

This creates a critical inconsistency where the StandaloneDiff variant cannot be fully utilized across all code paths.

The method needs a new match arm similar to:

 pub fn try_from_args(
     args: CommitTypeArgs,
     context: &ConstructionContext<'_, '_>,
 ) -> Result<CommitType, InstructionError> {
     match args {
         CommitTypeArgs::Standalone(accounts) => {
             // ... existing code ...
             Ok(CommitType::Standalone(committed_accounts))
         }
+        CommitTypeArgs::StandaloneDiff(accounts) => {
+            let committed_accounts_ref = Self::extract_commit_accounts(
+                &accounts,
+                context.transaction_context,
+            )?;
+            Self::validate_accounts(&committed_accounts_ref, context)?;
+            let committed_accounts = committed_accounts_ref
+                .into_iter()
+                .map(|el| {
+                    let mut committed_account: CommittedAccount = el.into();
+                    committed_account.account.owner = context
+                        .parent_program_id
+                        .unwrap_or(committed_account.account.owner);
+                    committed_account
+                })
+                .collect();
+            Ok(CommitType::StandaloneDiff(committed_accounts))
+        }
         CommitTypeArgs::WithBaseActions { ... } => {
             // ... existing code ...
         }
     }
 }

Based on past review comment.

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

224-228: Add observability logging for commit type selection.

The conditional logic correctly selects the commit type, but lacks logging to indicate which path was taken. This makes debugging and auditing more difficult.

Based on past review comment, consider adding:

 let commit_action = if opts.request_diff {
+    ic_msg!(
+        invoke_context,
+        "ScheduleCommit: using StandaloneDiff for {} accounts",
+        committed_accounts.len()
+    );
     CommitType::StandaloneDiff(committed_accounts)
 } else {
+    ic_msg!(
+        invoke_context,
+        "ScheduleCommit: using Standalone for {} accounts",
+        committed_accounts.len()
+    );
     CommitType::Standalone(committed_accounts)
 };
magicblock-committor-service/src/tasks/args_task.rs (1)

74-122: Network I/O in instruction() confirmed as unresolved; improve fallback logging.

The RPC-in-instruction issue is genuine and remains present despite the past review claiming it was addressed in commit 99f2e8f (which does not exist in the repository).

Confirmed concerns:

  • instruction() called multiple times per task: The method is invoked from delivery_preparator.rs (line 377, mapped over cleanup_tasks), tasks/utils.rs (line 58, mapped over tasks), and task_strategist.rs (line 217, in optimization loop). Each call triggers RPC I/O on the base-chain, multiplying network overhead and creating TOCTOU race conditions.

  • ChainConfig hardcoded locally (line 76): ChainConfig is properly injected into the service/processor but ArgsTask hardcodes ChainConfig::local() instead of receiving injected config. This remains unresolved.

  • Fallback log incomplete (line 90): The message contains a typo ("commmit_id" with 3 m's) and is missing the pubkey context for debugging. Improve clarity:

-                        log::warn!("Fallback to commit_state and send full-bytes, as rpc failed to fetch the delegated-account from base chain, commmit_id: {} , error: {}", value.commit_id, e);
+                        log::warn!(
+                            "Fallback to commit_state for account {}: RPC fetch failed, commit_id={} - {}",
+                            value.committed_account.pubkey,
+                            value.commit_id,
+                            e
+                        );

The architectural concerns about performing RPC I/O during instruction building should be addressed, and the config injection pattern needs to be established.

test-integration/programs/schedulecommit/src/lib.rs (3)

280-311: Header remains uninitialized after allocation—subsequent reads are undefined.

After allocate_account_and_assign_owner, the header fields (bids_len, asks_len) are still uninitialized. Any call to OrderBook::new on this account will read garbage.

Apply this fix to zero the header immediately after allocation:

     allocate_account_and_assign_owner(AllocateAndAssignAccountArgs {
         payer_info: payer,
         account_info: order_book,
         owner: &crate::ID,
         signer_seeds: &[b"order_book", book_manager.key.as_ref(), &[bump]],
         size: 10 * 1024,
     })?;
 
+    // Initialize header to zero
+    let mut data = order_book.try_borrow_mut_data()?;
+    data[..core::mem::size_of::<OrderBookHeader>()].fill(0);
 
     Ok(())

329-334: Error message references wrong key.

The PDA assertion message incorrectly shows payer.key instead of book_manager.key, making debugging harder.

     assert_keys_equal(order_book.key, &pda, || {
         format!(
             "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            order_book.key, book_manager.key
         )
     })?;

402-402: Inconsistent log message casing.

Message says "Update orderbook" but other logs use "OrderBook" with capital letters and space for consistency.

-    msg!("Update orderbook");
+    msg!("Update order book");
test-integration/Cargo.toml (1)

40-40: Local path dependencies will break CI/CD builds.

These local path dependencies point to repositories outside the current codebase (../../ephemeral-rollups-sdk and ../../delegation-program) that are not cloned by the CI workflow. This will cause build failures for all contributors and in continuous integration.

Choose one of the following solutions:

  1. Revert to git-based dependencies (recommended for now):
-ephemeral-rollups-sdk = { path = "../../ephemeral-rollups-sdk/rust/sdk"}
+ephemeral-rollups-sdk = { git = "https://github.com/magicblock-labs/ephemeral-rollups-sdk.git", rev = "..." }
  1. Update CI to clone required repositories before build steps in .github/workflows/ci-test-integration.yml

  2. Document the local setup in README with explicit clone instructions if local paths are intended for development only

Based on learnings: This appears to be a transition to local development setup but lacks the corresponding CI infrastructure updates.

Also applies to: 60-60

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 99f2e8f and 7eaaa13.

⛔ 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-committor-service/src/tasks/args_task.rs (6 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (7 hunks)
  • programs/magicblock/src/magicblock_processor.rs (2 hunks)
  • programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2 hunks)
  • test-integration/Cargo.toml (4 hunks)
  • test-integration/programs/schedulecommit/Cargo.toml (1 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (9 hunks)
  • test-integration/programs/schedulecommit/src/order_book.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 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-committor-service/src/tasks/args_task.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (5)
magicblock-committor-service/src/tasks/args_task.rs (4)
magicblock-committor-service/src/tasks/mod.rs (2)
  • instruction (66-66)
  • instruction (249-255)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • instruction (65-86)
  • new (37-45)
magicblock-committor-service/src/config.rs (1)
  • local (29-35)
magicblock-accounts/src/scheduled_commits_processor.rs (2)
  • new (66-90)
  • new (420-436)
programs/magicblock/src/magic_scheduled_base_intent.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
programs/magicblock/src/magicblock_processor.rs (1)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)
  • process_schedule_commit (34-258)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • committed_accounts (153-156)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
  • base_intent (544-549)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-106)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (105-125)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run_make_ci_format
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_test
🔇 Additional comments (14)
programs/magicblock/src/schedule_transactions/process_schedule_commit.rs (1)

29-32: Field addition looks correct.

The new request_diff field is properly scoped as pub(crate) and the Default trait will initialize it to false, maintaining backward compatibility.

programs/magicblock/src/magicblock_processor.rs (2)

44-51: ScheduleCommit handler correctly configured.

The handler properly sets request_diff: false to maintain the existing full-commit behavior for standard commits.


85-92: New instruction handler correctly implemented.

The ScheduleCommitDiffAndUndelegate handler properly enables both undelegation and diff-based commits by setting both flags to true. The implementation follows the established pattern from the other handlers.

programs/magicblock/src/magic_scheduled_base_intent.rs (4)

104-106: Delegation method correctly implemented.

The is_commit_diff() method appropriately delegates to the underlying base_intent, following the established pattern for other query methods in this struct.


155-163: Commit diff detection logic is correct.

The method correctly returns false for BaseActions and properly delegates to the commit-related variants to determine if differential commits are enabled.


317-327: StandaloneDiff variant added correctly.

The new variant follows the same structure as Standalone, holding Vec<CommittedAccount>. Note that full account data is stored here; the actual diff computation likely occurs downstream during commit processing.


448-484: Accessor methods properly handle StandaloneDiff.

All match expressions are now exhaustive and correctly handle the new StandaloneDiff variant. The is_commit_diff() method correctly returns true only for StandaloneDiff, and the accessor methods treat it consistently with Standalone.

magicblock-committor-service/src/tasks/args_task.rs (4)

1-24: LGTM: Imports support the CommitDiff feature.

All new imports are necessary for the RPC client setup, diff computation, and configuration.


30-30: LGTM: CommitDiff variant added.

Reusing CommitTask for the CommitDiff variant is appropriate since they share the same data requirements.


171-172: LGTM: Returning Err(self) for CommitDiff is correct.

The past review discussion thoroughly analyzed this and concluded that CommitDiff should return Err(self) (no optimization) because:

  • CommitDiff is already optimized by design—it transmits only the diff (e.g., 286 bytes) vs. full account data (10,240 bytes per your test)
  • Converting CommitDiff to BufferTask would be counterproductive and defeat its purpose
  • Err(self) correctly signals "no further optimization possible"

Suggestion: The TODO on line 171 can be resolved and removed based on the past review's analysis.


199-199: LGTM: Compute units appropriately reduced for CommitDiff.

The 65,000 compute unit allocation (5k less than Commit's 70k) aligns with your test observations and reflects the reduced data processing for diff-based commits.

test-integration/programs/schedulecommit/src/lib.rs (1)

419-439: LGTM—signer validation and error handling are now correct.

The function now properly returns NotEnoughAccountKeys when the accounts array doesn't match, and validates that payer is a signer before proceeding with the CPI call.

test-integration/programs/schedulecommit/Cargo.toml (1)

11-12: LGTM—dependencies appropriately support zero-copy OrderBook.

The rkyv crate provides AlignedVec for safe buffer allocation, and static_assertions enables compile-time layout verification. Both are correctly utilized in order_book.rs.

test-integration/Cargo.toml (1)

72-72: LGTM—workspace dependencies properly declared.

The rkyv and static_assertions crates are correctly added at the workspace level, enabling their use across integration test crates for zero-copy structures and compile-time assertions.

Also applies to: 91-91

@snawaz snawaz marked this pull request as draft November 2, 2025 12:23
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 7eaaa13 to c05f313 Compare November 2, 2025 13:10
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: 2

Caution

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

⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/mod.rs (1)

324-345: NullTaskInfoFetcher prevents CommitDiff testing; full implementation incomplete.

The test uses NullTaskInfoFetcher which returns Ok(None) for get_base_account, so the 1024-byte account test falls back to CommitState and skips the CommitDiff branch entirely. However, note that CommitDiff support is currently incomplete: BufferTask panics when encountering a CommitDiffTask (see buffer_task.rs:72), and args_task.rs:141-144 contains a TODO indicating that CommitDiff cannot yet execute as a BufferTask. Adding a mock fetcher that returns Some(account) would trigger this panic and break tests. Consider revisiting this test gap once the CommitDiff path is fully implemented.

♻️ Duplicate comments (11)
test-integration/programs/schedulecommit/src/api.rs (5)

133-148: Brittle user_seed dispatch routing.

The else branch (line 140) routes all non-"magic_schedule_commit" seeds to DelegateOrderBook. Since this is a public API, unknown seeds silently succeed with potentially incorrect behavior.

Consider either:

  1. Explicit match on known seeds (b"magic_schedule_commit", b"order_book") with error/panic for others
  2. Add a doc comment stating supported seeds and that others are treated as order-book by convention
🔎 Proposed fix (explicit matching)
     Instruction::new_with_borsh(
         program_id,
-        &if user_seed == b"magic_schedule_commit" {
+        &match user_seed {
+            b"magic_schedule_commit" => {
             ScheduleCommitInstruction::DelegateCpi(DelegateCpiArgs {
                 valid_until: i64::MAX,
                 commit_frequency_ms: 1_000_000_000,
                 player: player_or_book_manager,
                 validator,
             })
-        } else {
+            }
+            b"order_book" => {
             ScheduleCommitInstruction::DelegateOrderBook(
                 DelegateOrderBookArgs {
                     commit_frequency_ms: 1_000_000_000,
                     book_manager: player_or_book_manager,
                     validator,
                 },
             )
-        },
+            }
+            _ => panic!("Unsupported user_seed: only b\"magic_schedule_commit\" and b\"order_book\" are supported"),
+        },
         account_metas,
     )

56-75: Signer mismatch between init and grow operations.

init_order_book_instruction requires book_manager as a signer (line 44: true), but grow_order_book_instruction does not (line 65: false). This allows any payer to grow someone else's order book without authorization.

If book_manager should authorize growth (consistent with init), change line 65 to true and add assert_is_signer validation in the handler. If permissive growth is intentional, document this explicitly.

🔎 Proposed fix (if authorization required)
     let account_metas = vec![
         AccountMeta::new(payer, true),
-        AccountMeta::new_readonly(book_manager, false),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
         AccountMeta::new_readonly(system_program::id(), false),
     ];

113-117: Remove debug print statements.

These println! statements appear to be temporary debugging code and should be removed before merging.

🔎 Proposed fix
     let delegate_accounts = DelegateAccounts::new(pda, program_id);
-    println!("delegate_accounts: {:#?}", delegate_accounts);
-    println!(
-        "config: {:#?}",
-        dlp::pda::program_config_from_program_id(&crate::ID)
-    );
-
     let delegate_metas = DelegateAccountMetas::from(delegate_accounts);

184-200: Missing book_manager authorization in update operation.

Unlike init_order_book_instruction and grow_order_book_instruction, this function omits the book_manager account entirely. Since order books are PDAs derived from [b"order_book", book_manager.key], anyone can currently update any order book.


202-221: Missing book_manager authorization in schedule commit operation.

Similar to update_order_book_instruction, this function omits book_manager validation, allowing anyone to schedule commits for any order book.

test-integration/test-committor-service/tests/utils/transactions.rs (2)

238-239: Fix the copy-pasted comment.

The doc comment incorrectly refers to "counter" instead of "order book".

🔎 Proposed fix
-/// This needs to be run for each test that required a new counter to be delegated
+/// This needs to be run for each test that requires a new order book to be delegated
 #[allow(dead_code)]

249-249: Fix the debug message referencing wrong context.

The debug message still references "counter auth" but this function deals with order book accounts.

🔎 Proposed fix
-    debug!("Airdropped to counter auth: {} SOL", 777 * LAMPORTS_PER_SOL);
+    debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL);
magicblock-committor-service/src/tasks/args_task.rs (1)

206-212: reset_commit_id doesn't handle CommitDiff tasks.

When a CommitDiff task needs its commit_id reset (e.g., during retry), this method silently returns without updating. This was flagged in a past review.

🔎 Proposed fix
     fn reset_commit_id(&mut self, commit_id: u64) {
-        let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-            return;
-        };
-
-        commit_task.commit_id = commit_id;
+        match &mut self.task_type {
+            ArgsTaskType::Commit(task) => {
+                task.commit_id = commit_id;
+            }
+            ArgsTaskType::CommitDiff(task) => {
+                task.commit_id = commit_id;
+            }
+            _ => {}
+        }
     }
magicblock-committor-service/src/tasks/task_builder.rs (3)

60-60: Downgrade or remove debug logging before merge.

log::warn!("create_commit_task entered") fires on every commit task creation, which will flood production logs. This was flagged in past reviews.

🔎 Proposed fix
-        log::warn!("create_commit_task entered");
+        log::trace!("create_commit_task: pubkey={}", account.pubkey);

83-87: Remove verbose debug logging that dumps full account data.

Logging full base_account and account.account with {:#?} will flood logs and potentially leak sensitive account data. This was flagged in past reviews.

🔎 Proposed fix
-            log::warn!(
-                "create_commit_task: base_account: {:#?}, {:#?}",
-                base_account,
-                account.account
-            );
+            log::debug!(
+                "create_commit_task: using CommitDiff, pubkey={}, base_len={}, new_len={}",
+                account.pubkey, base_account.data.len(), account.account.data.len()
+            );

95-95: Same issue: verbose debug logging.

🔎 Proposed fix
-            log::warn!("create_commit_task: {:#?}", account.account);
+            log::debug!("create_commit_task: using CommitState, pubkey={}", account.pubkey);
🧹 Nitpick comments (1)
test-integration/test-committor-service/tests/utils/instructions.rs (1)

68-68: Remove debug print statement.

This println! appears to be leftover debugging code. Consider removing it or converting to log::debug! if the information is valuable for test diagnostics.

🔎 Proposed fix
-    println!("schedulecommit ID: {}", ID);
+    // If logging is needed:
+    // log::debug!("schedulecommit ID: {}", ID);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 14af81f and 5d5f54b.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (11)
  • Cargo.toml
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • test-integration/test-committor-service/Cargo.toml
  • Cargo.toml
🧰 Additional context used
🧠 Learnings (19)
📚 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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/api.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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/api.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-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.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:

  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/Cargo.toml
📚 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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.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-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
📚 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-committor-service/src/tasks/mod.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-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.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:

  • test-integration/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:

  • test-integration/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/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:

  • test-integration/Cargo.toml
📚 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:

  • test-integration/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:

  • test-integration/Cargo.toml
🧬 Code graph analysis (6)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-103)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (43-46)
  • get_base_account (275-280)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-103)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • init_order_book_instruction (36-54)
  • delegate_account_cpi_instruction (100-151)
magicblock-committor-service/src/tasks/task_builder.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (162-178)
  • new (52-55)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
  • init_and_delegate_order_book_on_chain (240-300)
  • fund_validator_auth_and_ensure_validator_fees_vault (303-344)
test-integration/test-committor-service/tests/utils/mod.rs (1)
  • ensure_validator_authority (35-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (20)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (4)

34-34: LGTM!

The new import for init_and_delegate_order_book_on_chain aligns with the added order-book test infrastructure.


98-121: Good test coverage for CommitDiff boundary conditions.

The new order-book tests effectively cover the critical transition points:

  • 100 and 679 bytes → CommitStrategy::Args (fits in transaction)
  • 681 bytes → CommitStrategy::FromBuffer (exceeds limit)
  • 10k bytes → CommitStrategy::FromBuffer

The comment at lines 110-113 clearly documents why 680 is skipped (both 679 and 680 produce 1644-byte encoded tx, but raw bytes for 680 exceed 1232 limit).


188-251: Well-structured test helper for order-book commit scenarios.

The commit_book_order_account function properly:

  1. Sets up the validator authority and fees vault
  2. Initializes and delegates an order book on-chain
  3. Modifies data to produce a diff
  4. Constructs the appropriate intent based on undelegate flag
  5. Validates against expected strategy

The data modification loop (lines 214-216) using wrapping_add(1) is a clean approach to guarantee a diff is produced.


320-324: Updated strategy expectations align with Args-centric commit flow.

The multi-account tests now correctly expect CommitStrategy::Args for scenarios where transaction size permits, reflecting the new CommitDiff optimization path.

test-integration/test-committor-service/tests/utils/transactions.rs (3)

15-19: LGTM!

The extended imports properly expose the new order-book instruction helpers needed for the test utilities.


124-134: Pragmatic handling of CommitState/CommitDiff log matching.

The approach to also match "CommitDiff" when searching for "CommitState" is reasonable given that CommitDiff is an optimized variant of CommitState. The inline comment clearly explains the rationale.


240-300: Good parallel structure with existing account delegation flow.

The init_and_delegate_order_book_on_chain function mirrors the structure of init_and_delegate_account_on_chain, making the codebase consistent and maintainable. The implementation correctly:

  1. Airdrops SOL to the payer
  2. Builds init and delegate instructions via the helper
  3. Sends both transactions with appropriate signers (note: book_manager signs the init tx)
  4. Retrieves and returns the delegated account
test-integration/test-committor-service/tests/utils/instructions.rs (3)

2-3: LGTM!

The new imports for Keypair and Signer are required for the order-book instruction helper.


54-59: LGTM!

The InitOrderBookAndDelegateIxs struct follows the established pattern from InitAccountAndDelegateIxs, appropriately including the book_manager keypair needed for signing the init transaction.


70-86: LGTM!

The PDA derivation and instruction construction correctly use:

  • Seeds [b"order_book", book_manager.pubkey().as_ref()] matching the on-chain derivation
  • init_order_book_instruction for initialization
  • delegate_account_cpi_instruction with b"order_book" seed for delegation

This aligns with the API in api.rs.

test-integration/programs/schedulecommit/src/api.rs (2)

11-14: LGTM!

The updated imports correctly bring in the new types needed for order-book operations.


36-54: LGTM!

The init_order_book_instruction correctly marks book_manager as a read-only signer (line 44), establishing proper authorization for order book creation.

magicblock-committor-service/src/tasks/mod.rs (1)

111-118: LGTM! CommitDiffTask struct is well-structured.

The struct correctly includes Clone and Debug derives (addressing prior feedback) and contains all necessary fields for diff-based commits: commit_id, allow_undelegation, committed_account, and base_account.

magicblock-committor-service/src/tasks/task_strategist.rs (2)

433-438: LGTM! MockInfoFetcher correctly implements get_base_account.

The mock returns Ok(None) which is appropriate for testing the fallback path. The typo from past reviews has been fixed.

Note: Like NullTaskInfoFetcher, this mock doesn't exercise the CommitDiff happy path. Consider adding a variant that returns Some(account) to test diff generation.


442-462: Async test helper looks correct.

The create_test_commit_task helper properly delegates to TaskBuilderImpl::create_commit_task with an Arc<NullTaskInfoFetcher>. The async pattern is correctly applied.

magicblock-committor-service/src/tasks/task_builder.rs (2)

45-51: LGTM! Threshold constant is well-documented.

The comment clearly explains why 256 bytes was chosen and the trade-off being made. This addresses prior feedback about documenting the rationale.


152-158: LGTM! Parallel task creation with join_all.

The refactoring correctly parallelizes commit task creation using join_all. Each account is processed independently with create_commit_task, allowing concurrent base-account fetches when applicable.

magicblock-committor-service/src/tasks/args_task.rs (3)

67-91: LGTM! CommitDiff instruction building is correct.

The implementation properly:

  • Constructs CommitDiffArgs with the diff computed via compute_diff
  • Logs diff size vs original size at info level (appropriate for observability)
  • Calls dlp::instruction_builder::commit_diff with correct parameters

140-152: Acknowledge: CommitDiff downgrade to BufferTask is documented.

The TODO correctly documents that CommitDiff is currently downgraded to CommitTask when converting to BufferTask. This is acceptable as an interim solution while buffer-based CommitDiff support is developed.


194-194: Verify: CommitDiff maps to TaskType::Commit intentionally.

ArgsTaskType::CommitDiff maps to TaskType::Commit. This means commit-diff tasks will be grouped/partitioned with regular commit tasks. Verify this is intentional, as past reviews questioned whether CommitDiff should have its own TaskType variant for distinct metrics/routing.

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 (1)
magicblock-committor-service/src/tasks/args_task.rs (1)

131-156: CommitDiff tasks don't have their commit_id reset

The reset_commit_id method in ArgsTask only handles ArgsTaskType::Commit, ignoring CommitDiff tasks:

fn reset_commit_id(&mut self, commit_id: u64) {
    let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
        return;
    };
    commit_task.commit_id = commit_id;
}

Both CommitTask and CommitDiffTask have commit_id fields and are logically equivalent commit operations (both map to TaskType::Commit). If a CommitDiff task is recycled during retry or repartitioning, its commit_id remains stale while the pipeline expects a new nonce, causing desynchronization.

Update this method to handle both variants:

fn reset_commit_id(&mut self, commit_id: u64) {
-   let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-       return;
-   };
-
-   commit_task.commit_id = commit_id;
+   match &mut self.task_type {
+       ArgsTaskType::Commit(task) => {
+           task.commit_id = commit_id;
+       }
+       ArgsTaskType::CommitDiff(task) => {
+           task.commit_id = commit_id;
+       }
+       _ => {
+           // Non-commit tasks don't carry a commit_id; nothing to reset.
+       }
+   }
}
♻️ Duplicate comments (7)
test-integration/test-committor-service/tests/utils/transactions.rs (1)

137-150: Fix counter-vs–order-book wording in helper comment and debug log

The new order-book helper still uses “counter” terminology in the doc comment and debug message, which will confuse future readers.

Proposed wording fixes
-/// This needs to be run for each test that required a new counter to be delegated
+/// This needs to be run for each test that requires a new order book to be delegated
 #[allow(dead_code)]
 pub async fn init_and_delegate_order_book_on_chain(
@@
-    debug!("Airdropped to counter auth: {} SOL", 777 * LAMPORTS_PER_SOL);
+    debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL);

Also applies to: 238-250

test-integration/programs/schedulecommit/src/api.rs (6)

56-75: Authorization inconsistency: book_manager should be a signer.

This issue was previously flagged. The book_manager is marked as a non-signer (line 65), inconsistent with init_order_book_instruction which requires the manager's signature. This allows any payer to grow another entity's order book without authorization.


107-110: PDA derivation uses arbitrary user_seed.

This concern was previously flagged. The arbitrary user_seed parameter may not match on-chain program expectations for canonical seeds like b"magic_schedule_commit" or b"order_book".


113-117: Remove debug print statements.

This issue was previously flagged. These println! statements should be removed before merging.


133-148: Permissive user_seed handling routes unknown seeds to DelegateOrderBook.

This concern was previously flagged. Any user_seed other than b"magic_schedule_commit" is treated as an order-book delegation, which is brittle for a public API.


184-200: Missing book_manager authorization.

This issue was previously flagged. The instruction omits the book_manager account, allowing any payer to update any order book. This is inconsistent with init_order_book_instruction and grow_order_book_instruction which validate the manager.


202-221: Missing book_manager authorization.

This issue was previously flagged. Similar to update_order_book_instruction, this function omits the book_manager account, allowing anyone to schedule commits for any order book without authorization.

🧹 Nitpick comments (3)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)

98-121: Order-book commit helper/tests look correct but are threshold‑sensitive

The commit_book_order_account helper and the new order-book tests correctly:

  • Initialize + delegate an order book on-chain
  • Mutate only the first changed_len bytes (with bounds-assert)
  • Feed that into a single-account Commit/Finalize intent with the expected CommitStrategy.

The 679/681 byte tests are tightly coupled to current encoding/threshold behavior (comment explains why 681 is the flip point). That’s fine for now, but these tests will be brittle if the diff/Args vs buffer thresholds or encoding change; be prepared to revisit the magic sizes if the planner or DLP args evolve.

Also applies to: 188-251


260-447: Multi-account strategy expectations match Args‑first planner but may be brittle

The updated expect_strategies maps (more CommitStrategy::Args, adjusted FromBufferWithLookupTable counts) are consistent with an Args/CommitDiff‑first planner that only falls back to buffers+ALTs when necessary. The patterns across the 2/3/4/5/6/8/20‑account tests look internally consistent.

If planner thresholds continue to evolve, consider gradually relaxing some of these assertions (e.g., asserting “at least one Args” or bounds on buffer counts) to reduce future churn, especially for tests whose purpose is end‑to‑end commit success rather than exact internal strategy distribution.

test-integration/test-committor-service/tests/utils/instructions.rs (1)

54-94: Avoid println! in test helper; use logging or drop it

The new order-book helper cleanly assembles InitOrderBookAndDelegateIxs, but println!("schedulecommit ID: {}", ID); will spam stdout for every call. Prefer either removing it or switching to a log::debug! (with appropriate logger init) so tests can control verbosity.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d5f54b and ab51f90.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (11)
  • Cargo.toml
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/Cargo.toml
🧰 Additional context used
🧠 Learnings (15)
📚 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
📚 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:

  • 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-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/api.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-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/api.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/mod.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:

  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/mod.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-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.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-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (6)
magicblock-committor-service/src/tasks/task_strategist.rs (4)
test-integration/test-committor-service/tests/common.rs (3)
  • get_base_account (145-150)
  • create_commit_task (162-178)
  • new (52-55)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
  • get_base_account (43-46)
  • get_base_account (275-280)
  • new (60-67)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-103)
magicblock-committor-service/src/tasks/task_builder.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (162-178)
  • new (52-55)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • init_order_book_instruction (36-54)
  • delegate_account_cpi_instruction (100-151)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
  • init_validator_fees_vault_ix (5-11)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-103)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
  • init_and_delegate_order_book_on_chain (240-300)
test-integration/test-committor-service/tests/utils/mod.rs (1)
  • ensure_validator_authority (35-44)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (9)
Cargo.toml (1)

98-100: Verify delegation-program rev and lock alignment

The new magicblock-delegation-program rev looks fine; just ensure this commit exists on the remote, matches the expected CommitDiff API, and that Cargo.lock (if committed) has been updated accordingly so CI builds reproducibly.

test-integration/test-committor-service/tests/utils/transactions.rs (1)

124-135: tx_logs_contain correctly handles CommitState vs CommitDiff logs

The special-casing of needle == "CommitState" to also accept "CommitDiff" aligns with the planner’s ability to choose either variant without forcing all tests to branch on that detail. The behavior is documented in-line and looks good.

test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)

68-96: Single-account tests now exercising Args path appropriately

Switching the single-account commit tests (100 B up to 10 KB) to expect CommitStrategy::Args matches the new CommitDiff/Args-first planner, while still keeping larger/bundled scenarios to cover buffer/ALT paths elsewhere in this file. This distribution of expectations looks coherent.

magicblock-committor-service/src/tasks/mod.rs (1)

17-18: CommitDiffTask definition and serialization tests are wired correctly

Introducing CommitDiffTask { commit_id, allow_undelegation, committed_account, base_account } in this module and re‑exporting TaskBuilderImpl provides the necessary building blocks for the new CommitDiff flow. The updated serialization_safety_test now:

  • Constructs commit tasks via TaskBuilderImpl::create_commit_task(..., &Arc::new(NullTaskInfoFetcher)).await
  • Exercises all ArgsTaskType variants, plus BufferTask preparation paths

which is a good sanity check for instruction shape and (de)serialization. No issues from this module’s side.

Also applies to: 32-33, 104-117, 305-459

magicblock-committor-service/src/tasks/task_builder.rs (2)

45-52: Commit vs CommitDiff selection and async task creation look correct

COMMIT_STATE_SIZE_THRESHOLD = 256 combined with get_base_account to decide between CommitTask and CommitDiffTask is a reasonable first cut, and using join_all to assemble commit tasks in parallel is a nice improvement over per-account awaits. The fallback behavior on Ok(None) / Err(e) (log and use CommitState) keeps CommitDiff as a best‑effort optimization without risking commit failures.

Also applies to: 53-103


152-158: join_all usage for commit task assembly is appropriate

Using join_all over the committed accounts to call create_commit_task(...).await in parallel is a good fit here and keeps the API aligned with the async TaskInfoFetcher. The expect on commit_ids.get is also reasonable given the invariant promised by fetch_next_commit_ids.

magicblock-committor-service/src/tasks/task_strategist.rs (1)

383-439: Async strategist tests and use of NullTaskInfoFetcher look good

The strategist tests now:

  • Build commit tasks via TaskBuilderImpl::create_commit_task(..., &Arc::new(NullTaskInfoFetcher)).await
  • Use join_all to generate multiple large commit tasks
  • Assert buffer vs Args strategies and ALT usage across a range of scenarios

Given NullTaskInfoFetcher::get_base_account always returns Ok(None), these tests intentionally exercise the Commit/Buffer path only, which is fine since CommitDiff behavior is covered elsewhere. No changes needed here.

Also applies to: 441-463, 496-607, 609-685

magicblock-committor-service/src/tasks/args_task.rs (1)

1-7: CommitDiff ArgsTask wiring is coherent with existing Commit flow

The new ArgsTaskType::CommitDiff(CommitDiffTask) variant, compute_diff call using ReadableAccount::data(), and the commit_diff instruction builder integrate cleanly:

  • No RPC in instruction(), only in-memory diff against base_account
  • compute_units/TaskType/LabelValue keep Commit and CommitDiff in the same operational bucket while still distinguishing them in metrics ("args_commit_diff")

This matches the PR’s goal of treating CommitDiff as an internal optimization without changing external task semantics.

Also applies to: 21-27, 50-91, 176-183, 191-199, 215-223

test-integration/programs/schedulecommit/src/api.rs (1)

36-54: LGTM!

The initialization instruction correctly marks book_manager as a signer, which is appropriate for account creation and establishes the authorization pattern for this order book.

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-committor-service/src/tasks/args_task.rs (1)

200-206: Fix reset_commit_id to handle CommitDiff tasks.

The reset_commit_id method only updates Commit tasks and silently ignores CommitDiff tasks. If CommitDiff tasks are recycled with new commit IDs, this will cause desynced submissions.

🔎 Proposed fix
 fn reset_commit_id(&mut self, commit_id: u64) {
-    let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-        return;
-    };
-
-    commit_task.commit_id = commit_id;
+    match &mut self.task_type {
+        ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+            task.commit_id = commit_id;
+        }
+        _ => {
+            // BaseAction, Finalize, Undelegate don't have commit_id
+        }
+    }
 }
♻️ Duplicate comments (1)
magicblock-committor-service/src/tasks/task_strategist.rs (1)

445-445: Inconsistent system program import usage.

Line 445 uses system_program::id() while line 505 uses system_program_id(). Both resolve to the same value, but this is inconsistent within the test module.

🔎 Proposed fix (use system_program_id consistently)
-                owner: system_program::id(),
+                owner: system_program_id(),
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)

170-177: Verify compute unit allocation for CommitDiff.

Both Commit and CommitDiff are allocated 70,000 compute units. However, the PR objectives mention that CommitDiff used 65k compute units in tests. Since CommitDiff sends only the diff (not full state), it may warrant a lower allocation.

Consider whether 65,000 or a more precise value would be more appropriate.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab51f90 and d308de5.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • magicblock-committor-service/src/tasks/task_builder.rs
🧰 Additional context used
🧠 Learnings (9)
📚 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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.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-committor-service/src/tasks/task_strategist.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:

  • magicblock-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (1)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • from (36-38)
  • value (210-218)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (7)
magicblock-committor-service/src/tasks/task_strategist.rs (6)

373-398: LGTM!

The new imports properly support the async test patterns (join_all), the extended MockInfoFetcher (MagicBlockRpcClientResult), and the new diff threshold tests (COMMIT_STATE_SIZE_THRESHOLD, NullTaskInfoFetcher).


401-431: LGTM!

The MockInfoFetcher now holds a HashMap<Pubkey, Account> enabling diff-path testing by returning base accounts from get_base_account. This addresses the previous concern about only testing direct commits.


569-632: Good addition of diff threshold tests.

These tests properly exercise the diff-based commit optimization:

  • Small diff on large account → Args strategy (efficient)
  • Threshold boundary cases → Args strategy
  • Large diff → Buffer strategy (fallback)

This addresses the prior concern about missing diff test coverage.


641-645: LGTM!

The join_all pattern for parallel task creation is correctly implemented and consistent across all similar test setups.


510-513: LGTM!

The async test conversion is correctly applied with #[tokio::test] and proper awaiting of the create_test_commit_task helper.


766-865: LGTM!

The integration tests for build_execution_strategy correctly validate single-stage, two-stage, and ALT scenarios using the async patterns. The use of MockInfoFetcher::default() (empty HashMap) is appropriate here since these tests focus on execution mode selection rather than diff behavior.

magicblock-committor-service/src/tasks/args_task.rs (1)

185-192: Clarify TaskType mapping for CommitDiff.

CommitDiff currently maps to TaskType::Commit (line 188), but a previous review suggested adding a distinct TaskType::CommitDiff variant to reflect the different execution models. The review was marked as addressed in commit 4916c85, yet the mapping remains unchanged.

Given taco-paco's feedback about separating task responsibilities, please clarify whether:

  1. The decision was made to keep both under TaskType::Commit, or
  2. This distinction will be introduced in a subsequent PR (matching the pattern of the TODO at line 135)

@snawaz
Copy link
Contributor Author

snawaz commented Dec 22, 2025

@taco-paco :

  • I adopted the existing approach everywhere. So no more design change (or any shortcuts) in this PR.
  • Added couple of tests in the tast_strategist.rs and test_ix_commit_local.rs.
  • I had to modify some existing tests because some tests which earlier required account-state to be passed as buffer, are now passed as args as the diff is small in such cases.

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

♻️ Duplicate comments (2)
test-integration/test-committor-service/tests/utils/transactions.rs (1)

238-238: Fix grammar in the comment.

The comment contains a grammatical error: "required" should be "requires".

🔎 Proposed fix
-/// This needs to be run for each test that required a new order_book to be delegated
+/// This needs to be run for each test that requires a new order_book to be delegated
magicblock-committor-service/src/tasks/args_task.rs (1)

200-206: Critical: reset_commit_id must handle CommitDiff variant.

When CommitDiff tasks are recycled, reset_commit_id silently returns without updating the commit ID, leaving stale commit IDs in place. This will cause nonce mismatches and transaction failures when the recycled task is submitted.

Both Commit and CommitDiff variants hold a commit_id field that must be updated during recycling.

🔎 Proposed fix
 fn reset_commit_id(&mut self, commit_id: u64) {
-    let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-        return;
-    };
-
-    commit_task.commit_id = commit_id;
+    match &mut self.task_type {
+        ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+            task.commit_id = commit_id;
+        }
+        _ => {
+            // Other task types don't have commit_id
+        }
+    }
 }
🧹 Nitpick comments (4)
test-integration/test-committor-service/tests/utils/transactions.rs (1)

238-298: Consider adding debug logs for consistency and debuggability.

The function logic is correct and properly handles order book initialization and delegation. However, it lacks debug logging present in the analogous init_and_delegate_account_on_chain function, which logs after airdrop, init, and delegate steps. Adding similar debug statements would improve consistency and help diagnose test failures.

🔎 Suggested debug logs
     rpc_client
         .request_airdrop(&payer.pubkey(), 777 * LAMPORTS_PER_SOL)
         .await
         .unwrap();
+    debug!("Airdropped to payer: {} SOL", 777 * LAMPORTS_PER_SOL);

     let InitOrderBookAndDelegateIxs {
         init,
         delegate,
         book_manager,
         order_book,
     } = init_order_book_account_and_delegate_ixs(payer.pubkey());

     let latest_block_hash = rpc_client.get_latest_blockhash().await.unwrap();

     //  Init account
     rpc_client
         .send_and_confirm_transaction_with_spinner_and_config(
             &Transaction::new_signed_with_payer(
                 &[init],
                 Some(&payer.pubkey()),
                 &[payer, &book_manager],
                 latest_block_hash,
             ),
             CommitmentConfig::confirmed(),
             RpcSendTransactionConfig {
                 skip_preflight: true,
                 ..Default::default()
             },
         )
         .await
         .expect("Failed to init account");
+    debug!("Init order_book: {:?}", order_book);

     // Delegate account
     rpc_client
         .send_and_confirm_transaction_with_spinner_and_config(
             &Transaction::new_signed_with_payer(
                 &[delegate],
                 Some(&payer.pubkey()),
                 &[&payer],
                 latest_block_hash,
             ),
             CommitmentConfig::confirmed(),
             RpcSendTransactionConfig {
                 skip_preflight: true,
                 ..Default::default()
             },
         )
         .await
         .expect("Failed to delegate");
+    debug!("Delegated order_book: {:?}", order_book);

     let order_book_acc = get_account!(rpc_client, order_book, "order_book");

     (order_book, order_book_acc)
magicblock-committor-service/src/tasks/args_task.rs (1)

67-85: Consider caching computed diff to avoid repeated computation.

The compute_diff call executes on every instruction() invocation. If instruction() is called multiple times (e.g., during transaction size calculation, optimization passes, or final assembly), the diff is recomputed each time, which is wasteful for large accounts.

Consider computing and caching the diff once during task construction or on first call to instruction(), then reusing the cached result.

🔎 Example refactor to cache diff

Add a cached diff field to CommitDiffTask:

pub struct CommitDiffTask {
    pub commit_id: u64,
    pub allow_undelegation: bool,
    pub committed_account: CommittedAccount,
    pub base_account: Account,
    cached_diff: OnceCell<Vec<u8>>, // or Option<Vec<u8>> with interior mutability
}

Then in instruction():

ArgsTaskType::CommitDiff(value) => {
    let diff = value.cached_diff.get_or_init(|| {
        compute_diff(
            value.base_account.data(),
            value.committed_account.account.data(),
        ).to_vec()
    });
    
    let args = CommitDiffArgs {
        nonce: value.commit_id,
        lamports: value.committed_account.account.lamports,
        diff: diff.clone(),
        allow_undelegation: value.allow_undelegation,
    };
    // ... rest of the code
}
magicblock-committor-service/src/tasks/task_builder.rs (1)

54-96: Consider batching base account fetches for multiple tasks.

The current implementation fetches base accounts individually for each commit task. When processing multiple accounts, this results in N sequential RPC calls (or N parallel calls with join_all in the caller).

Consider extending TaskInfoFetcher with a batch method like fetch_base_accounts(&[Pubkey]) that can fetch multiple base accounts in a single RPC call (using getMultipleAccounts). This would significantly reduce RPC overhead when committing multiple accounts.

Since this is an optimization that doesn't affect correctness and requires broader refactoring of the TaskInfoFetcher trait, it's acceptable to defer to a future PR.

magicblock-committor-service/src/tasks/task_strategist.rs (1)

435-866: Minor style inconsistency: Mixed system program imports.

Line 446 uses system_program::id() while line 505 uses system_program_id(). Both resolve to the same value.

For consistency, prefer using system_program_id() throughout since it's already imported at line 381.

This is a minor nitpick and doesn't affect correctness.

🔎 Suggested fix
         let committed_account = CommittedAccount {
             pubkey: Pubkey::new_unique(),
             account: Account {
                 lamports: 1000,
                 data: vec![1; data_size],
-                owner: system_program::id(),
+                owner: system_program_id(),
                 executable: false,
                 rent_epoch: 0,
             },
         };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d308de5 and 9f09261.

📒 Files selected for processing (5)
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • magicblock-committor-service/src/tasks/buffer_task.rs
🧰 Additional context used
🧠 Learnings (11)
📚 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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/test-committor-service/tests/utils/transactions.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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.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:

  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/utils/transactions.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.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-committor-service/tests/utils/transactions.rs
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (43-46)
  • get_base_account (275-280)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-95)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
  • init_validator_fees_vault_ix (5-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: run_make_ci_test
  • GitHub Check: Build Project
🔇 Additional comments (10)
test-integration/test-committor-service/tests/utils/transactions.rs (1)

16-18: LGTM! Necessary imports for order book support.

The added imports correctly support the new order book delegation functionality introduced in this file.

magicblock-committor-service/src/tasks/args_task.rs (4)

134-146: LGTM: Temporary downgrade documented in TODO.

The downgrade from CommitDiff to CommitTask before buffering is clearly documented as temporary. Per the PR objectives and reviewer feedback, this will be addressed in subsequent PRs when BufferTask gains CommitDiff support.

The current approach ensures correctness even if it sacrifices the diff optimization when buffering is needed.


170-178: Verify CommitDiff compute unit allocation.

The code allocates 70,000 compute units for CommitDiff, matching Commit. However, the PR description states that CommitDiff uses 65,000 compute units compared to Commit's 70,000.

Confirm whether this allocation should be reduced to 65,000 to match the actual on-chain compute usage, or if 70,000 is intentionally conservative to provide headroom.


185-193: Verify TaskType mapping for CommitDiff.

A previous review comment (marked as "✅ Addressed in commit 4916c85") recommended adding a separate TaskType::CommitDiff variant to distinguish commit-diff execution from regular commits. However, the current code still maps CommitDiff to TaskType::Commit.

Please confirm:

  1. Was the separate variant intentionally deferred to a future PR?
  2. Or should this mapping be updated to use TaskType::CommitDiff?

The distinction matters for metrics, task routing, and optimization decisions where CommitDiff has fundamentally different characteristics (RPC-based, non-bufferable, different compute profile).


209-219: LGTM: Appropriate label for metrics tracking.

The distinct label "args_commit_diff" enables separate metrics collection for CommitDiff tasks, which is useful for monitoring the adoption and performance of the diff optimization.

magicblock-committor-service/src/tasks/task_builder.rs (2)

45-51: LGTM: Well-documented threshold constant.

The COMMIT_STATE_SIZE_THRESHOLD is clearly documented with rationale. The 256-byte threshold appropriately targets small, frequently-updated accounts (like counters with a few integer fields) where diff encoding provides the most benefit.

Public visibility enables testing code to reference this threshold when verifying commit type selection.


144-150: LGTM: Effective use of parallel async task creation.

Using join_all to parallelize task creation is an excellent optimization. Since each task creation may fetch a base account via RPC, parallelizing these fetches significantly reduces total latency when processing multiple accounts.

The approach correctly shares the task_info_fetcher reference across all parallel tasks, avoiding redundant RPC client instantiation.

magicblock-committor-service/src/tasks/task_strategist.rs (3)

401-432: LGTM: MockInfoFetcher enables flexible test scenarios.

The MockInfoFetcher implementation correctly provides test control over base account availability. The HashMap-based approach allows tests to simulate various scenarios:

  • Account present (returns Some(account))
  • Account not found (returns None when pubkey not in map)
  • Different base account data for testing various diff sizes

The Default derivation enables concise test setup when no base accounts are needed.


435-476: LGTM: Test helper correctly simulates both commit types.

The async create_test_commit_task helper effectively simulates both commit scenarios:

  • diff_len == 0: Uses NullTaskInfoFetcher → no base account → creates CommitState task
  • diff_len > 0: Uses MockInfoFetcher with modified base → creates CommitDiff task with controlled diff size

The modification logic (wrapping_add to change first N bytes) provides realistic diff scenarios for testing optimization behavior.


570-632: Excellent: CommitDiff test coverage addresses reviewer feedback.

The new test functions comprehensively verify the CommitDiff behavior across multiple scenarios:

  1. Large account, small diff (lines 570-588): Verifies that Args strategy is used (no buffering needed for small diff)
  2. Large account, threshold-sized diff (lines 591-609): Verifies boundary behavior at COMMIT_STATE_SIZE_THRESHOLD
  3. Large account, large diff (lines 612-632): Verifies that Buffer strategy is used when diff exceeds threshold

These tests directly address the reviewer feedback (taco-paco) about missing CommitDiff test coverage. The tests verify both task type selection (CommitDiff vs Commit) and strategy selection (Args vs Buffer).

Based on learnings: Tests in this codebase use #[tokio::test] for async test functions and validate behavior through strategy assertions.

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.

Looks good, left some comments that we need to address.

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

♻️ Duplicate comments (8)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

41-47: Remove unused trait bounds on generic parameter.

The function body only inspects the structure of ScheduledCommitResult<T> (checking included.len(), excluded.len(), and sigs.len()) but never deserializes, formats, or compares values of type T. The trait bounds std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq are not used.

🔎 Proposed fix
 pub fn assert_one_committee_was_committed<T>(
     ctx: &ScheduleCommitTestContext,
     res: &ScheduledCommitResult<T>,
     is_single_stage: bool,
-) where
-    T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq,
-{
+) {
test-integration/test-committor-service/tests/utils/instructions.rs (1)

3-3: Remove unused import.

The Signer import is not used anywhere in this file and should be removed.

🔎 Proposed fix
-use test_kit::Signer;
test-integration/programs/schedulecommit/src/lib.rs (3)

307-341: Missing book_manager signer validation.

The function derives the order book PDA from book_manager.key (lines 320-323) and uses it in signer_seeds (line 336), but never validates that book_manager is a signer. The instruction builder in api.rs marks book_manager as a signer, but the handler doesn't enforce this requirement.

This creates an authorization gap where anyone can initialize an order book for any book_manager without their signature.

🔎 Proposed fix
     assert_is_signer(payer, "payer")?;
+    assert_is_signer(book_manager, "book_manager")?;

     let (pda, bump) = Pubkey::find_program_address(

390-423: Missing payer signer validation before delegation CPI.

The handler calls delegate_account (which creates accounts and transfers lamports) without first validating that payer is a signer. If the payer flag is missing, the CPI will fail with a less clear error message.

🔎 Proposed fix
     };

+    assert_is_signer(payer, "payer")?;
+
     let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];

     delegate_account(

449-469: Missing PDA and ownership validation for order_book_account.

The handler schedules commit and undelegate for order_book_account without verifying:

  • The account is the expected PDA derived from [b"order_book", book_manager.key]
  • The account is owned by this program

This allows committing arbitrary accounts via this instruction. While downstream checks in the delegation/magic program may enforce some constraints, explicit validation here would provide clearer error messages and prevent misuse.

Note: Full PDA validation requires book_manager to be available (either as an additional account or in instruction data) to recompute and verify the PDA.

test-integration/programs/schedulecommit/src/api.rs (3)

71-90: Authorization inconsistency: book_manager should be a signer.

init_order_book_instruction marks book_manager as a signer (line 59), but grow_order_book_instruction marks it as a non-signer (line 80). This means any payer can grow another entity's order book without authorization.

If book_manager should authorize growth (mirroring init semantics), update the account meta to require a signature and add corresponding on-chain validation in process_grow_order_book.

🔎 Proposed fix
         AccountMeta::new(payer, true),
-        AccountMeta::new_readonly(book_manager, false),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),

Then add validation in process_grow_order_book:

     assert_is_signer(payer, "payer")?;
+    assert_is_signer(book_manager, "book_manager")?;

197-213: Missing book_manager authorization for updates.

The function only requires payer signature and omits the book_manager account entirely. This creates an inconsistent authorization model:

  • Init and grow operations validate book_manager matches the order book's PDA derivation
  • Update operation skips this check, allowing anyone to modify any order book

Since order books are PDAs derived from [b"order_book", book_manager.key], the book_manager is the conceptual owner. Include and validate this account to maintain consistent authorization.


215-234: Missing book_manager authorization for commit scheduling.

Similar to update_order_book_instruction, this function omits the book_manager account. Without this validation, anyone can schedule commits for any order book without the owner's authorization.

Include book_manager in the account metas and validate authorization on-chain, consistent with init_order_book_instruction and grow_order_book_instruction.

🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/mod.rs (1)

307-447: Serialization tests are correctly structured.

The updated tests properly validate serialization safety for all task variants:

  • Tests are synchronous (appropriate for serialization validation per past feedback)
  • Coverage includes all ArgsTaskType variants (Commit, Finalize, Undelegate, BaseAction) and BufferTask preparation flows
  • Tests exercise .into() conversions from task types to ArgsTask/BufferTask

Optional: Consider adding CommitDiffTask serialization test

If CommitDiffTask serialization isn't already covered in args_task.rs (where ArgsTaskType::CommitDiff is presumably defined), you might add a dedicated test here to ensure the new variant serializes correctly. However, this is optional if coverage exists elsewhere.

🔎 Optional test addition
#[test]
fn test_commit_diff_task_serialization() {
    let validator = Pubkey::new_unique();
    
    let commit_diff_task = CommitDiffTask {
        commit_id: 999,
        allow_undelegation: true,
        committed_account: CommittedAccount {
            pubkey: Pubkey::new_unique(),
            account: Account {
                lamports: 5000,
                data: vec![1; 512],
                owner: Pubkey::new_unique(),
                executable: false,
                rent_epoch: 0,
            },
        },
        base_account: Account {
            lamports: 5000,
            data: vec![2; 512],
            owner: Pubkey::new_unique(),
            executable: false,
            rent_epoch: 0,
        },
    };
    
    // Test that CommitDiffTask can be converted and serialized
    // This would require ArgsTaskType::CommitDiff to be available
    // let args_task: ArgsTask = ArgsTaskType::CommitDiff(commit_diff_task).into();
    // assert_serializable(&args_task.instruction(&validator));
}
test-integration/test-committor-service/tests/utils/instructions.rs (1)

68-68: Remove debug print statement.

This println! statement adds noise to test output. Either remove it entirely or convert it to conditional debug logging if the information is valuable during debugging.

🔎 Proposed fix
-    println!("schedulecommit ID: {}", ID);

Or if logging is needed:

-    println!("schedulecommit ID: {}", ID);
+    log::debug!("schedulecommit ID: {}", ID);
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9f09261 and f372684.

📒 Files selected for processing (10)
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • magicblock-committor-service/src/intent_executor/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
🧰 Additional context used
🧠 Learnings (13)
📚 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/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.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/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.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/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.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-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/lib.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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:

  • magicblock-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.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-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/programs/schedulecommit/src/lib.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:

  • test-integration/programs/schedulecommit/src/lib.rs
🧬 Code graph analysis (4)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (4)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
  • fmt (40-49)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
  • assert_one_committee_account_was_undelegated_on_chain (190-196)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (109-143)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_new (116-118)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
  • get_context_with_delegated_committees (16-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_format
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_test
🔇 Additional comments (8)
magicblock-committor-service/src/tasks/mod.rs (3)

17-17: LGTM: Import is necessary for CommitDiffTask.

The Account import is correctly added to support the new CommitDiffTask struct's base_account field.


32-32: LGTM: TaskBuilderImpl re-export aligns with architecture.

Exposing TaskBuilderImpl publicly is consistent with the PR objective to centralize commit-variant decision logic in TaskBuilder rather than inside task constructors.


111-117: LGTM: CommitDiffTask struct is well-defined.

The new CommitDiffTask struct appropriately separates the commit-with-diff variant from CommitTask. The base_account field will hold the base-chain state needed for diff computation, and the Debug derive (requested in earlier reviews) aids diagnostics.

This addresses the architectural feedback to split task types rather than using optional fields or flags inside a single CommitTask struct.

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

48-51: LGTM! Clean integration of UserSeeds enum.

The changes consistently thread UserSeeds::MagicScheduleCommit through test setup and delegation calls, replacing the previous hardcoded byte string approach. This is a cleaner, more maintainable solution.

Also applies to: 104-107, 238-238

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

300-362: Excellent test design with reproducible randomness.

The order book test demonstrates best practices:

  • Uses seeded randomness (OsRngStdRng) for reproducibility
  • Prints the seed for debugging test failures
  • Generates realistic random order book data with controlled ranges
  • Verifies complete data integrity after commit/undelegate operations
  • Error messages reference the seed for investigation

The intentional println! of the seed (line 309) aids debugging and is appropriate for test code.

test-integration/programs/schedulecommit/src/lib.rs (1)

822-840: LGTM! Appropriate handling of multiple account types.

The branching logic cleanly handles both MainAccount and OrderBook deserialization based on data length, with appropriate error logging that doesn't fail the undelegation operation. This is a good defensive coding pattern.

test-integration/programs/schedulecommit/src/api.rs (1)

16-29: LGTM! Clean enum-based seed abstraction.

The UserSeeds enum with its bytes() helper provides a type-safe alternative to raw byte slices for PDA derivation. This is a good refactoring that improves maintainability and reduces errors.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)

72-73: LGTM! Consistent UserSeeds integration throughout.

The changes cleanly thread UserSeeds through the client context:

  • Constructors properly accept and store the seed
  • PDA derivation uses user_seed.bytes() for consistent seed handling
  • Init logic branches explicitly on seed variants with clear error handling
  • Delegation propagates the seed correctly

The integration is well-structured and maintains consistency across all operations.

Also applies to: 115-118, 166-211, 275-275

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

♻️ Duplicate comments (9)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

41-47: Remove unused trait bounds.

The trait bounds std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq on generic parameter T are not utilized by the function body. The function only inspects the ScheduledCommitResult structure and never deserializes or compares values of type T.

🔎 Proposed fix
-pub fn assert_one_committee_was_committed<T>(
+pub fn assert_one_committee_was_committed<T>(
     ctx: &ScheduleCommitTestContext,
     res: &ScheduledCommitResult<T>,
     is_single_stage: bool,
-) where
-    T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq,
-{
+) {
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)

166-169: Consider extracting compute budget values as named constants.

The compute unit limit (1,400,000) and price (10,000) are hardcoded. Extracting these as named constants would improve maintainability.

Example
const INIT_COMPUTE_UNIT_LIMIT: u32 = 1_400_000;
const INIT_COMPUTE_UNIT_PRICE: u64 = 10_000;

let mut ixs = vec![
    ComputeBudgetInstruction::set_compute_unit_limit(INIT_COMPUTE_UNIT_LIMIT),
    ComputeBudgetInstruction::set_compute_unit_price(INIT_COMPUTE_UNIT_PRICE),
];

193-206: Remove commented-out code block.

The 14-line commented TODO about growing order books adds noise. Consider tracking the account size limitation as a GitHub issue and replacing this block with a brief comment referencing the issue.

test-integration/programs/schedulecommit/src/api.rs (3)

71-90: Authorization inconsistency: grow_order_book_instruction should require book_manager signature.

init_order_book_instruction marks book_manager as a signer (line 59), but grow_order_book_instruction marks it as a non-signer (line 80). This inconsistency allows any payer to grow another entity's order book without authorization.

For consistent authorization semantics, grow_order_book_instruction should require the book_manager's signature, and the on-chain handler (process_grow_order_book in lib.rs) should validate it.

🔎 Recommended fix
     AccountMeta::new(payer, true),
-    AccountMeta::new_readonly(book_manager, false),
+    AccountMeta::new_readonly(book_manager, true),
     AccountMeta::new(order_book, false),

Also add assert_is_signer(book_manager, "book_manager")? in the on-chain handler.


197-213: Missing book_manager authorization in update_order_book_instruction.

The function only requires the payer signature and omits the book_manager account entirely. This is inconsistent with init_order_book_instruction and grow_order_book_instruction, which include and validate the book_manager.

Since order books are PDAs derived from [b"order_book", book_manager.key], the conceptual owner is the book_manager. Without this validation, anyone can modify any order book.

🔎 Recommended fix
 pub fn update_order_book_instruction(
     payer: Pubkey,
+    book_manager: Pubkey,
     order_book: Pubkey,
     update: BookUpdate,
 ) -> Instruction {
     let program_id = crate::id();
     let account_metas = vec![
         AccountMeta::new(payer, true),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
     ];

Also update the on-chain handler to validate the PDA derivation from book_manager.


215-234: Missing book_manager authorization in schedule_commit_diff_instruction_for_order_book.

Similar to update_order_book_instruction, this function omits the book_manager account and only requires the payer's signature. This allows anyone to schedule commits for any order book.

🔎 Recommended fix
 pub fn schedule_commit_diff_instruction_for_order_book(
     payer: Pubkey,
+    book_manager: Pubkey,
     order_book: Pubkey,
     magic_program_id: Pubkey,
     magic_context_id: Pubkey,
 ) -> Instruction {
     let program_id = crate::id();
     let account_metas = vec![
         AccountMeta::new(payer, true),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
         AccountMeta::new(magic_context_id, false),
         AccountMeta::new_readonly(magic_program_id, false),
     ];
test-integration/programs/schedulecommit/src/lib.rs (3)

307-341: Missing book_manager signer validation in process_init_order_book.

The function validates that payer is a signer (line 318) but does not validate book_manager. The instruction builder in api.rs marks book_manager as a signer (line 59), but the handler never checks this.

While the function will eventually fail in allocate_account_and_assign_owner (line 332) when it tries to use book_manager.key in signer_seeds, this produces a less clear error than validating up front.

🔎 Recommended fix
     assert_is_signer(payer, "payer")?;
+    assert_is_signer(book_manager, "book_manager")?;

     let (pda, bump) = Pubkey::find_program_address(

390-423: Missing payer signer validation before delegate_account CPI.

The handler calls delegate_account (line 404), which creates accounts and transfers lamports, without first validating that payer is a signer. If the payer flag is missing, the CPI will fail with a less clear error.

🔎 Recommended fix
     let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] =
         accounts
     else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };

+    assert_is_signer(payer, "payer")?;
+
     let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];

449-469: Missing PDA and ownership validation for order_book_account.

The handler schedules a commit and undelegate for order_book_account without verifying:

  • The account is the expected PDA derived from [b"order_book", book_manager.key]
  • The account is owned by this program

This allows committing arbitrary accounts via this instruction. While downstream checks in the delegation/magic program may enforce some constraints, explicit validation here would provide clearer error messages and prevent misuse.

Note: Full PDA validation requires book_manager to be available (either as an additional account or in instruction data) to recompute and verify the PDA.

🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/mod.rs (1)

104-109: Optional: Add Debug derive to CommitTask for consistency.

CommitDiffTask has Debug derive (line 111) but CommitTask does not. Adding Debug to CommitTask would improve consistency and provide better error diagnostics during debugging and logging.

🔎 Optional enhancement
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct CommitTask {
     pub commit_id: u64,
     pub allow_undelegation: bool,
     pub committed_account: CommittedAccount,
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f372684 and 8d88564.

📒 Files selected for processing (11)
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
🧰 Additional context used
🧠 Learnings (13)
📚 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-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.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-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.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-committor-service/src/intent_executor/mod.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.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:

  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.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-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/programs/schedulecommit/src/lib.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:

  • test-integration/programs/schedulecommit/src/lib.rs
🧬 Code graph analysis (7)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
  • schedule_commit_diff_instruction_for_order_book (215-234)
  • update_order_book_instruction (197-213)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
  • assert_one_committee_account_was_undelegated_on_chain (190-196)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
test-integration/programs/schedulecommit/src/utils/mod.rs (1)
magicblock-committor-program/src/state/changeset.rs (1)
  • lamports (105-110)
test-integration/programs/schedulecommit/src/api.rs (1)
test-integration/programs/flexi-counter/src/state.rs (1)
  • pda (34-37)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
  • pda_and_bump (404-408)
  • schedule_commit_cpi_instruction (177-195)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
  • get_context_with_delegated_committees (16-35)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-109)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (109-143)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
  • init_order_book_instruction (51-69)
  • init_payer_escrow (92-113)
  • init_account_instruction (31-49)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
  • GitHub Check: Build Project
🔇 Additional comments (14)
test-integration/programs/schedulecommit/src/utils/mod.rs (1)

75-79: LGTM! Useful debug logging for test scenarios.

The added log statement provides helpful observability by showing the calculated rent requirement and payer's available balance before the transfer operation. This will aid in diagnosing insufficient funds errors during test execution.

magicblock-committor-service/src/intent_executor/mod.rs (2)

9-10: LGTM: Test-only module correctly scoped.

The #[cfg(test)] attribute properly ensures this module is only compiled in test builds, as agreed upon in previous review feedback. The placement is correct per Rust conventions.


28-29: LGTM: Public re-export correctly enables cross-module test usage.

The public re-export with #[cfg(test)] correctly makes NullTaskInfoFetcher available to tests in other modules while ensuring it's excluded from production builds.

magicblock-committor-service/src/tasks/mod.rs (3)

32-32: LGTM! TaskBuilderImpl re-export enables public builder access.

Re-exporting TaskBuilderImpl makes the builder pattern accessible from the tasks module, which aligns with the PR objective of moving task construction logic into TaskBuilder. This is an intentional public API change.


111-117: LGTM! CommitDiffTask is well-structured.

The new CommitDiffTask struct cleanly represents diff-based commits with the required base_account field for diff computation. The #[derive(Clone, Debug)] is appropriate and enables proper debugging.


304-445: LGTM! Tests are properly simplified.

The serialization tests correctly validate all task variants without unnecessary async complexity. The tests were appropriately simplified per past review feedback to remove TaskBuilderImpl usage from pure serialization validation, keeping them focused and maintainable.

Based on past review comments.

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

16-35: LGTM! UserSeeds integration is clean and consistent.

The function correctly accepts and forwards the user_seed parameter to context constructors, and the explicit init_committees() and delegate_committees() calls provide clear visibility into the setup flow.

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)

56-59: LGTM! Consistent UserSeeds integration.

All context creation call sites correctly pass UserSeeds::MagicScheduleCommit to align with the new API requirements.

Also applies to: 176-179, 239-242, 741-744


113-167: LGTM! Order book commit helper is well-structured.

The function correctly:

  • Creates a context with UserSeeds::OrderBook
  • Constructs both the update and schedule-commit instructions
  • Bundles them in a single transaction
  • Returns the context and transaction result for verification

The implementation mirrors the existing commit helpers and follows established patterns.


300-362: LGTM! Excellent use of seeded randomness for reproducible testing.

The test correctly:

  • Uses OsRng to generate a seed and StdRng for deterministic generation
  • Prints the seed for easy reproduction on failures (line 309)
  • Generates realistic random order book data
  • Verifies the committed order book matches the input
  • Includes the seed in assertion messages for debugging

The random order book generation and thorough verification logic provide good test coverage for the diff-based commit path.

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

48-51: LGTM! UserSeeds parameter correctly threaded through.

All call sites properly pass UserSeeds::MagicScheduleCommit to align with the updated API signatures.

Also applies to: 104-107, 238-238

test-integration/programs/schedulecommit/src/api.rs (1)

16-29: LGTM! Type-safe seed handling.

The UserSeeds enum provides a clean, type-safe alternative to passing raw byte slices. The bytes() method provides clear mapping to the actual seed values used for PDA derivation.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)

66-80: LGTM! UserSeeds integration is clean.

The constructors correctly accept and store the user_seed parameter, threading it through to internal construction and preserving it in the context struct.

Also applies to: 158-158


265-303: LGTM! delegate_committees correctly passes UserSeeds.

The function properly forwards self.user_seed to delegate_account_cpi_instruction, maintaining type safety with the UserSeeds enum.

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

Caution

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

⚠️ Outside diff range comments (1)
magicblock-committor-service/src/tasks/args_task.rs (1)

200-206: reset_commit_id must also handle CommitDiff tasks.

When a CommitDiff task is recycled, the current code silently returns without updating the commit_id, leaving stale data. This will cause issues if commit IDs need to be refreshed after failures.

🔎 Proposed fix
     fn reset_commit_id(&mut self, commit_id: u64) {
-        let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-            return;
-        };
-
-        commit_task.commit_id = commit_id;
+        match &mut self.task_type {
+            ArgsTaskType::Commit(task) => {
+                task.commit_id = commit_id;
+            }
+            ArgsTaskType::CommitDiff(task) => {
+                task.commit_id = commit_id;
+            }
+            _ => {}
+        }
     }
♻️ Duplicate comments (6)
test-integration/test-tools/src/scheduled_commits.rs (1)

229-231: Verify if debug logging should be removed per past feedback.

Past review comments indicated this unconditional dump_chain_logs loop should be removed (taco-paco) or gated behind a debug flag. The code remains after recent cleanup commits. Confirm whether this is intentionally retained as temporary debugging code or was overlooked during review cleanup.

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

41-47: Unnecessary trait bounds on generic T.

The trait bounds std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq are not used by this function. The body only inspects res.included.len(), res.excluded.len(), and res.included.get(&pda) — none of which require deserializing or comparing values of type T.

🔎 Proposed fix
 pub fn assert_one_committee_was_committed<T>(
     ctx: &ScheduleCommitTestContext,
     res: &ScheduledCommitResult<T>,
     is_single_stage: bool,
-) where
-    T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq,
-{
+) {
magicblock-committor-service/src/tasks/task_strategist.rs (2)

419-425: Fix typo in comment: "Noti Found" → "Not Found".

🔎 Proposed fix
         async fn get_base_accounts(
             &self,
             _pubkeys: &[Pubkey],
         ) -> TaskInfoFetcherResult<HashMap<Pubkey, Account>> {
-            Ok(Default::default())
+            Ok(Default::default()) // Account Not Found
         }

377-377: Minor: Inconsistent system program import usage.

Line 439 uses system_program::id() while line 497 uses system_program_id(). Consider using one style consistently.

test-integration/programs/schedulecommit/src/lib.rs (2)

359-364: Typo in error message: uses payer.key instead of book_manager.key.

The error message references payer.key but should reference book_manager.key since the PDA is derived from book_manager.

🔎 Proposed fix
     assert_keys_equal(order_book.key, &pda, || {
         format!(
             "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            order_book.key, book_manager.key
         )
     })?;

390-423: process_delegate_order_book is missing payer signer validation.

The handler performs delegation CPI without first verifying that payer is a signer. While the CPI may fail with a less clear error, an explicit check provides better error messages.

🔎 Proposed fix
 pub fn process_delegate_order_book(
     accounts: &[AccountInfo],
     args: DelegateOrderBookArgs,
 ) -> Result<(), ProgramError> {
     msg!("Processing delegate_order_book instruction");

     let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] =
         accounts
     else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };

+    assert_is_signer(payer, "payer")?;
+
     let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)

153-156: Consider using remove instead of get().cloned() as noted in the TODO.

The TODO is valid - if accounts are guaranteed unique (which they should be since they're PDAs), using remove would avoid the clone overhead. However, keeping get().cloned() is defensive and won't cause correctness issues.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d88564 and d6ded46.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (32)
  • Cargo.toml
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-scenarios/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (11)
  • Cargo.toml
  • test-integration/programs/schedulecommit/Cargo.toml
  • magicblock-committor-service/src/intent_executor/mod.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/Cargo.toml
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
🧰 Additional context used
🧠 Learnings (21)
📓 Common learnings
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.
📚 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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-tools/src/scheduled_commits.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/test-committor-service/tests/common.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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/test-committor-service/tests/common.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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-tools/src/scheduled_commits.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/test-committor-service/tests/common.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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-19T12:55:48.931Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-tools/src/validator.rs:193-197
Timestamp: 2025-11-19T12:55:48.931Z
Learning: In the magicblock-validator codebase, when constructing arguments for the light CLI test validator in start_light_validator_with_config (test-integration/test-tools/src/validator.rs), the shlex::split approach is necessary because the light CLI does not handle whitespaces properly in validator arguments. The string concatenation + shlex parsing pattern should not be refactored to direct argument construction in this specific case.

Applied to files:

  • test-integration/test-ledger-restore/tests/08_commit_update.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • magicblock-committor-service/src/tasks/args_task.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-committor-service/src/tasks/task_strategist.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/lib.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-committor-service/src/intent_executor/task_info_fetcher.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:

  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/common.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/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.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:

  • test-integration/test-committor-service/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/lib.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:

  • test-integration/test-tools/src/scheduled_commits.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:

  • test-integration/test-tools/src/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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.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:

  • test-integration/schedulecommit/test-scenarios/Cargo.toml
  • test-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
🧬 Code graph analysis (11)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
test-integration/test-ledger-restore/src/lib.rs (1)
  • setup_validator_with_local_remote (104-118)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_accounts (35-40)
test-integration/test-committor-service/tests/common.rs (2)
  • get_base_accounts (146-163)
  • new (53-56)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (2)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
  • init_and_delegate_order_book_on_chain (240-298)
  • fund_validator_auth_and_ensure_validator_fees_vault (301-342)
test-integration/test-committor-service/tests/utils/mod.rs (1)
  • ensure_validator_authority (35-44)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
  • set_count_instruction (371-379)
  • update_order_book_instruction (197-213)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (4)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_commit_task (175-191)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)
test-integration/programs/schedulecommit/src/api.rs (3)
  • init_order_book_instruction (51-69)
  • init_payer_escrow (92-113)
  • init_account_instruction (31-49)
test-integration/programs/schedulecommit/src/lib.rs (3)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-109)
test-integration/test-tools/src/integration_test_context.rs (2)
  • delegate_account (601-619)
  • try_new (116-118)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (109-143)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • pda_and_bump (404-408)
  • schedule_commit_cpi_instruction (177-195)
test-integration/test-committor-service/tests/common.rs (2)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
  • new (58-65)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • pubkeys (112-123)
magicblock-rpc-client/src/lib.rs (1)
  • new (243-245)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
  • GitHub Check: Build Project
🔇 Additional comments (55)
test-integration/schedulecommit/test-scenarios/Cargo.toml (1)

19-20: Both rand and borsh dev-dependencies are actively used in the test code. rand is imported in tests/02_commit_and_undelegate.rs for random number generation (RngCore, SeedableRng), and borsh is used in tests/utils/mod.rs as a trait bound for deserialization. No issues found.

test-integration/test-tools/src/integration_test_context.rs (2)

160-162: LGTM! The format placeholder fix is correct.

The error message now properly includes the label parameter, so the panic will show which RPC client is missing (e.g., "rpc_client for [chain] does not exist" instead of the literal string "rpc_client for [{}] does not exist").


171-177: LGTM! The conditional transaction version logic is now documented.

The added comment clarifies that the chain cluster requires explicit version 0 support while the ephemeral cluster uses default version handling. This makes the conditional logic more maintainable.

test-integration/test-ledger-restore/tests/08_commit_update.rs (1)

55-55: LGTM: Proper TempDir lifetime management.

Binding the TempDir to _tmpdir (rather than discarding with _) correctly keeps the temporary directory alive for the entire function scope, preventing premature cleanup while the validator is running. The underscore prefix appropriately signals that the variable is intentionally unused while maintaining the necessary lifetime. This pattern is consistent with line 42.

Also applies to: 170-170

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

16-34: LGTM! UserSeeds parameter threading is correct.

The user_seed parameter is properly propagated to try_new and try_new_random_keys, consistent with the ScheduleCommitTestContext API shown in the relevant code snippets.

test-integration/test-committor-service/Cargo.toml (1)

26-26: LGTM! Dependency addition follows established patterns.

The program-schedulecommit dev-dependency with features = ["no-entrypoint"] is consistent with other program dependencies in this file and enables the test utilities that reference program_schedulecommit types (e.g., UserSeeds, order book instructions).

magicblock-committor-service/src/tasks/mod.rs (5)

17-17: LGTM! Import addition for Account type.

The solana_account::Account import is required for the new CommitDiffTask.base_account field.


32-33: LGTM! TaskBuilderImpl re-export.

Re-exporting TaskBuilderImpl from the module root provides a cleaner public API surface for callers.


111-117: LGTM! CommitDiffTask struct is well-structured.

The struct correctly includes Debug in its derives (addressing past review feedback) and has the required fields for diff-based commits:

  • commit_id for transaction ordering
  • allow_undelegation for post-commit behavior
  • committed_account containing the current ephemeral state
  • base_account for computing the diff against chain state

34-40: LGTM! TaskType enum expansion.

The addition of Finalize, Undelegate, and Action variants provides complete coverage of the task type system.


304-445: LGTM! Serialization safety tests.

The tests properly exercise all ArgsTaskType variants (Commit, Finalize, Undelegate, BaseAction) and BufferTask instruction serialization, ensuring instructions can be round-tripped through bincode.

magicblock-committor-service/src/tasks/task_strategist.rs (2)

429-468: LGTM! create_test_commit_task helper properly tests diff scenarios.

The helper correctly:

  • Creates a CommittedAccount with the specified data size
  • When diff_len > 0, creates a modified base_account by wrapping bytes to simulate changes
  • Uses TaskBuilderImpl::create_commit_task to produce the appropriate task type based on whether a base_account is provided

This enables testing both CommitState (no base_account) and CommitDiff (with base_account) paths.


561-621: LGTM! Tests for diff-based commit strategy selection.

The new tests properly verify the CommitDiff optimization behavior:

  • test_build_strategy_does_not_optimize_large_account_but_small_diff: 66KB account with threshold-sized diff stays as Args
  • test_build_strategy_does_not_optimize_large_account_and_above_threshold_diff: 66KB account with diff just above threshold stays as Args
  • test_build_strategy_does_optimize_large_account_and_large_diff: 66KB account with 4× threshold diff optimizes to Buffer

This validates that the CommitDiff strategy avoids buffer overhead when diffs are small enough to fit in instruction args.

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

40-44: LGTM! Batched get_base_accounts trait method.

This addresses the past review suggestion for batched base-account fetching. The method signature enables efficient retrieval of multiple accounts in a single RPC call.


272-290: LGTM! CacheTaskInfoFetcher implementation of get_base_accounts.

The implementation correctly:

  • Uses get_multiple_accounts for efficient batched fetching (reducing RPC round-trips)
  • Maps errors consistently with other methods using MagicBlockRpcClientError
  • Filters out None values (accounts that don't exist) and returns only found accounts
  • Returns a HashMap<Pubkey, Account> for easy lookup by callers

The pattern matches the MockTaskInfoFetcher implementation shown in the relevant code snippets.

test-integration/test-committor-service/tests/test_ix_commit_local.rs (4)

34-34: LGTM! Import for order book test utilities.

The import enables the new order book mutation tests that exercise the CommitDiff path with real on-chain accounts.


98-121: LGTM! Order book mutation tests for CommitDiff.

These tests exercise the CommitDiff path by:

  1. Creating real on-chain order book accounts via init_and_delegate_order_book_on_chain
  2. Modifying account data to create diffs of varying sizes
  3. Verifying the correct commit strategy is selected

The boundary tests (679, 680, 681 bytes) document the exact threshold where the strategy transitions from Args to FromBuffer, which is valuable for understanding and debugging the optimization behavior.


188-251: LGTM! commit_book_order_account helper is well-structured.

The helper correctly:

  • Initializes and delegates an order book on chain (providing a base account for diff computation)
  • Modifies changed_len bytes with wrapping_add(1) to create predictable diffs
  • Sets the owner to program_schedulecommit::id() for proper account handling
  • Builds and submits the commit intent with appropriate strategy expectations

This enables end-to-end testing of the CommitDiff optimization with real chain state.


260-408: LGTM! Updated strategy expectations reflect Args-based commit flow.

The expectation updates (e.g., CommitStrategy::Args instead of FromBuffer for various tests) correctly reflect the new commit planner that favors instruction args when transaction size permits. Tests that still expect FromBufferWithLookupTable are for larger bundles where the optimization correctly falls back to buffers.

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

1-41: LGTM! NullTaskInfoFetcher implementation.

This is a well-implemented Null Object pattern for testing scenarios that don't require real chain data:

  • All fetch methods return empty/default values
  • get_base_accounts returns an empty HashMap, which correctly triggers the CommitState fallback (since no base accounts are found for diff computation)
  • The implementation is minimal and consistent with the trait contract

This enables unit tests to construct tasks without RPC dependencies.

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (3)

8-8: LGTM! UserSeeds enum import.

Using the UserSeeds enum instead of raw byte strings (as discussed in past reviews) provides type safety and better self-documentation.


48-51: LGTM! UserSeeds parameter usage.

The UserSeeds::MagicScheduleCommit parameter is correctly passed to get_context_with_delegated_committees, consistent with the updated API.


234-239: LGTM! UserSeeds in delegate_account_cpi_instruction.

The UserSeeds::MagicScheduleCommit parameter is correctly passed to delegate_account_cpi_instruction, ensuring consistent seed usage across init and delegate operations.

magicblock-committor-service/src/tasks/task_builder.rs (3)

45-51: LGTM! Clear threshold documentation and reasonable default.

The 256-byte threshold is well-documented and provides a sensible boundary between small accounts (where full state transfer is efficient) and larger accounts (where diff-based commits reduce data transfer).


53-83: Task creation logic is correct and cleanly structured.

The helper correctly:

  1. Filters out base_account for small accounts (≤ threshold) to force CommitState
  2. Uses CommitDiff only when both the account exceeds the threshold AND a base_account is available
  3. Falls back to CommitState when base_account fetch fails or returns None

This ensures CommitDiff is only used when it can provide actual benefit.


113-132: Good use of parallel fetching to minimize latency.

Using tokio::join! to fetch commit IDs and base accounts concurrently is the right approach. This addresses the earlier reviewer feedback about sequential network calls.

magicblock-committor-service/src/tasks/args_task.rs (4)

1-6: Clean integration of CommitDiff imports and variant.

The new imports from dlp (CommitDiffArgs, CommitStateArgs, compute_diff) and the CommitDiff(CommitDiffTask) variant are properly structured.

Also applies to: 23-23


67-85: Instruction building is correct and efficient.

The diff is computed at instruction-building time using the stored base_account, avoiding any network I/O in instruction(). This addresses the earlier review concern about RPC calls in this method.


134-146: Acknowledged: Temporary downgrade path for CommitDiff optimization.

The TODO clearly documents that CommitDiff is converted back to CommitTask when optimizing to BufferTask because BufferTask doesn't yet support CommitDiff. This is a reasonable interim approach.


170-178: Compute units and task type mapping are consistent.

CommitDiff correctly uses the same 70,000 compute units as Commit, and mapping both to TaskType::Commit is reasonable since they're semantically similar operations. Based on learnings, these compute units represent per-task budgets that sum for multi-task transactions.

Also applies to: 185-192

test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)

7-11: Import adjustments align with new task creation API.

Replacing direct CommitTask usage with TaskBuilderImpl ensures tests use the same task creation logic as production code.


37-47: Test correctly uses TaskBuilderImpl::create_commit_task.

Passing None for base_account ensures a CommitState task is created (since the account data is small), which is appropriate for this test scenario.


93-102: BufferTask creation pattern is correct.

The .task_type.into() chain correctly extracts the ArgsTaskType and converts it to BufferTaskType for buffer-based task preparation.

test-integration/test-committor-service/tests/utils/transactions.rs (2)

124-134: Pragmatic handling of CommitState/CommitDiff in log matching.

The inline comment explains the rationale well - CommitDiff is an optimized form chosen by the service, so treating "CommitState" needle as matching either variant avoids widespread test changes.


238-298: New order book delegation helper follows established patterns.

The init_and_delegate_order_book_on_chain function mirrors the existing init_and_delegate_account_on_chain structure, using the appropriate order-book-specific instructions and account destructuring.

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4)

56-59: UserSeeds enum provides type-safe seed selection.

Using UserSeeds::MagicScheduleCommit instead of raw byte slices improves clarity and prevents mismatched seeds.


113-167: Order book commit helper is well-structured.

The function correctly:

  1. Creates context with UserSeeds::OrderBook
  2. Constructs update and diff instructions
  3. Sends transaction and returns result for verification

300-362: Excellent test design with reproducible randomness.

The test uses OsRng to generate a seed, then StdRng for deterministic generation. Including the seed in assertion messages enables easy reproduction of failures. The order book verification correctly checks both lengths and content equality.


309-309: Keeping println! for the seed is correct.

As discussed in past comments, this needs to print even when the test fails so the seed can be used for debugging. Using debug! would hide this critical information.

test-integration/test-committor-service/tests/common.rs (2)

116-119: Mock fetcher now properly wraps the RPC client.

The MockTaskInfoFetcher(MagicblockRpcClient) tuple struct and create_task_info_fetcher helper provide clean test infrastructure.

Also applies to: 122-122


146-163: get_base_accounts implementation correctly mirrors production code.

The implementation:

  1. Calls get_multiple_accounts on the RPC client
  2. Maps errors to TaskInfoFetcherError::MagicBlockRpcClientError
  3. Filters out None values (non-existent accounts) and collects into a HashMap

This matches the pattern in magicblock-committor-service/src/intent_executor/task_info_fetcher.rs.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (4)

66-80: Constructor signatures cleanly propagate UserSeeds.

Both try_new_random_keys and try_new accept UserSeeds and delegate to the internal constructor, maintaining a clean API.


115-118: PDA derivation uses the correct seed pattern.

Using user_seed.bytes() ensures the PDA derivation matches the on-chain program's expected seeds.


166-208: Instruction generation correctly branches on UserSeeds variant.

The match expression:

  • MagicScheduleCommitinit_account_instruction
  • OrderBookinit_order_book_instruction

The compute budget instructions (1,400,000 units, 10,000 price) are reasonable for complex initialization transactions.


193-206: Tracked: Commented TODO for grow_order_book.

The comment explains the 10KB delegation limit and the planned future work. This is acceptable as a tracked limitation.

test-integration/programs/schedulecommit/src/lib.rs (4)

36-41: Order book module and types are properly integrated.

The module structure and public exports (BookUpdate, OrderBookOwned, OrderLevel) along with the new DelegateOrderBookArgs struct provide a clean API for order book operations.

Also applies to: 56-61


310-341: process_init_order_book correctly allocates and assigns ownership.

The function:

  1. Validates payer is a signer
  2. Derives the expected PDA
  3. Validates the provided order_book matches the derived PDA
  4. Allocates 10KB and assigns to this program

Note: Past review flagged missing book_manager signer check. Since book_manager is used in PDA derivation seeds for allocate_account_and_assign_owner, the operation will fail if the account doesn't match, but an explicit early check would provide clearer errors.


449-469: process_schedulecommit_for_orderbook correctly validates payer and commits.

The handler validates the payer is a signer before calling commit_and_undelegate_accounts. The lack of PDA/ownership validation was noted in past reviews, but since this is test code and downstream checks exist, it's acceptable.


822-841: Undelegate handling now supports both account types.

The match on data.len() to determine whether to deserialize as MainAccount or OrderBook is a reasonable approach for this test program. Error logging provides visibility into deserialization failures.

test-integration/programs/schedulecommit/src/order_book.rs (6)

1-27: LGTM: Struct definitions and compile-time assertions.

The OrderLevel and BookUpdate structs are well-defined. The use of #[repr(C)] and compile-time assertions ensures predictable layout and catches size/alignment mismatches at build time.


28-53: LGTM: Header and owned representation.

The OrderBookHeader and OrderBookOwned designs are sound. The conversion correctly reverses asks back to their original order (line 50), matching the internal storage invariant.


86-143: LGTM: Safe construction with proper validation.

The try_new constructor correctly validates alignment (lines 112–123) and capacity bounds (lines 131–136) before creating typed references. These checks prevent the undefined behavior that would arise from unaligned access or out-of-bounds slices in bids()/asks_reversed().


150-187: LGTM: Safe and correct bid/ask insertion.

Both add_bids and add_asks properly check capacity before using unsafe slices. The unsafe helper methods are sound because:

  • Bounds are validated by the capacity check
  • Uninitialized memory is immediately filled before the slice is returned
  • Header lengths are updated atomically

The reverse-order copy in add_asks (lines 179–183) correctly implements the storage invariant.


189-210: LGTM: Safe accessors protected by constructor invariants.

The unsafe from_raw_parts calls in bids() and asks_reversed() are sound because:

  • The constructor validates alignment (lines 112–123) and capacity bounds (lines 131–136)
  • add_bids/add_asks are the only mutators and maintain the invariant bids_len + asks_len ≤ capacity
  • Header is private and cannot be corrupted externally

The u32→usize casts are safe in Solana's 64-bit environment.


212-234: LGTM: Private helpers and capacity calculation are sound.

The unsafe helper methods (lines 212–227) are correctly scoped as private and called only after capacity validation by their public callers (add_bids/add_asks), ensuring bounds are valid.

The remaining_capacity calculation (lines 229–234) performs u32 arithmetic that cannot overflow in practice: Solana's 10MB account limit means at most ~625K entries (10MB ÷ 16 bytes), well below u32::MAX. The constructor's capacity check (lines 131–136) ensures checked_sub will not fail.

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

♻️ Duplicate comments (2)
magicblock-committor-service/src/tasks/task_strategist.rs (2)

377-379: Minor: Inconsistent system program import usage.

Two imports for the same program ID are used inconsistently (line 439 uses system_program::id(), line 497 uses system_program_id()). Consider consolidating to one style for consistency.

🔎 Suggested consolidation
-use solana_program::system_program;
 use solana_pubkey::Pubkey;
 use solana_system_program::id as system_program_id;

Then update line 439:

-                owner: system_program::id(),
+                owner: system_program_id(),

419-425: MockInfoFetcher returns empty base accounts—intentional limitation.

This mock always returns an empty HashMap, so tests using TaskBuilderImpl::commit_tasks won't exercise the CommitDiff path. The unit tests in this file work around this by using create_test_commit_task, which directly provides base_account. For full integration coverage of the diff path, consider adding tests that use a mock returning actual base account data.

🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/task_builder.rs (2)

119-125: Minor inconsistency: threshold comparisons differ (>= vs >).

Line 122 uses >= COMMIT_STATE_SIZE_THRESHOLD to filter accounts for base fetching, but line 61 uses > COMMIT_STATE_SIZE_THRESHOLD to decide whether to use the diff. This means a 256-byte account will have its base fetched but won't use it (falling back to CommitState). Not incorrect, but wasteful for the edge case.

🔎 Align the comparisons
             let diffable_pubkeys = accounts
                 .iter()
                 .filter(|account| {
-                    account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD
+                    account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD
                 })

153-156: TODO is valid; consider addressing in this PR.

The note about using remove() instead of get().cloned() is a minor optimization. If account pubkeys are guaranteed unique (which they likely are given they represent distinct delegated accounts), using remove() avoids the clone cost.

🔎 Use remove if uniqueness is guaranteed
-                // TODO (snawaz): if accounts do not have duplicate, then we can use remove
-                // instead:
-                //  let base_account = base_accounts.remove(&account.pubkey);
-                let base_account = base_accounts.get(&account.pubkey).cloned();
+                let base_account = base_accounts.remove(&account.pubkey);

Note: This requires base_accounts to be mut.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d6ded46 and 30ef2fc.

📒 Files selected for processing (5)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
🧰 Additional context used
🧠 Learnings (9)
📚 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-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_builder.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-committor-service/tests/test_transaction_preparator.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:

  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/tests/common.rs
🧬 Code graph analysis (3)
magicblock-committor-service/src/tasks/task_builder.rs (3)
test-integration/test-committor-service/tests/common.rs (4)
  • create_commit_task (175-191)
  • fetch_next_commit_ids (126-131)
  • get_base_accounts (146-163)
  • new (53-56)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
  • fetch_next_commit_ids (24-27)
  • fetch_next_commit_ids (166-233)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • new (58-65)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_commit_task (175-191)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (10)
magicblock-committor-service/src/tasks/task_strategist.rs (2)

429-467: Well-structured test helper for diff scenarios.

The helper correctly creates distinct base_account data when diff_len > 0, enabling proper testing of both CommitDiff and Commit task paths. The wrapping_add(1) approach ensures predictable byte differences for the diff encoding.


561-620: Good test coverage for diff-based optimization boundaries.

These tests properly verify the optimization behavior around COMMIT_STATE_SIZE_THRESHOLD:

  • Small diff → Args strategy (no buffer needed)
  • Threshold+1 diff → Args strategy (still fits)
  • Large diff (4×threshold) → Buffer strategy (too large for args)

This addresses the reviewer concern about missing diff test coverage.

test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)

37-47: Correct migration to TaskBuilderImpl for commit task creation.

The test now uses TaskBuilderImpl::create_commit_task with None for base_account, which correctly produces a CommitState task for the small 5-byte account data. This aligns with the centralized task creation pattern.


93-102: BufferTask construction correctly extracts task_type from ArgsTask.

The pattern .task_type.into() properly converts the ArgsTaskType from the returned ArgsTask into BufferTaskType for buffer-based execution.

magicblock-committor-service/src/tasks/task_builder.rs (3)

45-51: Good documentation for the threshold constant.

The comment clearly explains the rationale for choosing 256 bytes as the threshold—sufficient for small accounts with typical integer fields. Making this pub const enables tests to reference it for boundary testing.


127-138: Good use of parallel fetching.

Using tokio::join! to fetch commit IDs and base accounts concurrently reduces latency compared to sequential calls. Error handling correctly propagates failures from either fetch operation.


54-82: Clean encapsulation of commit task creation logic.

The helper correctly:

  1. Clears base_account for accounts at or below threshold (ensuring small accounts always use CommitState)
  2. Creates CommitDiff when base_account is provided for large accounts
  3. Falls back to Commit otherwise

This centralizes the decision logic and prevents invalid task states.

test-integration/test-committor-service/tests/common.rs (3)

116-119: Good factory method for test infrastructure.

Adding create_task_info_fetcher improves code reuse and ensures consistent fetcher creation across tests.


146-163: Correct implementation matching the main TaskInfoFetcher.

The implementation correctly:

  1. Calls RPC to fetch multiple accounts
  2. Wraps errors into TaskInfoFetcherError
  3. Filters out None results (missing accounts)
  4. Returns a HashMap<Pubkey, Account>

This mirrors the CacheTaskInfoFetcher implementation in task_info_fetcher.rs, ensuring consistent behavior in tests.


122-122: MockTaskInfoFetcher now carries RPC client for real lookups.

The tuple struct change enables get_base_accounts to perform actual RPC calls, which is appropriate for integration tests that need to verify real account data. The create_task_info_fetcher factory method abstracts construction.

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

♻️ Duplicate comments (11)
magicblock-committor-service/src/tasks/args_task.rs (1)

200-206: CommitDiff tasks cannot be recycled—commit_id is never updated.

reset_commit_id only handles ArgsTaskType::Commit, returning early for all other variants including CommitDiff. When a CommitDiff task is recycled, the stale commit_id remains, causing desync in future submissions.

🔎 Proposed fix
-    let ArgsTaskType::Commit(commit_task) = &mut self.task_type else {
-        return;
-    };
-
-    commit_task.commit_id = commit_id;
+    match &mut self.task_type {
+        ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
+            task.commit_id = commit_id;
+        }
+        _ => {}
+    }

Based on past review comments.

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

41-47: Remove unused trait bounds.

The trait bounds std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq are not used by this function. The function body (lines 48-65) only inspects the structure of ScheduledCommitResult and never deserializes, formats, or compares values of type T.

🔎 Proposed fix
 pub fn assert_one_committee_was_committed<T>(
     ctx: &ScheduleCommitTestContext,
     res: &ScheduledCommitResult<T>,
     is_single_stage: bool,
-) where
-    T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq,
-{
+) {

Based on past review comments.

test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)

166-169: Consider extracting compute budget constants.

The compute unit limit (1,400,000) and price (10,000) are hardcoded. Extracting these as named constants would improve maintainability.

const INIT_COMPUTE_UNIT_LIMIT: u32 = 1_400_000;
const INIT_COMPUTE_UNIT_PRICE: u64 = 10_000;

let mut ixs = vec![
    ComputeBudgetInstruction::set_compute_unit_limit(INIT_COMPUTE_UNIT_LIMIT),
    ComputeBudgetInstruction::set_compute_unit_price(INIT_COMPUTE_UNIT_PRICE),
];

Based on past review comments.


193-206: Remove commented code block.

The 14-line commented TODO about growing order books adds noise. Track the account size limitation and future grow_order_book_instruction feature in a GitHub issue, then remove this block.

Based on past review comments.

test-integration/programs/schedulecommit/src/api.rs (3)

71-90: Authorization inconsistency: book_manager should be a signer.

Line 80 marks book_manager as a non-signer (false), but init_order_book_instruction requires book_manager to sign (line 59). This creates an authorization inconsistency where:

  • Init requires book_manager signature
  • Grow allows any payer to resize someone else's order book

If book_manager should authorize growth (mirroring init semantics), change line 80 to mark book_manager as a signer and add the corresponding validation in process_grow_order_book.

🔎 Proposed fix
     let account_metas = vec![
         AccountMeta::new(payer, true),
-        AccountMeta::new_readonly(book_manager, false),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
         AccountMeta::new_readonly(system_program::id(), false),
     ];

Based on past review comments.


197-213: Missing book_manager authorization.

The function omits the book_manager account. Since order books are PDAs derived from [b"order_book", book_manager.key], the book_manager is the conceptual owner. Without validation, anyone can update any order book.

Include book_manager in the account metas and validate authorization on-chain.

🔎 Proposed fix
 pub fn update_order_book_instruction(
     payer: Pubkey,
+    book_manager: Pubkey,
     order_book: Pubkey,
     update: BookUpdate,
 ) -> Instruction {
     let program_id = crate::id();
     let account_metas = vec![
         AccountMeta::new(payer, true),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
     ];

Based on past review comments.


215-234: Missing book_manager authorization.

Similar to update_order_book_instruction, this function omits the book_manager account. Anyone can schedule commits for any order book without proper authorization.

🔎 Proposed fix
 pub fn schedule_commit_diff_instruction_for_order_book(
     payer: Pubkey,
+    book_manager: Pubkey,
     order_book: Pubkey,
     magic_program_id: Pubkey,
     magic_context_id: Pubkey,
 ) -> Instruction {
     let program_id = crate::id();
     let account_metas = vec![
         AccountMeta::new(payer, true),
+        AccountMeta::new_readonly(book_manager, true),
         AccountMeta::new(order_book, false),
         AccountMeta::new(magic_context_id, false),
         AccountMeta::new_readonly(magic_program_id, false),
     ];

Based on past review comments.

test-integration/programs/schedulecommit/src/lib.rs (3)

307-341: Missing signer validation: book_manager must be verified.

Line 318 validates payer is a signer, but there's no check for book_manager. The instruction builder (api.rs line 59) marks book_manager as a signer, but the handler never validates this. Failing late in allocate_account_and_assign_owner produces a less clear error than validating up front.

🔎 Proposed fix
     assert_is_signer(payer, "payer")?;
+    assert_is_signer(book_manager, "book_manager")?;

     let (pda, bump) = Pubkey::find_program_address(

Based on past review comments.


390-423: Missing signer validation for payer before delegation CPI.

The handler calls delegate_account (which creates accounts and transfers lamports) without validating that payer is a signer. The CPI will fail with a less clear error if the payer flag is missing.

🔎 Proposed fix
     let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] =
         accounts
     else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };

+    assert_is_signer(payer, "payer")?;
+
     let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];

Based on past review comments.


449-469: Missing PDA and ownership validation for order_book_account.

The handler schedules a commit and undelegate for order_book_account without verifying:

  • The account is the expected PDA derived from [b"order_book", book_manager.key]
  • The account is owned by this program

This allows committing arbitrary accounts via this instruction.

Full PDA validation requires book_manager to be available (either as an additional account or in instruction data) to recompute and verify the PDA. Add explicit validation:

  1. Include book_manager account or pass its pubkey in instruction data
  2. Recompute PDA with seeds [b"order_book", book_manager.key.as_ref()]
  3. Assert order_book_account.key == &pda
  4. Assert order_book_account.owner == program_id

Based on past review comments.

magicblock-committor-service/src/tasks/task_strategist.rs (1)

420-425: Clarify which tests need CommitDiffTask coverage.

MockInfoFetcher returning an empty HashMap prevents tests using TaskBuilderImpl::commit_tasks (such as test_build_single_stage_mode, test_build_two_stage_mode_no_alts) from exercising the CommitDiffTask path, since base_account will always be None. However, the tests at lines 561-620 use create_test_commit_task directly, which bypasses MockInfoFetcher and can already construct CommitDiffTask tasks.

If the intent is to add integration tests that verify CommitDiffTask creation through the full commit_tasks flow, update MockInfoFetcher to conditionally return base accounts for accounts above COMMIT_STATE_SIZE_THRESHOLD. Alternatively, add assertions to the existing strategy tests to verify the task type of optimized_tasks[0] using the appropriate accessor method (not task_type()).

🧹 Nitpick comments (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)

41-45: Batch base-account fetch implementation looks good; consider an empty-slice fast path

The new get_base_accounts API and CacheTaskInfoFetcher implementation correctly mirror the existing get_multiple_accounts usage and safely filter out None entries into a HashMap.

As a small optimization, you could early-return Ok(HashMap::new()) when pubkeys.is_empty() to avoid an unnecessary RPC call on the hot path where no diffable accounts exist. This is purely a micro-optimization; the current behavior is functionally fine.

Also applies to: 273-290

test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)

68-121: Order-book commit strategy tests are well-targeted; consider clarifying the 679/680/681 comment

The new single-account and order-book tests nicely exercise the Args vs FromBuffer strategy boundary and verify we can still commit large (10KB) accounts via args when the diff is small.

One nit: in test_ix_commit_order_book_change_680_bytes, the comment discusses 679/680 while the call uses changed_len = 681. To make future maintenance easier, it may be worth tightening that comment to explicitly mention 681 as the point where you expect the planner to flip from Args to FromBuffer, and briefly restate the encoded-size reasoning there.

Also applies to: 188-251

magicblock-committor-service/src/tasks/task_builder.rs (1)

45-52: Align threshold comparisons to avoid unnecessary base-account fetches

create_commit_task uses len() > COMMIT_STATE_SIZE_THRESHOLD while diffable_pubkeys uses len() >= COMMIT_STATE_SIZE_THRESHOLD. For an account of exactly 256 bytes, this means:

  • get_base_accounts is called for that pubkey, but
  • create_commit_task will ignore any returned base_account and fall back to CommitState.

Functionally this is harmless but does introduce an avoidable RPC call. Consider making both checks either > or >= (matching the comment’s intent) so fetch and usage are consistent.

Also applies to: 119-125

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30ef2fc and 333f137.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (30)
  • Cargo.toml
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-scenarios/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (12)
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/programs/schedulecommit/Cargo.toml
  • test-integration/test-tools/src/scheduled_commits.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • Cargo.toml
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
🧰 Additional context used
🧠 Learnings (20)
📚 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-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/api.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_strategist.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/intent_executor/task_info_fetcher.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:

  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/Cargo.toml
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/utils/transactions.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/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.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:

  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_strategist.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:

  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/test-scenarios/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:

  • test-integration/Cargo.toml
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.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:

  • test-integration/Cargo.toml
📚 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:

  • test-integration/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:

  • test-integration/Cargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (12)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • get_base_accounts (146-163)
  • new (53-56)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
  • schedule_commit_diff_instruction_for_order_book (215-234)
  • set_count_instruction (371-379)
  • update_order_book_instruction (197-213)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
  • assert_one_committee_account_was_undelegated_on_chain (190-196)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • pda_and_bump (404-408)
  • schedule_commit_cpi_instruction (177-195)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (3)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
  • init_and_delegate_order_book_on_chain (240-298)
test-integration/test-committor-service/tests/utils/mod.rs (1)
  • ensure_validator_authority (35-44)
magicblock-committor-service/src/service.rs (1)
  • try_start (262-289)
magicblock-committor-service/src/tasks/task_builder.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
  • fetch_next_commit_ids (24-27)
  • fetch_next_commit_ids (166-233)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • new (58-65)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
test-integration/programs/schedulecommit/src/lib.rs (3)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-109)
test-integration/test-tools/src/integration_test_context.rs (2)
  • delegate_account (601-619)
  • try_new (116-118)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (106-140)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/api.rs (3)
  • init_order_book_instruction (51-69)
  • init_payer_escrow (92-113)
  • init_account_instruction (31-49)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_new (116-118)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
  • try_new (72-74)
  • try_new_random_keys (66-71)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
test-integration/programs/schedulecommit/src/api.rs (1)
test-integration/programs/flexi-counter/src/state.rs (1)
  • pda (34-37)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (3)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
  • init_validator_fees_vault_ix (5-11)
test-integration/test-committor-service/tests/common.rs (1)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
  • new (58-65)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • pubkeys (112-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
  • GitHub Check: Build Project
🔇 Additional comments (8)
test-integration/Cargo.toml (1)

74-74: Dependencies are actively used and appropriately added.

The additions of rkyv = "0.7.45" and static_assertions = "1.1.0" to workspace dependencies are correct:

  • rkyv is actively used in test-integration/programs/schedulecommit/src/order_book.rs for serialization via rkyv::AlignedVec
  • static_assertions is actively used in the same module for compile-time assertions via const_assert
  • Both are properly referenced as workspace dependencies in the schedulecommit program's Cargo.toml
  • Versions are stable and compatible
test-integration/schedulecommit/test-scenarios/Cargo.toml (2)

19-19: LGTM! Appropriate test dependency.

Adding rand as a dev-dependency is appropriate for the randomized test scenarios and seeded data generation mentioned in the PR objectives.


20-20: No action needed; borsh version is compatible.

The test-scenarios crate does not interact with magic-domain-program types. Adding borsh = { workspace = true } is appropriate for test serialization and uses workspace version 1.5.1, which is compatible with the 1.5.x series used elsewhere in the codebase (including the 1.5.3 pinned in magicblock-api).

Likely an incorrect or invalid review comment.

test-integration/programs/schedulecommit/src/order_book.rs (1)

55-75: Zero‑copy OrderBook layout and unsafe usage look sound for this test program

The combination of:

  • repr(C) + const_assert!s on size/alignment,
  • explicit runtime alignment checks in try_new,
  • header bounds check (bids_len + asks_len <= capacity), and
  • using rkyv::AlignedVec in the Borsh path

makes the typed pointer/slice usages in bids(), asks_reversed(), and the internal *_with_uninitialized_slots helpers safe from UB, given Solana’s 10MB account bound.

The remaining capacity math and asks/bids layout invariants are consistent with the documented growth model. For a test-only program this is a reasonable and robust design.

Also applies to: 106-140, 186-224, 209-230

magicblock-committor-service/src/tasks/mod.rs (1)

17-17: CommitDiffTask wiring and serialization tests are coherent

Exposing TaskBuilderImpl and adding CommitDiffTask { …, base_account: Account } integrate cleanly with the existing task/ArgsTask machinery. The serialization tests still cover all Args/Buffer variants (via CommitTask), and the additional Account import is appropriate for both production and test code. No issues from this module’s changes.

Also applies to: 32-33, 111-117, 304-437

test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)

1-1: UserSeeds integration in context setup is correct

Passing UserSeeds::MagicScheduleCommit into ScheduleCommitTestContext::try_new / try_new_random_keys aligns with the new API and makes the seed choice explicit for these security tests. Behavior remains equivalent to the previous hard-coded seed usage.

Also applies to: 28-36

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

13-19: Order-book CommitDiff flow and randomized regression test look solid

commit_and_undelegate_order_book_account correctly chains update_order_book_instruction with schedule_commit_diff_instruction_for_order_book using UserSeeds::OrderBook, and the huge-order-book test validates that the committed OrderBookOwned exactly matches the generated BookUpdate (with a reproducible RNG seed).

This gives good end-to-end coverage of the new diff-based order-book path.

Also applies to: 113-167, 300-362

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

5-11: UserSeeds::MagicScheduleCommit wiring keeps commit tests aligned with new API

Updating both get_context_with_delegated_committees callers and delegate_account_cpi_instruction to pass UserSeeds::MagicScheduleCommit matches the new API surface and makes the seed choice explicit. The commit/undelegate behavior under test remains the same, just parameterized via the enum.

Also applies to: 45-52, 101-107, 222-239

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

♻️ Duplicate comments (1)
test-integration/programs/schedulecommit/src/order_book.rs (1)

142-145: Consider failing loudly on capacity exhaustion to maintain test invariants.

The current implementation silently ignores failures from add_bids and add_asks, which can leave the order book in a partially updated state if capacity is exhausted mid-update (e.g., bids succeed but asks fail). For test code, this could mask capacity planning issues.

Since you stated "It's a test. So let it panic!" in a previous review, consider unwrapping the results to make capacity issues immediately visible:

 pub fn update_from(&mut self, updates: BookUpdate) {
-    self.add_bids(&updates.bids);
-    self.add_asks(&updates.asks);
+    self.add_bids(&updates.bids)
+        .expect("insufficient capacity for bids in update");
+    self.add_asks(&updates.asks)
+        .expect("insufficient capacity for asks in update");
 }

This ensures test failures are loud rather than leaving the book in an inconsistent state.

🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)

137-137: Base account fetch errors silently fall back to CommitState.

Using unwrap_or_default() means any error fetching base accounts is silently ignored, and all affected accounts will use CommitState instead of CommitDiff. This matches the PR's intent that CommitDiff is an optimization, not a requirement.

Consider adding a debug/warn log when the fallback occurs to aid troubleshooting:

🔎 Optional: Add warning log on fallback
-        let base_accounts = base_accounts.unwrap_or_default();
+        let base_accounts = match base_accounts {
+            Ok(accounts) => accounts,
+            Err(err) => {
+                log::warn!(
+                    "Failed to fetch base accounts for CommitDiff (intent_id={}): {}; falling back to CommitState",
+                    base_intent.id, err
+                );
+                Default::default()
+            }
+        };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 333f137 and aad2791.

📒 Files selected for processing (6)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • test-integration/test-committor-service/tests/common.rs
🧰 Additional context used
🧠 Learnings (11)
📚 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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.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-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/order_book.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.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-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_strategist.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-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/intent_executor/task_info_fetcher.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:

  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.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-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/programs/schedulecommit/src/order_book.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:

  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
🧬 Code graph analysis (4)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
  • fetch_next_commit_ids (24-27)
  • fetch_next_commit_ids (166-233)
  • new (58-65)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • get_base_accounts (146-163)
  • new (53-56)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • new (42-47)
  • strategy (181-183)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (40-48)
  • strategy (132-134)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_commit_task (175-191)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (12)
test-integration/programs/schedulecommit/src/order_book.rs (1)

1-231: LGTM! Previous critical issues have been successfully addressed.

The implementation now includes proper safeguards:

  • Alignment validation in try_new (lines 109-120) prevents UB from unaligned typed references
  • Capacity bounds checking (lines 128-133) ensures header lengths never exceed backing storage
  • Mutable aliasing issue resolved with mut book_bytes binding (line 64)

The unsafe slice operations in bids(), asks_reversed(), and the internal helpers are now safe because all invariants are established and validated at construction time in try_new.

The remaining_capacity arithmetic is correct given Solana's 10MB account limit, as previously discussed.

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

40-44: Trait method addition looks correct.

The new get_base_accounts method extends the TaskInfoFetcher trait to support batch fetching of base accounts for CommitDiff optimization. The signature is appropriate for the use case.


273-290: Implementation is correct and handles missing accounts gracefully.

The implementation correctly:

  • Fetches accounts in a single batched RPC call
  • Filters out None values for accounts that don't exist
  • Maps errors appropriately

One observation: unlike fetch_metadata_with_retries, this method has no retry logic. Per previous review discussions, base account fetching is treated as best-effort (falling back to CommitState if unavailable), so this is acceptable behavior.

test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)

38-43: Test now uses TaskBuilderImpl for task construction.

Using TaskBuilderImpl::create_commit_task ensures the test exercises the actual task creation logic and respects the COMMIT_STATE_SIZE_THRESHOLD invariants. Passing None for base_account correctly produces a CommitTask (not CommitDiff) since this test uses small account data.


93-102: The From<ArgsTaskType> implementation for BufferTaskType is correctly implemented.

The .task_type.into() pattern extracts ArgsTaskType from the ArgsTask and converts it to BufferTaskType via the From implementation defined in magicblock-committor-service/src/tasks/buffer_task.rs:68. Since the test uses create_commit_task() which produces a Commit variant, the conversion succeeds and constructs valid buffer tasks.

magicblock-committor-service/src/tasks/task_builder.rs (3)

45-51: Threshold constant is well-documented.

The COMMIT_STATE_SIZE_THRESHOLD of 256 bytes is a reasonable choice for distinguishing small accounts (that benefit from CommitState's simplicity) from larger accounts (that benefit from CommitDiff's reduced data transfer). The comment clearly explains the rationale.


54-82: Task creation logic correctly implements CommitDiff selection.

The method properly:

  1. Checks if the account size exceeds COMMIT_STATE_SIZE_THRESHOLD before using base_account
  2. Creates CommitDiffTask only when a valid base_account is available for large accounts
  3. Falls back to CommitTask for small accounts or when no base account exists

The .into() conversion at the end cleanly wraps the ArgsTaskType into an ArgsTask.


152-158: Task creation loop is correct; TODO for future optimization is valid.

The TODO notes that remove() could be used instead of get().cloned() if accounts are guaranteed unique, which would avoid cloning. This is a reasonable future optimization but the current implementation is correct and safe.

magicblock-committor-service/src/tasks/task_strategist.rs (4)

419-425: MockInfoFetcher correctly returns empty map for base accounts.

Returning Ok(Default::default()) simulates the scenario where no base accounts are found on-chain, which causes all commit tasks to use CommitState. This is appropriate for existing tests that don't specifically test CommitDiff behavior.


429-468: Test helper correctly scaffolds diff-based commit task creation.

The create_test_commit_task helper:

  • Creates a CommitTask when diff_len == 0 (no base account)
  • Creates a CommitDiffTask when diff_len > 0 by generating a modified base_account
  • Uses wrapping_add(1) to create realistic byte differences

The assertion at line 455 guards against test misconfiguration. This enables comprehensive testing of both commit paths.


561-620: New tests comprehensively cover threshold-based optimization decisions.

These tests verify the key optimization scenarios:

  1. Large account, small diff (line 565): Uses Args strategy because CommitDiff instruction is small
  2. Large account, threshold+1 diff (line 585): Still uses Args - diff is small enough
  3. Large account, large diff (line 604): Falls back to Buffer strategy when diff exceeds capacity

The tests exercise the new CommitDiff path through TaskBuilderImpl::create_commit_task and verify that the strategy selection correctly considers the encoded instruction size, not just raw data size.


502-517: Existing tests correctly updated with diff_len=0 parameter.

All existing tests that previously tested CommitState behavior now explicitly pass diff_len=0, preserving their original semantics while adapting to the new helper signature.

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

🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/task_builder.rs (1)

119-125: Minor inconsistency: >= vs > threshold comparison.

The diffable_pubkeys filter uses >= (line 122: account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD), but create_commit_task uses > (line 61: account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD).

This means accounts with exactly 256 bytes will have their base account fetched but then ignored. Consider aligning both comparisons:

🔎 Proposed fix (use consistent `>` comparison)
         let diffable_pubkeys = accounts
             .iter()
             .filter(|account| {
-                account.account.data.len() >= COMMIT_STATE_SIZE_THRESHOLD
+                account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD
             })
             .map(|account| account.pubkey)
             .collect::<Vec<_>>();
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 333f137 and 5050443.

📒 Files selected for processing (6)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
🧰 Additional context used
🧠 Learnings (8)
📚 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-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/tests/test_transaction_preparator.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:

  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/common.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/src/tasks/task_strategist.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-committor-service/tests/common.rs
🧬 Code graph analysis (4)
magicblock-committor-service/src/tasks/task_builder.rs (3)
test-integration/test-committor-service/tests/common.rs (4)
  • create_commit_task (175-191)
  • fetch_next_commit_ids (126-131)
  • get_base_accounts (146-163)
  • new (53-56)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (5)
  • fetch_next_commit_ids (24-27)
  • fetch_next_commit_ids (166-233)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • new (58-65)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (42-47)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (2)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
magicblock-committor-service/src/tasks/task_strategist.rs (3)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • strategy (181-183)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • strategy (132-134)
test-integration/test-committor-service/tests/common.rs (1)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
  • new (58-65)
  • get_base_accounts (41-44)
  • get_base_accounts (273-290)
  • pubkeys (112-123)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: run_make_ci_test
  • GitHub Check: Build Project
🔇 Additional comments (19)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (4)

6-11: Import changes look correct.

The imports now reflect the shift to using TaskBuilderImpl for commit task creation. The removal of direct CommitTask import and addition of TaskBuilderImpl aligns with the PR's goal of centralizing task creation logic.


37-47: Correct usage of TaskBuilderImpl::create_commit_task.

The test properly uses the new task creation API with None for base_account, which will produce a CommitTask (not CommitDiff) since the account data is small (5 bytes, well below the 256-byte threshold).


93-122: Buffer task construction pattern is correct.

The .task_type.into() pattern properly extracts ArgsTaskType from the created ArgsTask and converts it to BufferTaskType for the BufferTask::new_preparation_required call. This aligns with the BufferTask::new signature shown in the relevant code snippets.


194-215: Consistent task creation pattern maintained.

The BufferTask construction follows the same pattern established in the previous test, ensuring consistency across the test suite.

test-integration/test-committor-service/tests/common.rs (4)

13-14: Import additions are correct.

The new imports for TaskInfoFetcherError and TaskInfoFetcherResult are required for implementing the get_base_accounts trait method.


115-119: Good helper extraction for MockTaskInfoFetcher creation.

Centralizing MockTaskInfoFetcher construction in create_task_info_fetcher reduces duplication and ensures the mock is consistently initialized with the RPC client across all tests.


122-122: Struct change to hold RPC client is appropriate.

Converting MockTaskInfoFetcher to a tuple struct with MagicblockRpcClient is necessary for the get_base_accounts implementation to make actual RPC calls in integration tests.


146-163: get_base_accounts implementation mirrors production code correctly.

The implementation follows the same pattern as CacheTaskInfoFetcher::get_base_accounts shown in the relevant code snippets: calling get_multiple_accounts, mapping errors to TaskInfoFetcherError::MagicBlockRpcClientError, and building a HashMap by filtering out None results.

magicblock-committor-service/src/tasks/task_strategist.rs (6)

292-292: Debug log removal is good.

Past review comments flagged debug println! statements; this removal addresses that feedback.


377-393: Import additions support new test functionality.

The system_program and COMMIT_STATE_SIZE_THRESHOLD imports are required for the updated test helper and new threshold-based test scenarios.


419-425: Mock returns empty base accounts, but new tests cover diff path directly.

The MockInfoFetcher::get_base_accounts returns an empty map, which means tests using TaskBuilderImpl::commit_tasks won't create CommitDiff tasks. However, the new tests (lines 561-620) correctly test the diff path by calling create_test_commit_task directly with a base_account, bypassing the fetcher and validating create_commit_task logic.


429-468: Test helper correctly supports both CommitState and CommitDiff paths.

The create_test_commit_task helper:

  • Creates a CommittedAccount with data_size bytes
  • When diff_len > 0, creates a base_account with the first diff_len bytes mutated
  • Passes the appropriate base_account (Some or None) to TaskBuilderImpl::create_commit_task

This design allows testing the threshold-based task type selection in create_commit_task.


561-620: New threshold-based tests validate diff optimization correctly.

These tests verify the strategy selection based on diff size:

  • Lines 561-578: Large account (66KB) with small diff (256 bytes) → TaskStrategy::Args (fits in transaction)
  • Lines 580-598: Large account with diff just above threshold (257 bytes) → TaskStrategy::Args (still fits)
  • Lines 600-620: Large account with large diff (1024 bytes) → TaskStrategy::Buffer (too large, needs buffer)

The tests correctly validate that CommitDiff tasks are optimized to buffers only when the encoded diff exceeds transaction size limits.


505-505: Existing tests correctly updated with diff_len=0.

All pre-existing tests now pass diff_len=0 to create_test_commit_task, preserving their original behavior of testing the CommitState path.

magicblock-committor-service/src/tasks/task_builder.rs (5)

9-13: Import additions are appropriate.

The new imports for Account, CommitDiffTask, and CommitTask are required for the create_commit_task implementation.


45-51: Threshold constant is well-documented.

The COMMIT_STATE_SIZE_THRESHOLD of 256 bytes is appropriately documented with rationale for the choice. Making it pub enables its use in tests for threshold-based validation.


53-83: create_commit_task implementation is correct and clean.

The function properly:

  1. Only considers base_account for accounts larger than the threshold (line 61: >)
  2. Creates CommitDiffTask when base_account is available
  3. Falls back to CommitTask otherwise
  4. Converts to ArgsTask via .into()

This ensures small accounts always use the simpler CommitState path regardless of whether base data is available.


137-143: Graceful fallback on base account fetch failure.

When get_base_accounts fails, the code logs a warning and falls back to an empty map, causing all tasks to use CommitState instead of CommitDiff. This is appropriate degradation behavior that prioritizes commit success over optimization.


154-164: Task creation loop correctly uses the new API.

The loop properly:

  1. Retrieves commit_id from the fetched map (with expect for invariant violation)
  2. Clones base_account from the map when available
  3. Delegates to create_commit_task for task type selection

The TODO about using remove() instead of get().cloned() is a reasonable future optimization if account uniqueness can be guaranteed.

coderabbitai[bot]

This comment was marked as spam.

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!

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

♻️ Duplicate comments (8)
test-integration/test-committor-service/tests/utils/instructions.rs (1)

2-4: Remove unused Signer import; order-book helper looks good

The InitOrderBookAndDelegateIxs struct and init_order_book_account_and_delegate_ixs helper correctly derive the order_book PDA, build the init and delegate instructions, and wire UserSeeds::OrderBook.

However, use test_kit::Signer; is unused and will cause unused_import lints; please drop it unless you plan to call trait methods from this module.

The println!("schedulecommit ID: {}", ID); is test‑only; if you want it to respect log levels, consider switching to debug!, but that’s optional.

Also applies to: 54-94

test-integration/programs/schedulecommit/src/api.rs (3)

71-90: Authorization inconsistency: grow_order_book_instruction should require book_manager signature.

Line 80 marks book_manager as read-only non-signer (false), while init_order_book_instruction (line 59) marks it as a signer (true). This allows any payer to grow another entity's order book without authorization.

If book_manager should authorize growth (consistent with initialization), update line 80 to require a signature and add the corresponding on-chain validation in process_grow_order_book.


197-213: Missing book_manager authorization in update_order_book_instruction.

Similar to past feedback, this function omits the book_manager account. Since order books are PDAs derived from [b"order_book", book_manager.key], the conceptual owner should authorize updates.

Consider adding book_manager as a parameter and account meta, then validate authorization on-chain in process_update_order_book.


215-234: Missing book_manager authorization in schedule_commit_diff_instruction_for_order_book.

As with update_order_book_instruction, this function lacks the book_manager account, allowing anyone to schedule commits for any order book.

Add book_manager as a parameter and validate authorization on-chain in process_schedulecommit_for_orderbook.

test-integration/programs/schedulecommit/src/lib.rs (4)

307-341: Missing signer validation for book_manager in process_init_order_book.

Line 318 validates payer is a signer, but there's no corresponding check for book_manager. The instruction builder in api.rs (line 59) marks book_manager as a signer, but this handler never validates it.

Add assert_is_signer(book_manager, "book_manager")?; after line 318 to ensure authorization is checked before account creation.


343-385: Error message typo: should reference book_manager, not payer.

Line 362 incorrectly references payer.key in the PDA validation error message. It should reference book_manager.key to match the PDA derivation logic.

🔎 Proposed fix
     assert_keys_equal(order_book.key, &pda, || {
         format!(
             "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            order_book.key, book_manager.key
         )
     })?;

390-423: Missing signer validation for payer in process_delegate_order_book.

The handler calls delegate_account (which creates accounts and transfers lamports) without first validating that payer is a signer. Add an explicit signer check before the CPI to provide clear error messages when the payer flag is missing.

🔎 Proposed fix
     let [payer, order_book, owner_program, buffer, delegation_record, delegation_metadata, delegation_program, system_program] =
         accounts
     else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };
 
+    assert_is_signer(payer, "payer")?;
+
     let seeds_no_bump = [b"order_book", args.book_manager.as_ref()];

449-469: Missing PDA and ownership validation in process_schedulecommit_for_orderbook.

The handler schedules a commit for order_book_account without verifying:

  • The account is the expected PDA derived from the appropriate seeds.
  • The account is owned by this program.

This allows committing arbitrary accounts via this instruction. Add explicit validation to verify ownership and optionally validate the PDA derivation if book_manager can be passed as an account or in instruction data.

🔎 Recommended validation
     let [payer, order_book_account, magic_context, magic_program] = accounts
     else {
         return Err(ProgramError::NotEnoughAccountKeys);
     };
 
     assert_is_signer(payer, "payer")?;
 
+    // Validate order_book_account is owned by this program
+    if order_book_account.owner != &crate::ID {
+        msg!("order_book_account must be owned by this program");
+        return Err(ProgramError::IllegalOwner);
+    }
+
+    // Note: Full PDA validation would require book_manager to be passed
+    // as an account or in instruction data
+
     commit_and_undelegate_accounts(
🧹 Nitpick comments (5)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)

273-290: Implementation looks correct.

The batched RPC call with proper error wrapping and filter_map to exclude missing accounts is well-structured. Consider whether an empty pubkeys slice should short-circuit to avoid an unnecessary RPC call (similar to fetch_metadata_with_retries at line 73-75), though this is a minor optimization.

🔎 Optional: Early return for empty pubkeys
 async fn get_base_accounts(
     &self,
     pubkeys: &[Pubkey],
 ) -> TaskInfoFetcherResult<HashMap<Pubkey, Account>> {
+    if pubkeys.is_empty() {
+        return Ok(HashMap::new());
+    }
     self.rpc_client
         .get_multiple_accounts(pubkeys, None)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (2)

90-95: Unnecessary join_all for synchronous operations.

The closure |data| async { ... } doesn't perform any async I/O—create_commit_task and BufferTask::new_preparation_required are synchronous. Wrapping them in async {} and using join_all adds overhead without concurrency benefit.

🔎 Simpler synchronous collection
-    let buffer_tasks = join_all(datas.iter().map(|data| async {
-        let task = BufferTaskType::Commit(create_commit_task(data.as_slice()));
-        Box::new(BufferTask::new_preparation_required(task))
-            as Box<dyn BaseTask>
-    }))
-    .await;
+    let buffer_tasks: Vec<Box<dyn BaseTask>> = datas
+        .iter()
+        .map(|data| {
+            let task = BufferTaskType::Commit(create_commit_task(data.as_slice()));
+            Box::new(BufferTask::new_preparation_required(task)) as Box<dyn BaseTask>
+        })
+        .collect();

166-170: Same observation: join_all wraps synchronous code.

Similar to above—ArgsTask::from(task) is synchronous, so join_all provides no concurrency benefit here.

test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)

34-41: Order-book commit helper and strategy tests are sound; watch undelegate semantics later

The new order-book flow (init_and_delegate_order_book_on_chain + commit_book_order_account) correctly:

  • funds the validator auth,
  • starts the committor service,
  • initializes and delegates an order-book account,
  • mutates exactly changed_len bytes before committing, and
  • verifies the chosen CommitStrategy for diff‑vs‑buffer scenarios.

The single/multi‑account tests updated to prefer CommitStrategy::Args are consistent with a diff‑first planner.

One caveat for future extensions: commit_book_order_account accepts undelegate, but all current call sites pass false. If you later add order‑book tests with undelegate = true, ix_commit_local’s expected_owner logic (which currently assumes flexi‑counter for undelegated accounts) will need to be extended to handle schedulecommit‑owned order‑book accounts.

Also applies to: 68-121, 188-251

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

41-47: Generic trait bounds remain unused but acceptable.

As noted in previous reviews, the trait bounds BorshDeserialize, PartialEq, and Eq on line 46 are not used by the function body. However, since this has been previously discussed and deferred, leaving them as-is for now is acceptable. Consider removing unused bounds in a future cleanup PR.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 252862d and 3406ed9.

⛔ Files ignored due to path filters (3)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
  • test-integration/schedulecommit/elfs/dlp.so is excluded by !**/*.so
📒 Files selected for processing (30)
  • Cargo.toml
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/Cargo.toml
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-scenarios/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/test-committor-service/Cargo.toml
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/utils/instructions.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/test-tools/src/scheduled_commits.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • test-integration/test-tools/src/scheduled_commits.rs
  • test-integration/programs/schedulecommit/Cargo.toml
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • Cargo.toml
🧰 Additional context used
🧠 Learnings (21)
📚 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-committor-service/src/tasks/task_strategist.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/Cargo.toml
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/common.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/task_strategist.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/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/Cargo.toml
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
📚 Learning: 2025-11-19T12:55:48.931Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-tools/src/validator.rs:193-197
Timestamp: 2025-11-19T12:55:48.931Z
Learning: In the magicblock-validator codebase, when constructing arguments for the light CLI test validator in start_light_validator_with_config (test-integration/test-tools/src/validator.rs), the shlex::split approach is necessary because the light CLI does not handle whitespaces properly in validator arguments. The string concatenation + shlex parsing pattern should not be refactored to direct argument construction in this specific case.

Applied to files:

  • test-integration/test-ledger-restore/tests/08_commit_update.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-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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-committor-service/src/tasks/mod.rs
📚 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-committor-service/src/tasks/mod.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:

  • test-integration/test-committor-service/Cargo.toml
  • test-integration/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:

  • test-integration/test-committor-service/tests/common.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/test-committor-service/tests/utils/transactions.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:

  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/test-scenarios/Cargo.toml
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-11-21T13:56:03.885Z
Learnt from: snawaz
Repo: magicblock-labs/magicblock-validator PR: 575
File: test-integration/programs/schedulecommit/src/utils/mod.rs:71-71
Timestamp: 2025-11-21T13:56:03.885Z
Learning: In Solana programs (BPF runtime), defensive checked conversions to `usize` (e.g., `try_into()`) are unnecessary when casting from `u64`. Solana exclusively runs in 64-bit environments where `usize` is 64 bits, so truncation is not a concern and simple `as usize` casts are appropriate.

Applied to files:

  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/programs/schedulecommit/src/order_book.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:

  • test-integration/Cargo.toml
📚 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:

  • test-integration/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:

  • test-integration/Cargo.toml
📚 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-committor-service/src/intent_executor/task_info_fetcher.rs
🧬 Code graph analysis (14)
magicblock-committor-service/src/tasks/task_strategist.rs (4)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • new (42-47)
  • strategy (181-183)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (40-48)
  • strategy (132-134)
magicblock-committor-service/src/tasks/mod.rs (1)
  • strategy (90-90)
test-integration/test-ledger-restore/tests/08_commit_update.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/src/lib.rs (1)
  • setup_validator_with_local_remote (104-118)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2)
test-integration/programs/schedulecommit/src/api.rs (2)
  • pda_and_bump (404-408)
  • schedule_commit_cpi_instruction (177-195)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)
  • get_context_with_delegated_committees (16-35)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • from (36-38)
  • value (210-218)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (175-191)
  • new (53-56)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (40-48)
  • new_preparation_required (33-38)
test-integration/test-committor-service/tests/utils/instructions.rs (1)
test-integration/programs/schedulecommit/src/api.rs (2)
  • init_order_book_instruction (51-69)
  • delegate_account_cpi_instruction (115-164)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_commit_task (175-191)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • new (40-48)
magicblock-committor-service/src/tasks/task_builder.rs (1)
  • create_commit_task (54-82)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
test-integration/test-committor-service/tests/utils/transactions.rs (2)
  • init_and_delegate_order_book_on_chain (240-298)
  • fund_validator_auth_and_ensure_validator_fees_vault (301-342)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (2)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (106-140)
test-integration/test-tools/src/integration_test_context.rs (1)
  • try_new (116-118)
test-integration/test-committor-service/tests/utils/transactions.rs (1)
test-integration/test-committor-service/tests/utils/instructions.rs (2)
  • init_account_and_delegate_ixs (21-52)
  • init_order_book_account_and_delegate_ixs (61-94)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-109)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • try_new (106-140)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (3)
test-integration/programs/schedulecommit/src/api.rs (2)
  • schedule_commit_diff_instruction_for_order_book (215-234)
  • set_count_instruction (371-379)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (2)
  • get_context_with_delegated_committees (16-35)
  • assert_one_committee_was_committed (41-65)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
  • get_base_accounts (146-163)
  • new (53-56)
magicblock-rpc-client/src/lib.rs (1)
  • new (243-245)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (36)
test-integration/test-committor-service/Cargo.toml (1)

26-26: LGTM! Consistent dev-dependency addition.

The new program-schedulecommit dev-dependency follows the same pattern as program-flexi-counter (line 25) and correctly uses the no-entrypoint feature, which is standard for Solana programs used as library dependencies in tests.

Verified that:

  • The test-integration workspace Cargo.toml defines program-schedulecommit at programs/schedulecommit
  • The program-schedulecommit crate exports the no-entrypoint feature
  • This dependency is actively used in test files (e.g., test_ix_commit_local.rs)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)

55-61: LGTM! Proper TempDir binding prevents premature cleanup.

Binding _tmpdir (instead of _) ensures the TempDir stays alive for the function scope, preventing the temporary directory from being deleted while the validator is still running.

Also applies to: 170-176

test-integration/schedulecommit/test-scenarios/Cargo.toml (1)

19-20: LGTM!

Adding rand and borsh as workspace dev-dependencies appropriately supports the new OrderBook test scaffolding introduced in this PR.

test-integration/Cargo.toml (1)

40-40: LGTM!

Dependency updates look appropriate:

  • ephemeral-rollups-sdk placement normalized
  • magicblock-delegation-program rev bump aligns with CommitDiff support
  • rkyv and static_assertions additions support test serialization needs

Also applies to: 60-62, 74-74, 93-93

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

41-44: LGTM! Clean trait extension for batch account fetching.

The new get_base_accounts method provides efficient batch retrieval for the CommitDiff optimization path.

test-integration/test-committor-service/tests/utils/transactions.rs (3)

16-19: LGTM!

Import additions properly expose the new InitOrderBookAndDelegateIxs for order book test setup.


124-134: Pragmatic CommitState/CommitDiff handling.

The inline comment clearly explains why searching for "CommitState" also matches "CommitDiff"—this accommodates the optimizer's choice without forcing test updates. This trade-off is reasonable given the PR context.


238-298: LGTM! New order book initialization helper.

The function follows the established pattern from init_and_delegate_account_on_chain and correctly handles the two-phase init + delegate flow with the book_manager keypair as an additional signer.

test-integration/test-committor-service/tests/test_delivery_preparator.rs (1)

2-2: Import added for join_all.

test-integration/schedulecommit/test-security/tests/01_invocations.rs (2)

1-1: LGTM!

Import addition for UserSeeds alongside existing imports.


30-36: Correctly propagates UserSeeds to test context constructors.

The UserSeeds::MagicScheduleCommit parameter is now consistently passed to both try_new and try_new_random_keys, aligning with the broader API changes for seed-driven delegation flows.

magicblock-committor-service/src/tasks/buffer_task.rs (2)

7-8: LGTM!

The cfg guard correctly limits this import to test/dev contexts.


67-76: Temporary test scaffolding acknowledged.

Per prior discussion, the panic! for CommitDiff is intentional—this variant should not reach this code path in current tests, and the message clearly indicates this is temporary until the next PR adds proper support. The cfg guard ensures this doesn't affect production code.

test-integration/schedulecommit/client/src/verify.rs (1)

2-23: Order-book verify helper correctly mirrors existing API

The added OrderBookOwned import and fetch_and_verify_order_book_commit_result_from_logs helper cleanly mirror the existing MainAccount-based function and keep call sites explicit. No changes needed.

magicblock-committor-service/src/tasks/mod.rs (1)

17-17: CommitDiffTask and TaskBuilderImpl exposure look consistent

Importing Account, defining CommitDiffTask with base_account: Account, and re‑exporting TaskBuilderImpl align with the new diff‑based commit flow and match the builder API. Struct fields and derives are appropriate; no further changes needed.

Also applies to: 32-33, 111-117

test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

13-19: Order-book diff commit flow and randomized test are well wired

The new order-book path (commit_and_undelegate_order_book_account plus test_committing_and_undelegating_huge_order_book_account) correctly uses UserSeeds::OrderBook, wires update_order_book_instruction and schedule_commit_diff_instruction_for_order_book, and validates that the committed OrderBookOwned exactly matches the generated BookUpdate (with reproducible RNG seeding). Existing helpers updated to pass UserSeeds::MagicScheduleCommit remain consistent with the new API.

Also applies to: 113-167, 300-362, 741-744

test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (1)

5-11: UserSeeds integration in commit tests is consistent

Passing UserSeeds::MagicScheduleCommit to both get_context_with_delegated_committees and delegate_account_cpi_instruction keeps PDA derivation and delegation semantics in sync with the updated schedulecommit API. The tests remain logically identical while being explicit about the user seed in use.

Also applies to: 45-52, 101-107, 222-239

magicblock-committor-service/src/tasks/task_strategist.rs (1)

377-392: Diff-aware strategist tests correctly exercise COMMIT_STATE_SIZE_THRESHOLD behavior

The updated test scaffolding—MockInfoFetcher with get_base_accounts, create_test_commit_task feeding TaskBuilderImpl::create_commit_task, and the new diff‑size‑sensitive tests—does a good job of validating that:

  • small diffs on large accounts stay on the Args/CommitDiff path, and
  • only when the diff becomes large do we fall back to buffer‑based commits.

This keeps TaskStrategist’s optimization decisions aligned with COMMIT_STATE_SIZE_THRESHOLD and the real commit task builder. No changes needed.

Also applies to: 396-425, 428-468, 503-559, 561-620, 700-711, 713-751, 753-853

magicblock-committor-service/src/tasks/task_builder.rs (4)

45-51: LGTM! Threshold constant is well-documented.

The 256-byte threshold is a reasonable choice for distinguishing small accounts that benefit from full-state commits versus larger accounts that benefit from differential commits. The documentation clearly explains the rationale.


53-83: LGTM! Task selection logic is sound.

The method correctly:

  • Applies the threshold to determine when differential commits are beneficial.
  • Gracefully falls back to full-state commits when base_account is unavailable or account is too small.
  • Uses field initialization shorthand for cleaner code.

113-143: LGTM! Parallel fetching optimizes latency.

The implementation efficiently:

  • Fetches commit IDs and base accounts concurrently using tokio::join!.
  • Filters accounts by threshold to avoid unnecessary base account fetches.
  • Handles errors appropriately: propagates commit ID failures (required) while gracefully degrading to full-state commits when base account fetches fail.

154-164: LGTM! Task creation integrates cleanly with the factory method.

The code correctly:

  • Retrieves commit IDs with appropriate error handling.
  • Clones base accounts from the map (reasonable since the map is only used here).
  • Delegates task creation to create_commit_task for consistent behavior.

The TODO comment about using .remove() is a valid micro-optimization for the future if duplicate accounts are confirmed to never occur.

test-integration/test-committor-service/tests/test_transaction_preparator.rs (1)

38-43: LGTM! Tests consistently use the factory method.

All test cases now create commit tasks via TaskBuilderImpl::create_commit_task(...), ensuring tests exercise the same code path as production. Passing None for base_account is appropriate for these tests, which focus on transaction preparation rather than differential commits.

Also applies to: 94-101, 106-111, 195-202

test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1)

16-34: LGTM! UserSeeds integration is clean.

The function signature now accepts user_seed and correctly propagates it to the context constructors. The explicit init and delegate calls with transaction hash logging are helpful for debugging test scenarios.

test-integration/test-committor-service/tests/common.rs (2)

116-119: LGTM! Helper method simplifies test fixture usage.

The create_task_info_fetcher helper correctly constructs an Arc<MockTaskInfoFetcher> wrapping the test RPC client, centralizing the fetcher creation logic for test code.


122-122: LGTM! MockTaskInfoFetcher implementation is correct.

The implementation:

  • Correctly delegates to the inner MagicblockRpcClient for account fetches.
  • Maps RPC errors to the appropriate TaskInfoFetcherError variant.
  • Filters out None accounts and zips the results into a HashMap keyed by pubkey.

This aligns with the production CacheTaskInfoFetcher implementation pattern.

Also applies to: 146-163

test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)

66-80: LGTM! UserSeeds integration is consistent.

The constructors now accept user_seed and store it in the context. The PDA derivation at lines 115-118 correctly uses user_seed.bytes() and payer_ephem.pubkey(), matching the on-chain PDA derivation pattern in the program.

Also applies to: 115-118


166-208: LGTM! Order-book initialization branch is correct.

The init_committees method:

  • Adds compute budget instructions for sufficient CU allocation.
  • Branches on user_seed to call the appropriate initialization instruction (MainAccount vs OrderBook).
  • The commented-out grow_order_book code (lines 193-206) documents future work but doesn't impede functionality.

The implementation aligns with the program's instruction handlers.


265-275: LGTM! Delegation correctly passes user_seed.

The delegate_committees method now passes self.user_seed to delegate_account_cpi_instruction, ensuring the CPI instruction derives the correct PDA and uses the appropriate delegation variant (DelegateCpi vs DelegateOrderBook).

test-integration/programs/schedulecommit/src/api.rs (1)

16-29: LGTM! UserSeeds enum improves type safety.

The enum-based approach is cleaner and safer than passing raw byte slices. The bytes() helper provides a single source of truth for seed values.

test-integration/programs/schedulecommit/src/lib.rs (1)

822-841: LGTM! Undelegate handler gracefully supports multiple account layouts.

The updated logic:

  • Attempts to deserialize as MainAccount first (matching the discriminant size).
  • Falls back to OrderBook for other sizes.
  • Logs deserialization failures without failing the transaction (helpful for debugging).

This flexible approach allows undelegation to work across different account types.

test-integration/programs/schedulecommit/src/order_book.rs (5)

10-20: LGTM! Compile-time assertions document alignment requirements.

The const_assert! macros (lines 19-20, 34-35) document the expected alignment and size of OrderLevel and OrderBookHeader. This helps catch unintended layout changes at compile time.

Also applies to: 28-35


55-82: LGTM! Custom deserializer safely handles alignment.

The BorshDeserialize implementation:

  • Uses rkyv::AlignedVec to ensure proper alignment before constructing the OrderBook.
  • Copies the input bytes to avoid aliasing violations (appropriate for test code).
  • Converts via the safe try_new constructor, which validates alignment and capacity.

This approach avoids undefined behavior while providing a convenient deserialization path for test code.


106-140: LGTM! Runtime validation prevents undefined behavior.

The try_new method includes critical safety checks:

  • Lines 109-120: Validates alignment of header and levels to prevent misaligned pointer dereferences.
  • Lines 126-133: Validates that header lengths don't exceed capacity, preventing out-of-bounds slice construction in bids() and asks_reversed().

These guards ensure the unsafe operations in this type are sound and will fail cleanly if given malformed data.


142-184: LGTM! Update methods correctly manage bidirectional growth.

The update_from, add_bids, and add_asks methods:

  • Check remaining capacity before growing (preventing buffer overflows).
  • Use unsafe helpers to access uninitialized slots (appropriate for zero-copy pattern).
  • Correctly implement the bidirectional growth model (bids from left, asks from right in reverse order).

The implementation is sound given the validation in try_new.


186-199: LGTM! Accessor methods are safe given validation.

The bids() and asks_reversed() methods use slice::from_raw_parts to create typed slices over the order levels. These operations are safe because:

  • try_new validates alignment.
  • try_new validates that bids_len + asks_len <= capacity.
  • The layout ensures no overlap between bids and asks regions.

The comment at line 191 correctly notes that asks_reversed() returns entries in reverse order (latest first).

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

🧹 Nitpick comments (2)
magicblock-committor-service/src/tasks/args_task.rs (2)

67-85: Consider caching the computed diff if instruction() may be called multiple times.

The diff is computed on-demand each time instruction() is called. While compute_diff is a pure computation (no I/O), it still involves iterating through the account data. If instruction() can be invoked multiple times for the same task (e.g., during serialization, logging, or retries), the diff would be recomputed unnecessarily.

Consider computing the diff once during task construction and storing it in CommitDiffTask, then referencing the cached value here. This would eliminate redundant computation while keeping the instruction builder clean.

💡 Potential optimization approach

Add a diff: Vec<u8> field to CommitDiffTask and compute it once during task creation, then reference it here:

 ArgsTaskType::CommitDiff(value) => {
     let args = CommitDiffArgs {
         nonce: value.commit_id,
         lamports: value.committed_account.account.lamports,
-        diff: compute_diff(
-            value.base_account.data(),
-            value.committed_account.account.data(),
-        )
-        .to_vec(),
+        diff: value.diff.clone(),
         allow_undelegation: value.allow_undelegation,
     };

188-188: Consider whether CommitDiff warrants a distinct TaskType variant.

Mapping CommitDiff to TaskType::Commit groups two operations with different characteristics:

  • Commit: Full state transfer, directly optimizable to BufferTask
  • CommitDiff: Differential update, downgrades to Commit before BufferTask conversion (lines 134-146)

While grouping them may simplify current logic, a distinct TaskType::CommitDiff would:

  • Make the execution model differences explicit
  • Enable separate metrics/monitoring for diff vs. full commits
  • Align type semantics with actual behavior

This aligns with your TODO comment expressing uncertainty about the correct approach. Consider confirming with reviewers whether the semantic distinction justifies a separate variant.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3406ed9 and f092b0b.

📒 Files selected for processing (1)
  • magicblock-committor-service/src/tasks/args_task.rs
🧰 Additional context used
🧠 Learnings (3)
📚 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-committor-service/src/tasks/args_task.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-committor-service/src/tasks/args_task.rs
📚 Learning: 2025-10-26T08:49:31.543Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 585
File: magicblock-committor-service/src/tasks/buffer_task.rs:111-115
Timestamp: 2025-10-26T08:49:31.543Z
Learning: In the magicblock-committor-service, compute units returned by the `compute_units()` method in task implementations (such as `BufferTask`, `ArgsTask`, etc.) represent the compute budget for a single task. Transactions can comprise multiple tasks, and the total compute budget for a transaction is computed as the sum of the compute units of all tasks included in that transaction.

Applied to files:

  • magicblock-committor-service/src/tasks/args_task.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (4)
magicblock-committor-service/src/tasks/args_task.rs (4)

1-27: LGTM!

The imports and type definitions are clean and appropriate for adding CommitDiff support. The new ArgsTaskType::CommitDiff variant extends the enum naturally.


134-146: Temporary downgrade is acceptable given planned follow-up work.

The TODO clearly documents that this downgrade from CommitDiff to CommitTask is temporary until BufferTask supports CommitDiff. This is a reasonable intermediate state, and the explicit comment ensures the technical debt is tracked.


200-212: LGTM!

reset_commit_id now correctly handles both Commit and CommitDiff variants. This addresses the previous critical issue where CommitDiff tasks would retain stale commit IDs during recycling or retries.


219-219: LGTM!

The label value "args_commit_diff" follows the existing naming pattern and enables proper metrics tracking for CommitDiff tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants