Skip to content

Conversation

@snawaz
Copy link

@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 and schedule commits for them.
    • Commit-diff flow and size-aware strategy: diff-based commits for large state changes with a threshold-based selection and optional base-account lookup.
    • Selectable user-seed modes to choose delegation/init behavior (OrderBook vs default).
    • Parallel base-account fetching to speed commit preparation.
  • Tests

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

    • Dependency updates and new workspace test deps.

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

Copy link
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/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.

@snawaz snawaz force-pushed the snawaz/commit-diff branch 2 times, most recently from ea0dc4f to 30ef2fc Compare December 23, 2025 14:07
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.

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 30ef2fc to ad52f20 Compare December 23, 2025 14:12
@snawaz snawaz force-pushed the snawaz/commit-diff branch from ad52f20 to 333f137 Compare December 23, 2025 21:45
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

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 333f137 to aad2791 Compare December 23, 2025 22:10
@magicblock-labs magicblock-labs deleted a comment from coderabbitai bot Dec 23, 2025
@snawaz snawaz force-pushed the snawaz/commit-diff branch from aad2791 to 5050443 Compare December 23, 2025 22:13
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.

@magicblock-labs magicblock-labs deleted a comment from coderabbitai bot Dec 23, 2025
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 5050443 to 252862d Compare December 23, 2025 22:23
coderabbitai[bot]

This comment was marked as spam.

@magicblock-labs magicblock-labs deleted a comment from coderabbitai bot Dec 24, 2025
@magicblock-labs magicblock-labs deleted a comment from coderabbitai bot Dec 24, 2025
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!

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.

4 participants