Skip to content

Commit c81ea69

Browse files
committed
update optimistic nonce if behind
1 parent 20b7714 commit c81ea69

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

executors/src/eoa/store/atomic.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ impl AtomicEoaExecutorStore {
401401

402402
// First, read current health data
403403
let current_health = self.get_eoa_health().await?;
404+
let optimistic_nonce = self.get_optimistic_transaction_count().await?;
404405

405406
// Prepare health update if health data exists
406407
let health_update = if let Some(mut health) = current_health {
@@ -417,6 +418,18 @@ impl AtomicEoaExecutorStore {
417418
// Update cached transaction count
418419
pipeline.set(&tx_count_key, current_chain_tx_count);
419420

421+
if current_chain_tx_count + 1 > optimistic_nonce {
422+
tracing::warn!(
423+
current_chain_tx_count = current_chain_tx_count,
424+
optimistic_nonce = optimistic_nonce,
425+
"Optimistic nonce was behind fresh chain transaction count, updating to match"
426+
);
427+
pipeline.set(
428+
self.optimistic_transaction_count_key_name(),
429+
current_chain_tx_count + 1,
430+
);
431+
}
432+
420433
// Update health data only if it exists
421434
if let Some(ref health_json) = health_update {
422435
let health_key = self.eoa_health_key_name();

executors/src/eoa/store/pending.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SafeRedisTransaction for MovePendingToBorrowedWithIncrementedNonces<'_> {
5959
let current_optimistic: Option<u64> = conn
6060
.get(self.keys.optimistic_transaction_count_key_name())
6161
.await?;
62-
let current_nonce = current_optimistic.ok_or(TransactionStoreError::NonceSyncRequired {
62+
let current_optimistic_nonce = current_optimistic.ok_or(TransactionStoreError::NonceSyncRequired {
6363
eoa: self.eoa,
6464
chain_id: self.chain_id,
6565
})?;
@@ -74,7 +74,7 @@ impl SafeRedisTransaction for MovePendingToBorrowedWithIncrementedNonces<'_> {
7474

7575
// Check that nonces are sequential with no gaps
7676
for (i, &nonce) in nonces.iter().enumerate() {
77-
let expected_nonce = current_nonce + i as u64;
77+
let expected_nonce = current_optimistic_nonce + i as u64;
7878
if nonce != expected_nonce {
7979
return Err(TransactionStoreError::InternalError {
8080
message: format!(

executors/src/eoa/worker/send.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ impl<C: Chain> EoaExecutorWorker<C> {
293293
/// Process new transactions with fixed iterations and simple sequential nonces
294294
async fn process_new_transactions(&self, budget: u64) -> Result<u32, EoaExecutorWorkerError> {
295295
if budget == 0 {
296+
tracing::warn!("No budget to process new transactions");
296297
return Ok(0);
297298
}
298299

0 commit comments

Comments
 (0)