diff --git a/apps/submitter/lib/handlers/createAccount/createAccount.ts b/apps/submitter/lib/handlers/createAccount/createAccount.ts index 4768e6a91..6a098a1ae 100644 --- a/apps/submitter/lib/handlers/createAccount/createAccount.ts +++ b/apps/submitter/lib/handlers/createAccount/createAccount.ts @@ -14,7 +14,10 @@ import { CreateAccount, type CreateAccountInput, type CreateAccountOutput } from const WaitForReceiptError = Symbol("WaitForReceiptError") -async function createAccount({ salt, owner }: CreateAccountInput): Promise { +async function createAccount( + { salt, owner }: CreateAccountInput, + noNonceRetry?: "noNonceRetry", +): Promise { assertDef(salt) // from validator let evmTxInfo: Optional | undefined const predictedAddress = computeHappyAccountAddress(salt, owner) @@ -75,7 +78,14 @@ async function createAccount({ salt, owner }: CreateAccountInput): Promise { - const { entryPoint = deployment.EntryPoint, timeout, earlyExit, replacedTx } = input + const { entryPoint = deployment.EntryPoint, timeout, earlyExit, replacedTx, noNonceRetry } = input let boop = input.boop const boopHash = computeHash(boop) @@ -164,9 +165,13 @@ async function submitInternal(input: SubmitInternalInput): Promise e instanceof InsufficientFundsError)) { + if (isNonceTooLowError(error)) { + evmNonceManager.resyncIfTooLow(accountDeployer.address) + if (!noNonceRetry) { + logger.warn("EVM nonce too low, retrying submit", boopHash) + return await submitInternal({ ...input, noNonceRetry: true }) + } + } else if ((error as BaseError)?.walk((e) => e instanceof InsufficientFundsError)) { return { status: SubmitterError.UnexpectedError, error: "Submitter failed to pay for the boop.",