Skip to content

Commit

Permalink
revert sequence also for unknown transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
zvolin committed Jan 10, 2025
1 parent f4b8eb2 commit 3cb0ece
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions grpc/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,6 @@ where
let tx_status = self.client.tx_status(hash).await?;
match tx_status.status {
TxStatus::Pending => interval.tick().await,
TxStatus::Unknown => return Err(Error::TxNotFound(hash)),
TxStatus::Evicted => {
// node will treat this transaction like if it never happened, so
// we need to revert the account's sequence to the one of evicted tx.
// all transactions that were already submitted after this one
// will fail due to incorrect sequence number.
let mut acc = self.account.lock().await;
acc.sequence = sequence;
return Err(Error::TxEvicted(hash));
}
TxStatus::Committed => {
if tx_status.execution_code == ErrorCode::Success {
return Ok(TxInfo {
Expand All @@ -419,6 +409,22 @@ where
));
}
}
// node will treat this transaction like if it never happened, so
// we need to revert the account's sequence to the one of evicted tx.
// all transactions that were already submitted after this one will fail
// due to incorrect sequence number.
TxStatus::Evicted => {
let mut acc = self.account.lock().await;
acc.sequence = sequence;
return Err(Error::TxEvicted(hash));
}
// this case should never happen for node that accepted a broadcast
// however we handle it the same as evicted for extra safety
TxStatus::Unknown => {
let mut acc = self.account.lock().await;
acc.sequence = sequence;
return Err(Error::TxNotFound(hash));
}
}
}
}
Expand Down

0 comments on commit 3cb0ece

Please sign in to comment.