Skip to content

Commit 9d49a9d

Browse files
committed
Use CommitPolicy and call commit_diff version from the test propgram
1 parent a6ebcd3 commit 9d49a9d

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

magicblock-accounts/src/scheduled_commits_processor.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ impl<C: BaseIntentCommittor> ScheduledCommitsProcessorImpl<C> {
357357
excluded_pubkeys: intent_meta.excluded_pubkeys,
358358
feepayers: intent_meta.feepayers,
359359
requested_undelegation: intent_meta.requested_undelegation,
360+
commit_diff: intent_meta.commit_diff,
360361
}
361362
}
362363
}
@@ -424,6 +425,7 @@ struct ScheduledBaseIntentMeta {
424425
feepayers: HashSet<FeePayerAccount>,
425426
intent_sent_transaction: Transaction,
426427
requested_undelegation: bool,
428+
commit_diff: bool,
427429
}
428430

429431
impl ScheduledBaseIntentMeta {
@@ -443,6 +445,7 @@ impl ScheduledBaseIntentMeta {
443445
feepayers,
444446
intent_sent_transaction: intent.action_sent_transaction.clone(),
445447
requested_undelegation: intent.is_undelegate(),
448+
commit_diff: intent.is_commit_diff(),
446449
}
447450
}
448451
}

programs/magicblock/src/magic_scheduled_base_intent.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ impl ScheduledBaseIntent {
101101
self.base_intent.is_undelegate()
102102
}
103103

104+
pub fn is_commit_diff(&self) -> bool {
105+
self.base_intent.is_commit_diff()
106+
}
107+
104108
pub fn is_empty(&self) -> bool {
105109
self.base_intent.is_empty()
106110
}
@@ -148,6 +152,16 @@ impl MagicBaseIntent {
148152
}
149153
}
150154

155+
pub fn is_commit_diff(&self) -> bool {
156+
match &self {
157+
MagicBaseIntent::BaseActions(_) => false,
158+
MagicBaseIntent::Commit(c) => c.is_commit_diff(),
159+
MagicBaseIntent::CommitAndUndelegate(c) => {
160+
c.commit_action.is_commit_diff()
161+
}
162+
}
163+
}
164+
151165
fn get_committed_accounts(&self) -> Option<&Vec<CommittedAccount>> {
152166
match self {
153167
MagicBaseIntent::BaseActions(_) => None,

programs/magicblock/src/schedule_transactions/process_scheduled_commit_sent.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct SentCommit {
2828
pub excluded_pubkeys: Vec<Pubkey>,
2929
pub feepayers: HashSet<FeePayerAccount>,
3030
pub requested_undelegation: bool,
31+
pub commit_diff: bool,
3132
}
3233

3334
/// This is a printable version of the SentCommit struct.
@@ -43,6 +44,7 @@ struct SentCommitPrintable {
4344
excluded_pubkeys: String,
4445
feepayers: String,
4546
requested_undelegation: bool,
47+
commit_diff: bool,
4648
}
4749

4850
impl From<SentCommit> for SentCommitPrintable {
@@ -76,6 +78,7 @@ impl From<SentCommit> for SentCommitPrintable {
7678
.collect::<Vec<_>>()
7779
.join(", "),
7880
requested_undelegation: commit.requested_undelegation,
81+
commit_diff: commit.commit_diff,
7982
}
8083
}
8184
}
@@ -223,6 +226,9 @@ pub fn process_scheduled_commit_sent(
223226
if commit.requested_undelegation {
224227
ic_msg!(invoke_context, "ScheduledCommitSent requested undelegation",);
225228
}
229+
if commit.commit_diff {
230+
ic_msg!(invoke_context, "ScheduledCommitSent requested commit_diff",);
231+
}
226232

227233
Ok(())
228234
}

test-integration/programs/flexi-counter/src/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ fn process_add_and_schedule_commit(
342342
// Request the PDA counter account to be committed
343343
if undelegate {
344344
msg!("invoke commit_and_undelegate_accounts");
345-
commit_and_undelegate_accounts(
345+
commit_diff_and_undelegate_accounts(
346346
payer_info,
347347
vec![counter_pda_info],
348348
magic_context_info,

test-integration/programs/schedulecommit-security/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use borsh::{BorshDeserialize, BorshSerialize};
2-
use ephemeral_rollups_sdk::ephem::create_schedule_commit_ix;
2+
use ephemeral_rollups_sdk::ephem::{create_schedule_commit_ix, CommitPolicy};
33
use program_schedulecommit::{
44
api::schedule_commit_cpi_instruction, process_schedulecommit_cpi,
55
ProcessSchedulecommitCpiArgs,
@@ -146,6 +146,7 @@ fn process_sibling_schedule_cpis(
146146
magic_context,
147147
magic_program,
148148
false,
149+
CommitPolicy::UseFullBytes,
149150
);
150151
invoke(
151152
&direct_ix,

0 commit comments

Comments
 (0)