Skip to content

Conversation

@taco-paco
Copy link
Contributor

@taco-paco taco-paco commented Dec 3, 2025

  1. Parallel task building for commit & finalize stage
  2. Execution mode without ALTs always preferred, even if will tale 2 TXs
  3. Removed unnecessary chain requests

#684

Summary by CodeRabbit

  • New Features

    • Configurable task execution strategies (single-stage and two-stage) with ability to inspect ALT usage; parallel task preparation for better throughput.
  • Bug Fixes

    • Improved error logging for failed commit operations with additional context.
  • Chores

    • Simplified lookup-table and buffer preparation; removed some timing capture calls.
  • Tests

    • Updated unit and integration tests and test helpers to reflect new strategy behavior and updated expectations.

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

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

Manual Deploy Available

You can trigger a manual deploy of this PR branch to testnet:

Deploy to Testnet 🚀

Alternative: Comment /deploy on this PR to trigger deployment directly.

⚠️ Note: Manual deploy requires authorization. Only authorized users can trigger deployments.

Comment updated automatically when the PR is synchronized.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 3, 2025

📝 Walkthrough

Walkthrough

Replaces single-transaction unification with a strategy-driven execution flow by adding TaskStrategist::build_execution_strategy and the StrategyExecutionMode enum (SingleStage / TwoStage), runs commit and finalize task builders in parallel, and exposes ALT-usage inspection APIs. Simplifies delivery preparation by removing chunked account deserialization and timer stop calls. Updates test helpers to support undelegate intents (is_undelegate flag). Expands commit-failure logging in build_sent_commit to include intent_id, slot, and blockhash.

Possibly related PRs

Suggested reviewers

  • thlorenz
  • bmuddha
  • Dodecahedr0x
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/base-layer-ix/speedup-execution

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

Caution

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

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

728-775: Missing imports for CommitAndUndelegate and UndelegateType.

The function uses CommitAndUndelegate and UndelegateType::Standalone at lines 763-766, but these types are not imported within the function's use block (lines 733-739) or at the module level.

Add the missing imports:

 #[cfg(test)]
 pub(crate) fn create_test_intent(
     id: u64,
     pubkeys: &[Pubkey],
     is_undelegate: bool,
 ) -> ScheduledBaseIntentWrapper {
     use magicblock_program::magic_scheduled_base_intent::{
-        CommitType, CommittedAccount, MagicBaseIntent,
+        CommitAndUndelegate, CommitType, CommittedAccount, MagicBaseIntent,
+        UndelegateType,
     };
📜 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 02fd8fe and 299b133.

📒 Files selected for processing (7)
  • magicblock-accounts/src/scheduled_commits_processor.rs (1 hunks)
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (8 hunks)
  • magicblock-committor-service/src/intent_execution_manager/intent_scheduler.rs (15 hunks)
  • magicblock-committor-service/src/intent_executor/mod.rs (5 hunks)
  • magicblock-committor-service/src/tasks/task_strategist.rs (3 hunks)
  • magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (3 hunks)
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 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-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-accounts/src/scheduled_commits_processor.rs
  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_executor/mod.rs
📚 Learning: 2025-10-21T14:00:54.642Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 578
File: magicblock-aperture/src/requests/websocket/account_subscribe.rs:18-27
Timestamp: 2025-10-21T14:00:54.642Z
Learning: In magicblock-aperture account_subscribe handler (src/requests/websocket/account_subscribe.rs), the RpcAccountInfoConfig fields data_slice, commitment, and min_context_slot are currently ignored—only encoding is applied. This is tracked as technical debt in issue #579: https://github.com/magicblock-labs/magicblock-validator/issues/579

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/tasks/task_strategist.rs
📚 Learning: 2025-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

  • magicblock-committor-service/src/tasks/task_strategist.rs
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs
📚 Learning: 2025-11-04T10:53:50.922Z
Learnt from: bmuddha
Repo: magicblock-labs/magicblock-validator PR: 589
File: magicblock-processor/src/scheduler/locks.rs:110-122
Timestamp: 2025-11-04T10:53:50.922Z
Learning: In magicblock-processor, the TransactionScheduler runs in a single, dedicated thread and will always remain single-threaded. The `next_transaction_id()` function in scheduler/locks.rs uses `unsafe static mut` which is safe given this architectural guarantee.

Applied to files:

  • magicblock-committor-service/src/intent_execution_manager/intent_scheduler.rs
🧬 Code graph analysis (2)
magicblock-accounts/src/scheduled_commits_processor.rs (1)
test-integration/test-tools/src/conversions.rs (1)
  • err (8-8)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (2)
magicblock-metrics/src/metrics/mod.rs (2)
  • observe_committor_intent_task_preparation_time (556-564)
  • observe_committor_intent_alt_preparation_time (566-568)
magicblock-committor-service/src/tasks/mod.rs (1)
  • write_instructions (187-204)
🔇 Additional comments (12)
magicblock-accounts/src/scheduled_commits_processor.rs (1)

283-284: LGTM! Improved error logging for better observability.

Adding the intent_id to the error log makes it easier to trace and debug commit failures by correlating them with specific intents. The format is correct and consistent with other logging patterns in the file.

magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (2)

68-73: Timer handling change looks correct.

The _timer pattern relies on HistogramTimer::drop() to call stop_and_record() automatically when the timer goes out of scope. This is idiomatic for Prometheus histogram timers and ensures timing is recorded even if early returns occur.


400-402: Good optimization to short-circuit ALT preparation.

Early return when no lookup table keys are needed avoids unnecessary table_mania operations. This aligns well with the PR's goal of preferring execution modes without ALTs.

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

246-256: Test expectation correctly updated for new execution strategy.

The change from expecting FromBufferWithLookupTable + FromBuffer to only FromBuffer reflects the PR's optimization: preferring two-stage execution without ALTs over single-stage with ALTs, since ALT activation latency is significant.

This aligns with the build_execution_strategy logic that checks if !single_stage_strategy.uses_alts() before falling back to two-stage.

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

434-438: Test helper signature update applied consistently.

All create_test_intent calls correctly pass false for the new is_undelegate parameter, maintaining existing test behavior. This is a mechanical update following the test helper signature change.

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

312-321: Test updates are consistent and maintain existing behavior.

All test invocations correctly pass false for is_undelegate, preserving the original test semantics while enabling the new capability for undelegate scenario testing elsewhere.

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

187-202: Parallel task building is a good optimization.

Using join to build commit and finalize tasks concurrently is efficient. The error handling with (commit_tasks?, finalize_tasks?) correctly propagates any errors from either future.


204-233: Clean execution strategy pattern matching.

The branching on StrategyExecutionMode is well-structured:

  • SingleStage path reuses the existing single_stage_execution_flow
  • TwoStage path properly destructures commit and finalize stages

The trace logging at lines 212 and 224 provides good observability for debugging execution mode selection.


163-184: Standalone actions path correctly uses simpler strategy builder.

For intents without committed accounts (BaseActions), building only commit tasks and using build_strategy directly is correct since there's no finalize stage needed.

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

44-68: Well-designed execution mode abstraction.

The uses_alts() methods on both TransactionStrategy and StrategyExecutionMode provide clean introspection for ALT usage. The enum clearly captures the two execution paths with appropriate data for each.


124-142: ALT avoidance logic correctly implements the optimization.

The decision flow is sound:

  1. If single-stage doesn't need ALTs → use it (fastest)
  2. If single-stage needs ALTs but two-stage doesn't → use two-stage (avoids ALT latency)
  3. If both need ALTs → use single-stage (fewer transactions)

The inline comment at lines 129-131 clearly documents the rationale about ALT activation latency.


394-416: MockInfoFetcher implementation is appropriate for unit tests.

The mock provides predictable responses for task building without requiring actual chain state. The implementation correctly satisfies the TaskInfoFetcher trait requirements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

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

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

430-436: create_test_intent signature updates look consistent

All updated call sites now pass false for the new is_undelegate flag, which keeps these engine tests exercising the original “commit-only” behavior while matching the new helper signature. This aligns with the helper’s semantics (undelegate only when explicitly requested) and avoids unintentionally changing what these tests cover. You may later want a dedicated engine test exercising is_undelegate = true, but nothing is blocking here.

Also applies to: 452-457, 475-482, 503-509, 537-544, 571-580, 605-612, 666-676

♻️ Duplicate comments (1)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (1)

78-82: Same timer verification needed as lines 68-74.

This segment has the same timer pattern change as lines 68-74. Please ensure the timer guard behavior is confirmed for both metrics observations.

📜 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 f2a2217 and 8ebb4c9.

📒 Files selected for processing (4)
  • magicblock-committor-service/src/intent_execution_manager/intent_execution_engine.rs (8 hunks)
  • magicblock-committor-service/src/intent_executor/mod.rs (5 hunks)
  • magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (3 hunks)
  • test-integration/test-committor-service/tests/test_ix_commit_local.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 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-11-19T09:34:37.917Z
Learnt from: thlorenz
Repo: magicblock-labs/magicblock-validator PR: 621
File: test-integration/test-chainlink/tests/ix_remote_account_provider.rs:62-63
Timestamp: 2025-11-19T09:34:37.917Z
Learning: In test-integration/test-chainlink/tests/ix_remote_account_provider.rs and similar test files, the `_fwd_rx` receiver returned by `init_remote_account_provider()` is intentionally kept alive (but unused) to prevent "receiver dropped" errors on the sender side. The pattern `let (remote_account_provider, _fwd_rx) = init_remote_account_provider().await;` should NOT be changed to `let (remote_account_provider, _) = ...` because dropping the receiver would cause send() operations to fail.

Applied to files:

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

Applied to files:

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

Applied to files:

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

Applied to files:

  • magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs
🧬 Code graph analysis (1)
magicblock-committor-service/src/intent_executor/mod.rs (2)
magicblock-committor-service/src/tasks/task_builder.rs (4)
  • commit_tasks (26-30)
  • commit_tasks (46-104)
  • finalize_tasks (33-36)
  • finalize_tasks (107-199)
magicblock-committor-service/src/tasks/task_strategist.rs (1)
  • build_execution_strategy (77-143)
🔇 Additional comments (4)
magicblock-committor-service/src/transaction_preparator/delivery_preparator.rs (3)

240-256: LGTM! Valid optimization removing unnecessary RPC call.

The simplification directly uses preparation_task.chunks instead of fetching and deserializing the on-chain chunks PDA. Since chunks represents the immutable source data to be written (not on-chain state tracking), this eliminates an unnecessary RPC call while preserving correctness.


400-403: LGTM! Good optimization for the no-ALT case.

The early return when lookup_table_keys is empty avoids unnecessary HashSet construction and TableMania operations, improving performance when address lookup tables are not needed.


68-74: No action required. The timer guard behavior is correct as implemented.

HistogramTimer from the prometheus crate is a RAII guard that records metrics automatically when dropped. The _timer binding keeps the guard in scope through the async block execution, and it will record timing data when the block exits. This follows the established pattern elsewhere in the codebase (e.g., magicblock-aperture/src/requests/http/send_transaction.rs). The underscore prefix correctly signals that the binding is held intentionally for its side effects rather than being unused.

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

140-185: Execution-mode selection via StrategyExecutionMode is wired correctly

The new execute_inner flow cleanly separates intents with and without committed pubkeys:

  • For intents without committed pubkeys (e.g., MagicBaseIntent::BaseActions), you build tasks via TaskBuilderImpl::commit_tasks and immediately feed them into TaskStrategist::build_strategy for a single‑stage path. That matches the behavior of commit_tasks for BaseActions (pure Args/BaseAction tasks) and keeps these intents out of the two‑stage machinery.
  • For intents with committed pubkeys, you delegate the choice between single‑stage and two‑stage execution to TaskStrategist::build_execution_strategy, then branch on StrategyExecutionMode and call either single_stage_execution_flow or two_stage_execution_flow using the previously extracted committed_pubkeys.

This preserves the existing CPI‑limit fallback (still handled inside single_stage_execution_flow) and centralizes strategy selection per the new API, without changing how two_stage_execution_flow is driven. The layering looks sound. One thing to double‑check is that get_committed_pubkeys() never returns None for a Commit/CommitAndUndelegate intent with “empty but semantically meaningful” commits; otherwise those would now be routed through the BaseActions branch and skip status persistence.

Also applies to: 204-233

Comment on lines +187 to +202
// Build tasks for commit & finalize stages
let (commit_tasks, finalize_tasks) = {
let commit_tasks_fut = TaskBuilderImpl::commit_tasks(
&self.task_info_fetcher,
&base_intent,
persister,
);
let finalize_tasks_fut = TaskBuilderImpl::finalize_tasks(
&self.task_info_fetcher,
&base_intent,
);
let (commit_tasks, finalize_tasks) =
join(commit_tasks_fut, finalize_tasks_fut).await;

(commit_tasks?, finalize_tasks?)
};
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

Parallel commit/finalize task building is fine, but consider try_join to avoid extra work on errors

Building commit and finalize task lists in parallel with:

let (commit_tasks, finalize_tasks) =
    join(commit_tasks_fut, finalize_tasks_fut).await;
let (commit_tasks, finalize_tasks) = (commit_tasks?, finalize_tasks?);

correctly overlaps the two builder futures and matches the intent of the new strategy‑selection flow. However:

  • join will always await both futures to completion, even if one returns an error; you then early‑return on the first ?, but any side effects of the other builder (extra RPC fetches, rent reimbursement lookups, etc.) have already happened.
  • If you’d prefer to short‑circuit work and side effects when one builder fails, using futures_util::future::try_join or tokio::try_join! over the same two futures would preserve behavior while avoiding unnecessary work on failing paths.

Also worth confirming that TaskInfoFetcher and the underlying builders are safe to call concurrently on the shared Arc (they look read‑oriented from the snippets, so this is likely fine).

Copy link
Contributor

@bmuddha bmuddha left a comment

Choose a reason for hiding this comment

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

Nice optimizations

@taco-paco taco-paco merged commit 63e3b90 into master Dec 5, 2025
18 checks passed
@taco-paco taco-paco deleted the feat/base-layer-ix/speedup-execution branch December 5, 2025 04:41
thlorenz added a commit that referenced this pull request Dec 5, 2025
* master:
  Some optimizations for intent execution (#711)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants