Skip to content

Commit 2bafa8e

Browse files
authored
feat: allow custom discriminator in actions (#574)
Users have bad UX with hardcoded discriminator in dlp. Right now users have to define a fixed entrypoint with fixed discriminator. This is cumbersome and not flexible. This pr adapts changes made in dlp [PR](magicblock-labs/delegation-program#105) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - Refactor - Reworked scheduling/handler flow: replaced redelegation-intent path with explicit commit and undelegate action handlers. - Removed legacy redelegation payload types and simplified call dispatch. - Eliminated unused context data from task payloads. - Tests - Updated tests to match new action shapes; redelegation intent test path disabled. - Chores - Updated workspace dependency revisions (no feature changes). <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 36fb2d6 commit 2bafa8e

File tree

20 files changed

+285
-455
lines changed

20 files changed

+285
-455
lines changed

Cargo.lock

Lines changed: 65 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ magicblock-config = { path = "./magicblock-config" }
124124
magicblock-config-helpers = { path = "./magicblock-config-helpers" }
125125
magicblock-config-macro = { path = "./magicblock-config-macro" }
126126
magicblock-core = { path = "./magicblock-core" }
127-
magicblock-delegation-program = { git = "https://github.com/magicblock-labs/delegation-program.git", rev = "5fb8d20", features = [
127+
magicblock-delegation-program = { git = "https://github.com/magicblock-labs/delegation-program.git", rev = "aa1de56d90c", features = [
128128
"no-entrypoint",
129129
] }
130130
magicblock-geyser-plugin = { path = "./magicblock-geyser-plugin" }

magicblock-committor-service/src/intent_executor/error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ impl TransactionStrategyExecutionError {
119119
) -> Self {
120120
// There's always 2 budget instructions in front
121121
const OFFSET: u8 = 2;
122-
const OUTDATED_SLOT: u32 = dlp::error::DlpError::OutdatedSlot as u32;
122+
const NONCE_OUT_OF_ORDER: u32 =
123+
dlp::error::DlpError::NonceOutOfOrder as u32;
123124

124125
match err {
125126
// Filter CommitIdError by custom error code
126127
transaction_err @ TransactionError::InstructionError(
127128
_,
128-
InstructionError::Custom(OUTDATED_SLOT),
129+
InstructionError::Custom(NONCE_OUT_OF_ORDER),
129130
) => TransactionStrategyExecutionError::CommitIDError(
130131
transaction_err,
131132
),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ impl BaseTask for ArgsTask {
8989
action.escrow_authority,
9090
account_metas,
9191
CallHandlerArgs {
92-
context: value.context,
9392
data: action.data_per_program.data.clone(),
9493
escrow_index: action.data_per_program.escrow_index,
9594
},

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use dlp::args::Context;
21
use dyn_clone::DynClone;
32
use magicblock_committor_program::{
43
instruction_builder::{
@@ -119,7 +118,6 @@ pub struct FinalizeTask {
119118

120119
#[derive(Clone)]
121120
pub struct BaseActionTask {
122-
pub context: Context,
123121
pub action: BaseAction,
124122
}
125123

@@ -346,7 +344,6 @@ mod serialization_safety_test {
346344

347345
// Test BaseAction variant
348346
let base_action: ArgsTask = ArgsTaskType::BaseAction(BaseActionTask {
349-
context: Context::Undelegate,
350347
action: BaseAction {
351348
destination_program: Pubkey::new_unique(),
352349
escrow_authority: Pubkey::new_unique(),

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::sync::Arc;
22

33
use async_trait::async_trait;
4-
use dlp::args::Context;
54
use log::error;
65
use magicblock_program::magic_scheduled_base_intent::{
76
CommitType, CommittedAccount, MagicBaseIntent, ScheduledBaseIntent,
@@ -53,10 +52,7 @@ impl TasksBuilder for TaskBuilderImpl {
5352
let tasks = actions
5453
.iter()
5554
.map(|el| {
56-
let task = BaseActionTask {
57-
context: Context::Standalone,
58-
action: el.clone(),
59-
};
55+
let task = BaseActionTask { action: el.clone() };
6056
let task =
6157
ArgsTask::new(ArgsTaskType::BaseAction(task));
6258
Box::new(task) as Box<dyn BaseTask>
@@ -148,7 +144,6 @@ impl TasksBuilder for TaskBuilderImpl {
148144
.collect::<Vec<_>>();
149145
tasks.extend(base_actions.iter().map(|action| {
150146
let task = BaseActionTask {
151-
context: Context::Commit,
152147
action: action.clone(),
153148
};
154149
let task =
@@ -188,7 +183,6 @@ impl TasksBuilder for TaskBuilderImpl {
188183
UndelegateType::WithBaseActions(actions) => {
189184
tasks.extend(actions.iter().map(|action| {
190185
let task = BaseActionTask {
191-
context: Context::Undelegate,
192186
action: action.clone(),
193187
};
194188
let task =

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ pub type TaskStrategistResult<T, E = TaskStrategistError> = Result<T, E>;
249249

250250
#[cfg(test)]
251251
mod tests {
252-
use dlp::args::Context;
253252
use magicblock_program::magic_scheduled_base_intent::{
254253
BaseAction, CommittedAccount, ProgramArgs,
255254
};
@@ -283,7 +282,6 @@ mod tests {
283282
// Helper to create a Base action task
284283
fn create_test_base_action_task(len: usize) -> ArgsTask {
285284
ArgsTask::new(ArgsTaskType::BaseAction(BaseActionTask {
286-
context: Context::Commit,
287285
action: BaseAction {
288286
destination_program: Pubkey::new_unique(),
289287
escrow_authority: Pubkey::new_unique(),

0 commit comments

Comments
 (0)