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

Release Notes

  • New Features

    • Added order book support with initialization, updates, and scheduled commits.
    • Implemented optimized commit strategy that selects diff-based or state-based commits based on account size.
  • Refactor

    • Extended task information fetcher with base account retrieval capability.
    • Updated commit task creation to use builder pattern for improved flexibility.

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

♻️ Duplicate comments (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (1)

55-60: Consider adding observability.

The method correctly delegates to the RPC client and propagates errors. As noted in previous reviews, adding tracing (e.g., #[tracing::instrument] or manual spans) would help diagnose fetch failures, latency, and per-account performance in production.

Example instrumentation:

+    #[tracing::instrument(skip(self), fields(pubkey = %pubkey))]
     pub async fn fetch_account(
         &self,
         pubkey: &Pubkey,
     ) -> Result<Account, solana_rpc_client_api::client_error::Error> {
+        tracing::debug!("Fetching account from RPC");
-        self.rpc_client.get_account(pubkey).await
+        let result = self.rpc_client.get_account(pubkey).await;
+        if let Err(ref e) = result {
+            tracing::warn!("Failed to fetch account: {}", e);
+        }
+        result
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3999503 and 256ab3f.

📒 Files selected for processing (1)
  • magicblock-committor-service/src/tasks/account_fetcher.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 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/account_fetcher.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/account_fetcher.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/account_fetcher.rs
🧬 Code graph analysis (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (2)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (124-155)
magicblock-committor-service/src/config.rs (2)
  • local (29-35)
  • mainnet (21-27)
⏰ 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: Build Project
  • GitHub Check: run_make_ci_test
🔇 Additional comments (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (1)

1-11: LGTM! Clean struct definition.

The imports are appropriate and the struct is simple and focused, wrapping a single RpcClient to handle account fetching responsibilities.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

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

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

159-171: Tx length calculation TODO correctly flags recomputation; future optimization only.

calculate_tx_length reassembles the full transaction on every call, which is expensive but acceptable given current usage. The TODO is appropriate—if this becomes hot, consider reusing already computed instructions/budgets or caching the encoded size instead of rebuilding the tx each time.


253-292: Async test helper and join_all usage look correct; consider decoupling from real RPC if tests get slow/flaky.

The async create_test_commit_task helper and its use across the strategy tests are idiomatic and align with the new CommitTask::new(...).await API. The only caveat is that using AccountFetcher::new() in unit tests ties them to whatever RPC endpoint is configured at runtime; if that ever becomes a source of slowness or flakiness, it would be worth introducing a test-local/mock AccountFetcher (or feature-gated dev config) so these tests remain deterministic and offline-friendly.

Also applies to: 326-383, 385-457, 459-515

♻️ Duplicate comments (2)
magicblock-committor-service/src/tasks/mod.rs (2)

110-219: CommitTask CommitDiff/CommitState selection logic looks sound; minor follow‑ups only.

The async constructor and fields (base_account, force_commit_state) correctly implement the intended behavior:

  • For accounts with data.len() > COMMIT_STATE_SIZE_THRESHOLD, you eagerly fetch base_account via AccountFetcher; on failure you log with pubkey+commit_id and fall back cleanly to CommitState.
  • is_commit_diff() is consistent with the constructor (threshold + base_account.is_some() + not forced), and create_commit_ix() switches between diff/state based solely on the presence of base_account, with force_commit_state() providing an explicit override.
  • create_commit_state_ix() and create_commit_diff_ix() build the appropriate DLP args; computing the diff from ReadableAccount::data() is correct, and the early return when force_commit_state is set avoids unnecessary diff work.

Two minor, non-blocking considerations:

  • AccountFetcher is consumed by value; if call sites later want to reuse a shared fetcher, changing this to accept &AccountFetcher or an Arc<AccountFetcher> might be preferable.
  • Long term, splitting “commit full state” vs “commit diff” into separate task types (as already discussed in review) would let you drop the Option<Account> + force_commit_state from a single struct and simplify invariants.

Overall, the implementation is coherent and matches the CommitDiff design goals.


1-5: AccountFetcher imports/module exposure are fine; glob can be scoped to tests if desired.

pub mod account_fetcher; plus use solana_account::{Account, ReadableAccount}; correctly support the new CommitTask logic. The top-level use account_fetcher::*; appears to be used only indirectly by the test module; if production code doesn’t rely on those symbols, you could either gate that glob with #[cfg(test)] or import AccountFetcher directly inside the test module to keep the main module namespace tighter.

Also applies to: 21-21, 36-37

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 256ab3f and 59b7935.

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (126-157)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (1)
  • new (20-53)
⏰ 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: Build Project
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (1)
magicblock-committor-service/src/tasks/mod.rs (1)

421-443: Serialization tests correctly follow the async CommitTask API; consider isolating RPC behavior.

The three serialization tests now:

  • Use CommitTask::new(...).await with very small payloads (3 bytes) in the first two tests, which keeps them on the CommitState path and avoids unnecessary RPC.
  • Use a 1024‑byte payload in test_preparation_instructions_serialization, which will cross COMMIT_STATE_SIZE_THRESHOLD and trigger AccountFetcher::fetch_account for each run before falling back to buffer preparation logic.

Functionally this is fine—the tests still exercise the instruction/serialization paths—but it does couple the last test to the configured RPC endpoint and can make it slower or environment‑dependent (especially since the pubkeys are random and fetches will likely fail). If that becomes an issue, consider:

  • Injecting a mock/test AccountFetcher for these tests, or
  • Using a payload size below the threshold when you only care about buffer chunking/serialization, or
  • Moving any “real RPC” coverage to an integration test that expects network access.

Also worth double‑checking that fetch_account uses a non-blocking pattern (e.g., spawn_blocking) or that these tests always run on a multi-thread runtime, to avoid accidentally blocking the executor thread.

Also applies to: 485-507, 512-535

⛔ 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

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 59b7935 to c07a177 Compare November 17, 2025 10:31
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 (2)
magicblock-committor-service/src/tasks/task_strategist.rs (1)

343-362: Use multi_thread runtime for tests that trigger blocking RPC calls.

This test creates a 1000-byte account, which exceeds COMMIT_STATE_SIZE_THRESHOLD (256 bytes). CommitTask::new().await will call fetch_account(), which performs blocking RPC operations and requires a multi-threaded Tokio runtime to avoid hanging.

Apply this diff:

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

Also applies to: Lines 364-383, 385-409, 411-436, 438-457, 459-474, 476-515

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

512-549: Use multi_thread runtime for test with 1024-byte account.

This test creates a 1024-byte account, which exceeds COMMIT_STATE_SIZE_THRESHOLD (256 bytes). CommitTask::new().await will call fetch_account() that performs blocking RPC operations, requiring a multi-threaded Tokio runtime.

The other two tests (test_args_task_instruction_serialization and test_buffer_task_instruction_serialization) use 3-byte accounts (below threshold) and correctly use the default #[tokio::test].

Apply this diff:

-    #[tokio::test]
+    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
     async fn test_preparation_instructions_serialization() {
♻️ Duplicate comments (2)
test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (2)

100-101: Same issue: duplicate hardcoded seed.

This is the second occurrence of the hardcoded b"magic_schedule_commit" seed. See the comment on lines 46-47 for the suggestion to extract this to a constant.


232-232: Same issue: third occurrence of hardcoded seed.

This is the third occurrence of the hardcoded b"magic_schedule_commit" seed in the helper function. See the comment on lines 46-47 for the suggestion to extract this to a constant.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59b7935 and c07a177.

📒 Files selected for processing (3)
  • magicblock-committor-service/src/tasks/mod.rs (7 hunks)
  • magicblock-committor-service/src/tasks/task_strategist.rs (11 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 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
📚 Learning: 2025-11-07T13:20:13.793Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/coordinator.rs:227-238
Timestamp: 2025-11-07T13:20:13.793Z
Learning: In magicblock-processor's ExecutionCoordinator (scheduler/coordinator.rs), the `account_contention` HashMap intentionally does not call `shrink_to_fit()`. Maintaining slack capacity is beneficial for performance by avoiding frequent reallocations during high transaction throughput. As long as empty entries are removed from the map (which `clear_account_contention` does), the capacity overhead is acceptable.

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
🧬 Code graph analysis (3)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (1)
  • new (20-53)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (126-157)
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). (3)
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (4)
magicblock-committor-service/src/tasks/mod.rs (4)

119-124: COMMIT_STATE_SIZE_THRESHOLD rationale is clear and well-documented.

The comment explains the threshold choice (256 bytes can hold 8 u32 or 4 u64 fields) and the trade-off between CommitDiff (lower instruction size) vs CommitState (no RPC overhead). This addresses previous review feedback requesting documentation of this constant.


126-157: Async constructor properly handles base account fetch with fallback.

The implementation correctly:

  • Fetches base account only when data exceeds threshold
  • Logs warnings on fetch failure and falls back to commit_state
  • Handles the Result properly

This addresses multiple past review concerns about RPC integration and error handling.


159-168: Commit path selection logic is correct and defensive.

The is_commit_diff() check ensures all three conditions are met (not forced, exceeds threshold, and base_account fetched successfully) before using the diff path. The force_commit_state() method provides a clean escape hatch if needed.


170-219: Instruction builders correctly implement diff/state paths.

The implementation properly:

  • Selects diff or state path based on base_account availability
  • Uses compute_diff to generate minimal changeset
  • Falls back to state if force_commit_state is set (defensive, though redundant per past reviews)
  • Passes correct arguments to delegation program instruction builders

) -> Result<usize, SignerError> {
// Get initial transaction size
let calculate_tx_length = |tasks: &[Box<dyn BaseTask>]| {
// TODO (snawaz): we seem to discard lots of heavy computations here
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

TODO is valid but consider filing a tracking issue.

The TODO correctly identifies that calculate_tx_length builds and discards full transactions multiple times during optimization. This is a legitimate performance concern, but it's a pre-existing issue you're now documenting rather than introducing. Consider filing a GitHub issue to track this optimization opportunity so it doesn't get lost.

🤖 Prompt for AI Agents
magicblock-committor-service/src/tasks/task_strategist.rs around line 160: the
TODO noting that calculate_tx_length builds and discards full transactions
during optimization should be tracked externally; create a GitHub issue
describing the performance problem, expected impact, and possible remediation
approaches, then update the TODO comment to reference the new issue number
(e.g., "TODO (snawaz): see GH-<issue-number> — avoid rebuilding full txs in
calculate_tx_length") and include labels/assignee as appropriate so the
optimization isn’t lost.

Comment on lines +46 to +47
let ctx =
get_context_with_delegated_committees(1, b"magic_schedule_commit");
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Extract the hardcoded seed to a test constant.

The seed value b"magic_schedule_commit" is duplicated across multiple test functions (lines 47, 101, 232). Consider extracting it to a module-level constant for maintainability.

Apply this diff to define and use a constant:

+const TEST_USER_SEED: &[u8] = b"magic_schedule_commit";
+
 #[test]
 fn test_committing_one_account() {
     run_test!({
         let ctx =
-            get_context_with_delegated_committees(1, b"magic_schedule_commit");
+            get_context_with_delegated_committees(1, TEST_USER_SEED);

Then update the other two occurrences on lines 101 and 232 similarly.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In test-integration/schedulecommit/test-scenarios/tests/01_commits.rs around
lines 46-47, 101, and 232, the byte string seed b"magic_schedule_commit" is
duplicated; extract it to a module-level constant (e.g., const
MAGIC_SCHEDULE_COMMIT_SEED: &[u8] = b"magic_schedule_commit";) placed near the
top of the file, then replace the three hardcoded occurrences with the constant
name so all tests use the shared constant.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

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

63-71: involved_accounts TODO is valid—recomputing full instructions is expensive

The TODO accurately notes that involved_accounts currently rebuilds the full instruction (including diff computation for large commit tasks) just to collect pubkeys. That’s acceptable for now but potentially costly as CommitDiff usage grows. A future helper that extracts account metas without constructing args/diffs would be a worthwhile optimization.


110-117: CommitTask structure and threshold rationale are reasonable

Adding base_account: Option<Account> and force_commit_state to CommitTask, along with COMMIT_STATE_SIZE_THRESHOLD = 256 and its explanatory comment, gives a clear mechanism to decide between CommitDiff and CommitState. The threshold documentation (8×u32 or 4×u64) is helpful; if you later tune this constant empirically, the comment already sets the expectation that it’s about payload size trade-offs.

Also applies to: 119-125


412-423: Fix tests: AccountFetcher::new() has been removed—construct via AccountFetcher::with_client() with a test MagicblockRpcClient

In the serialization tests and other test locations, CommitTask::new() is called with AccountFetcher::new(), but AccountFetcher::new() no longer exists. The AccountFetcher struct now requires construction via with_client(rpc_client: MagicblockRpcClient).

Affected locations:

  • magicblock-committor-service/src/tasks/mod.rs: lines 445, 509, 537 (in serialization_safety_test)
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs: lines 44, 103, 115, 207
  • test-integration/test-committor-service/tests/common.rs: line 165
  • magicblock-committor-service/src/tasks/task_strategist.rs: line 288

Update all these calls to construct an AccountFetcher via with_client(). For unit tests, construct a test MagicblockRpcClient using the pattern from test-integration/test-committor-service/tests/common.rs (lines 34–40), or create a shared helper to avoid duplication. For example:

let rpc_client = RpcClient::new_with_commitment(
    "http://localhost:7799".to_string(),
    CommitmentConfig::confirmed()
);
let account_fetcher = AccountFetcher::with_client(MagicblockRpcClient::new(Arc::new(rpc_client)));

Apply the same pattern consistently across all affected test files.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c07a177 and 9da0edd.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3 hunks)
  • magicblock-committor-service/src/tasks/account_fetcher.rs (1 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (7 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (6 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 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/account_fetcher.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-07T14:20:31.457Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: magicblock-chainlink/src/remote_account_provider/chain_pubsub_actor.rs:457-495
Timestamp: 2025-11-07T14:20:31.457Z
Learning: In magicblock-chainlink/src/remote_account_provider/chain_pubsub_client.rs, the unsubscribe closure returned by PubSubConnection::account_subscribe(...) resolves to () (unit), not a Result. Downstream code should not attempt to inspect an unsubscribe result and can optionally wrap it in a timeout to guard against hangs.

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/account_fetcher.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/account_fetcher.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (3)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (2)
  • join_all (467-476)
  • new (49-59)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (126-162)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
magicblock-committor-service/src/tasks/account_fetcher.rs (1)
  • with_client (54-56)
magicblock-committor-service/src/tasks/mod.rs (2)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (36-41)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
🪛 GitHub Actions: Run CI - Lint
magicblock-committor-service/src/tasks/account_fetcher.rs

[error] Build failed: 6 previous errors prevented compilation (lint step).

magicblock-committor-service/src/tasks/task_builder.rs

[error] Build failed: 6 previous errors prevented compilation (lint step).

magicblock-committor-service/src/intent_executor/task_info_fetcher.rs

[error] Build failed: 6 previous errors prevented compilation (lint step).

magicblock-committor-service/src/tasks/mod.rs

[error] 445-445: AccountFetcher::new() not found. Use AccountFetcher::with_client(...) or implement a new constructor.


[error] 509-509: AccountFetcher::new() not found. Use AccountFetcher::with_client(...) or implement a new constructor.


[error] Build failed: 6 previous errors prevented compilation (lint step).

⏰ 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 (7)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)

14-15: Centralizing AccountFetcher creation via TaskInfoFetcher is a good direction

Wiring new_account_fetcher into TaskInfoFetcher and implementing it in CacheTaskInfoFetcher by cloning the shared MagicblockRpcClient keeps RPC config and client lifecycle out of task code, while still allowing per-task fetchers. This aligns with earlier concerns about constructing clients per account and is a solid intermediate step until all chain reads are fully moved into the fetcher.

Also applies to: 41-42, 270-272

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

47-50: Parallel CommitTask construction with TaskInfoFetcher wiring looks correct

Using task_info_fetcher.fetch_next_commit_ids followed by join_all to asynchronously construct CommitTask::new(..., task_info_fetcher.new_account_fetcher()).await per account is a reasonable way to parallelize commit task creation while keeping RPC configuration centralized behind the fetcher. Aside from the persister bug above, the commit path wiring itself is coherent.

Also applies to: 71-79, 89-103


108-110: Finalize path rename to task_info_fetcher maintains consistency

Renaming the finalize API parameter to task_info_fetcher and using it to drive fetch_rent_reimbursements keeps both commit and finalize flows on the same abstraction. The rest of the finalize logic is unchanged and remains straightforward.

Also applies to: 165-175

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

1-5: Publicly exposing account_fetcher and CommitDiff args integration is consistent

Re-exporting account_fetcher at the module level and importing CommitDiffArgs/CommitStateArgs plus compute_diff keeps the commit-task module self-contained and ready to build either state or diff instructions. This matches the new CommitDiff flow described in the PR objectives.

Also applies to: 36-37


126-162: Async CommitTask::new correctly gates base-account fetch and logs fallbacks

The async constructor:

  • Only attempts a base-chain fetch when committed_account.account.data.len() > COMMIT_STATE_SIZE_THRESHOLD.
  • Uses account_fetcher.fetch_account and distinguishes between Ok(Some), Ok(None), and Err(e).
  • Logs clear warnings on not-found and RPC failure, then falls back to full CommitState.

This is a robust pattern that prevents CommitDiff from silently failing to engage without operator visibility, while still ensuring commits proceed via the state path.


183-196: CommitState/CommitDiff instruction builders are well-structured

Both create_commit_state_ix and create_commit_diff_ix build their respective args (including lamports, cloned data or diff, and allow_undelegation) and delegate to the appropriate dlp::instruction_builder functions. Using ReadableAccount::data() for the base account and computing the diff against committed_account.account.data() is consistent with the CommitDiff semantics.

Please double-check against the DLP compute_diff and commit_diff/commit_state APIs to ensure the argument ordering and data slices match the program’s expectations.

Also applies to: 198-224


516-539: Consider whether test_preparation_instructions_serialization should trigger base-account fetch

This test uses data: vec![0; 1024], which is above COMMIT_STATE_SIZE_THRESHOLD (256), so CommitTask::new will attempt to fetch the base account via AccountFetcher. If your MagicblockRpcClient performs blocking I/O under the hood, this may require a multi-threaded Tokio runtime (or a stubbed client) to avoid hangs in unit tests. Alternatively, if you want this test to remain purely local/serialization-only, you could lower the test data size below the threshold so no RPC is attempted.

Comment on lines 8 to 10
pub struct AccountFetcher {
rpc_client: MagicblockRpcClient,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

AccountFetcher injection-based design looks good; consider dropping dead constructor scaffolding

AccountFetcher now cleanly wraps an injected MagicblockRpcClient via with_client and fetch_account simply delegates to get_account, which aligns with earlier feedback about avoiding per-account RpcClient construction. The large commented-out new()/Default scaffolding no longer reflects how this type is used; consider removing it to reduce confusion and keep the module focused.

Also applies to: 54-63

🤖 Prompt for AI Agents
magicblock-committor-service/src/tasks/account_fetcher.rs lines 8-10 (and also
remove dead scaffolding at lines 54-63): the AccountFetcher struct now uses
dependency injection via with_client and the old commented-out/new()/Default
constructor scaffolding is dead code and misleading; delete the commented-out
new()/Default implementations and any unused constructor scaffolding (including
the block at lines 54-63) so the file only contains the injected constructor and
fetch_account delegation, and run cargo fmt/check to ensure no leftover imports
or warnings remain.

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 9da0edd to cf6229d Compare November 17, 2025 13:36
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (3)
magicblock-committor-service/src/tasks/task_strategist.rs (2)

253-292: Async helper wiring for create_test_commit_task looks correct.

Using an async helper with CommitTask::new(..., &Arc::new(NullTaskInfoFetcher)).await keeps the tests aligned with the new constructor while intentionally avoiding real base‑account RPC. If you ever need many tasks in a single test, you could hoist let fetcher = Arc::new(NullTaskInfoFetcher); and pass &fetcher to avoid constructing multiple Arcs, but that’s a micro‑optimization for tests.


459-474: test_optimize_strategy_prioritizes_largest_tasks is potentially brittle.

Here both “larger” tasks are created with the same data_size (1000), but the test assumes tasks[1] is the one optimized to TaskStrategy::Buffer. The optimizer pulls from a heap keyed by size and index, so with equal sizes it may legitimately pick the last task (index 2) first, which could break this assertion depending on thresholds.

Consider either:

  • Making the “largest” task strictly larger, or
  • Relaxing the assertion to check that the small task stays Args and at least one of the two large tasks becomes Buffer.

For example:

-            Box::new(create_test_commit_task(2, 1000).await)
+            Box::new(create_test_commit_task(2, 2000).await)

This guarantees that tasks[1] is unambiguously the largest and should be optimized first.

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

162-181: create_commit_task helper disables commit‑diff via NullTaskInfoFetcher.

The async helper now uses a static AtomicU64 for unique commit IDs and CommitTask::new(..., &Arc::new(NullTaskInfoFetcher)).await, which is a sensible default for tests that only care about commit‑state behavior and not diffs. If you later want this helper to be usable in commit‑diff scenarios, consider parameterizing it over a &Arc<impl TaskInfoFetcher> instead of hard‑wiring NullTaskInfoFetcher.

♻️ Duplicate comments (2)
magicblock-committor-service/src/tasks/task_builder.rs (1)

75-88: Fix persister call: &Option<P> doesn’t have set_commit_id.

persister is &Option<P>, but the code calls persister.set_commit_id(...) directly, which won’t compile and also ignores the None case conceptually.

Guard the call with an if let Some(persister):

-        // Persist commit ids for commitees
-        commit_ids
-            .iter()
-            .for_each(|(pubkey, commit_id) | {
-                if let Err(err) = persister.set_commit_id(base_intent.id, pubkey, *commit_id) {
-                    error!("Failed to persist commit id: {}, for message id: {} with pubkey {}: {}", commit_id, base_intent.id, pubkey, err);
-                }
-            });
+        // Persist commit ids for commitees (if a persister is configured)
+        if let Some(persister) = persister {
+            commit_ids.iter().for_each(|(pubkey, commit_id)| {
+                if let Err(err) =
+                    persister.set_commit_id(base_intent.id, pubkey, *commit_id)
+                {
+                    error!(
+                        "Failed to persist commit id: {}, for message id: {} with pubkey {}: {}",
+                        commit_id, base_intent.id, pubkey, err
+                    );
+                }
+            });
+        }
magicblock-committor-service/src/tasks/mod.rs (1)

112-171: CommitTask diff/state selection looks correct; consider decoupling the fetcher and diff-specific state

The core behavior here looks good:

  • CommitTask::new gates base-account fetch behind COMMIT_STATE_SIZE_THRESHOLD and cleanly falls back to CommitState with warnings on Ok(None) and Err(_).
  • force_commit_state and is_commit_diff behave coherently with the constructor invariants, and create_commit_ix delegates to the appropriate builder.

Two non-blocking improvements to consider:

  • The signature pub async fn new<C: TaskInfoFetcher>(..., task_info_fetcher: &Arc<C>) unnecessarily couples the API to Arc, forcing tests to pass &Arc::new(NullTaskInfoFetcher). A more flexible shape like

    pub async fn new<F>(..., fetcher: &F) -> Self
    where
        F: TaskInfoFetcher + ?Sized,

    would let callers use either a plain fetcher or an Arc<F> without changing this type.

  • CommitTask now represents both full-state and diff commits via base_account: Option<Account> and force_commit_state: bool. Long term, splitting this into explicit variants (e.g. a separate CommitDiffTask or a task enum) would eliminate the Option<Account>/flag coupling and align with earlier suggestions to distinguish “commit full state” vs “commit diff” at the type level.

Also applies to: 177-226

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9da0edd and cf6229d.

📒 Files selected for processing (6)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_strategist.rs (11 hunks)
  • test-integration/test-committor-service/tests/common.rs (6 hunks)
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs (3 hunks)
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • test-integration/test-committor-service/tests/common.rs
🧬 Code graph analysis (6)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (128-164)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_task_info_fetcher (117-119)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/tasks/task_strategist.rs (2)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (128-164)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • new (108-120)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
test-integration/test-committor-service/tests/common.rs (5)
  • get_base_account (146-151)
  • fetch_next_commit_ids (126-131)
  • fetch_rent_reimbursements (133-138)
  • peek_commit_id (140-142)
  • reset (144-144)
magicblock-committor-service/src/intent_executor/mod.rs (4)
  • fetch_next_commit_ids (799-804)
  • fetch_rent_reimbursements (806-811)
  • peek_commit_id (813-815)
  • reset (817-817)
magicblock-committor-service/src/tasks/task_builder.rs (3)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (2)
  • join_all (467-476)
  • new (49-59)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (128-164)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • new (108-120)
magicblock-committor-service/src/tasks/mod.rs (3)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • instruction (45-85)
  • new (36-41)
magicblock-committor-service/src/tasks/buffer_task.rs (3)
  • instruction (65-86)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
  • new (61-69)
test-integration/test-committor-service/tests/common.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
  • new (61-69)
  • get_base_account (42-47)
  • get_base_account (276-281)
  • get_base_account (322-327)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (128-164)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • new (108-120)
⏰ 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 (11)
magicblock-committor-service/src/tasks/task_strategist.rs (3)

159-171: TODO on calculate_tx_length is fine and non‑behavioral.

The added TODO correctly notes the repeated transaction construction cost but doesn’t alter behavior; the closure remains side‑effect‑free and safe to call within the optimization loop.


326-457: New async strategy tests exercise buffer/ALT paths well.

The updated async tests (test_build_strategy_with_single_small_task, buffer optimization, multi‑buffer, ALT usage, and failure when overfitting) are consistent with the strategy behavior and correctly drive TaskStrategist::build_strategy via ArgsTask/CommitTask plus join_all. No issues spotted in the async usage or assertions.


476-515: Mixed task‑type optimization test is well‑structured.

test_mixed_task_types_with_optimization gives a good end‑to‑end check: one large commit task plus finalize/base/undelegate, asserting that only the commit is buffered, others stay Args, and ALTs are engaged. The expectations align with the intended strategy semantics.

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

11-15: New get_base_account hook on TaskInfoFetcher is well‑designed.

Adding async fn get_base_account(...) -> MagicBlockRpcClientResult<Option<Account>> with a default Ok(None) cleanly extends the trait for commit‑diff support without breaking existing implementors. This keeps the “no base account available” case explicit and cheap.

Also applies to: 41-47


275-281: CacheTaskInfoFetcher::get_base_account correctly delegates to RPC.

The implementation simply forwards to self.rpc_client.get_account(pubkey).await, letting MagicBlockRpcClientError flow through the existing TaskInfoFetcherError::MagicBlockRpcClientError path. Given commit‑diff is an optimization, a single RPC attempt with upstream logging/fallback is reasonable here.


296-328: NullTaskInfoFetcher is appropriate for tests/dev utilities.

For test/dev contexts, returning deterministic zeros and Ok(None) from get_base_account keeps behavior predictable and avoids external RPC dependencies, while still satisfying the TaskInfoFetcher contract.

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

23-37: Task builder trait signature updates are consistent with the new fetcher model.

Switching both commit_tasks and finalize_tasks to accept task_info_fetcher: &Arc<C> matches the updated CommitTask::new API and centralizes all account/nonce lookups through TaskInfoFetcher. The generics remain straightforward and keep the builder decoupled from a concrete fetcher implementation.

Also applies to: 47-50


89-101: Parallel commit task construction via join_all is a good improvement.

Building all commit tasks with join_all over the committed accounts and a shared task_info_fetcher avoids repeated fetcher instantiation and keeps per‑account async work nicely parallelized. The closure correctly pulls commit_id from the pre‑fetched map and awaits CommitTask::new(...) before boxing the task.


171-175: Finalize path correctly reuses task_info_fetcher for rent reimbursements.

Using task_info_fetcher.fetch_rent_reimbursements(&pubkeys).await in the CommitAndUndelegate branch keeps rent‑payer resolution consistent with the commit side and centralizes the logic in TaskInfoFetcher.

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

9-18: Fixture now cleanly injects a task‑info fetcher into the intent executor.

TestFixture::create_intent_executor delegating to self.create_task_info_fetcher() (returning Arc<MockTaskInfoFetcher>) aligns the integration tests with the production pattern of passing an Arc into IntentExecutorImpl::new. This keeps tests exercising the same abstraction boundary.

Also applies to: 102-119


122-152: MockTaskInfoFetcher implementation matches the TaskInfoFetcher contract.

Wrapping MagicblockRpcClient and implementing fetch_next_commit_ids, fetch_rent_reimbursements, peek_commit_id, reset, and get_base_account provides a realistic but deterministic fetcher for tests. Delegating get_base_account to self.0.get_account(pubkey).await ensures commit‑diff logic can be exercised in integration tests without special hooks.

Comment on lines 37 to 47
let tasks = vec![
Box::new(ArgsTask::new(ArgsTaskType::Commit(CommitTask {
commit_id: 1,
committed_account: committed_account.clone(),
allow_undelegation: true,
}))) as Box<dyn BaseTask>,
Box::new(ArgsTask::new(ArgsTaskType::Commit(
CommitTask::new(
1,
true,
committed_account.clone(),
&fixture.create_task_info_fetcher(),
)
.await,
))) as Box<dyn BaseTask>,
Box::new(ArgsTask::new(ArgsTaskType::Finalize(FinalizeTask {
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Async CommitTask::new wiring in tests looks good.

All three tests correctly await CommitTask::new(..., &fixture.create_task_info_fetcher()) before wrapping in ArgsTask/BufferTask, so they exercise the new constructor and task‑info fetcher path end‑to‑end. If you want to trim a bit of duplication, you could bind a single let task_info_fetcher = fixture.create_task_info_fetcher(); per test and pass &task_info_fetcher into each CommitTask::new call instead of recreating it.

Also applies to: 96-105, 109-117, 200-209

🤖 Prompt for AI Agents
In test-integration/test-committor-service/tests/test_transaction_preparator.rs
around lines 37 to 47 (also apply similar change at 96-105, 109-117, 200-209):
tests repeatedly call fixture.create_task_info_fetcher() inline for each
CommitTask::new; bind let task_info_fetcher =
fixture.create_task_info_fetcher(); once at the start of the test and pass
&task_info_fetcher into each CommitTask::new invocation to remove duplication
while preserving the awaited constructor usage.

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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf6229d and 9e8da2d.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (3 hunks)
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs (6 hunks)
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs (9 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

  • test-integration/test-committor-service/tests/test_delivery_preparator.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/test_ix_commit_local.rs
  • magicblock-committor-service/src/tasks/args_task.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:

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

Applied to files:

  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
🧬 Code graph analysis (4)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (163-181)
  • new (53-56)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
magicblock-validator/src/main.rs (1)
  • init_logger (13-50)
magicblock-committor-service/src/tasks/args_task.rs (2)
magicblock-committor-service/src/tasks/mod.rs (1)
  • new (128-164)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
test-integration/test-committor-service/tests/common.rs (5)
  • get_base_account (146-151)
  • fetch_next_commit_ids (126-131)
  • fetch_rent_reimbursements (133-138)
  • peek_commit_id (140-142)
  • reset (144-144)
⏰ 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: Build Project
  • GitHub Check: run_make_ci_test
🔇 Additional comments (7)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (2)

2-2: Parallel commit-task construction via join_all looks correct.

Importing join_all and using it over datas.iter().map(|data| async { ... }) to build BufferTask/ArgsTask instances concurrently is sound, and join_all preserves input order so the later datas[i] assertions stay valid.

Also applies to: 90-96, 167-172


25-25: Good reuse of create_commit_task helper in tests.

Switching these tests to the shared create_commit_task(&data).await helper keeps commit-id generation and CommitTask construction consistent across test cases and avoids duplication; the added mut bindings for tasks that are later mutated are appropriate.

Also applies to: 212-212, 301-303

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

65-68: Single-account 100-byte path now correctly asserts Args strategy.

Expecting CommitStrategy::Args for a 100-byte single-account commit aligns with the new preference for arg-based commits on small accounts and avoids unnecessary buffer usage.


151-152: Large-commit TODO documentation is clear and non-invasive.

The extended TODOs describing 1 MB/10 MB and “max Solana account size” scenarios are well scoped and informative; leaving them in this test file as forward-looking notes is reasonable for now.

Also applies to: 465-486

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

1-1: Instruction path now correctly delegates to CommitTask::create_commit_ix.

Routing ArgsTaskType::Commit through value.create_commit_ix(validator) and using CallHandlerArgs for base actions centralizes commit/commit-diff encoding in CommitTask and keeps instruction() free of RPC/side effects, which is a cleaner separation of concerns.

Also applies to: 44-85


87-102: CommitDiff-aware optimize behavior is a reasonable interim downgrade strategy.

The value.is_commit_diff() guard plus value.force_commit_state() before wrapping in BufferTask::new_preparation_required(BufferTaskType::Commit(value)) ensures that BufferTask only handles full commit-state payloads, while diff-capable tasks can still run via Args when optimize() is not invoked. This avoids panics and respects current BufferTask limitations; the TODO comment clearly marks the technical debt.

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

11-15: New get_base_account plumbing and NullTaskInfoFetcher look sound.

Extending TaskInfoFetcher with get_base_account (defaulting to Ok(None)), wiring CacheTaskInfoFetcher through rpc_client.get_account, and introducing NullTaskInfoFetcher for tests/dev contexts gives CommitTask a clean, injectable way to obtain base accounts for diff computation while preserving backward compatibility for existing fetchers. The error typing via MagicBlockRpcClientResult is consistent with the RPC client, and returning Ok(None) gracefully triggers the CommitState fallback.

Also applies to: 42-47, 276-281, 296-328

Comment on lines 42 to 47
async fn get_base_account(
&self,
_pubkey: &Pubkey,
) -> MagicBlockRpcClientResult<Option<Account>> {
Ok(None) // AccountNotFound
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider batched base-account fetching for high-volume CommitDiff usage.

get_base_account currently issues one get_account RPC per pubkey via CacheTaskInfoFetcher, which is fine initially but may become a bottleneck when many large delegated accounts are committed in one run. Longer term, you might want a batched variant (e.g., get_base_accounts(&[Pubkey]) backed by get_multiple_accounts) to reduce round-trips and better align with the existing metadata-fetch retry logic.

Also applies to: 276-281

@snawaz
Copy link
Author

snawaz commented Nov 18, 2025

@taco-paco :

I made the following changes:

  • Removed account_fetcher.rs completely.
  • Used TaskInfoFetcher. Now it has get_account() as well.
    • Added NullTaskInfoFetcher for some of the tests.
  • Removed some of TODO (snawaz) and some cleanup.

The decision to make what variant of commit it is, is still with the CommitTask (specifically new() optimize(), etc).

I'm not resolving Rabbit's feedbacks yet — they're mostly minor and I'll see them in next week.

The last 3 commits are the latest ones with these commit messages (commit-ids might change):

  • Use TaskInfoFetcher
  • Review and cleanup
  • Delete some TODO (snawaz)]

Copy link
Contributor

@taco-paco taco-paco left a comment

Choose a reason for hiding this comment

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

Looks much better, bet there still some things we shall improve, especially testing for Diff.

Comment on lines 42 to 47
async fn get_base_account(
&self,
_pubkey: &Pubkey,
) -> MagicBlockRpcClientResult<Option<Account>> {
Ok(None) // AccountNotFound
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it needed for tests?

Suggested change
async fn get_base_account(
&self,
_pubkey: &Pubkey,
) -> MagicBlockRpcClientResult<Option<Account>> {
Ok(None) // AccountNotFound
}
async fn get_base_account(
&self,
_pubkey: &Pubkey,
) -> MagicBlockRpcClientResult<Option<Account>>;

Let's let implementors define default behaviour.

Comment on lines 296 to 328
#[cfg(any(test, feature = "dev-context-only-utils"))]
pub struct NullTaskInfoFetcher;

#[cfg(any(test, feature = "dev-context-only-utils"))]
#[async_trait]
impl TaskInfoFetcher for NullTaskInfoFetcher {
async fn fetch_next_commit_ids(
&self,
_pubkeys: &[Pubkey],
) -> TaskInfoFetcherResult<HashMap<Pubkey, u64>> {
Ok(Default::default())
}

async fn fetch_rent_reimbursements(
&self,
_pubkeys: &[Pubkey],
) -> TaskInfoFetcherResult<Vec<Pubkey>> {
Ok(Default::default())
}

fn peek_commit_id(&self, _pubkey: &Pubkey) -> Option<u64> {
None
}

fn reset(&self, _: ResetType) {}

async fn get_base_account(
&self,
_pubkey: &Pubkey,
) -> MagicBlockRpcClientResult<Option<Account>> {
Ok(None) // AccountNotFound
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this in separate tests.rs file or somehing like mock.rs

let base_account = if committed_account.account.data.len()
> CommitTask::COMMIT_STATE_SIZE_THRESHOLD
{
match task_info_fetcher
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we fetch this outside?
We can supply base_account as an argument instead.

  1. We would remove async from constructor
  2. We wouldn't need TaskInfoFetcher at all in CommitTask
  3. Task could still decide for itself if it needs to upgrade or not as was your idea

Copy link
Author

Choose a reason for hiding this comment

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

No. We should not do that. base_account is conditionally fetched by CommitTask.

Copy link
Author

Choose a reason for hiding this comment

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

I used CommitTaskBuilder which fetches the base account and then creates the task.

}

pub fn create_commit_ix(&self, validator: &Pubkey) -> Instruction {
if let Some(fetched_account) = self.base_account.as_ref() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we check is_commit_diff here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes. That can be used as well, but we still need to unwrap base_account here. So I kept it simple here.

(logs, sig)
};

println!("Ephem Logs level-1: {:#?}", ephem_logs_l1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like specific to a particular test.
This shall be removed

committed_account: account.clone(),
});
account.clone(),
task_info_fetcher,
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we could supply base_account directly

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need for constructor to be async

Copy link
Author

Choose a reason for hiding this comment

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

I explained in the previous comment why I passed task_info_fetcher instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

We missing tests for Diff here. Right now NullTaskInfoFetcher::get_base_account always returns Ok(None).
So we only test direct commit.

We shall have various test that ensure that resulting task is Diff as expected or is Direct commit as expected kind of like here

        assert!(matches!(
            strategy.optimized_tasks[0].strategy(),
            TaskStrategy::Buffer
        ));

}

pub fn is_commit_diff(&self) -> bool {
!self.force_commit_state
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems rather complicated, comparing to the case if we would have separate type for Diff.

We would just need to check the type.

match commit_task_type {
     CommitTaskType::CommitDirect => false,
    CommitTaskType::CommitDiff => true
}

Copy link
Author

Choose a reason for hiding this comment

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

Your suggestion merely replaced boolean with enum. The value of enum (i.e commit_task_type) still needs to be computed. Its not decided by the caller, but the task itself.

@snawaz snawaz requested a review from taco-paco November 18, 2025 13:35
@magicblock-labs magicblock-labs deleted a comment from coderabbitai bot Nov 18, 2025
Comment on lines 146 to 148
CommitType::StandaloneDiff(accounts) => {
accounts.iter().map(finalize_task).collect()
}
Copy link
Author

Choose a reason for hiding this comment

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

Not going to modify the working old branch in this PR. Note that I'm a new developer and I do not want to be too clever in my first PR.

let base_account = if committed_account.account.data.len()
> CommitTask::COMMIT_STATE_SIZE_THRESHOLD
{
match task_info_fetcher
Copy link
Author

Choose a reason for hiding this comment

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

No. We should not do that. base_account is conditionally fetched by CommitTask.

}

pub fn is_commit_diff(&self) -> bool {
!self.force_commit_state
Copy link
Author

Choose a reason for hiding this comment

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

Your suggestion merely replaced boolean with enum. The value of enum (i.e commit_task_type) still needs to be computed. Its not decided by the caller, but the task itself.

}

pub fn create_commit_ix(&self, validator: &Pubkey) -> Instruction {
if let Some(fetched_account) = self.base_account.as_ref() {
Copy link
Author

Choose a reason for hiding this comment

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

Yes. That can be used as well, but we still need to unwrap base_account here. So I kept it simple here.

committed_account: account.clone(),
});
account.clone(),
task_info_fetcher,
Copy link
Author

Choose a reason for hiding this comment

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

I explained in the previous comment why I passed task_info_fetcher instead.

@snawaz snawaz force-pushed the snawaz/commit-diff branch from 9e8da2d to 34d41c2 Compare November 21, 2025 18:44
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

📝 Walkthrough

Walkthrough

This PR extends the committor service with adaptive commit strategy selection based on account data availability. It introduces a get_base_account method to the TaskInfoFetcher trait, enabling retrieval of base accounts for diff-based commits. A new asynchronous CommitTaskBuilder constructor determines whether to use commit_diff or commit_state strategies based on account size and data presence. The PR also adds comprehensive order book support to the test integration's ScheduleCommit program, including instruction handlers, zero-copy data structures, and account lifecycle management. Test utilities are updated throughout to support async task construction and parameterizable user seeds for flexible PDA derivation.

Possibly related PRs

Suggested reviewers

  • thlorenz
  • taco-paco
  • GabrielePicco

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 48.36% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature: adding support for CommitDiff optimization to efficiently handle small changes in large delegated accounts.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

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

⚠️ Outside diff range comments (2)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)

65-345: Updated CommitStrategy expectations look coherent with Args/CommitDiff-first planner.

The shifts from FromBuffer to Args (and mixed Args/FromBufferWithLookupTable in bundle tests) are internally consistent and match the documented behavior where small deltas on reasonably sized accounts stay in-args and larger/more crowded bundles still use buffers + ALTs.

If you expect commit-planner thresholds to keep evolving, consider, in a later PR, relaxing some of these exact-count assertions (e.g., asserting minimum Args usage or upper bounds on buffer commits) to avoid brittleness.

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

3-13: Import for CommitTaskBuilder is missing (compile error)

This file uses CommitTaskBuilder::create_commit_task(...) but never imports CommitTaskBuilder from magicblock_committor_service::tasks, so it won’t compile.

Add CommitTaskBuilder to the tasks import list:

 use magicblock_committor_service::{
     persist::IntentPersisterImpl,
     tasks::{
         args_task::{ArgsTask, ArgsTaskType},
         buffer_task::{BufferTask, BufferTaskType},
         task_strategist::{TaskStrategist, TransactionStrategy},
         utils::TransactionUtils,
-        BaseActionTask, BaseTask, CommitTask, FinalizeTask, PreparationState,
+        BaseActionTask, BaseTask, CommitTask, CommitTaskBuilder,
+        FinalizeTask, PreparationState,
         UndelegateTask,
     },

After that, all the new CommitTaskBuilder::create_commit_task(...) usages in this test should compile as intended.

If you want to reduce churn in tests, you can also bind let task_info_fetcher = fixture.create_task_info_fetcher(); once per test and pass &task_info_fetcher into each builder call instead of recreating it each time.

Also applies to: 38-46, 96-105, 109-117, 200-209

♻️ Duplicate comments (8)
test-integration/test-tools/src/scheduled_commits.rs (1)

182-196: Reduce or remove unconditional ephem-log println! debug output

These two println! calls:

println!("Ephem Logs level-1: {:#?}", ephem_logs_l1);
println!("Ephem Logs level-2: {:#?}", ephem_logs_l2);

will dump entire log vectors on every successful run of fetch_schedule_commit_result, making all integration tests very noisy and harder to scan, especially when accounts/logs are large. The error-context messages around the fetches already include the logs when something goes wrong, so keeping these unconditional prints provides limited extra value.

Given the prior review note (“This shall be removed”) about similar debug prints here, I’d recommend:

  • Either removing these two println!s before merging, or
  • Gating them behind an explicit debug toggle (e.g., an env var like MAGICBLOCK_DEBUG_LOGS or a bool argument) so they only run when you’re actively debugging.

Minor nit (optional): consider renaming scheduled_commmit_sent_sigscheduled_commit_sent_sig to avoid the double mm typo and improve readability.

Also applies to: 198-211, 213-213

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

41-47: Remove unnecessary trait bounds on T in assert_one_committee_was_committed.

The function body never inspects or compares values of type T; it only looks at the ScheduledCommitResult’s structural fields. The bounds

  • std::fmt::Debug
  • borsh::BorshDeserialize
  • PartialEq + Eq

are therefore unused and can be dropped to make this helper usable with any T carried in ScheduledCommitResult.

-pub fn assert_one_committee_was_committed<T>(
+pub fn assert_one_committee_was_committed<T>(
     ctx: &ScheduleCommitTestContext,
-    res: &ScheduledCommitResult<T>,
-    is_single_stage: bool,
-) where
-    T: std::fmt::Debug + borsh::BorshDeserialize + PartialEq + Eq,
-{
+    res: &ScheduledCommitResult<T>,
+    is_single_stage: bool,
+) {
test-integration/programs/schedulecommit/src/order_book.rs (1)

127-130: Capacity exhaustion in update_from still silently no-ops.

update_from ignores the Option returned by add_bids/add_asks, so if an update doesn’t fit, it is silently dropped instead of panicking or surfacing an error. For a test helper, this makes it harder to detect when the book’s configured capacity is too small for a scenario.

If you want capacity issues to be loud (as previously discussed), consider tightening this to panic:

     pub fn update_from(&mut self, updates: BookUpdate) {
-        self.add_bids(&updates.bids);
-        self.add_asks(&updates.asks);
+        self.add_bids(&updates.bids)
+            .expect("order_book capacity exhausted while adding bids");
+        self.add_asks(&updates.asks)
+            .expect("order_book capacity exhausted while adding asks");
     }

This keeps the semantics simple for tests: either the full update applies or the test fails immediately.

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

2-23: Duplication for OrderBook-owned variant is acceptable given prior discussion.

The new fetch_and_verify_order_book_commit_result_from_logs mirrors fetch_and_verify_commit_result_from_logs but for OrderBookOwned. Since you've already decided not to genericize this helper in earlier review, the current duplication is fine and keeps call sites simple.

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

159-171: TODO about repeated assemble_tasks_tx work is valid; fine to leave as tracked debt.

The comment at Line 160 correctly notes that calculate_tx_length rebuilds and encodes full transactions multiple times during optimization. That’s real performance debt, but it’s pre-existing behavior you’re just documenting. Keeping the TODO here is fine for now; just ensure it’s tracked in an issue so it doesn’t get lost.


271-294: Strategist tests exercise buffer/ALT paths but not CommitDiff behavior.

The new async helper create_test_commit_task uses NullTaskInfoFetcher, so base_account is always None and these tests only cover CommitState→Buffer/ALT behavior. As taco-paco noted, you’ll eventually want strategist-level tests where TaskInfoFetcher returns a base account so you can assert:

  • When a diff-eligible task stays on the Args path, and
  • How it behaves once buffer optimization kicks in.

Not required for this PR, but worth adding once CommitDiff semantics settle.

Also applies to: 328-439

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

36-75: Order-book grow/update helpers still bypass book_manager authorization.

init_order_book_instruction requires book_manager as a signer (AccountMeta::new_readonly(book_manager, true)), but:

  • grow_order_book_instruction uses AccountMeta::new_readonly(book_manager, false), and
  • update_order_book_instruction omits book_manager entirely.

This lets any payer invoke grow/update on any order book in these helpers. Even though this is under test-integration/programs, if the intent is to model realistic authorization, consider requiring book_manager as a signer for grow and including it (and validating it) for update as well, or at least documenting the relaxed model for tests.

Also applies to: 178-195

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

334-351: Prevent size overflow before realloc

new_size = data_len() + additional_space as usize trusts attacker-controlled input. On BPF this wraps in release mode, so a large additional_space can underflow the sum and shrink the buffer, truncating order book data. Use checked addition and error out instead.

-    let new_size = order_book.data_len() + additional_space as usize;
+    let additional = additional_space as usize;
+    let new_size = order_book
+        .data_len()
+        .checked_add(additional)
+        .ok_or(ProgramError::InvalidArgument)?;
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 710792e and 34d41c2.

⛔ 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 (1 hunks)
  • magicblock-committor-service/Cargo.toml (1 hunks)
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (2 hunks)
  • magicblock-committor-service/src/intent_executor/mod.rs (3 hunks)
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1 hunks)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (3 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_strategist.rs (11 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (1 hunks)
  • test-integration/Cargo.toml (4 hunks)
  • test-integration/programs/schedulecommit/Cargo.toml (1 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (5 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (8 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 (3 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1 hunks)
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs (1 hunks)
  • test-integration/test-committor-service/tests/common.rs (6 hunks)
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs (6 hunks)
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs (9 hunks)
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs (3 hunks)
  • test-integration/test-committor-service/tests/utils/transactions.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 (18)
📚 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
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • programs/magicblock/src/magic_scheduled_base_intent.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_delivery_preparator.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/test_ix_commit_local.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_delivery_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:

  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.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-tools/src/integration_test_context.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/schedulecommit/client/src/verify.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/schedulecommit/test-scenarios/tests/01_commits.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.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:

  • Cargo.toml
  • 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/programs/schedulecommit/src/utils/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/programs/schedulecommit/src/lib.rs
📚 Learning: 2025-10-14T09:56:14.047Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 564
File: test-integration/programs/flexi-counter/src/processor/call_handler.rs:122-125
Timestamp: 2025-10-14T09:56:14.047Z
Learning: The file test-integration/programs/flexi-counter/src/processor/call_handler.rs contains a test smart contract used for integration testing, not production code.

Applied to files:

  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/Cargo.toml
  • magicblock-committor-service/src/tasks/args_task.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/intent_executor/task_info_fetcher.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • programs/magicblock/src/magic_scheduled_base_intent.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/intent_execution_manager/intent_execution_engine.rs
  • magicblock-committor-service/src/intent_executor/mod.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-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-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-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/programs/schedulecommit/Cargo.toml
📚 Learning: 2025-11-04T10:48:00.070Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/mod.rs:217-219
Timestamp: 2025-11-04T10:48:00.070Z
Learning: In magicblock-validator, the codebase uses a pattern where types containing non-Send/non-Sync fields (like Rc<RefCell<...>>) are marked with unsafe impl Send when they are guaranteed to be confined to a single thread through careful API design and thread spawning patterns.

Applied to files:

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

Applied to files:

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

Applied to files:

  • test-integration/test-committor-service/tests/common.rs
🧬 Code graph analysis (20)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
magicblock-validator/src/main.rs (1)
  • init_logger (13-50)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (1)
  • get_base_account (804-809)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • get_base_account (827-832)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
test-integration/test-committor-service/tests/common.rs (1)
  • get_base_account (146-151)
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-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)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (3)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (42-45)
  • get_base_account (274-279)
test-integration/test-committor-service/tests/common.rs (1)
  • get_base_account (146-151)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (4)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (6)
  • fetch_next_commit_ids (784-789)
  • fetch_rent_reimbursements (791-796)
  • peek_commit_id (798-800)
  • None (393-393)
  • reset (802-802)
  • get_base_account (804-809)
magicblock-committor-service/src/intent_executor/mod.rs (7)
  • fetch_next_commit_ids (807-812)
  • fetch_rent_reimbursements (814-819)
  • peek_commit_id (821-823)
  • None (844-844)
  • None (860-860)
  • reset (825-825)
  • get_base_account (827-832)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (10)
  • fetch_next_commit_ids (25-28)
  • fetch_next_commit_ids (167-234)
  • fetch_rent_reimbursements (31-34)
  • fetch_rent_reimbursements (236-251)
  • peek_commit_id (37-37)
  • peek_commit_id (254-257)
  • reset (40-40)
  • reset (260-272)
  • get_base_account (42-45)
  • get_base_account (274-279)
test-integration/test-committor-service/tests/common.rs (5)
  • fetch_next_commit_ids (126-131)
  • fetch_rent_reimbursements (133-138)
  • peek_commit_id (140-142)
  • reset (144-144)
  • get_base_account (146-151)
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_instruction (237-255)
  • schedule_commit_diff_instruction_for_order_book (196-215)
  • update_order_book_instruction (178-194)
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/programs/schedulecommit/src/order_book.rs (1)
  • bids (171-173)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
magicblock-committor-service/src/intent_executor/mod.rs (3)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (2)
  • get_base_account (804-809)
  • None (393-393)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (42-45)
  • get_base_account (274-279)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
magicblock-committor-service/src/tasks/mod.rs (4)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • instruction (45-85)
  • new (36-41)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • instruction (65-86)
  • new (37-45)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (163-181)
  • new (53-56)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
  • new (59-67)
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)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (4)
test-integration/test-committor-service/tests/common.rs (3)
  • new (53-56)
  • create_commit_task (163-181)
  • create_task_info_fetcher (117-119)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (36-41)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
magicblock-committor-service/src/tasks/args_task.rs (1)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
test-integration/programs/schedulecommit/src/lib.rs (2)
test-integration/programs/schedulecommit/src/utils/mod.rs (3)
  • assert_is_signer (30-44)
  • assert_keys_equal (16-28)
  • allocate_account_and_assign_owner (58-106)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (105-125)
magicblock-committor-service/src/tasks/task_builder.rs (2)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (163-181)
  • new (53-56)
magicblock-committor-service/src/tasks/task_strategist.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
  • new (53-56)
  • create_commit_task (163-181)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
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)
test-integration/test-committor-service/tests/common.rs (3)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
  • new (59-67)
  • get_base_account (42-45)
  • get_base_account (274-279)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (163-181)
  • new (53-56)
🔇 Additional comments (34)
test-integration/programs/schedulecommit/src/utils/mod.rs (4)

53-53: Good API alignment improvement.

Changing the size field to u64 aligns with Solana's system_instruction::allocate API and eliminates the need for type conversions at the call site.


71-71: Cast is appropriate for Solana's 64-bit environment.

The as usize cast is safe here since Solana programs run exclusively in 64-bit environments where usize equals u64. This approach is consistent with established patterns.

Based on learnings.


75-79: Helpful observability addition.

The logging message improves debuggability by showing the required lamports and available payer balance, which is useful for diagnosing allocation failures.


90-90: Cleaner API usage.

Passing size directly to system_instruction::allocate eliminates the previous conversion and potential panic point, making the code more straightforward and robust.

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

55-61: Keep TempDir bound to avoid premature directory cleanup

Capturing the first tuple element as _tmpdir (instead of _) correctly keeps the TempDir alive for the entire write() scope, preventing the underlying temporary directory from being deleted while the validator/ctx are still in use. The leading underscore avoids unused-variable warnings and documents the intent.
Based on learnings


170-176: Same lifetime fix for read() setup

Mirroring write(), binding the TempDir as _tmpdir here ensures the directory survives for the whole read() scope, avoiding early cleanup while the validator and cloned accounts are being used. This is the right pattern for resource guards you need to keep alive but never otherwise reference.
Based on learnings

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

19-20: LGTM — test dependencies are reasonable.

rand and borsh are appropriately placed as dev-dependencies to support test scenario generation and serialization testing.

test-integration/Cargo.toml (2)

40-40: LGTM — ephemeral-rollups-sdk remains a git-based dependency.

The reordering maintains the git-based reference, avoiding the CI path-dependency issues from previous feedback. No functional change.


60-60: I'll search for information about this specific commit and CommitDiff features in the magicblock-delegation-program project.

I was unable to find specific information about commit e8d03936 or a feature called "CommitDiff" in the publicly available documentation. Let me search more specifically for commit history and this feature.

Unable to verify CommitDiff feature existence in commit e8d03936.

After multiple web searches, I could not find any reference to a feature called "CommitDiff" in the magicblock-labs/delegation-program documentation, changelog, or codebase. The delegation-program supports core functionality including account delegation, state commits (synchronization back to Solana), and account undelegation, but there is no evidence of a specific "CommitDiff" capability. Additionally, I could not access specific details about commit e8d03936 from public sources.

Without being able to confirm the existence or compatibility status of this feature, please manually verify that:

  1. Commit e8d03936 is the correct revision for your use case
  2. The delegation-program at this revision meets your workspace requirements
  3. Integration tests in test-integration/Cargo.toml run successfully with this dependency version
test-integration/programs/schedulecommit/Cargo.toml (1)

11-12: No issues found — both dependencies are actively used.

Verification confirms that rkyv and static_assertions are actively used in the program:

  • rkyv::AlignedVec is used in order_book.rs:64 for serialization
  • static_assertions::const_assert is used in order_book.rs:7 for compile-time assertions

The dependencies appropriately support the CommitDiff serialization feature. No unused transitive dependencies.

Cargo.toml (2)

111-114: The magicblock-aperture path dependency is valid and properly integrated.

Verification confirms:

  • Directory exists at workspace root (./magicblock-aperture)
  • Contains valid Cargo.toml with proper workspace configuration
  • Declared in workspace members list
  • Follows the same pattern as 20+ other legitimate path dependencies in the workspace (magicblock-committor-service, magicblock-config, magicblock-core, etc.)

This is not a temporary workaround like previous CI concerns—it is permanent workspace infrastructure. The workspace resolver handles this correctly.


112-114: CommitDiff instruction support is present in revision e8d03936.

Commit e8d03936 introduces an optimization to CommitDiff using efficient merge_diff_copy that avoids heap allocation, confirming the new revision includes the CommitDiff functionality required by this PR. The revision upgrade is compatible.

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

157-175: Stricter client presence + explicit v0 handling look good.

Turning a missing rpc_client into a panic with a labeled message and explicitly setting max_supported_transaction_version for "chain" improves diagnostics and makes the version behavior explicit without changing intended semantics in this test context.

test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)

28-36: Context creation correctly updated for new user_seed API.

The prepare_ctx_with_account_to_commit helper now passes the expected user_seed into both try_new and try_new_random_keys, preserving the previous behavior while satisfying the new constructor signature.

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

310-465: CommittedAccount abstraction and CommitType refactor look sound.

The introduction of CommittedAccountRef and CommittedAccount cleanly separates on‑chain account views from the owned representation used in commits, and CommitType::try_from_args now consistently validates delegation/ownership before snapshotting and rewriting the owner to parent_program_id. I don’t see correctness or safety issues in this refactor.

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

16-35: User seed correctly threaded into context helper.

get_context_with_delegated_committees now accepts user_seed and forwards it to both try_new variants before initializing and delegating committees, which matches the updated client API and keeps the helper’s behavior intact.

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

123-133: CommitState-vs-CommitDiff log matching behavior is clear and aligned with intent.

The special-casing of "CommitState" to also match "CommitDiff" is well-documented here and keeps existing tests stable while allowing the optimized path.

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

7-12: NullTaskInfoFetcher module gating and re-export are well-scoped.

The cfg(any(test, feature = "dev-context-only-utils")) gating keeps NullTaskInfoFetcher confined to tests/dev utilities while still letting downstream code import it from intent_executor when needed.


787-833: MockInfoFetcher implementation correctly adapts to new TaskInfoFetcher API.

Adding get_base_account that returns Ok(None) is an appropriate no-op implementation for these tests and keeps the trait object-safe and coherent across production and test code.

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

11-46: New TaskInfoFetcher::get_base_account signature fits existing error model and callers.

Extending the trait with get_base_account returning MagicBlockRpcClientResult<Option<Account>> integrates cleanly with the existing TaskInfoFetcherError::MagicBlockRpcClientError and matches how tests and null/buffer fetchers are implemented elsewhere.


274-279: CacheTaskInfoFetcher get_base_account implementation is straightforward and correct.

Delegating to self.rpc_client.get_account(pubkey).await is an appropriate baseline implementation; any future need for batching can be handled separately without affecting the trait contract.

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

2-304: Async create_commit_task integration and join_all usage look correct.

All call sites now properly await create_commit_task, and the join_all patterns for building multiple buffer/args tasks are sound (no lifetime issues with datas, and results are collected before datas drops). The tests accurately exercise both initial and re-prepare flows with mutated commit data.

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

46-47: User seed propagation into context and delegation looks correct

Passing b"magic_schedule_commit" into get_context_with_delegated_committees and delegate_account_cpi_instruction aligns with the updated helper signature and keeps the delegation context/seed consistent across tests.

Also applies to: 100-101, 232-233

magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (1)

347-349: MockInfoFetcher update cleanly satisfies new TaskInfoFetcher API

The added MagicBlockRpcClientResult/Account imports and get_base_account implementation (Ok(None)) correctly extend MockInfoFetcher to match the updated TaskInfoFetcher trait without affecting existing test behavior.

Also applies to: 804-809

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

1-41: NullTaskInfoFetcher is a correct null-object implementation

All TaskInfoFetcher methods return empty collections/None/Ok(None) as expected from a no-op fetcher, and get_base_account aligns with the commit‑diff fallback logic (treating missing base accounts as AccountNotFound).

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

55-57: Seeded contexts and order-book CommitDiff test look sound

  • Using get_context_with_delegated_committees(…, b"magic_schedule_commit") in the single/two‑account helpers and b"order_book" for the order‑book helper correctly aligns with the updated context initializer that now requires a user seed.
  • commit_and_undelegate_order_book_account composes the update_order_book_instruction and schedule_commit_diff_instruction_for_order_book in a single transaction against the delegated committee account, which matches the intended CommitDiff flow.
  • test_committing_and_undelegating_huge_order_book_account’s seeded RNG setup, detailed failure messages (including rng_seed), and strict equality checks on bids/asks provide robust, reproducible coverage for large order‑book commits.

Also applies to: 173-174, 110-164, 244-312


150-161: Replace println! with debug!/info! for consistent logging

This file otherwise uses the log macros; the remaining println! calls (e.g., in commit_and_undelegate_order_book_account and the huge order‑book test) are inconsistent and bypass the configured logger.

Consider switching them to debug! or info!, for example:

-    println!("txhash (scheduled_commit): {:?}", tx_res);
+    debug!("txhash (scheduled_commit): {:?}", tx_res);

-            println!("Important: use {rng_seed} as seed to regenerate the random inputs in case of test failure");
+            info!("Important: use {rng_seed} as seed to regenerate the random inputs in case of test failure");
-            println!(
+            info!(
                 "BookUpdate: total = {}, bids = {}, asks = {}",
                 update.bids.len() + update.asks.len(),
                 update.bids.len(),
                 update.asks.len()
             );

[ suggest_optional_refactor]
[ duplicate_comment]

Also applies to: 252-275, 268-273

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

27-32: Async commit task construction via TaskInfoFetcher looks correct.

Using task_info_fetcher: &Arc<C> plus a single fetch_next_commit_ids call and then join_all over CommitTaskBuilder::create_commit_task gives you one RPC batch for IDs and concurrent per-account base‑account fetching, while preserving task ordering. The expect on commit_ids.get(&account.pubkey) is reasonable given the documented invariant that the fetcher must return IDs for all input pubkeys. No changes needed here.

Also applies to: 48-51, 72-80, 90-103


35-38: Finalize path’s switch to TaskInfoFetcher is consistent and localized.

Threading task_info_fetcher: &Arc<C> into finalize_tasks and using fetch_rent_reimbursements(&pubkeys) keeps all chain/RPC I/O behind the same trait as the commit side, and the error mapping to FinalizedTasksBuildError is clear. Just ensure your TaskInfoFetcher implementations guarantee a 1:1 mapping between pubkeys and rent_reimbursements, since the subsequent zip will silently drop mismatches.

Also applies to: 107-111, 167-176

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

1-2: Delegating commit instruction building to CommitTask is a good consolidation.

Having ArgsTaskType::Commit call value.create_commit_ix(validator) centralizes Commit vs CommitDiff encoding in CommitTask and keeps ArgsTask free of DLP‑specific argument wiring. This also supports the earlier goal of avoiding any RPC or diff computation inside instruction(). Looks good.

Also applies to: 44-83


87-107: Confirm intended downgrade of diff-capable commits during buffer optimization.

For Commit tasks where value.is_commit_diff() is true, optimize now calls value.force_commit_state() and then wraps it in a BufferTask. That means CommitDiff is only exercised when the unoptimized Args transaction already fits, and any task that needs buffer optimization will fall back to CommitState semantics, as your TODO notes.

If this is the intended interim behavior, fine; just ensure:

  • You have tests that cover both cases (diff path taken vs downgraded when buffers are needed), and
  • Future work to support diff via buffers removes force_commit_state() and/or routes such tasks to a dedicated diff-aware buffer variant instead of silently downgrading them.
test-integration/programs/schedulecommit/src/api.rs (2)

100-145: Seed-based delegation split (main vs order-book) is clear; constrain callers to known seeds.

delegate_account_cpi_instruction now:

  • Derives the delegated PDA as [user_seed, player_or_book_manager], and
  • Chooses between DelegateCpi and DelegateOrderBook based on user_seed == b"magic_schedule_commit".

This matches the two PDA schemes you’re exercising from the client. Just make sure all call sites only ever pass the two canonical seeds ("magic_schedule_commit" and "order_book"); anything else will derive a mismatched PDA but still go down the order-book branch.


196-215: Double-check account order for ScheduleCommitForOrderBook.

schedule_commit_diff_instruction_for_order_book wires accounts as [payer, order_book, magic_context_id, magic_program_id]. Please verify this matches the on-chain ScheduleCommitForOrderBook handler’s expected account order; a drift here would be hard to diagnose from tests.

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

34-35: user_seed wiring across PDAs, init, and delegation is coherent.

Storing user_seed in ScheduleCommitTestContext, deriving committee PDAs with [user_seed, payer_ephem], branching in init_committees between init_account_instruction and init_order_book_instruction, and then reusing the same seed in delegate_account_cpi_instruction keeps the main-account and order-book flows consistent end to end. The fallback error for unsupported seeds in init_committees is also helpful. No issues from a correctness standpoint.

Also applies to: 66-80, 103-121, 153-159, 165-211, 268-276

rand = "0.8.5"
random-port = "0.1.1"
rayon = "1.10.0"
rkyv = "0.7.45"
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 21, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify rkyv and static_assertions workspace dependency versions.

Lines 74 and 93 add rkyv = "0.7.45" and static_assertions = "1.1.0" to workspace.dependencies. Ensure these versions are:

  1. Compatible with other Solana/workspace dependencies (especially solana-program, solana-sdk)
  2. Consistent across the workspace (check if they appear in root Cargo.toml or other workspace members)
  3. Not introducing transitive dependency conflicts

Also applies to: 93-93


🏁 Script executed:

#!/bin/bash
# Check workspace-wide usage of rkyv and static_assertions
echo "=== Checking rkyv usage in workspace ==="
rg -n "rkyv" --type toml Cargo.toml test-integration/Cargo.toml

echo ""
echo "=== Checking static_assertions usage in workspace ==="
rg -n "static_assertions" --type toml Cargo.toml test-integration/Cargo.toml

echo ""
echo "=== Checking for version consistency in root Cargo.toml ==="
grep -n "static_assertions\|rkyv" Cargo.toml

Length of output: 337



🏁 Script executed:

#!/bin/bash
# Check Solana dependencies in root Cargo.toml to assess compatibility
echo "=== Solana dependencies in root Cargo.toml ==="
rg -A2 -B2 "solana-program|solana-sdk" --type toml Cargo.toml | head -50

echo ""
echo "=== Check if test-integration actually uses rkyv ==="
rg -n "rkyv" --type rust test-integration/src/ || echo "No rkyv usage found in test-integration/src"

echo ""
echo "=== Check if rkyv is in root workspace.dependencies (workspace.dependencies section) ==="
sed -n '/\[workspace\.dependencies\]/,/^\[/p' Cargo.toml | grep -n "rkyv" || echo "rkyv NOT found in root workspace.dependencies"

echo ""
echo "=== List all workspace.dependencies in root Cargo.toml ==="
sed -n '/\[workspace\.dependencies\]/,/^\[/p' Cargo.toml | head -30

Length of output: 1575


🏁 Script executed:

#!/bin/bash
# Check Solana dependencies and full workspace.dependencies section
echo "=== Solana dependencies (from root Cargo.toml) ==="
grep -n "solana-program\|solana-sdk" Cargo.toml | head -10

echo ""
echo "=== Full workspace.dependencies section in root Cargo.toml ==="
sed -n '/\[workspace\.dependencies\]/,/^$/p' Cargo.toml

echo ""
echo "=== Check if test-integration Cargo.toml references rkyv in code ==="
grep -r "rkyv" test-integration/Cargo.toml

echo ""
echo "=== Get the dependencies section from test-integration/Cargo.toml ==="
sed -n '/\[dependencies\]/,/^\[/p' test-integration/Cargo.toml | grep -E "rkyv|static_assertions"

Length of output: 3365


🏁 Script executed:

#!/bin/bash
# Check test-integration/Cargo.toml structure and any workspace definition
echo "=== Full test-integration/Cargo.toml content ==="
cat test-integration/Cargo.toml

echo ""
echo "=== Check for rkyv usage anywhere in the codebase ==="
rg -n "rkyv" --type rust . 2>/dev/null | head -20 || echo "No rkyv Rust usage found"

echo ""
echo "=== Check if test-integration is a workspace member ==="
grep -A 20 "\[workspace\]" Cargo.toml | grep -E "members|test-integration"

Length of output: 4143


</web_search>


🌐 Web query:

rkyv 0.7.45 Solana compatibility

💡 Result:

Short answer: Yes — rkyv 0.7.45 can be used in Solana (BPF) programs, but you must build it for no‑std/32‑bit BPF by adjusting features.

What to do

  • Use the rkyv 0.7.45 crate (release exists). [1][2]
  • Disable/std opt out default features and enable the minimal features required for BPF:
    • compile rkyv with no std (disable the "std" feature),
    • enable alloc only if you need heap types (Vec/String) and your program supplies an allocator,
    • enable pointer_width_32 so usize/isize are serialized as 32‑bit (matches Solana BPF). [3]
  • Ensure every dependency in your dependency graph is also no_std/no‑alloc (Cargo features are unioned).
  • Avoid/disable features that pull in bytecheck/std or other non‑BPF‑compatible code, or provide no_std versions of those crates.

References

  • rkyv crate documentation (features, pointer_width_32, alloc/std notes). [3]
  • rkyv 0.7.45 release/package listing. [2][4]

If you want, tell me your Cargo.toml and I’ll produce the exact dependency lines / feature flags to compile rkyv 0.7.45 for Solana BPF.


🏁 Script executed:

#!/bin/bash
# Check how rkyv is declared in the actual programs using it
echo "=== Search for rkyv declaration in schedulecommit program ==="
find test-integration/programs -name "Cargo.toml" -exec grep -H "rkyv" {} \;

echo ""
echo "=== Check schedulecommit program's Cargo.toml dependencies ==="
cat test-integration/programs/schedulecommit/Cargo.toml | grep -A 3 -B 3 "rkyv\|dependencies"

echo ""
echo "=== Check for any feature configuration in test-integration workspace.dependencies ==="
grep -A 1 "^rkyv" test-integration/Cargo.toml

echo ""
echo "=== Verify rkyv usage context in order_book.rs ==="
sed -n '60,70p' test-integration/programs/schedulecommit/src/order_book.rs

Length of output: 1228


Reconfigure rkyv with BPF-compatible feature flags in test-integration/Cargo.toml line 74.

rkyv = "0.7.45" is used by the schedulecommit Solana program but lacks critical Solana BPF compatibility features. Change to:

rkyv = { version = "0.7.45", default-features = false, features = ["alloc", "pointer_width_32"] }

The default features include std, which is incompatible with Solana BPF programs. The pointer_width_32 and alloc flags are required for BPF serialization (the code uses rkyv::AlignedVec).

static_assertions = "1.1.0" is consistent across both workspaces and requires no changes.

🤖 Prompt for AI Agents
In test-integration/Cargo.toml around line 74, the rkyv dependency is currently
declared as rkyv = "0.7.45" which brings default (std) features incompatible
with Solana BPF; update the dependency to explicitly disable default features
and enable alloc and pointer_width_32 by changing the declaration to use a table
with version = "0.7.45", default-features = false, and features =
["alloc","pointer_width_32"] so the crate builds for 32-bit BPF and supports
rkyv::AlignedVec.

Copy link
Author

Choose a reason for hiding this comment

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

You're wrong.

See the code carefully again. rkyv is used by code which does NOT run inside the Solana BPF VM.

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find all actual rkyv usage in the codebase
echo "=== All rkyv imports and usage in Rust files ==="
rg -n "use.*rkyv|rkyv::" --type rust test-integration/

echo ""
echo "=== Check schedulecommit program's crate-type and target ==="
cat test-integration/programs/schedulecommit/Cargo.toml

echo ""
echo "=== Check for cfg attributes around rkyv usage in order_book.rs ==="
cat test-integration/programs/schedulecommit/src/order_book.rs | head -100

echo ""
echo "=== Check how OrderBook is used - is it only in tests? ==="
rg -n "OrderBook" --type rust test-integration/schedulecommit/ -C 2 | head -50

Length of output: 4911


@snawaz, you're absolutely right, and I apologize for the incorrect analysis.

Looking at the actual usage, rkyv appears only in the BorshDeserialize implementation for OrderBookOwned in order_book.rs line 64, which is explicitly marked in the comment as "test code." This deserialization method is called exclusively by off-chain test/verification code (in schedulecommit/client/src/verify.rs), not by the on-chain BPF program.

The on-chain code uses the zero-copy OrderBook<'a> structure that operates directly on account data without any serialization dependencies. When the schedulecommit program compiles to BPF (via the "cdylib" target), the OrderBookOwned deserialization path with rkyv::AlignedVec is never executed.

The current declaration rkyv = "0.7.45" with default features (including std) is correct for this off-chain usage. No BPF-specific feature flags are needed.


🧠 Learnings used
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.

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.

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.

@snawaz snawaz force-pushed the snawaz/commit-diff branch 4 times, most recently from 7d6f839 to faed161 Compare November 21, 2025 21:24
@snawaz snawaz force-pushed the snawaz/commit-diff branch from faed161 to 9c11945 Compare November 21, 2025 21:34
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 9c11945 to a42745b Compare November 21, 2025 23: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: 3

Caution

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

⚠️ Outside diff range comments (2)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)

465-488: Large‑commit TODO is clear; consider linking to a tracking issue

The expanded TODO block for 1 MB / “max Solana account size” scenarios is well described. To avoid this stress‑test work getting lost, it would be helpful to reference a tracking issue or design doc here once one exists (e.g., // TODO(...): ... (tracked in issue #NNN)).

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

162-180: Confirm whether tests using create_commit_task are meant to exercise CommitDiff

create_commit_task now always uses NullTaskInfoFetcher, which guarantees base_account is None and thus forces the CommitState path even for large accounts. That’s fine for pure serialization tests, but if any callers of this helper are intended to cover CommitDiff behavior, they won’t actually hit the diff path.

If you need CommitDiff coverage through this helper, consider either:

  • Accepting a TaskInfoFetcher (or Arc<dyn TaskInfoFetcher>) parameter, or
  • Switching to a real/test TaskInfoFetcher that returns Some(Account) for large accounts in the relevant tests.

Otherwise, leaving it as-is is reasonable for state-only tests.

♻️ Duplicate comments (8)
test-integration/programs/schedulecommit/src/lib.rs (1)

327-332: Fix process_grow_order_book PDA error message to reference book_manager

The PDA assertion still formats the message with payer.key instead of book_manager.key:

format!(
    "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
    order_book.key, payer.key
)

For debugging, this should show the book manager whose key is used in the PDA derivation:

-            "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
-            order_book.key, payer.key
+            "PDA for the account ('{}') and for book_manager ('{}') is incorrect",
+            order_book.key, book_manager.key

[suggest_minor_issue]

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

229-231: Unconditional dump_chain_logs still makes happy-path tests noisy and slow

This helper will hit RPC and dump full chain logs for every commit signature on every successful run. That was already called out earlier; the concern still applies.

Consider either:

  • Removing these calls now that debugging is done, or
  • Gating them behind an env flag / debug mode, or
  • Moving them into specific failing paths/tests that actually need deep logs.
test-integration/schedulecommit/client/src/schedule_commit_context.rs (1)

193-207: Remove stale commented-out grow-order-book block; track via issue instead

This 10+ line commented block under the b"order_book" arm is now just noise in a hot helper:

//// TODO...
// ixs.extend(self.committees.iter().flat_map(|(payer, committee)| {
//     [grow_order_book_instruction(...)]
// }));

Given CommitDiff/grow behavior is already being exercised elsewhere, and this TODO has been called out before, consider:

  • Moving the “relax account size / grow order book” work into a GitHub issue, then
  • Deleting this commented code entirely, possibly leaving a 1‑line comment with the issue reference if you want breadcrumbs.

This keeps the test context focused and easier to scan.

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

138-141: Avoid silently dropping updates when order-book capacity is exhausted

update_from currently ignores the Option returned by add_bids/add_asks:

pub fn update_from(&mut self, updates: BookUpdate) {
    self.add_bids(&updates.bids);
    self.add_asks(&updates.asks);
}

If capacity is insufficient, those helpers return None and the update is silently dropped (or partially applied). Earlier discussion indicated you’d rather have tests panic than fail quietly.

To align with that intent and keep the API simple, consider:

 pub fn update_from(&mut self, updates: BookUpdate) {
-    self.add_bids(&updates.bids);
-    self.add_asks(&updates.asks);
+    self.add_bids(&updates.bids)
+        .expect("order_book capacity exhausted while adding bids");
+    self.add_asks(&updates.asks)
+        .expect("order_book capacity exhausted while adding asks");
 }

This keeps the zero-copy layout as-is but guarantees you’ll see an immediate, clear failure instead of silent truncation.

test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)

28-36: Context initialization correctly forwards user_seed (consider centralizing the literal)

Updating prepare_ctx_with_account_to_commit to pass b"magic_schedule_commit" into both try_new and try_new_random_keys matches the new ScheduleCommitTestContext API and keeps the test context wiring consistent. As this same seed string appears in other schedulecommit tests, you may eventually want a shared constant to avoid drift across files.

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

46-47: Avoid repeating the literal b"magic_schedule_commit" in multiple call sites

The new user_seed plumbing is correct, but the same byte string is now hardcoded in three places (two get_context_with_delegated_committees calls and init_and_delegate_player). Consider extracting a module-level test constant (e.g. const TEST_USER_SEED: &[u8] = b"magic_schedule_commit";) and using it everywhere to keep these tests in sync if the seed ever changes.

Also applies to: 100-101, 216-233

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

12-16: get_base_account design is fine; consider a batched path later for performance

Extending TaskInfoFetcher with async get_base_account and wiring CacheTaskInfoFetcher to rpc_client.get_account is a reasonable first step to support CommitDiff logic. For workloads that touch many large delegated accounts in one run, calling get_account per pubkey may become a bottleneck; a future get_base_accounts(&[Pubkey]) backed by get_multiple_accounts could reduce round‑trips and better match the existing batched metadata fetch.

Also applies to: 43-47, 276-281

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

55-57: Order‑book CommitDiff test flow is solid; align logging with existing log macros

The new order‑book helper and test_committing_and_undelegating_huge_order_book_account correctly:

  • apply an UpdateOrderBook,
  • schedule a CommitDiff via schedule_commit_diff_instruction_for_order_book,
  • verify the committed book exactly matches the generated BookUpdate, and
  • assert the committee account was undelegated on‑chain.

The only nit is consistency: the println! calls (e.g., for the scheduled‑commit tx hash and RNG seed/update sizes) bypass the logging pipeline while the rest of this file uses info!/debug!. Consider swapping those println!s for debug!/info! so test output respects the configured log level.

Also applies to: 110-164, 244-312

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34d41c2 and a42745b.

⛔ 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 (1 hunks)
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (2 hunks)
  • magicblock-committor-service/src/intent_executor/mod.rs (4 hunks)
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1 hunks)
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (3 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_builder.rs (6 hunks)
  • magicblock-committor-service/src/tasks/task_strategist.rs (11 hunks)
  • magicblock-processor/src/executor/processing.rs (0 hunks)
  • programs/magicblock/src/magic_scheduled_base_intent.rs (1 hunks)
  • test-integration/Cargo.toml (4 hunks)
  • test-integration/programs/schedulecommit/Cargo.toml (1 hunks)
  • test-integration/programs/schedulecommit/src/api.rs (5 hunks)
  • test-integration/programs/schedulecommit/src/lib.rs (8 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 (3 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (4 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (1 hunks)
  • test-integration/schedulecommit/test-security/tests/01_invocations.rs (1 hunks)
  • test-integration/test-committor-service/tests/common.rs (5 hunks)
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs (6 hunks)
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs (9 hunks)
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs (4 hunks)
  • test-integration/test-committor-service/tests/utils/transactions.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)
💤 Files with no reviewable changes (1)
  • magicblock-processor/src/executor/processing.rs
🧰 Additional context used
🧠 Learnings (19)
📚 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/test_ix_commit_local.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • test-integration/test-tools/src/integration_test_context.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs
  • magicblock-committor-service/src/tasks/mod.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:

  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/programs/schedulecommit/src/api.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.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
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs
  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • test-integration/test-committor-service/tests/common.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • test-integration/test-committor-service/tests/test_delivery_preparator.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.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/programs/schedulecommit/Cargo.toml
  • test-integration/Cargo.toml
📚 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/mod.rs
  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/utils/mod.rs
  • test-integration/test-ledger-restore/tests/08_commit_update.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
📚 Learning: 2025-10-21T13:06:38.900Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/http/get_program_accounts.rs:17-25
Timestamp: 2025-10-21T13:06:38.900Z
Learning: The magicblock validator does not support ledger forking, so commitment-based state queries (processed/confirmed/finalized) are not applicable. RPC methods can safely ignore commitment and minContextSlot parameters from Solana RPC config objects.

Applied to files:

  • magicblock-committor-service/src/intent_executor/mod.rs
📚 Learning: 2025-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/mod.rs
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs
  • test-integration/test-committor-service/tests/common.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.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/intent_executor/mod.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/mod.rs
  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • test-integration/programs/schedulecommit/src/lib.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
  • test-integration/programs/schedulecommit/src/order_book.rs
  • test-integration/schedulecommit/client/src/schedule_commit_context.rs
📚 Learning: 2025-11-07T13:09:52.253Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: test-kit/src/lib.rs:275-0
Timestamp: 2025-11-07T13:09:52.253Z
Learning: In test-kit, the transaction scheduler in ExecutionTestEnv is not expected to shut down during tests. Therefore, using `.unwrap()` in test helper methods like `schedule_transaction` is acceptable and will not cause issues in the test environment.

Applied to files:

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

Applied to files:

  • test-integration/Cargo.toml
  • test-integration/programs/schedulecommit/src/utils/mod.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-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-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-18T08:47:39.702Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/tests/04_redeleg_other_separate_slots.rs:158-165
Timestamp: 2025-11-18T08:47:39.702Z
Learning: In magicblock-chainlink tests involving compressed accounts, `set_remote_slot()` sets the slot of the `AccountSharedData`, while `compressed_account_shared_with_owner_and_slot()` sets the slot of the delegation record. These are two different fields and both calls are necessary.

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/intent_executor/task_info_fetcher.rs
🧬 Code graph analysis (22)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (1)
magicblock-validator/src/main.rs (1)
  • init_logger (13-50)
magicblock-committor-service/src/intent_executor/mod.rs (2)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (43-46)
  • get_base_account (276-281)
magicblock-committor-service/src/tasks/task_builder.rs (3)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (2)
  • join_all (467-476)
  • new (49-59)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (162-180)
  • new (52-55)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (10)
  • fetch_next_commit_ids (26-29)
  • fetch_next_commit_ids (169-236)
  • fetch_rent_reimbursements (32-35)
  • fetch_rent_reimbursements (238-253)
  • peek_commit_id (38-38)
  • peek_commit_id (256-259)
  • reset (41-41)
  • reset (262-274)
  • get_base_account (43-46)
  • get_base_account (276-281)
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)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (3)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (2)
  • get_base_account (43-46)
  • get_base_account (276-281)
test-integration/test-committor-service/tests/common.rs (1)
  • get_base_account (145-150)
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)
test-integration/test-tools/src/integration_test_context.rs (1)
magicblock-chainlink/src/remote_account_provider/mod.rs (2)
  • rpc_client (1068-1070)
  • rpc_client (1080-1082)
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/test-committor-service/tests/common.rs (4)
magicblock-committor-service/src/intent_executor/mod.rs (2)
  • new (113-125)
  • get_base_account (826-831)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (3)
  • new (60-68)
  • get_base_account (43-46)
  • get_base_account (276-281)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
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-136)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (5)
test-integration/programs/schedulecommit/src/api.rs (2)
  • schedule_commit_diff_instruction_for_order_book (196-215)
  • update_order_book_instruction (178-194)
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 (213-217)
  • ephem_blockhash (331-333)
  • ephem_client (327-329)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • bids (182-184)
test-integration/schedulecommit/client/src/verify.rs (1)
  • fetch_and_verify_order_book_commit_result_from_logs (16-23)
magicblock-committor-service/src/tasks/task_strategist.rs (2)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • new (36-41)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
test-integration/test-committor-service/tests/test_delivery_preparator.rs (1)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (162-180)
  • new (52-55)
test-integration/schedulecommit/client/src/verify.rs (2)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/test-scenarios/tests/utils/mod.rs (3)
test-integration/schedulecommit/test-security/tests/01_invocations.rs (1)
  • ctx (148-149)
test-integration/test-ledger-restore/tests/08_commit_update.rs (1)
  • ctx (90-91)
test-integration/schedulecommit/client/src/schedule_commit_context.rs (3)
  • try_new (72-74)
  • ncommittees (102-121)
  • try_new_random_keys (66-71)
magicblock-committor-service/src/tasks/args_task.rs (1)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/tasks/mod.rs (2)
test-integration/test-committor-service/tests/common.rs (2)
  • create_commit_task (162-180)
  • new (52-55)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (1)
  • new (60-68)
test-integration/test-committor-service/tests/test_transaction_preparator.rs (3)
test-integration/test-committor-service/tests/common.rs (3)
  • new (52-55)
  • create_commit_task (162-180)
  • create_task_info_fetcher (116-118)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
  • new (37-45)
  • new_preparation_required (30-35)
magicblock-committor-service/src/tasks/mod.rs (1)
  • create_commit_task (121-157)
test-integration/programs/schedulecommit/src/api.rs (1)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • new (105-136)
magicblock-committor-service/src/intent_executor/task_info_fetcher.rs (4)
magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (1)
  • get_base_account (804-809)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • get_base_account (826-831)
magicblock-committor-service/src/intent_executor/null_task_info_fetcher.rs (1)
  • get_base_account (36-41)
test-integration/test-committor-service/tests/common.rs (1)
  • get_base_account (145-150)
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)
🔇 Additional comments (33)
test-integration/programs/schedulecommit/Cargo.toml (1)

11-12: LGTM! Dependencies added for test infrastructure.

The addition of rkyv and static_assertions as workspace dependencies is appropriate. Based on the codebase analysis, rkyv is used exclusively in off-chain test/verification code (e.g., OrderBookOwned deserialization), not in the BPF program itself, so the default features (including std) are correct. static_assertions enables compile-time checks for the test program.

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

123-133: LGTM! Pragmatic solution with clear documentation.

The special-case handling for "CommitState" to also match "CommitDiff" is well-justified and clearly documented in the inline comment. Since CommitDiff is an optimized variant of CommitState chosen automatically by the committor service, this approach appropriately abstracts the implementation detail from test assertions.

Cargo.toml (1)

111-114: LGTM! Dependency updates aligned with PR objectives.

The addition of magicblock-aperture and the revision update for magicblock-delegation-program (from aa1de56d90c to e8d03936) support the CommitDiff functionality introduced in this PR. The local path dependencies are acknowledged as temporary and will be converted to git references before merge.

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

19-20: LGTM! Test dependencies added appropriately.

The addition of rand and borsh as workspace dev-dependencies is appropriate for test scenarios. These enable random data generation and serialization/deserialization support in test code.

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

158-160: LGTM! Error message now properly formatted.

The change from .expect() to .unwrap_or_else() correctly fixes the format placeholder issue, ensuring the panic message includes the actual label value when the RPC client doesn't exist.


169-176: LGTM! Transaction version handling documented.

The conditional max_supported_transaction_version logic is well-documented. Setting Some(0) for the chain cluster enables explicit v0 transaction support, while the ephemeral cluster uses default version handling. The inline comment clearly explains this distinction.

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

55-55: LGTM! Proper temporary directory handling.

The destructuring now correctly captures the _tmpdir value returned by setup_validator_with_local_remote. Binding it (even as _tmpdir) keeps the temporary directory alive for the scope, preventing premature cleanup. This is the standard Rust pattern for managing temporary resources.


170-170: LGTM! Consistent temporary directory handling.

Same proper handling of the temporary directory as in the write function above.

test-integration/Cargo.toml (3)

40-40: LGTM! Dependency reordering.

The reordering of ephemeral-rollups-sdk has no functional impact and likely improves organization.


60-62: LGTM! Delegation program revision updated.

The revision update for magicblock-delegation-program (from aa1de56d90c to e8d03936) aligns with the CommitDiff functionality. The local path dependency concern noted in past reviews is acknowledged as temporary and will be addressed before merge.


74-74: LGTM! Test infrastructure dependencies added.

The additions of rkyv = "0.7.45" and static_assertions = "1.1.0" to workspace dependencies are appropriate. As confirmed in the codebase analysis, rkyv is used exclusively in off-chain test/verification code (not BPF programs), so the default features (including std) are correct. static_assertions provides compile-time checks for test infrastructure.

Also applies to: 93-93

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

53-53: LGTM! Type improved for consistency with Solana APIs.

Changing the size field from usize to u64 aligns better with Solana's system instruction APIs (e.g., system_instruction::allocate expects u64) and provides consistency across the codebase.


70-71: LGTM! Safe cast for 64-bit Solana environment.

The cast size as usize is safe because Solana exclusively runs in 64-bit environments where usize is 64 bits, so no truncation can occur. Based on learnings.


75-80: LGTM! Helpful debug logging added.

The debug log printing required_lamports and payer balance aids in troubleshooting account allocation issues during testing.


90-90: LGTM! Cleaner API usage.

Passing size directly to system_instruction::allocate (which accepts u64) is cleaner than the previous try_into().unwrap() conversion and aligns with the updated field type.

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

158-282: Updated CommitStrategy expectations look consistent with Args‑first planner

The revised expect_strategies(...) maps across the multi‑account and bundle‑size tests (more CommitStrategy::Args, adjusted FromBufferWithLookupTable counts) match the described behavior of the new planner that prefers Args when the intent fits and falls back to buffers+ALTs only when needed. The comments explaining when ALTs are required (e.g., undelegate‑all scenarios and large bundles) still align with the expectations.

Also applies to: 284-345


786-787: MockInfoFetcher::get_base_account stub is adequate for current tests

Adding get_base_account returning Ok(None) keeps the test MockInfoFetcher compatible with the extended TaskInfoFetcher trait, and is appropriate as long as these tests don't rely on diff behavior that needs the base account contents. If future tests start exercising CommitDiff based on base-account size or data, you'll likely want to extend this mock to return a synthetic Account instead of None.

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

2-3: Order‑book verify helper matches existing pattern

The new fetch_and_verify_order_book_commit_result_from_logs mirrors the existing MainAccount helper and cleanly exposes ScheduledCommitResult<OrderBookOwned> without changing the underlying flow. This keeps call sites simple and is fine even with the small duplication.

Also applies to: 16-23

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

7-9: cfg‑gated NullTaskInfoFetcher export is well‑scoped

The new null_task_info_fetcher module and pub use are both guarded by #[cfg(any(test, feature = "dev-context-only-utils"))], so tests and dev‑context utilities can rely on NullTaskInfoFetcher without affecting production builds. This is a good pattern for exposing test‑only helpers.

Also applies to: 28-29


786-787: Test MockInfoFetcher fully implements the extended trait

The added imports and get_base_account implementation in the test module keep MockInfoFetcher in sync with the updated TaskInfoFetcher trait while clearly signaling “no base account available” via Ok(None). That’s appropriate for this unit test, which only needs commit IDs and rent reimbursements.

Also applies to: 803-832

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

2-3: Async create_commit_task + join_all usage is appropriate for test setup

Migrating to the async create_commit_task helper and using join_all to build multiple BufferTask/ArgsTask instances keeps the tests aligned with the new builder API while avoiding unnecessary sequential awaits. The closures only capture references into the local datas array and are awaited via join_all (not spawned), so lifetimes and ordering remain correct for the subsequent assertions.

Also applies to: 25-31, 90-97, 167-172, 211-213, 300-303

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

310-325: CommittedAccount abstraction cleans up commit‑account handling

Introducing the CommittedAccount struct (with CommittedAccountRef and the From impl) and then using it inside CommitType::try_from_args removes ad‑hoc tuple handling and centralizes the AccountSharedDataAccount conversion. The subsequent owner override via context.parent_program_id.unwrap_or(...) preserves the previous behavior while making the code easier to follow.

Also applies to: 413-463

magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (1)

347-369: Test TaskInfoFetcher extension is consistent and safe

The added MagicBlockRpcClientResult / Account imports and MockInfoFetcher::get_base_account stub cleanly track the TaskInfoFetcher trait extension and correctly model “account not found” as Ok(None) for tests. No issues from a correctness or async standpoint.

Also applies to: 780-809

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

1-42: NullTaskInfoFetcher implementation matches intended null‑object semantics

NullTaskInfoFetcher returns empty maps, empty vectors, None for peek, and Ok(None) for get_base_account, which is exactly what you want from a no‑op test/dummy fetcher. The implementation is simple, deterministic, and correctly satisfies the TaskInfoFetcher trait.

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

10-12: CommitTaskBuilder + TaskInfoFetcher wiring in transaction‑preparator tests looks correct

All three tests now construct commit tasks via CommitTaskBuilder::create_commit_task(..., &fixture.create_task_info_fetcher()).await, which correctly exercises the async builder and TaskInfoFetcher integration without changing the behavioral expectations of the tests. No functional or async‑lifetime issues stand out.

Also applies to: 37-47, 96-117, 200-209

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

16-35: Seeded context helper and generic commit assertion integrate cleanly

Threading user_seed through get_context_with_delegated_committees to the ScheduleCommitTestContext constructors, and performing both init_committees() and delegate_committees() inside the helper, matches how the tests use this function and is required for the new order‑book scenarios.

The generic assert_one_committee_was_committed<T> over ScheduledCommitResult<T> is a reasonable generalization for non‑MainAccount payloads (like order books) and doesn’t change the assertion semantics.

Also applies to: 40-47

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

24-38: Async commit‑task building via TaskInfoFetcher is correctly wired

The TasksBuilder::commit_tasks refactor to use a single task_info_fetcher: &Arc<C> plus join_all to build CommitTasks is sound:

  • Commit ids are fetched once via fetch_next_commit_ids and persisted before task construction.
  • Each async closure looks up its pubkey’s commit id and calls CommitTaskBuilder::create_commit_task(..., task_info_fetcher).await, enabling concurrent base‑account RPCs while reusing the same fetcher.
  • The expect on the commit_ids map is appropriate given the “all or error” contract.
  • Finalize‑stage usage of fetch_rent_reimbursements is unchanged aside from the parameter rename and remains coherent.

Overall this aligns TaskBuilderImpl with the new CommitDiff‑capable builder without introducing new correctness or concurrency issues.

Also applies to: 72-89, 90-105, 108-199

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

1-12: CommitTask‑driven instruction generation and guarded CommitDiff downgrade look correct

Routing commit instructions through CommitTask::create_commit_ix(validator) makes ArgsTask::instruction pure and keeps diff/state decision logic encapsulated in CommitTask, which is a good separation of concerns.

In optimize(), the explicit value.is_commit_diff() check plus force_commit_state() before wrapping in a BufferTask matches the documented intent: CommitDiff tasks remain on the Args path unless they’re being converted into buffer‑based commits, at which point they are intentionally downgraded to CommitState until BufferTask learns how to handle diffs. This is consistent with the current design and avoids accidental use of CommitDiff in unsupported paths.

Also applies to: 44-85, 87-112, 131-137, 145-165

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

159-171: TaskStrategist remains correct; new async tests cover builder‑based commit tasks

The core strategist logic is unchanged aside from the TODO, and the new test module wiring looks good:

  • create_test_commit_task builds commit tasks via CommitTaskBuilder::create_commit_task(..., &Arc::new(NullTaskInfoFetcher)).await, so the strategist is exercised against the same commit‑task shape used in production (minus base‑account fetching).
  • The suite of #[tokio::test] cases verifies:
    • small commit stays as Args,
    • large commit(s) convert to Buffer,
    • multiple commits lead to multiple buffers and, when necessary, ALTs,
    • failure when even ALTs can’t make the tx fit, and
    • that optimization prioritizes the largest tasks and leaves non‑commit tasks (Finalize/BaseAction/Undelegate) as Args.

This gives solid coverage of the sizing/optimization behavior with the new async commit‑task construction.

Also applies to: 253-269, 271-276, 328-518

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

101-122: MockTaskInfoFetcher wiring with IntentExecutor looks correct

Using MockTaskInfoFetcher as a thin wrapper over MagicblockRpcClient and injecting it via create_task_info_fetcher() into IntentExecutorImpl::new cleanly aligns tests with the real TaskInfoFetcher flow, including get_base_account. No issues from a correctness or design perspective here.


145-150: Thin get_base_account wrapper is appropriate for integration tests

Delegating MockTaskInfoFetcher::get_base_account directly to self.0.get_account(pubkey).await is a straightforward way to exercise real RPC-based base-account lookups in integration tests and matches the TaskInfoFetcher trait semantics. This is consistent with the new CommitDiff flow and needs no changes.

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

160-230: CommitTask diff/state selection and instruction builders are coherent

The extended CommitTask implementation behaves as expected:

  • is_commit_diff() requires:

    • !force_commit_state,
    • account data length > COMMIT_STATE_SIZE_THRESHOLD,
    • base_account.is_some().
  • create_commit_ix() chooses:

    • Diff path when base_account is Some (with a defensive force_commit_state check inside create_commit_diff_ix), otherwise
    • CommitState.
  • create_commit_state_ix() and create_commit_diff_ix() construct CommitStateArgs/CommitDiffArgs with consistent fields, and compute_diff(base, target) uses ReadableAccount::data() for both account views.

This matches the intended semantics: CommitDiff is used only when a base account is available and not forced off, with a clean fallback to CommitState in all other scenarios. No functional issues here.


418-563: Async serialization tests now exercise the builder path without real RPC, which is appropriate

The updated tests:

  • Construct CommitTasks via CommitTaskBuilder::create_commit_task(...).await and wrap them in ArgsTask/BufferTask variants.
  • Use NullTaskInfoFetcher everywhere in this module, so no real RPC calls occur; even the 1024‑byte case in test_preparation_instructions_serialization only hits the builder with a cheap Ok(None).
  • Assert that instructions from ArgsTask, BufferTask (including preparation init/realloc/write Ixs) are serializable via bincode.

This gives good coverage of the new builder-based construction and ensures the public instruction shapes remain serializable, without introducing blocking I/O into the tests. Looks solid.

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