Skip to content

Commit cb6b8c8

Browse files
committed
refactor: Simplify Task types
1 parent 3beda6e commit cb6b8c8

File tree

18 files changed

+900
-959
lines changed

18 files changed

+900
-959
lines changed

magicblock-committor-service/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ IntentExecutor - responsible for execution of Intent. Calls **TransactionPrepar
2323
TransactionPreparator - is an entity that handles all of the above "Transaction preparation" calling **TaskBuilderV1**, **TaskStrategist**, **DeliveryPreparator** and then assempling it all and passing to **MessageExecutor**
2424

2525
## DeliveryPreparator
26-
After our **BaseTask**s are ready we need to prepare eveything for their successful execution. **DeliveryPreparator** - handles ALTs and commit buffers
26+
After our **Task**s are ready we need to prepare eveything for their successful execution. **DeliveryPreparator** - handles ALTs and commit buffers
2727

2828
## TaskBuilder
2929
First, lets build atomic tasks from scheduled message/intent.
3030

31-
High level: TaskBuilder responsible for creating BaseTasks(to be renamed...) from ScheduledBaseIntent(to be renamed...).
31+
High level: TaskBuilder responsible for creating Tasks(to be renamed...) from ScheduledBaseIntent(to be renamed...).
3232
Details: To do that is requires additional information from DelegationMetadata, it is provided **CommitIdFetcher**
3333

34-
### BaseTask
35-
High level: BaseTask - is an atomic operation that is to be performed on the Base layer, like: Commit, Undelegate, Finalize, Action.
34+
### Task
35+
High level: Task - is an atomic operation that is to be performed on the Base layer, like: Commit, Undelegate, Finalize, Action.
3636

37-
Details: There's to implementation of BaseTask: ArgsTask, BufferTask. ArgsTask - gives instruction using args. BufferTask - gives instruction using buffer. BufferTask at the moment supports only commits
37+
Details: There's to implementation of Task: ArgsTask, BufferTask. ArgsTask - gives instruction using args. BufferTask - gives instruction using buffer. BufferTask at the moment supports only commits
3838

3939
### TaskInfoFetcher
4040
High level: for account to be accepted by `dlp` it needs to have incremental commit ids. TaskInfoFetcher provides a user with the correct ids/nonces for set of committees

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use solana_sdk::{
1212
use crate::{
1313
tasks::{
1414
task_builder::TaskBuilderError, task_strategist::TaskStrategistError,
15-
BaseTask, TaskType,
15+
Task, TaskType,
1616
},
1717
transaction_preparator::error::TransactionPreparatorError,
1818
};
@@ -138,7 +138,7 @@ impl TransactionStrategyExecutionError {
138138
pub fn try_from_transaction_error(
139139
err: TransactionError,
140140
signature: Option<Signature>,
141-
tasks: &[Box<dyn BaseTask>],
141+
tasks: &[Task],
142142
) -> Result<Self, TransactionError> {
143143
// There's always 2 budget instructions in front
144144
const OFFSET: u8 = 2;
@@ -196,7 +196,7 @@ impl TransactionStrategyExecutionError {
196196
}
197197

198198
pub(crate) struct IntentTransactionErrorMapper<'a> {
199-
pub tasks: &'a [Box<dyn BaseTask>],
199+
pub tasks: &'a [Task],
200200
}
201201
impl TransactionErrorMapper for IntentTransactionErrorMapper<'_> {
202202
type ExecutionError = TransactionStrategyExecutionError;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ use crate::{
5454
TaskStrategist, TaskStrategistError, TransactionStrategy,
5555
},
5656
task_visitors::utility_visitor::TaskVisitorUtils,
57-
BaseTask, TaskType,
57+
Task, TaskType,
5858
},
5959
transaction_preparator::{
6060
error::TransactionPreparatorError, TransactionPreparator,
@@ -128,8 +128,8 @@ where
128128
/// Checks if it is possible to unite Commit & Finalize stages in 1 transaction
129129
/// Returns corresponding `TransactionStrategy` if possible, otherwise `None`
130130
fn try_unite_tasks<P: IntentPersister>(
131-
commit_tasks: &[Box<dyn BaseTask>],
132-
finalize_task: &[Box<dyn BaseTask>],
131+
commit_tasks: &[Task],
132+
finalize_task: &[Task],
133133
authority: &Pubkey,
134134
persister: &Option<P>,
135135
) -> Result<Option<TransactionStrategy>, SignerError> {
@@ -180,7 +180,7 @@ where
180180
}
181181

182182
// Build tasks for commit stage
183-
let commit_tasks = TaskBuilderImpl::commit_tasks(
183+
let commit_tasks = TaskBuilderImpl::create_commit_tasks(
184184
&self.task_info_fetcher,
185185
&base_intent,
186186
persister,
@@ -627,7 +627,7 @@ where
627627
async fn execute_message_with_retries(
628628
&self,
629629
prepared_message: VersionedMessage,
630-
tasks: &[Box<dyn BaseTask>],
630+
tasks: &[Task],
631631
) -> IntentExecutorResult<Signature, TransactionStrategyExecutionError>
632632
{
633633
struct IntentErrorMapper<TxMap> {
@@ -838,7 +838,7 @@ mod tests {
838838
let intent = create_test_intent(0, &pubkey);
839839

840840
let info_fetcher = Arc::new(MockInfoFetcher);
841-
let commit_task = TaskBuilderImpl::commit_tasks(
841+
let commit_task = TaskBuilderImpl::create_commit_tasks(
842842
&info_fetcher,
843843
&intent,
844844
&None::<IntentPersisterImpl>,

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

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)