Skip to content

Commit 3997517

Browse files
authored
revert redis deletion (#50)
1 parent db42d11 commit 3997517

File tree

4 files changed

+53
-28
lines changed

4 files changed

+53
-28
lines changed

executors/src/eoa/store/submitted.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,20 @@ impl SafeRedisTransaction for CleanSubmittedTransactions<'_> {
357357

358358
// IMMEDIATE CLEANUP: Delete all transaction data since it's confirmed
359359
// Note: Hash mappings will be cleaned up periodically by maintenance script
360-
let keys_to_delete = self.keys.get_all_transaction_keys(id);
361-
for key in keys_to_delete {
362-
pipeline.del(&key);
363-
}
360+
// TODO: Buggy deletions, fix later
361+
// let keys_to_delete = self.keys.get_all_transaction_keys(id);
362+
// for key in keys_to_delete {
363+
// pipeline.del(&key);
364+
// }
365+
366+
let data_key_name = self.keys.transaction_data_key_name(id);
367+
pipeline.hset(&data_key_name, "status", "confirmed");
368+
pipeline.hset(&data_key_name, "completed_at", now);
369+
pipeline.hset(
370+
&data_key_name,
371+
"receipt",
372+
confirmed_tx.receipt_serialized.clone(),
373+
);
364374

365375
if let SubmittedTransactionHydrated::Real(tx) = tx {
366376
// Record metrics: transaction queued to mined for confirmed transactions

executors/src/eoa/worker/confirm.rs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::{
88
eoa::{
99
EoaExecutorStore,
1010
store::{
11-
CleanupReport, ConfirmedTransaction, ReplacedTransaction, SubmittedTransactionDehydrated,
12-
TransactionStoreError,
11+
CleanupReport, ConfirmedTransaction, ReplacedTransaction,
12+
SubmittedTransactionDehydrated, TransactionStoreError,
1313
},
1414
worker::{
1515
EoaExecutorWorker,
@@ -49,9 +49,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
4949

5050
if self.store.is_manual_reset_scheduled().await? {
5151
tracing::info!("Manual reset scheduled, executing now");
52-
self.store
53-
.reset_nonces(transaction_counts.latest)
54-
.await?;
52+
self.store.reset_nonces(transaction_counts.latest).await?;
5553
}
5654

5755
let cached_transaction_count = match self.store.get_cached_transaction_count().await {
@@ -111,31 +109,39 @@ impl<C: Chain> EoaExecutorWorker<C> {
111109
error = ?e,
112110
"Failed to attempt gas bump for stalled nonce, trying fallback"
113111
);
114-
112+
115113
// Fallback: try to send a no-op transaction
116114
tracing::info!(
117115
nonce = transaction_counts.preconfirmed,
118116
"Gas bump failed, attempting no-op transaction as fallback"
119117
);
120-
if let Ok(noop_tx) = self.send_noop_transaction(transaction_counts.preconfirmed).await {
118+
if let Ok(noop_tx) = self
119+
.send_noop_transaction(transaction_counts.preconfirmed)
120+
.await
121+
{
121122
if let Err(e) = self.store.process_noop_transactions(&[noop_tx]).await {
122123
tracing::error!(
123124
error = ?e,
124125
"Failed to process fallback no-op transaction for stalled nonce"
125126
);
126127
}
127128
} else {
128-
tracing::error!("Failed to send fallback no-op transaction for stalled nonce");
129-
129+
tracing::error!(
130+
"Failed to send fallback no-op transaction for stalled nonce"
131+
);
132+
130133
// Ultimate fallback: check if we should trigger auto-reset
131-
let time_since_movement = now.saturating_sub(current_health.last_nonce_movement_at);
132-
if time_since_movement > 5 * 60 * 1000 && submitted_count > 0 { // 5 minutes
134+
let time_since_movement =
135+
now.saturating_sub(current_health.last_nonce_movement_at);
136+
137+
if (time_since_movement > (5 * 60 * 1000)) && (submitted_count > 0) {
138+
// 5 minutes
133139
tracing::warn!(
134140
nonce = transaction_counts.preconfirmed,
135141
time_since_movement = time_since_movement,
136142
"EOA appears permanently stuck, scheduling auto-reset"
137143
);
138-
144+
139145
if let Err(e) = self.store.schedule_manual_reset().await {
140146
tracing::error!(error = ?e, "Failed to schedule auto-reset");
141147
}
@@ -251,7 +257,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
251257
.clean_submitted_transactions(
252258
&successes,
253259
TransactionCounts {
254-
latest: transaction_counts.latest.saturating_sub(1), // Use latest for replacement detection
260+
latest: transaction_counts.latest.saturating_sub(1), // Use latest for replacement detection
255261
preconfirmed: transaction_counts.preconfirmed.saturating_sub(1), // Use preconfirmed for confirmation
256262
},
257263
self.webhook_queue.clone(),
@@ -425,14 +431,19 @@ impl<C: Chain> EoaExecutorWorker<C> {
425431
.await?;
426432

427433
// Send the bumped transaction with retry logic
428-
match self.send_tx_envelope_with_retry(bumped_tx.into(), crate::eoa::worker::error::SendContext::InitialBroadcast)
434+
match self
435+
.send_tx_envelope_with_retry(
436+
bumped_tx.into(),
437+
crate::eoa::worker::error::SendContext::InitialBroadcast,
438+
)
429439
.instrument(tracing::info_span!(
430-
"send_tx_envelope_with_retry",
440+
"send_tx_envelope_with_retry",
431441
transaction_id = %newest_transaction_data.transaction_id,
432442
nonce = expected_nonce,
433443
context = "gas_bump"
434444
))
435-
.await {
445+
.await
446+
{
436447
Ok(_) => {
437448
tracing::info!(
438449
transaction_id = ?newest_transaction_data.transaction_id,

executors/src/eoa/worker/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
326326
.recover_borrowed_state()
327327
.await
328328
.map_err(|e| {
329-
tracing::error!("Error in recover_borrowed_state: {}", e);
329+
tracing::error!(error = ?e, "Error in recover_borrowed_state");
330330
e
331331
})
332332
.map_err(|e| e.handle())?;
@@ -455,7 +455,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
455455
SendContext::Rebroadcast,
456456
)
457457
.instrument(tracing::info_span!(
458-
"send_tx_envelope_with_retry",
458+
"send_tx_envelope_with_retry",
459459
transaction_id = %transaction_id,
460460
nonce = nonce,
461461
context = "recovery_rebroadcast"

executors/src/eoa/worker/send.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ use tokio_retry2::{
77
use tracing::Instrument;
88

99
use crate::eoa::{
10+
EoaExecutorStore,
1011
store::{BorrowedTransaction, PendingTransaction, SubmissionResult},
1112
worker::{
13+
EoaExecutorWorker,
1214
error::{
13-
classify_send_error, is_retryable_preparation_error, should_update_balance_threshold, EoaExecutorWorkerError, SendContext, SendErrorClassification
14-
}, EoaExecutorWorker
15-
}, EoaExecutorStore,
15+
EoaExecutorWorkerError, SendContext, SendErrorClassification, classify_send_error,
16+
is_retryable_preparation_error, should_update_balance_threshold,
17+
},
18+
},
1619
};
1720

1821
const HEALTH_CHECK_INTERVAL_MS: u64 = 60 * 5 * 1000; // 5 minutes in ms
@@ -26,7 +29,8 @@ impl<C: Chain> EoaExecutorWorker<C> {
2629
alloy::providers::PendingTransactionBuilder<alloy::network::Ethereum>,
2730
alloy::transports::RpcError<alloy::transports::TransportErrorKind>,
2831
> {
29-
let retry_strategy = ExponentialBackoff::from_millis(500)
32+
let retry_strategy = ExponentialBackoff::from_millis(100)
33+
.max_delay_millis(1000)
3034
.map(jitter) // add jitter
3135
.take(3); // limit to 3 retries
3236

@@ -198,7 +202,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
198202
SendContext::InitialBroadcast,
199203
)
200204
.instrument(tracing::info_span!(
201-
"send_tx_envelope_with_retry",
205+
"send_tx_envelope_with_retry",
202206
transaction_id = %borrowed_tx.transaction_id,
203207
context = "recycled_nonces"
204208
))
@@ -433,7 +437,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
433437
SendContext::InitialBroadcast,
434438
)
435439
.instrument(tracing::info_span!(
436-
"send_tx_envelope_with_retry",
440+
"send_tx_envelope_with_retry",
437441
transaction_id = %borrowed_tx.transaction_id,
438442
context = "new_transactions"
439443
))

0 commit comments

Comments
 (0)