Skip to content

Commit

Permalink
initial commit (#333)
Browse files Browse the repository at this point in the history
* initial commit

* add log

---------

Co-authored-by: mouseless <[email protected]>
  • Loading branch information
mouseless0x and mouseless0x authored Oct 19, 2024
1 parent f7ccd43 commit c15467a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
55 changes: 30 additions & 25 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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) },
Expand Down
9 changes: 8 additions & 1 deletion src/executor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c15467a

Please sign in to comment.