Skip to content

Conversation

@snawaz
Copy link

@snawaz snawaz commented Nov 6, 2025

Problem

The previous PR #575 in this stack implements support for CommitDiff that executes as ArgsTask. When the transaction size grows beyond the limit, CommitDiff first degrades to CommitState and then gets executed as BufferTask to reduce the transaction size.

Degration of CommitDiff to CommitState is not a desirable thing.

Solution

So this PR implements support for CommitDiff as BufferTask. Means degradation of CommitDiff to CommitState is not required anymore.

Related

Another PR magicblock-labs/delegation-program#118 that implements CommitDiffFromBuffer instruction, is created in the delegation-program.

Screenshot

image

Summary by CodeRabbit

  • New Features

    • Added support for commit-diff operations to handle state changes more efficiently.
  • Refactor

    • Extended task handling so commit-diff is treated consistently with commit operations.
    • Made task strategy selection available more broadly to enable wider integration.
  • Tests

    • Expanded test scenarios to cover much larger datasets and simplified expected commit-strategy outcomes.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

📝 Walkthrough

Walkthrough

Adds CommitDiff handling throughout the committor service: introduces BufferTaskType::CommitDiff, updates ArgsTask to emit CommitDiff directly, and changes buffer preparation to compute a diff, set committed_data to the diff, and derive chunks from the diff length. Instruction generation now uses commit_diff_from_buffer. Visitor logic (persistor and utility visitors) was updated to match both Commit and CommitDiff. TaskStrategy is now public (removed the #[cfg(test)] gate). A test widened random bid/ask generation ranges from 5..10 to 5..100.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 632a4f9 and e0844fd.

📒 Files selected for processing (8)
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
  • magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs
  • test-integration/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
💤 Files with no reviewable changes (1)
  • magicblock-committor-service/src/tasks/mod.rs
✅ Files skipped from review due to trivial changes (1)
  • test-integration/Cargo.toml
🧰 Additional context used
🧠 Learnings (6)
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs
📚 Learning: 2025-12-03T09:36:01.527Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: magicblock-chainlink/src/remote_account_provider/mod.rs:1350-1353
Timestamp: 2025-12-03T09:36:01.527Z
Learning: Repo: magicblock-labs/magicblock-validator
File: magicblock-chainlink/src/remote_account_provider/mod.rs
Context: consolidate_fetched_remote_accounts
Learning: For unexpected result counts (>2), the project prefers logging an error and returning an empty Vec over panicking; acceptable during development per maintainer (Dodecahedr0x).

Applied to files:

  • test-integration/test-committor-service/tests/test_ix_commit_local.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
📚 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
📚 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/buffer_task.rs
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs (2)
magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1)
  • visit_buffer_task (68-107)
magicblock-committor-service/src/tasks/visitor.rs (1)
  • visit_buffer_task (5-5)
magicblock-committor-service/src/tasks/args_task.rs (3)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • value (216-221)
magicblock-committor-service/src/intent_executor/mod.rs (1)
  • value (80-88)
magicblock-committor-service/src/intent_executor/error.rs (2)
  • value (120-132)
  • value (247-255)
⏰ 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). (9)
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
🔇 Additional comments (12)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

312-318: LGTM!

Expanding the random generation ranges from 5..10 to 5..100 for bids and asks increases test coverage and better exercises the CommitDiff functionality with larger data changes, which aligns well with this PR's objective of supporting larger commits via BufferTask.

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

134-138: LGTM!

The change to emit BufferTaskType::CommitDiff(value) directly instead of converting to a Commit task preserves the CommitDiff semantics throughout the buffer path. This is the core change that enables executing CommitDiff as BufferTask without degrading to CommitState, which aligns perfectly with the PR objectives.

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

19-37: LGTM!

The refactoring from if let guards to explicit pattern matching clearly handles both Commit and CommitDiff variants to extract commit metadata. The logic correctly populates CommitMeta with the same fields for both variants, enabling the utility visitor to work uniformly with the new CommitDiff support.


39-56: LGTM!

The visit_buffer_task implementation mirrors the visit_args_task pattern and correctly handles both BufferTaskType::Commit and BufferTaskType::CommitDiff to extract commit metadata.

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

26-66: LGTM with note on existing feedback.

The refactoring correctly handles both ArgsTaskType::Commit and ArgsTaskType::CommitDiff by invoking set_commit_strategy with appropriate parameters. The error handling logic is duplicated between the two variants, which was already flagged in previous review comments suggesting extraction to a helper method for improved maintainability.


68-107: LGTM with note on existing feedback.

The visit_buffer_task implementation follows the same pattern as visit_args_task and correctly persists the commit strategy for both BufferTaskType::Commit and BufferTaskType::CommitDiff. As with the Args variant, the duplication was noted in previous reviews.

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

52-84: LGTM!

The preparation_required method correctly handles both Commit and CommitDiff variants:

  • For Commit: uses full account data and derives chunks from data length
  • For CommitDiff: computes diff, derives chunks from diff length, and sets committed_data to the diff

This implementation properly supports the BufferTask workflow for CommitDiff, with the diff serving as the buffer content that will be chunked and written. The compute_diff argument order (base, committed) is correct per previous review feedback.


87-98: LGTM!

The From<ArgsTaskType> implementation correctly maps both Commit and CommitDiff variants to their corresponding BufferTaskType variants, with appropriate error handling for unsupported task types.


100-146: LGTM!

The instruction() method correctly generates instructions for both task types:

  • Commit: uses commit_state_from_buffer
  • CommitDiff: uses commit_diff_from_buffer

Both variants properly:

  1. Derive the buffer PDA from validator, pubkey, and commit_id
  2. Pass the correct arguments including nonce, lamports, and allow_undelegation flag

The instruction generation aligns with the preparation logic where the buffer contains either full state or diff data.


195-212: LGTM!

The reset_commit_id method correctly handles both Commit and CommitDiff variants, updating the commit_id and triggering re-preparation when the ID changes. The early return optimization avoids unnecessary work when the ID is unchanged.


215-222: LGTM!

The LabelValue implementation correctly provides distinct metric labels for Commit ("buffer_commit") and CommitDiff ("buffer_commit_diff"), enabling proper observability for the different code paths.

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

338-344: The FromBufferWithLookupTable strategy is already verified in other tests with larger bundle sizes (bundle_size=4, bundle_size=6, bundle_size=8, and tests with 20 accounts), so its functionality with CommitDiff is confirmed. The simplification to all Args for bundle_size=3 appears to be the expected strategy selection for that configuration—not an anomaly. No action needed.


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
Author

snawaz commented Nov 6, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@snawaz snawaz requested a review from GabrielePicco November 6, 2025 05:23
@snawaz snawaz marked this pull request as ready for review November 6, 2025 05:23
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 4 times, most recently from dd95c9a to 4a09180 Compare November 10, 2025 06:35
@snawaz snawaz force-pushed the snawaz/commit-diff branch 2 times, most recently from 4ea5450 to 41493c5 Compare November 10, 2025 07:00
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 2 times, most recently from 17f396e to 3259f79 Compare November 17, 2025 05:57
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 385e7a3 to 3999503 Compare November 17, 2025 05:59
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 2 times, most recently from 23a797e to 64d79cc Compare November 17, 2025 06:16
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 3999503 to 256ab3f Compare November 17, 2025 06:16
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 2 times, most recently from 5838b75 to e182eb1 Compare November 17, 2025 10:31
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 59b7935 to c07a177 Compare November 17, 2025 10:31
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 2 times, most recently from 18adf1e to 5b95cad Compare November 17, 2025 13:36
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 9da0edd to cf6229d Compare November 17, 2025 13:36
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 2 times, most recently from 2aada37 to 2eb5776 Compare November 18, 2025 12:36
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 9be6a8a to b94a549 Compare November 21, 2025 18:44
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 7d6f839 to faed161 Compare November 21, 2025 21:24
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 74155a6 to 280eeb7 Compare November 21, 2025 21:34
@snawaz snawaz force-pushed the snawaz/commit-diff branch 2 times, most recently from 9c11945 to a42745b Compare November 21, 2025 23:52
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 280eeb7 to e3ce6e6 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: 2

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

561-586: Tests still serialize Args-style commit instructions for BufferTask; add coverage for buffer strategy and *_from_buffer builders

test_buffer_task_instruction_serialization constructs BufferTaskType::Commit with a CommitTask from CommitTaskBuilder::create_commit_task(...), which still defaults to TaskStrategy::Args. Because BufferTask::instruction() now just delegates to CommitTask::create_commit_ix(), this test ends up exercising the Args path (plain commit_state / commit_diff) rather than the new buffer-based commit_*_from_buffer instructions.

To actually cover the buffer paths and the new buffer instruction builders, update the test to either:

  • call switch_to_buffer_strategy() on the CommitTask before wrapping it in BufferTaskType::Commit, or
  • construct a CommitTask with TaskStrategy::Buffer via the builder or a helper, and assert that create_commit_ix() produces the expected *_from_buffer variants.

This aligns the test with the intended semantics of BufferTask and gives direct coverage of the new buffer commit flows.

📜 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 cbbf5ee and e3ce6e6.

⛔ 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 (6)
  • Cargo.toml (1 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (1 hunks)
  • magicblock-committor-service/src/tasks/buffer_task.rs (2 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (5 hunks)
  • test-integration/Cargo.toml (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
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.
📚 Learning: 2025-10-26T16:54:39.084Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 587
File: test-manual/Cargo.toml:0-0
Timestamp: 2025-10-26T16:54:39.084Z
Learning: In the magicblock-validator repository, use git branch references (not commit hashes or tags) for the helius-laserstream dependency to allow automatic updates when the branch is pushed to.

Applied to files:

  • Cargo.toml
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

  • magicblock-committor-service/src/tasks/mod.rs
🧬 Code graph analysis (3)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)
test-integration/programs/schedulecommit/src/order_book.rs (1)
  • bids (182-184)
magicblock-committor-service/src/tasks/buffer_task.rs (3)
magicblock-committor-program/src/state/chunks.rs (1)
  • from_data_length (46-49)
magicblock-committor-service/src/tasks/mod.rs (1)
  • optimize (78-80)
magicblock-committor-service/src/tasks/args_task.rs (1)
  • optimize (87-100)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/persist/types/commit_strategy.rs (1)
  • args (17-23)
🔇 Additional comments (6)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

256-262: Change is appropriate for stress-testing the BufferTask implementation.

The 10x increase in test data (max 200 entries vs. 20 previously) aligns with the PR's goal of validating CommitDiff as BufferTask for large accounts. Verification confirms:

  • CI runs on extra-large runner with adequate resources
  • No explicit test timeout configured (relies on GitHub Actions default 360-minute limit)
  • Test is intentionally "huge" and properly instrumented with seed output for reproducibility

No environment capacity concerns identified.

Cargo.toml (1)

112-114: Delegation-program git rev bump looks consistent; verify compatibility with new buffer commit instructions

The new magicblock-delegation-program rev is pinned consistently here and in test-integration/Cargo.toml, and the feature set is unchanged ("no-entrypoint"), so workspace wiring looks good. Please just confirm this rev contains the *_from_buffer commit instructions your new CommitTask buffer paths rely on and that integration tests pass against it.

test-integration/Cargo.toml (1)

60-62: Test workspace dependency aligned with root; ensure integration tests cover new buffer commit paths

The magicblock-delegation-program rev here matches the root workspace and keeps "no-entrypoint", so dependency alignment looks correct. Please make sure the updated integration tests actually exercise the new buffer-based commit/diff paths against this program version.

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

91-95: Commit optimization correctly switches to Buffer strategy before wrapping in BufferTask

Routing ArgsTaskType::Commit through value.switch_to_buffer_strategy() before constructing BufferTaskType::Commit ensures that optimized commit tasks consistently take the buffer-based path (and thus use the new *_from_buffer instructions). This aligns with the new TaskStrategy design and fixes the prior need for ad‑hoc flags.

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

55-59: TaskStrategy + CommitTask refactor gives a clean two-path model (Args vs Buffer)

Introducing TaskStrategy and threading it through CommitTask (with CommitTaskBuilder defaulting to Args and switch_to_buffer_strategy() for buffer flows) makes the commit behavior explicit and removes the previous ad‑hoc flagging. The create_commit_ix() match on (strategy, base_account) cleanly encodes:

  • Args + no base account → CommitState.
  • Args + base account → CommitDiff.
  • Buffer + no base account → CommitStateFromBuffer.
  • Buffer + base account → CommitDiffFromBuffer.

This layout is straightforward to reason about and aligns well with the PR’s goal of supporting CommitDiff via BufferTask without degrading to CommitState purely due to transaction-size constraints.

Also applies to: 149-167, 169-193


4-6: I'll search the public magicblock repositories to verify the API contract.

I need to search for the actual source code of the delegation-program repository to verify the API contract. Let me look for the specific function signatures.

Based on my web search for the magicblock-delegation-program repository, I was unable to access the specific source code details needed to verify the API contract. The searches returned the repository index and documentation pages, but not the actual function signatures for commit_state_from_buffer, commit_diff_from_buffer, or the CommitStateFromBufferArgs struct definition.

To properly verify the concerns raised in this review comment, you would need to:

  1. Review the delegation-program repository source code (specifically the instruction builders and args modules) to confirm that both commit_state_from_buffer and commit_diff_from_buffer accept the same CommitStateFromBufferArgs struct
  2. Examine the on-chain processor implementations to verify that buffer contents are interpreted consistently as either full state or diff bytes, matching how BufferTask::preparation_required prepares them
  3. Confirm the buffer PDA derivation uses the same parameters across all functions

The original concern about the API contract alignment is valid and warrants manual verification against the actual dlp crate implementation.

Verify that commit_state_from_buffer and commit_diff_from_buffer in the dlp crate both accept CommitStateFromBufferArgs, and confirm the on-chain handlers interpret buffer contents consistently with how BufferTask prepares them (lines 244-293 and related code).

@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from e3ce6e6 to 044c9cf Compare December 16, 2025 09:08
@snawaz snawaz force-pushed the snawaz/commit-diff branch from a42745b to 00b3b98 Compare December 16, 2025 09:08
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

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

221-243: Reuse compute_diff() to avoid duplicate diff computation logic.

The inline compute_diff call at lines 229-232 duplicates the logic already encapsulated in self.compute_diff(). Consider delegating to the method for consistency.

Based on past review comments, apply this refactor to reuse the existing method:

 fn create_commit_diff_ix(
     &self,
     validator: &Pubkey,
     base_account: &Account,
 ) -> Instruction {
+    let diff = self
+        .compute_diff()
+        .expect("base_account must be Some when using CommitDiff");
+
     let args = CommitDiffArgs {
         nonce: self.commit_id,
         lamports: self.committed_account.account.lamports,
-        diff: compute_diff(
-            base_account.data(),
-            self.committed_account.account.data(),
-        )
-        .to_vec(),
+        diff: diff.to_vec(),
         allow_undelegation: self.allow_undelegation,
     };

     dlp::instruction_builder::commit_diff(
         *validator,
         self.committed_account.pubkey,
         self.committed_account.account.owner,
         args,
     )
 }

563-587: Add test coverage for buffer instruction builders.

The test_buffer_task_instruction_serialization test constructs CommitTask via CommitTaskBuilder::create_commit_task(), which defaults to TaskStrategy::Args. Since the test never calls switch_to_buffer_strategy(), it never exercises the new create_commit_state_from_buffer_ix and create_commit_diff_from_buffer_ix paths.

Based on past review comments, update the test to cover buffer paths:

 #[tokio::test]
 async fn test_buffer_task_instruction_serialization() {
     let validator = Pubkey::new_unique();

+    // Test with buffer strategy to exercise buffer instruction builders
     let buffer_task =
         BufferTask::new_preparation_required(BufferTaskType::Commit(
             CommitTaskBuilder::create_commit_task(
                 456,
                 false,
                 CommittedAccount {
                     pubkey: Pubkey::new_unique(),
                     account: Account {
                         lamports: 2000,
                         data: vec![7, 8, 9],
                         owner: Pubkey::new_unique(),
                         executable: false,
                         rent_epoch: 0,
                     },
                 },
                 &Arc::new(NullTaskInfoFetcher),
             )
-            .await,
+            .await
+            .switch_to_buffer_strategy(),
         ));
     assert_serializable(&buffer_task.instruction(&validator));
 }
📜 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 e3ce6e6 and 044c9cf.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/tasks/args_task.rs (1 hunks)
  • magicblock-committor-service/src/tasks/buffer_task.rs (2 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (5 hunks)
  • test-integration/Cargo.toml (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

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

Applied to files:

  • test-integration/Cargo.toml
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/buffer_task.rs (3)
magicblock-committor-program/src/state/chunks.rs (1)
  • from_data_length (46-49)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • value (162-169)
  • optimize (92-105)
magicblock-committor-service/src/tasks/mod.rs (1)
  • optimize (79-81)
magicblock-committor-service/src/tasks/mod.rs (1)
magicblock-committor-service/src/persist/types/commit_strategy.rs (1)
  • args (17-23)
🔇 Additional comments (9)
magicblock-committor-service/src/tasks/args_task.rs (1)

96-99: LGTM! Clean refactoring to use buffer strategy switching.

The simplified logic correctly switches to buffer strategy before wrapping in BufferTaskType::Commit, eliminating the need for special-case handling. This aligns with the PR objectives to support CommitDiff as a BufferTask without degrading to CommitState.

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

49-61: LGTM! Diff-aware state computation correctly supports CommitDiff as BufferTask.

The logic now computes diff when available and uses it for both chunking and buffer preparation, which directly addresses the PR objective of supporting CommitDiff as a BufferTask without degrading to CommitState.

Note: The main flow in args_task.rs line 98 correctly calls switch_to_buffer_strategy() before constructing BufferTask, ensuring the strategy is set properly.


69-69: LGTM! Unified instruction creation simplifies the code.

Replacing manual PDA-based instruction assembly with value.create_commit_ix(validator) delegates to the CommitTask's strategy-aware instruction creation, making the code cleaner and more maintainable.

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

4-4: LGTM! TaskStrategy is now unconditionally public to support the two-strategy architecture.

Making TaskStrategy public enables the Args/Buffer strategy pattern throughout the codebase, which is essential for the new buffer-based commit flow.

Also applies to: 56-60


155-155: LGTM! Strategy field replaces force_commit_state with explicit Args/Buffer control.

The new strategy field provides clearer control over instruction generation compared to the previous force_commit_state flag, aligning with the PR's goal of supporting CommitDiff as a BufferTask.

Also applies to: 165-167


170-173: LGTM! Strategy switching method provides clean transition to buffer path.

The switch_to_buffer_strategy() method enables explicit control over strategy transitions, used by ArgsTask::optimize() to move commits to the buffer path.


175-194: LGTM! Strategy-aware instruction dispatch correctly routes Args vs Buffer paths.

The branching on self.strategy with nested checks for base_account ensures the correct instruction builder is called for each combination (Args with diff/state, Buffer with diff/state from buffer).


197-204: LGTM! Centralized diff computation reduces code duplication.

The compute_diff() method provides a single point for diff computation logic, used by BufferTask during preparation. This is good for maintainability.


245-268: LGTM! Buffer-based commit state instruction correctly uses buffer PDA.

The implementation properly derives the buffer PDA and constructs the instruction with CommitStateFromBufferArgs, aligning with how PreparationTask initializes and writes buffer data.

@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch 3 times, most recently from eff43ea to 646ab8b Compare December 19, 2025 17:58
@snawaz snawaz force-pushed the snawaz/commit-diff branch from 61b7a03 to 54a1a4c Compare December 19, 2025 17:58
@snawaz snawaz changed the base branch from snawaz/commit-diff to graphite-base/616 December 20, 2025 04:52
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 646ab8b to 171b9dc Compare December 20, 2025 08:54
@snawaz snawaz changed the base branch from graphite-base/616 to snawaz/commit-diff December 20, 2025 08:54
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

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

50-82: Verify CommitTask has Buffer strategy when constructing BufferTask.

As noted in the past review comment, BufferTask construction should ensure the embedded CommitTask (or CommitDiffTask) has the correct strategy. While ArgsTask::optimize calls switch_to_buffer_strategy() before wrapping, other construction paths (including tests) might not. Consider adding a debug assertion or making this self-contained.

📜 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 646ab8b and 171b9dc.

⛔ 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 (8)
  • Cargo.toml (1 hunks)
  • magicblock-committor-service/src/tasks/args_task.rs (1 hunks)
  • magicblock-committor-service/src/tasks/buffer_task.rs (7 hunks)
  • magicblock-committor-service/src/tasks/mod.rs (0 hunks)
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (2 hunks)
  • magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs (1 hunks)
  • test-integration/Cargo.toml (1 hunks)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1 hunks)
💤 Files with no reviewable changes (1)
  • magicblock-committor-service/src/tasks/mod.rs
🧰 Additional context used
🧠 Learnings (7)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

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

Applied to files:

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

Applied to files:

  • Cargo.toml
  • test-integration/Cargo.toml
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

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

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/buffer_task.rs
🧬 Code graph analysis (2)
magicblock-committor-service/src/tasks/args_task.rs (1)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • value (203-208)
magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs (2)
magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1)
  • visit_buffer_task (68-107)
magicblock-committor-service/src/tasks/visitor.rs (1)
  • visit_buffer_task (5-5)
🔇 Additional comments (7)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

306-312: LGTM: Expanded test data range enhances coverage for CommitDiff scenarios.

The increase from 5..10 to 5..100 for both bids and asks provides better coverage of varying data sizes and diff complexities, which is valuable for exercising the new CommitDiff buffer path introduced in this PR.

Cargo.toml (1)

98-100: Dependency update supports the new CommitDiffFromBuffer instruction.

The revision update to ea1f2f916268132248fe8d5de5f07d76765dd937 aligns with the delegation-program PR #118 mentioned in the PR description, which implements the CommitDiffFromBuffer instruction required by this feature.

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

134-138: LGTM: CommitDiff now optimizes to BufferTaskType::CommitDiff instead of degrading to Commit.

This change implements the core PR objective: CommitDiff is now executed as a BufferTask directly, avoiding the previous degradation to CommitState. The optimization path correctly wraps the CommitDiffTask in BufferTaskType::CommitDiff.

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

22-36: LGTM: Explicit pattern matching ensures CommitMeta extraction for both Commit and CommitDiff.

The refactor from conditional logic to explicit pattern matching correctly handles both CommitDiff and Commit variants, ensuring commit metadata is properly extracted for both task types.


42-55: LGTM: BufferTask visitor properly handles both Commit and CommitDiff variants.

Consistent with the ArgsTask visitor changes, this correctly extracts commit metadata for both Commit and CommitDiff buffer tasks.

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

109-129: LGTM: CommitDiff instruction handling mirrors Commit path with commit_diff_from_buffer.

The instruction construction for CommitDiff correctly:

  • Derives the same buffer PDA as the Commit path
  • Uses commit_diff_from_buffer instead of commit_state_from_buffer
  • Passes identical CommitStateFromBufferArgs structure

This maintains consistency with the preparation and buffer writing logic.


183-196: LGTM: reset_commit_id properly handles both Commit and CommitDiff variants.

The implementation correctly updates the commit_id field for both task variants and triggers re-preparation by calling preparation_required. The early return optimization when the commit_id hasn't changed is a nice touch.

@snawaz snawaz changed the base branch from snawaz/commit-diff to graphite-base/616 December 20, 2025 14:33
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 171b9dc to 2f514f5 Compare December 22, 2025 09:00
@snawaz snawaz changed the base branch from graphite-base/616 to snawaz/commit-diff December 22, 2025 09:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

67-82: CRITICAL: compute_diff argument order is reversed.

The compute_diff call in buffer_task.rs (lines 68-70) has arguments in the opposite order compared to the original implementation in args_task.rs:

  • buffer_task.rs: compute_diff(&task.committed_account.account.data, &task.base_account.data) → (committed, base)
  • args_task.rs: compute_diff(value.base_account.data(), value.committed_account.account.data()) → (base, committed)

The correct order is (base, committed) to compute what changed from the base state to the committed state. This inconsistency will produce inverted diffs, leading to incorrect commit operations.

             BufferTaskType::CommitDiff(task) => {
                 let diff = compute_diff(
-                    &task.committed_account.account.data,
-                    &task.base_account.data,
+                    &task.base_account.data,
+                    &task.committed_account.account.data,
                 )
                 .to_vec();
🧹 Nitpick comments (1)
magicblock-committor-service/src/tasks/buffer_task.rs (1)

100-143: Consider refactoring to reduce code duplication.

The Commit and CommitDiff branches have identical logic except for the final instruction builder call (commit_state_from_buffer vs commit_diff_from_buffer). Consider extracting the common logic to reduce duplication.

🔎 Example refactoring approach
 fn instruction(&self, validator: &Pubkey) -> Instruction {
-        match &self.task_type {
-            BufferTaskType::Commit(task) => {
-                let commit_id_slice = task.commit_id.to_le_bytes();
-                let (commit_buffer_pubkey, _) =
-                    magicblock_committor_program::pdas::buffer_pda(
-                        validator,
-                        &task.committed_account.pubkey,
-                        &commit_id_slice,
-                    );
-
-                dlp::instruction_builder::commit_state_from_buffer(
-                    *validator,
-                    task.committed_account.pubkey,
-                    task.committed_account.account.owner,
-                    commit_buffer_pubkey,
-                    CommitStateFromBufferArgs {
-                        nonce: task.commit_id,
-                        lamports: task.committed_account.account.lamports,
-                        allow_undelegation: task.allow_undelegation,
-                    },
-                )
-            }
-            BufferTaskType::CommitDiff(task) => {
-                let commit_id_slice = task.commit_id.to_le_bytes();
-                let (commit_buffer_pubkey, _) =
-                    magicblock_committor_program::pdas::buffer_pda(
-                        validator,
-                        &task.committed_account.pubkey,
-                        &commit_id_slice,
-                    );
-
-                dlp::instruction_builder::commit_diff_from_buffer(
-                    *validator,
-                    task.committed_account.pubkey,
-                    task.committed_account.account.owner,
-                    commit_buffer_pubkey,
-                    CommitStateFromBufferArgs {
-                        nonce: task.commit_id,
-                        lamports: task.committed_account.account.lamports,
-                        allow_undelegation: task.allow_undelegation,
-                    },
-                )
-            }
+        let (task_commit_id, task_pubkey, task_owner, task_lamports, task_allow_undelegation, is_diff) = match &self.task_type {
+            BufferTaskType::Commit(task) => (
+                task.commit_id,
+                task.committed_account.pubkey,
+                task.committed_account.account.owner,
+                task.committed_account.account.lamports,
+                task.allow_undelegation,
+                false,
+            ),
+            BufferTaskType::CommitDiff(task) => (
+                task.commit_id,
+                task.committed_account.pubkey,
+                task.committed_account.account.owner,
+                task.committed_account.account.lamports,
+                task.allow_undelegation,
+                true,
+            ),
+        };
+
+        let commit_id_slice = task_commit_id.to_le_bytes();
+        let (commit_buffer_pubkey, _) = magicblock_committor_program::pdas::buffer_pda(
+            validator,
+            &task_pubkey,
+            &commit_id_slice,
+        );
+
+        let args = CommitStateFromBufferArgs {
+            nonce: task_commit_id,
+            lamports: task_lamports,
+            allow_undelegation: task_allow_undelegation,
+        };
+
+        if is_diff {
+            dlp::instruction_builder::commit_diff_from_buffer(
+                *validator,
+                task_pubkey,
+                task_owner,
+                commit_buffer_pubkey,
+                args,
+            )
+        } else {
+            dlp::instruction_builder::commit_state_from_buffer(
+                *validator,
+                task_pubkey,
+                task_owner,
+                commit_buffer_pubkey,
+                args,
+            )
         }
     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 171b9dc and 2f514f5.

📒 Files selected for processing (7)
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
  • magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs
  • test-integration/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
💤 Files with no reviewable changes (1)
  • magicblock-committor-service/src/tasks/mod.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
  • magicblock-committor-service/src/tasks/args_task.rs
  • test-integration/Cargo.toml
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-12-03T09:33:48.707Z
Learnt from: Dodecahedr0x
Repo: magicblock-labs/magicblock-validator PR: 639
File: test-integration/test-committor-service/tests/test_ix_commit_local.rs:867-881
Timestamp: 2025-12-03T09:33:48.707Z
Learning: Repo: magicblock-labs/magicblock-validator PR: 639
Context: test-integration/test-committor-service/tests/test_ix_commit_local.rs (ix_commit_local)
Learning: The PhotonIndexer used for compressed account fetches (get_compressed_account) has built‑in retry logic (defaults to ~10 attempts), so tests should not add separate retry loops around compressed fetches unless there’s a specific need.

Applied to files:

  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.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/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.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/buffer_task.rs
🧬 Code graph analysis (3)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)
test-integration/test-committor-service/tests/test_ix_commit_local.rs (3)
  • map (455-455)
  • map (470-470)
  • map (480-480)
magicblock-committor-service/src/tasks/buffer_task.rs (2)
magicblock-committor-service/src/tasks/args_task.rs (2)
  • task_type (177-185)
  • optimize (125-143)
magicblock-committor-program/src/state/chunks.rs (1)
  • from_data_length (48-51)
magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs (2)
magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs (1)
  • visit_buffer_task (68-107)
magicblock-committor-service/src/tasks/visitor.rs (1)
  • visit_buffer_task (5-5)
⏰ 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). (10)
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: run_make_ci_lint
  • GitHub Check: run_make_ci_test
  • GitHub Check: Build Project
  • GitHub Check: run_make_ci_format
🔇 Additional comments (9)
test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs (1)

306-312: Test data expansion appropriately stresses the BufferTask CommitDiff implementation.

The expanded ranges for order book entries (from 5..10 to 5..100) increase test coverage from ~20 to ~200 total entries per test run. The seed-based reproducibility mechanism ensures deterministic failure investigation. Existing transaction confirmation retry logic (40 attempts over ~20 seconds) adequately handles the increased data volume.

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

1-1: LGTM!

The compute_diff import is necessary for computing diffs in the CommitDiff path.


24-24: LGTM!

The addition of the CommitDiff variant follows the existing pattern and enables CommitDiff to be executed as a BufferTask.


172-176: LGTM!

The compute units for CommitDiff match Commit at 70,000, which is reasonable since both operations involve similar buffer-based commitment logic.


183-188: LGTM!

Mapping CommitDiff to TaskType::Commit is correct and consistent with the args_task.rs implementation.


196-212: LGTM!

The reset_commit_id implementation correctly handles both Commit and CommitDiff variants, ensuring the commit_id is updated and preparation state is recalculated.


215-222: LGTM!

The distinct label value "buffer_commit_diff" for CommitDiff enables proper differentiation in metrics and observability, which is valuable for monitoring the new commit path.

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

19-37: LGTM!

The match statement correctly handles both Commit and CommitDiff variants for extracting CommitMeta. The identical logic for both variants could be simplified using a guard pattern, but the current implementation is clear and maintainable.

💡 Optional: Simplify using match guards

If you want to reduce duplication, consider:

match &task.task_type {
    ArgsTaskType::Commit(task) | ArgsTaskType::CommitDiff(task) => {
        *commit_meta = Some(CommitMeta {
            committed_pubkey: task.committed_account.pubkey,
            commit_id: task.commit_id,
        })
    }
    _ => *commit_meta = None,
}

However, this requires that both CommitTask and CommitDiffTask have identical field structures for committed_account and commit_id.


39-56: LGTM!

The match statement correctly handles both Commit and CommitDiff variants for BufferTask, maintaining consistency with the visit_args_task implementation.

@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 2f514f5 to 632a4f9 Compare December 22, 2025 09:32
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

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

35-63: Duplication already flagged in previous review.

The duplicated error handling logic between Commit and CommitDiff variants was already identified in a previous review. Please address the earlier suggestion to extract the shared persist-and-log logic into a helper method.


77-104: Duplication already flagged in previous review.

The duplicated error handling pattern here mirrors the same issue in visit_args_task. Both were identified in previous reviews and can benefit from the same helper function extraction.

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

93-95: Update panic message to reflect CommitDiff support.

The panic message states "Only commit task can be BufferTask currently," but now both Commit and CommitDiff are supported. Consider updating for clarity.

🔎 Suggested message update
-            _ => unimplemented!(
-                "Only commit task can be BufferTask currently. Fix your tests"
-            ),
+            _ => unimplemented!(
+                "Only Commit and CommitDiff tasks can be BufferTask. Fix your tests"
+            ),
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f514f5 and 632a4f9.

📒 Files selected for processing (7)
  • magicblock-committor-service/src/tasks/args_task.rs
  • magicblock-committor-service/src/tasks/buffer_task.rs
  • magicblock-committor-service/src/tasks/mod.rs
  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
  • magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs
  • test-integration/Cargo.toml
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
💤 Files with no reviewable changes (1)
  • magicblock-committor-service/src/tasks/mod.rs
🚧 Files skipped from review as they are similar to previous changes (3)
  • test-integration/schedulecommit/test-scenarios/tests/02_commit_and_undelegate.rs
  • magicblock-committor-service/src/tasks/task_visitors/utility_visitor.rs
  • test-integration/Cargo.toml
🧰 Additional context used
🧠 Learnings (3)
📚 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/buffer_task.rs
📚 Learning: 2025-11-21T10:22:07.520Z
Learnt from: taco-paco
Repo: magicblock-labs/magicblock-validator PR: 661
File: magicblock-committor-service/src/intent_executor/single_stage_executor.rs:20-28
Timestamp: 2025-11-21T10:22:07.520Z
Learning: In magicblock-committor-service's SingleStageExecutor and TwoStageExecutor (single_stage_executor.rs and two_stage_executor.rs), the fields transaction_strategy, junk, and patched_errors are intentionally public because these executors are designed to be used independently outside of the IntentExecutor scope, and callers need access to these execution reports for cleanup and error handling.

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/task_visitors/persistor_visitor.rs
🧬 Code graph analysis (1)
magicblock-committor-service/src/tasks/args_task.rs (1)
magicblock-committor-service/src/tasks/buffer_task.rs (1)
  • value (216-221)
⏰ 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). (7)
  • GitHub Check: Build Project
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: Graphite / mergeability_check
  • GitHub Check: run_make_ci_test
  • GitHub Check: run_make_ci_lint
🔇 Additional comments (5)
magicblock-committor-service/src/tasks/args_task.rs (1)

134-137: LGTM! Correctly implements direct CommitDiff optimization.

The change properly implements the PR objective by emitting BufferTaskType::CommitDiff(value) directly instead of degrading to CommitTask. This aligns with the new CommitDiff variant support added in buffer_task.rs.

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

52-84: LGTM! Preparation logic correctly handles both Commit and CommitDiff.

The preparation logic appropriately:

  • Uses full account data and creates chunks based on data length for Commit
  • Computes diff (with correct argument order) and creates chunks based on diff length for CommitDiff

Both paths correctly set committed_data to what will be written to the buffer.


100-145: LGTM! Instruction generation correctly handles both variants.

The implementation properly:

  • Uses commit_state_from_buffer for Commit tasks
  • Uses commit_diff_from_buffer for CommitDiff tasks
  • Both share the same args structure (CommitStateFromBufferArgs), with the instruction type determining how the buffer contents are interpreted on-chain

This aligns with the related delegation-program PR #118 that implements the CommitDiffFromBuffer instruction.


171-187: LGTM! Compute units and task type mappings are consistent.

The CommitDiff variant correctly:

  • Uses the same compute units (70,000) as Commit, which is appropriate given similar on-chain processing
  • Maps to TaskType::Commit, maintaining consistency with the Commit variant

195-221: LGTM! Reset and labeling logic correctly updated.

The implementation properly:

  • Handles reset_commit_id for both Commit and CommitDiff variants with early returns for unchanged IDs
  • Re-derives preparation state after commit_id changes
  • Provides consistent label naming: "buffer_commit_diff" follows the established pattern

@snawaz snawaz changed the base branch from snawaz/commit-diff to graphite-base/616 December 22, 2025 15:43
@snawaz snawaz force-pushed the snawaz/commit-diff-buffer branch from 632a4f9 to e0844fd Compare December 22, 2025 18:40
@snawaz snawaz changed the base branch from graphite-base/616 to snawaz/commit-diff December 22, 2025 18:40
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.

2 participants