From c15467afc141ea6ea7dc9dfc28e90723407edad6 Mon Sep 17 00:00:00 2001 From: mous <97399882+mouseless0x@users.noreply.github.com> Date: Sat, 19 Oct 2024 01:01:34 +0100 Subject: [PATCH] initial commit (#333) * initial commit * add log --------- Co-authored-by: mouseless <97399882+mouseless-eth@users.noreply.github.com> --- src/executor/executor.ts | 55 ++++++++++++++++++++++------------------ src/executor/utils.ts | 9 ++++++- 2 files changed, 38 insertions(+), 26 deletions(-) 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