Skip to content

Commit c2e3b13

Browse files
committed
Cleanup
1 parent 6f02ed7 commit c2e3b13

8 files changed

Lines changed: 35 additions & 82 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ impl TransactionStrategyExecutionError {
177177
tasks: &[Box<dyn BaseTask>],
178178
) -> Result<Self, TransactionError> {
179179
// There's always 3 budget instructions in front
180+
// TODO (snawaz): this is offset-sensitive, if we add or remove any instruction from the
181+
// front, that leads to incorrect error reporting. so if possible, make it offset-insensitive.
180182
const OFFSET: u8 = 3;
181183
const NONCE_OUT_OF_ORDER: u32 =
182184
dlp::error::DlpError::NonceOutOfOrder as u32;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,6 @@ where
619619
)
620620
.await?;
621621

622-
// println!("prepared_message: {:#?}", prepared_message);
623-
624622
// Execute strategy
625623
let execution_result = self
626624
.execute_message_with_retries(

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ where
5858
.await
5959
.map_err(IntentExecutorError::FailedFinalizePreparationError)?;
6060

61-
println!("execution_result: {:#?}", execution_result);
62-
6361
// Process error: Ok - return, Err - handle further
6462
let execution_err = match execution_result {
6563
// break with result, strategy that was executed at this point has to be returned for cleanup
@@ -133,7 +131,6 @@ where
133131
TransactionStrategyExecutionError::CommitIDError(_, _) => {
134132
// Here we patch strategy for it to be retried in next iteration
135133
// & we also record data that has to be cleaned up after patch
136-
println!("patch_strategy");
137134
let to_cleanup = inner
138135
.handle_commit_id_error(
139136
committed_pubkeys,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ impl TaskInfoFetcher for CacheTaskInfoFetcher {
197197
cache.push(*pubkey, *id);
198198
});
199199

200-
println!("fetcher! commit_ids: {:?}", result);
201200
return Ok(result);
202201
}
203202

@@ -230,7 +229,6 @@ impl TaskInfoFetcher for CacheTaskInfoFetcher {
230229
});
231230
}
232231

233-
println!("fetcher commit_ids: {:?}", result);
234232
Ok(result)
235233
}
236234

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ impl TasksBuilder for TaskBuilderImpl {
134134
let commit_ids =
135135
commit_ids.map_err(TaskBuilderError::CommitTasksBuildError)?;
136136

137-
println!("task_builder commit_ids: {:?}", commit_ids);
138-
139137
let base_accounts = match base_accounts {
140138
Ok(map) => map,
141139
Err(err) => {

test-integration/test-committor-service/tests/test_intent_executor.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use futures::future::join_all;
1515
use magicblock_committor_program::pdas;
1616
use magicblock_committor_service::{
1717
intent_executor::{
18-
error::{IntentExecutorError, TransactionStrategyExecutionError},
18+
error::TransactionStrategyExecutionError,
1919
task_info_fetcher::{CacheTaskInfoFetcher, TaskInfoFetcher},
2020
ExecutionOutput, IntentExecutionResult, IntentExecutor,
2121
IntentExecutorImpl,
@@ -52,7 +52,6 @@ use solana_sdk::{
5252
transaction::Transaction,
5353
};
5454

55-
use self::utils::transactions::print_log_messages;
5655
use crate::{
5756
common::TestFixture,
5857
utils::{
@@ -364,16 +363,6 @@ async fn test_commit_id_error_recovery() {
364363
patched_errors,
365364
} = res;
366365

367-
if let Err(IntentExecutorError::FailedToFinalizeError {
368-
err: _,
369-
commit_signature: _,
370-
finalize_signature: Some(sig),
371-
}) = &res
372-
{
373-
let rpc_client = RpcClient::new("http://localhost:7799".to_string());
374-
print_log_messages(&rpc_client, sig).await;
375-
}
376-
377366
assert!(
378367
res.is_ok(),
379368
"res: {:?}, patched_errors: {:#?}",

test-integration/test-committor-service/tests/test_ix_commit_local.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async fn test_ix_commit_order_book_change_671_bytes() {
109109
async fn test_ix_commit_order_book_change_673_bytes() {
110110
// We cannot use 672 as changed_len because that both 671 and 672 produce encoded tx
111111
// of size 1644 (which is the max limit), but while the size of raw bytes for 671 is within
112-
// 1232 limit, the size for 672 execeds by 1 (1233). That is why we used
112+
// 1232 limit, the size for 672 exceeds by 1 (1233). That is why we used
113113
// 673 as changed_len where CommitStrategy goes from Args to FromBuffer.
114114
commit_book_order_account(673, CommitStrategy::FromBuffer, false).await;
115115
}

test-integration/test-committor-service/tests/utils/transactions.rs

Lines changed: 31 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -69,54 +69,10 @@ macro_rules! get_account {
6969
}
7070

7171
#[allow(dead_code)]
72-
pub async fn print_log_messages(rpc_client: &RpcClient, signature: &Signature) {
73-
const MAX_RETRIES: usize = 5;
74-
let mut retries = MAX_RETRIES;
75-
let tx = loop {
76-
match rpc_client
77-
.get_transaction_with_config(
78-
signature,
79-
RpcTransactionConfig {
80-
commitment: Some(CommitmentConfig::confirmed()),
81-
max_supported_transaction_version: Some(0),
82-
..Default::default()
83-
},
84-
)
85-
.await
86-
{
87-
Ok(tx) => break tx,
88-
Err(err) => {
89-
log::error!("Failed to get transaction: {}", err);
90-
retries -= 1;
91-
if retries == 0 {
92-
panic!(
93-
"Failed to get transaction after {} retries",
94-
MAX_RETRIES
95-
);
96-
}
97-
tokio::time::sleep(tokio::time::Duration::from_millis(100))
98-
.await;
99-
}
100-
};
101-
};
102-
let logs = tx
103-
.transaction
104-
.meta
105-
.as_ref()
106-
.unwrap()
107-
.log_messages
108-
.clone()
109-
.unwrap_or_else(Vec::new);
110-
111-
println!("logs: {:#?}", logs);
112-
}
113-
114-
#[allow(dead_code)]
115-
pub async fn tx_logs_contain(
72+
pub async fn fetch_tx_logs(
11673
rpc_client: &RpcClient,
11774
signature: &Signature,
118-
needle: &str,
119-
) -> bool {
75+
) -> Vec<String> {
12076
// NOTE: we encountered the following error a few times which makes tests fail for the
12177
// wrong reason:
12278
// Error {
@@ -156,25 +112,40 @@ pub async fn tx_logs_contain(
156112
}
157113
};
158114
};
159-
let logs = tx
160-
.transaction
115+
tx.transaction
161116
.meta
162117
.as_ref()
163118
.unwrap()
164119
.log_messages
165120
.clone()
166-
.unwrap_or_else(Vec::new);
167-
logs.iter().any(|log| {
168-
// Lots of existing tests pass "CommitState" as needle argument to this function, but since now CommitTask
169-
// could invoke CommitState or CommitDiff depending on the size of the account, we also look for "CommitDiff"
170-
// in the logs when needle == CommitState. It's easier to make this little adjustment here than computing
171-
// the decision and passing either CommitState or CommitDiff from the tests themselves.
172-
if needle == "CommitState" {
173-
log.contains(needle) || log.contains("CommitDiff")
174-
} else {
175-
log.contains(needle)
176-
}
177-
})
121+
.unwrap_or_else(Vec::new)
122+
}
123+
124+
#[allow(dead_code)]
125+
pub async fn print_tx_logs(rpc_client: &RpcClient, signature: &Signature) {
126+
println!("logs: {:#?}", fetch_tx_logs(rpc_client, signature).await);
127+
}
128+
129+
#[allow(dead_code)]
130+
pub async fn tx_logs_contain(
131+
rpc_client: &RpcClient,
132+
signature: &Signature,
133+
needle: &str,
134+
) -> bool {
135+
fetch_tx_logs(rpc_client, signature)
136+
.await
137+
.iter()
138+
.any(|log| {
139+
// Lots of existing tests pass "CommitState" as needle argument to this function, but since now CommitTask
140+
// could invoke CommitState or CommitDiff depending on the size of the account, we also look for "CommitDiff"
141+
// in the logs when needle == CommitState. It's easier to make this little adjustment here than computing
142+
// the decision and passing either CommitState or CommitDiff from the tests themselves.
143+
if needle == "CommitState" {
144+
log.contains(needle) || log.contains("CommitDiff")
145+
} else {
146+
log.contains(needle)
147+
}
148+
})
178149
}
179150

180151
/// This needs to be run for each test that required a new counter to be delegated

0 commit comments

Comments
 (0)