From 9d63f5de6c2b49f8cd1ea73c93a5a409ceb80a66 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:59:00 +0100 Subject: [PATCH 1/2] initial commit --- src/executor/executor.ts | 54 +++++++++++++++++++++------------------- src/executor/utils.ts | 9 ++++++- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/executor/executor.ts b/src/executor/executor.ts index 20b15db0..ed81c1e1 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,31 @@ export class Executor { break } catch (e: unknown) { + if (e instanceof BaseError) { + if (isTransactionUnderpricedError(e)) { + 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 +825,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 From 127488733ccf975b29e9a591b32fc60b4887366b Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Sat, 19 Oct 2024 00:59:28 +0100 Subject: [PATCH 2/2] add log --- src/executor/executor.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/executor/executor.ts b/src/executor/executor.ts index ed81c1e1..006ad4ac 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -552,6 +552,7 @@ export class Executor { } catch (e: unknown) { if (e instanceof BaseError) { if (isTransactionUnderpricedError(e)) { + this.logger.warn("Transaction underpriced, retrying") request.maxFeePerGas = scaleBigIntByPercent( request.maxFeePerGas, 150