refactor: rename Magic base actions to pre/post action semantics#1267
refactor: rename Magic base actions to pre/post action semantics#1267snawaz wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis PR refactors base-layer action naming across the MagicBlock validator to improve semantic clarity. It renames Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/stubs/changeset_committor_stub.rs (1)
254-297:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winInclude finalize intents in callback counting.
count_bundle_callbacksstill ignoresib.commit_finalizeandib.commit_finalize_and_undelegate. Bundles that carryBasePostActionsthere will get a shortercallbacks_reportfrom this stub than the real executor produces.Proposed fix
fn count_bundle_callbacks(bundle: &ScheduledIntentBundle) -> usize { let ib = &bundle.intent_bundle; + let count_actions = + |actions: &[magicblock_program::magic_scheduled_base_intent::BaseAction]| { + actions.iter().filter(|a| a.callback.is_some()).count() + }; + let count_commit = |ct: &CommitType| match ct { + CommitType::Standalone(_) => 0, + CommitType::BasePostActions { base_post_actions, .. } => { + count_actions(base_post_actions) + } + }; + let count_undelegate = |ut: &UndelegateType| match ut { + UndelegateType::Standalone => 0, + UndelegateType::BasePostActions(actions) => count_actions(actions), + }; - let from_commit = ib - .commit - .as_ref() - .map(|ct| match ct { - CommitType::Standalone(_) => 0, - CommitType::BasePostActions { - base_post_actions, .. - } => base_post_actions - .iter() - .filter(|a| a.callback.is_some()) - .count(), - }) - .unwrap_or(0); + let from_commit = ib.commit.as_ref().map(count_commit).unwrap_or(0); let from_cau = ib .commit_and_undelegate .as_ref() - .map(|cau| { - let from_commit_action = match &cau.commit_action { - CommitType::Standalone(_) => 0, - CommitType::BasePostActions { - base_post_actions, .. - } => base_post_actions - .iter() - .filter(|a| a.callback.is_some()) - .count(), - }; - let from_undelegate = match &cau.undelegate_action { - UndelegateType::Standalone => 0, - UndelegateType::BasePostActions(actions) => { - actions.iter().filter(|a| a.callback.is_some()).count() - } - }; - from_commit_action + from_undelegate - }) + .map(|cau| count_commit(&cau.commit_action) + count_undelegate(&cau.undelegate_action)) + .unwrap_or(0); + + let from_commit_finalize = ib + .commit_finalize + .as_ref() + .map(count_commit) + .unwrap_or(0); + + let from_commit_finalize_and_undelegate = ib + .commit_finalize_and_undelegate + .as_ref() + .map(|cau| count_commit(&cau.commit_action) + count_undelegate(&cau.undelegate_action)) .unwrap_or(0); let from_base_pre_actions = ib .base_pre_actions .iter() - .filter(|a| a.callback.is_some()) - .count(); + .filter(|a| a.callback.is_some()) + .count(); - from_commit + from_cau + from_base_pre_actions + from_commit + + from_cau + + from_commit_finalize + + from_commit_finalize_and_undelegate + + from_base_pre_actions }🤖 Prompt for 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. In `@magicblock-committor-service/src/stubs/changeset_committor_stub.rs` around lines 254 - 297, count_bundle_callbacks currently sums callbacks from ib.commit, ib.commit_and_undelegate, and ib.base_pre_actions but omits ib.commit_finalize and ib.commit_finalize_and_undelegate; update the logic to include those two by mirroring the existing counting approach: for ib.commit_finalize (and for the commit part of ib.commit_finalize_and_undelegate) count BasePostActions entries with a Some(callback) similar to how from_commit/from_cau are computed, and for commit_finalize_and_undelegate also add the undelegate part (counting actions with callback.is_some()) so the total includes finalize intents; reference the existing variables/branches handling CommitType::BasePostActions and UndelegateType::BasePostActions to implement this.
🤖 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.
Outside diff comments:
In `@magicblock-committor-service/src/stubs/changeset_committor_stub.rs`:
- Around line 254-297: count_bundle_callbacks currently sums callbacks from
ib.commit, ib.commit_and_undelegate, and ib.base_pre_actions but omits
ib.commit_finalize and ib.commit_finalize_and_undelegate; update the logic to
include those two by mirroring the existing counting approach: for
ib.commit_finalize (and for the commit part of
ib.commit_finalize_and_undelegate) count BasePostActions entries with a
Some(callback) similar to how from_commit/from_cau are computed, and for
commit_finalize_and_undelegate also add the undelegate part (counting actions
with callback.is_some()) so the total includes finalize intents; reference the
existing variables/branches handling CommitType::BasePostActions and
UndelegateType::BasePostActions to implement this.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 69750cb7-1f2c-42bc-9b42-21705d20ff37
📒 Files selected for processing (11)
magicblock-committor-service/src/intent_executor/mod.rsmagicblock-committor-service/src/persist/commit_persister.rsmagicblock-committor-service/src/stubs/changeset_committor_stub.rsmagicblock-committor-service/src/tasks/task_builder.rsmagicblock-magic-program-api/src/args.rsmagicblock-magic-program-api/src/instruction.rsprograms/magicblock/src/magic_scheduled_base_intent.rsprograms/magicblock/src/schedule_transactions/process_schedule_commit_tests.rstest-integration/programs/flexi-counter/src/processor/schedule_intent.rstest-integration/test-committor-service/tests/test_intent_executor.rstest-integration/test-committor-service/tests/test_transaction_preparator.rs

Summary
Breaking Changes
Test Plan
Summary by CodeRabbit
Documentation
Chores