From fffb965f2f341ff735bc23095d53133804c6f389 Mon Sep 17 00:00:00 2001 From: Daniil Naumetc <11177808+kekonen@users.noreply.github.com> Date: Tue, 7 Dec 2021 00:15:51 +0100 Subject: [PATCH] fix: nonce too low for different providers (#655) --- ethers-providers/src/pending_escalator.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ethers-providers/src/pending_escalator.rs b/ethers-providers/src/pending_escalator.rs index bbc45aea..511fca36 100644 --- a/ethers-providers/src/pending_escalator.rs +++ b/ethers-providers/src/pending_escalator.rs @@ -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) { @@ -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!(