diff --git a/src/executor/executor.ts b/src/executor/executor.ts index 20b15db0..006ad4ac 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -40,18 +40,20 @@ import { InsufficientFundsError, IntrinsicGasTooLowError, NonceTooLowError, + TransactionExecutionError, encodeFunctionData, getContract, type Account, type Hex, - TransactionExecutionError + BaseError } from "viem" import { type CompressedFilterOpsAndEstimateGasParams, createCompressedCalldata, filterOpsAndEstimateGas, flushStuckTransaction, - simulatedOpsToResults + simulatedOpsToResults, + isTransactionUnderpricedError } from "./utils" import type { SendTransactionErrorType } from "viem" import type { AltoConfig } from "../createConfig" @@ -548,6 +550,32 @@ export class Executor { break } catch (e: unknown) { + if (e instanceof BaseError) { + if (isTransactionUnderpricedError(e)) { + this.logger.warn("Transaction underpriced, retrying") + request.maxFeePerGas = scaleBigIntByPercent( + request.maxFeePerGas, + 150 + ) + request.maxPriorityFeePerGas = scaleBigIntByPercent( + request.maxPriorityFeePerGas, + 150 + ) + //this.markWalletProcessed(wallet) + //return opsWithHashToBundle.map((owh) => { + // return { + // status: "resubmit", + // info: { + // entryPoint, + // userOpHash: owh.userOperationHash, + // userOperation: owh.mempoolUserOperation, + // reason: "replacement transaction underpriced" + // } + // } + //}) + } + } + const error = e as SendTransactionErrorType let isErrorHandled = false @@ -798,29 +826,6 @@ export class Executor { }) } - if ( - e?.details - ?.toLowerCase() - .includes("replacement transaction underpriced") - ) { - childLogger.error( - { error: e }, - "replacement transaction underpriced" - ) - this.markWalletProcessed(wallet) - return opsWithHashToBundle.map((owh) => { - return { - status: "resubmit", - info: { - entryPoint, - userOpHash: owh.userOperationHash, - userOperation: owh.mempoolUserOperation, - reason: "replacement transaction underpriced" - } - } - }) - } - sentry.captureException(err) childLogger.error( { error: JSON.stringify(err) }, diff --git a/src/executor/utils.ts b/src/executor/utils.ts index 824186f3..46219661 100644 --- a/src/executor/utils.ts +++ b/src/executor/utils.ts @@ -39,9 +39,16 @@ import { concat, decodeErrorResult, hexToBytes, - numberToHex + numberToHex, + BaseError } from "viem" +export const isTransactionUnderpricedError = (e: BaseError) => { + return e?.details + ?.toLowerCase() + .includes("replacement transaction underpriced") +} + export function simulatedOpsToResults( simulatedOps: { owh: UserOperationWithHash