Skip to content

Commit b3bfe59

Browse files
committed
Add CommitType::StandaloneDiff
1 parent a346694 commit b3bfe59

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ impl TasksBuilder for TaskBuilderImpl {
138138
CommitType::Standalone(accounts) => {
139139
accounts.iter().map(finalize_task).collect()
140140
}
141+
CommitType::StandaloneDiff(accounts) => {
142+
accounts.iter().map(finalize_task).collect()
143+
}
141144
CommitType::WithBaseActions {
142145
committed_accounts,
143146
base_actions,

programs/magicblock/src/magic_scheduled_base_intent.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ impl<'a> From<CommittedAccountRef<'a>> for CommittedAccount {
303303
pub enum CommitType {
304304
/// Regular commit without actions
305305
Standalone(Vec<CommittedAccount>), // accounts to commit
306+
StandaloneDiff(Vec<CommittedAccount>), // accounts to commit
306307
/// Commits accounts and runs actions
307308
WithBaseActions {
308309
committed_accounts: Vec<CommittedAccount>,
@@ -432,6 +433,7 @@ impl CommitType {
432433
pub fn get_committed_accounts(&self) -> &Vec<CommittedAccount> {
433434
match self {
434435
Self::Standalone(committed_accounts) => committed_accounts,
436+
Self::StandaloneDiff(committed_accounts) => committed_accounts,
435437
Self::WithBaseActions {
436438
committed_accounts, ..
437439
} => committed_accounts,
@@ -441,6 +443,7 @@ impl CommitType {
441443
pub fn get_committed_accounts_mut(&mut self) -> &mut Vec<CommittedAccount> {
442444
match self {
443445
Self::Standalone(committed_accounts) => committed_accounts,
446+
Self::StandaloneDiff(committed_accounts) => committed_accounts,
444447
Self::WithBaseActions {
445448
committed_accounts, ..
446449
} => committed_accounts,
@@ -452,6 +455,9 @@ impl CommitType {
452455
Self::Standalone(committed_accounts) => {
453456
committed_accounts.is_empty()
454457
}
458+
Self::StandaloneDiff(committed_accounts) => {
459+
committed_accounts.is_empty()
460+
}
455461
Self::WithBaseActions {
456462
committed_accounts, ..
457463
} => committed_accounts.is_empty(),

programs/magicblock/src/magicblock_processor.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare_process_instruction!(
4141
invoke_context,
4242
ProcessScheduleCommitOptions {
4343
request_undelegation: false,
44+
request_diff: false,
4445
},
4546
),
4647
MagicBlockInstruction::ScheduleCommitAndUndelegate => {
@@ -49,6 +50,7 @@ declare_process_instruction!(
4950
invoke_context,
5051
ProcessScheduleCommitOptions {
5152
request_undelegation: true,
53+
request_diff: false,
5254
},
5355
)
5456
}
@@ -76,7 +78,14 @@ declare_process_instruction!(
7678
process_process_tasks(signers, invoke_context)
7779
}
7880
MagicBlockInstruction::ScheduleCommitDiffAndUndelegate => {
79-
todo!();
81+
process_schedule_commit(
82+
signers,
83+
invoke_context,
84+
ProcessScheduleCommitOptions {
85+
request_undelegation: true,
86+
request_diff: true,
87+
},
88+
)
8089
}
8190
}
8291
}

programs/magicblock/src/schedule_transactions/process_schedule_commit.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::{
2828
#[derive(Default)]
2929
pub(crate) struct ProcessScheduleCommitOptions {
3030
pub request_undelegation: bool,
31+
pub request_diff: bool,
3132
}
3233

3334
pub(crate) fn process_schedule_commit(
@@ -220,13 +221,19 @@ pub(crate) fn process_schedule_commit(
220221
InstructionUtils::scheduled_commit_sent(intent_id, blockhash);
221222
let commit_sent_sig = action_sent_transaction.signatures[0];
222223

224+
let commit_action = if opts.request_diff {
225+
CommitType::StandaloneDiff(committed_accounts)
226+
} else {
227+
CommitType::Standalone(committed_accounts)
228+
};
229+
223230
let base_intent = if opts.request_undelegation {
224231
MagicBaseIntent::CommitAndUndelegate(CommitAndUndelegate {
225-
commit_action: CommitType::Standalone(committed_accounts),
232+
commit_action,
226233
undelegate_action: UndelegateType::Standalone,
227234
})
228235
} else {
229-
MagicBaseIntent::Commit(CommitType::Standalone(committed_accounts))
236+
MagicBaseIntent::Commit(commit_action)
230237
};
231238
let scheduled_base_intent = ScheduledBaseIntent {
232239
id: intent_id,

0 commit comments

Comments
 (0)