Skip to content

Commit 2a2b718

Browse files
committed
Premptively burn nonce on time out
1 parent d3a7ae1 commit 2a2b718

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/executors/priority_executor.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct PriorityExecutor {
4646
enum TransactionOutcome {
4747
Success(Option<u64>),
4848
Failure(Option<u64>),
49+
TimedOut(Option<u64>),
4950
RetryableFailure,
5051
}
5152

@@ -113,8 +114,8 @@ impl PriorityExecutor {
113114
anyhow::anyhow!("{} - Error waiting for confirmations: {}", order_hash, e)
114115
}),
115116
Err(_) => {
116-
warn!("{} - Timed out waiting for transaction receipt", order_hash);
117-
return Ok(TransactionOutcome::Failure(None));
117+
warn!("{} - Timed out waiting for transaction receipt attempting to burn nonce", order_hash);
118+
return Ok(TransactionOutcome::TimedOut(None));
118119
}
119120
};
120121

@@ -465,6 +466,21 @@ impl Executor<SubmitTxToMempoolWithExecutionMetadata> for PriorityExecutor {
465466
Ok(TransactionOutcome::RetryableFailure) | Err(_) => {
466467
// Skip the order for now
467468
}
469+
Ok(TransactionOutcome::TimedOut(_result)) => {
470+
// no successes and revert protection is enabled, burn nonce
471+
// this is to allow the next tx from this wallet to be submitted
472+
// it may be that one order succeeded, but the others timed out
473+
// however, we only want to burn the nonce if all txs timed out
474+
if i == results.len() - 1 && action.metadata.revert_protection {
475+
burn_nonce(
476+
&self.sender_client,
477+
&wallet,
478+
address,
479+
nonce,
480+
&order_hash
481+
).await?;
482+
}
483+
}
468484
}
469485
}
470486

0 commit comments

Comments
 (0)