Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix: nonce too low for different providers (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
kekonen authored Dec 6, 2021
1 parent a9a47a4 commit fffb965
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ethers-providers/src/pending_escalator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ macro_rules! completed {
};
}

/// Tests Provider error for nonce too low issue through debug contents
fn is_nonce_too_low(e: &ProviderError) -> bool {
let debug_str = format!("{:?}", e);

debug_str.contains("nonce too low") // Geth, Arbitrum, Optimism
|| debug_str.contains("nonce is too low") // Parity
|| debug_str.contains("invalid transaction nonce") // Arbitrum
}

macro_rules! poll_broadcast_fut {
($cx:ident, $this:ident, $fut:ident) => {
match $fut.as_mut().poll($cx) {
Expand All @@ -142,7 +151,7 @@ macro_rules! poll_broadcast_fut {
Poll::Ready(Err(e)) => {
// kludge. Prevents erroring on "nonce too low" which indicates
// a previous escalation confirmed during this broadcast attempt
if format!("{:?}", e).contains("nonce too low") {
if is_nonce_too_low(&e) {
check_all_receipts!($cx, $this);
} else {
tracing::error!(
Expand Down

0 comments on commit fffb965

Please sign in to comment.