Skip to content

refactor: outbox intent program - #1430

Open
taco-paco wants to merge 14 commits into
feat/mimd-0025/mainfrom
feat/mimd-0025/outbox-intent-program
Open

refactor: outbox intent program#1430
taco-paco wants to merge 14 commits into
feat/mimd-0025/mainfrom
feat/mimd-0025/outbox-intent-program

Conversation

@taco-paco

@taco-paco taco-paco commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Extract Outbox intent logic into separate program. As new patching functionality and maybe more will come this will allow us to keep magic-program itself smaller from outbox related things

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • New Features

    • Added dedicated handling for creating, closing, notifying, and updating outbox-intent accounts.
    • Updated instruction flows and account ownership to use the dedicated outbox-intent program.
    • Registered the outbox-intent program for reliable processing and cross-program calls.
  • Bug Fixes

    • Improved account protection, blacklisting, scanning, and ownership checks.
    • Deprecated the previous scheduled-commit notification path.
  • Tests

    • Added commit-sent status validation and signature reporting to integration tests.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d15942ec-d02d-4b42-8f02-01843eab710a

📥 Commits

Reviewing files that changed from the base of the PR and between cb4da46 and c356151.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • Cargo.toml

📝 Walkthrough

Walkthrough

The change introduces a dedicated outbox intent program with its own program ID, instruction enum, builtin entrypoint, PDA derivation, account ownership, and CPI flows. Scheduled commit, acceptance, creation, closure, and execution-stage operations are routed through the new program and ephemeral system program. Module exports, validators, readers, test utilities, unit tests, integration result tracking, and Solana dependency revisions are updated accordingly.

Suggested reviewers: gabrielepicco, snawaz

Mergeability Score: ⚪ Minimal · up to c3561

This refactor has no supplied evidence of a concrete behavior, dependency, deployment, or runtime problem; no actionable merge-blocking risk remains after normal checks and review.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mimd-0025/outbox-intent-program

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-magic-program-api/src/instruction.rs`:
- Around line 62-64: Update the public account-layout documentation near the
scheduling commit instructions to describe five fixed accounts in order:
validator, outbox program, magic context, vault, and ephemeral system program.
Change the documented PDA starting index from 4 to 5 so it matches the
processor’s expected layout.

In `@programs/magicblock/src/outbox_intent/process_create_outbox_intent.rs`:
- Around line 44-50: In the create-outbox-intent flow, validate that the PDA
account data length matches data.len() before calling copy_from_slice. Return
the appropriate instruction error on mismatch, and retain the existing copy
behavior only when lengths match to prevent a validator panic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: aedfbb5c-cd71-4e59-b8a1-97c0a4bdee3e

📥 Commits

Reviewing files that changed from the base of the PR and between 20b7d6d and 6cdfc50.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (24)
  • Cargo.toml
  • magicblock-accounts-db/src/reset.rs
  • magicblock-chainlink/src/chainlink/blacklisted_accounts.rs
  • magicblock-committor-service/src/outbox/outbox_intent_bundles_reader.rs
  • magicblock-core/src/intent/outbox.rs
  • magicblock-magic-program-api/src/instruction.rs
  • magicblock-magic-program-api/src/lib.rs
  • magicblock-processor/src/builtins.rs
  • programs/magicblock/src/intent_bundles/mod.rs
  • programs/magicblock/src/intent_bundles/process_accept_scheduled_commits.rs
  • programs/magicblock/src/intent_bundles/schedule/mod.rs
  • programs/magicblock/src/intent_bundles/schedule/process_schedule_commit_tests.rs
  • programs/magicblock/src/lib.rs
  • programs/magicblock/src/magicblock_processor.rs
  • programs/magicblock/src/outbox_intent/mod.rs
  • programs/magicblock/src/outbox_intent/outbox_intent_bundles.rs
  • programs/magicblock/src/outbox_intent/process_create_outbox_intent.rs
  • programs/magicblock/src/outbox_intent/process_scheduled_commit_sent.rs
  • programs/magicblock/src/outbox_intent/process_set_intent_execution_stage.rs
  • programs/magicblock/src/test_utils/mod.rs
  • programs/magicblock/src/utils/instruction_utils.rs
  • test-integration/Cargo.toml
  • test-integration/test-schedule-intent/tests/test_schedule_intents.rs
  • test-integration/test-tools/src/scheduled_commits.rs

Comment thread magicblock-magic-program-api/src/instruction.rs
Comment thread programs/magicblock/src/outbox_intent/process_create_outbox_intent.rs Outdated
…program

# Conflicts:
#	Cargo.toml
#	test-integration/Cargo.toml
…program

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	magicblock-magic-program-api/src/instruction.rs
#	programs/magicblock/src/intent_bundles/schedule/mod.rs
#	programs/magicblock/src/magicblock_processor.rs
#	programs/magicblock/src/outbox_intent/mod.rs
#	programs/magicblock/src/outbox_intent/process_close_outbox_intent.rs
#	programs/magicblock/src/outbox_intent/process_scheduled_commit_sent.rs
#	test-integration/Cargo.lock
#	test-integration/Cargo.toml

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@magicblock-magic-program-api/src/instruction.rs`:
- Around line 431-438: Update the account documentation for CloseOutboxIntent so
account index 1 is identified as the Ephemeral System Program and uses
EPHEMERAL_SYSTEM_PROGRAM_ID, matching process_close_outbox_intent::validate and
InstructionUtils::close_outbox_intent_instruction; leave the remaining account
entries unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ec5627af-108b-482f-b0e9-5c99d8fb4f5b

📥 Commits

Reviewing files that changed from the base of the PR and between 50df170 and 1ffe4ef.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • test-integration/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • Cargo.toml
  • magicblock-magic-program-api/src/instruction.rs
  • programs/magicblock/src/magicblock_processor.rs
  • programs/magicblock/src/outbox_intent/mod.rs
  • programs/magicblock/src/outbox_intent/outbox_intent_bundles.rs
  • programs/magicblock/src/outbox_intent/process_close_outbox_intent.rs
  • programs/magicblock/src/outbox_intent/process_scheduled_commit_sent.rs
  • programs/magicblock/src/utils/instruction_utils.rs
  • test-integration/Cargo.toml

Comment thread magicblock-magic-program-api/src/instruction.rs
@bmuddha
bmuddha removed their request for review August 12, 2026 18:17
@github-actions

Copy link
Copy Markdown
Contributor

redsuite: PR vs feat/mimd-0025/main

Single-run diff on shared runners — indicative only; statistical verdicts come from Bencher thresholds.

redline/clone_lru_churn/cap360
  read latency us                    median 95 → 450 (+373.7%)  p95 1146 → 3254 (+183.9%)  ▲ worse
  (8 flat/mixed/info metric(s) not shown)

redline/clone_lru_churn/closure
  read latency us                    median 95 → 362 (+281.1%)  p95 143 → 617 (+331.5%)  ▲ worse
  (8 flat/mixed/info metric(s) not shown)

redline/commit_width_envelope/w2
  er delivery us                     median 395 → 1421 (+259.7%)  p95 523 → 1667 (+218.7%)  ▲ worse
  (6 flat/mixed/info metric(s) not shown)

redline/commit_width_envelope/w4
  er delivery us                     median 467 → 1112 (+138.1%)  p95 580 → 1290 (+122.4%)  ▲ worse
  (6 flat/mixed/info metric(s) not shown)

redline/ensure_gate_stall/healthy
  delivery us                        median 172 → 565 (+228.5%)  p95 246 → 989 (+302.0%)  ▲ worse
  (6 flat/mixed/info metric(s) not shown)

redline/protocol_boundary_selftest/threads4
  delivery us                        median 157 → 372 (+136.9%)  p95 219 → 760 (+247.0%)  ▲ worse
  (2 flat/mixed/info metric(s) not shown)

redline/rpc_capacity_blast
  delivery us                        median 10096 → 4444 (-56.0%)  p95 64776 → 29893 (-53.9%)  ▼ better
  (6 flat/mixed/info metric(s) not shown)

redline/storage_prodsize_sustain/prod_cadence
  window A delivery us               median 167 → 366 (+119.2%)  p95 239 → 686 (+187.0%)  ▲ worse
  window B delivery us               median 165 → 414 (+150.9%)  p95 228 → 728 (+219.3%)  ▲ worse
  window B validator tx avg us       71.7 → 144.9 (+102.0%)  ▲ worse
  (6 flat/mixed/info metric(s) not shown)

9 metric(s) worse than base

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectmagicblock-labs
Branchfeat/mimd-0025/outbox-intent-program
Testbedblacksmith-8vcpu-ubuntu-2404

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

🐰 View full continuous benchmarking report in Bencher

@snawaz snawaz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall, the idea and impl look good.

However, the new program should be moved to its own crate, physically separating from magic program. Apart from that, we can move more instructions (at least Accept* ix) from magic-program to outbox-program.

@@ -73,17 +74,8 @@ pub enum MagicBlockInstruction {
/// - **4..n** `[WRITE]` Outbox intent PDAs, one per accepted intent, seeds: `["outbox-intent", intent_id.to_le_bytes()]`
AcceptScheduleCommits,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think AcceptScheduleCommits should also be moved to Outbox program.

It's at the boundary. So I guess it can be in either program, but since it's practically an internal ix, we can move it too. That way eventually the magic-program will have public facing instructions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The problem is that you can't modify MagicContext from outbox-program without CPIing into magic-program. For me this make outbox have a control of magic program which I think should be the other way around, hence the current implementation


let outbox_candidates_iter = self.accounts_db.get_program_accounts(
&magicblock_program::ID,
&magicblock_program::OUTBOX_INTENT_PROGRAM_ID,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The path magicblock_program::OUTBOX_INTENT_PROGRAM_ID looks weird. That feels like outbox program is a child program of the magic program.

Why dont we physically separate outbox program into its own crate? It'll be better in the long run, with clean boundaries. The paths will also look sensible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree, I created a similiar #1431 for that some time ago. But I considered refactoring out of scope this PR. Especially when reviewers ask for a more atomic changes.
This can be done in another PR.

…program

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	magicblock-accounts-db/src/reset.rs
#	magicblock-chainlink/src/chainlink/blacklisted_accounts.rs
#	magicblock-committor-service/src/outbox/outbox_intent_bundles_reader.rs
#	magicblock-processor/src/builtins.rs
#	programs/magicblock/src/intent_bundles/process_accept_scheduled_commits.rs
#	programs/magicblock/src/intent_bundles/schedule/mod.rs
#	programs/magicblock/src/intent_bundles/schedule/process_schedule_commit_tests.rs
#	programs/magicblock/src/lib.rs
#	programs/magicblock/src/magicblock_processor.rs
#	programs/magicblock/src/outbox_intent/process_close_outbox_intent.rs
#	programs/magicblock/src/outbox_intent/process_scheduled_commit_sent.rs
#	programs/magicblock/src/test_utils/mod.rs
#	programs/magicblock/src/utils/instruction_utils.rs
#	test-integration/Cargo.lock
#	test-integration/Cargo.toml
…program

# Conflicts:
#	programs/magicblock/src/outbox_intent/process_close_outbox_intent.rs
#	programs/magicblock/src/outbox_intent/process_scheduled_commit_sent.rs
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