fix: nonce too low for different providers (#655)

This commit is contained in:
Daniil Naumetc 2021-12-07 00:15:51 +01:00 committed by GitHub
parent a9a47a4cd6
commit fffb965f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -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!(