Skip to content

Commit e0f71f3

Browse files
committed
refactor: Simplify Task types
1 parent 4d93f4e commit e0f71f3

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
@@ -53,7 +53,7 @@ use crate::{
5353
TaskStrategist, TaskStrategistError, TransactionStrategy,
5454
},
5555
task_visitors::utility_visitor::TaskVisitorUtils,
56-
BaseTask, TaskType,
56+
Task, TaskType,
5757
},
5858
transaction_preparator::{
5959
error::TransactionPreparatorError, TransactionPreparator,
@@ -127,8 +127,8 @@ where
127127
/// Checks if it is possible to unite Commit & Finalize stages in 1 transaction
128128
/// Returns corresponding `TransactionStrategy` if possible, otherwise `None`
129129
fn try_unite_tasks<P: IntentPersister>(
130-
commit_tasks: &[Box<dyn BaseTask>],
131-
finalize_task: &[Box<dyn BaseTask>],
130+
commit_tasks: &[Task],
131+
finalize_task: &[Task],
132132
authority: &Pubkey,
133133
persister: &Option<P>,
134134
) -> Result<Option<TransactionStrategy>, SignerError> {
@@ -179,7 +179,7 @@ where
179179
}
180180

181181
// Build tasks for commit stage
182-
let commit_tasks = TaskBuilderImpl::commit_tasks(
182+
let commit_tasks = TaskBuilderImpl::create_commit_tasks(
183183
&self.task_info_fetcher,
184184
&base_intent,
185185
persister,
@@ -626,7 +626,7 @@ where
626626
async fn execute_message_with_retries(
627627
&self,
628628
prepared_message: VersionedMessage,
629-
tasks: &[Box<dyn BaseTask>],
629+
tasks: &[Task],
630630
) -> IntentExecutorResult<Signature, TransactionStrategyExecutionError>
631631
{
632632
struct IntentErrorMapper<TxMap> {
@@ -837,7 +837,7 @@ mod tests {
837837
let intent = create_test_intent(0, &pubkey);
838838

839839
let info_fetcher = Arc::new(MockInfoFetcher);
840-
let commit_task = TaskBuilderImpl::commit_tasks(
840+
let commit_task = TaskBuilderImpl::create_commit_tasks(
841841
&info_fetcher,
842842
&intent,
843843
&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)