diff --git a/scripts/localDeployer/index.ts b/scripts/localDeployer/index.ts index e04f4695..b5852fcc 100644 --- a/scripts/localDeployer/index.ts +++ b/scripts/localDeployer/index.ts @@ -63,7 +63,6 @@ const verifyDeployed = async (addresses: Address[]) => { }) if (bytecode === undefined) { - // biome-ignore lint/suspicious/noConsoleLog: it is oke console.log(`CONTRACT ${address} NOT DEPLOYED!!!`) process.exit(1) } @@ -71,7 +70,6 @@ const verifyDeployed = async (addresses: Address[]) => { } const main = async () => { - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== DEPLOYING V0.7 CORE CONTRACTS ==========") const txs: Hex[] = [] @@ -103,7 +101,6 @@ const main = async () => { ) console.log("Deployed EntryPointSimulations") - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== DEPLOYING V0.6 CORE CONTRACTS ==========") txs.push( @@ -124,7 +121,6 @@ const main = async () => { ) console.log("Deployed SimpleAccountFactory v0.6") - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== DEPLOYING SAFE CONTRACTS ==========") txs.push( @@ -205,7 +201,6 @@ const main = async () => { ) console.log("Deployed Safe Multi Send Call Only") - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== DEPLOYING BICONOMY CONTRACTS ==========") await anvilClient.setCode({ @@ -250,7 +245,6 @@ const main = async () => { ) console.log("Deployed Biconomy Default Fallback Handler") - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== DEPLOYING KERNEL CONTRACTS ==========") txs.push( @@ -280,7 +274,6 @@ const main = async () => { ) console.log("Deployed Kernel Factory") - // biome-ignore lint/suspicious/noConsoleLog: [] console.log("========== MISC ==========") await anvilClient.setCode({ diff --git a/src/cli/alto.ts b/src/cli/alto.ts index 26fefe38..e5e3f0f1 100644 --- a/src/cli/alto.ts +++ b/src/cli/alto.ts @@ -1,6 +1,7 @@ #!/usr/bin/env node import * as sentry from "@sentry/node" import dotenv from "dotenv" +import { HttpRequestError, InternalRpcError, TimeoutError } from "viem" import yargs from "yargs" import { hideBin } from "yargs/helpers" import { @@ -16,7 +17,6 @@ import { serverOptions } from "./config" import { registerCommandToYargs } from "./util" -import { TimeoutError, HttpRequestError, InternalRpcError } from "viem" // Load environment variables from .env file if (process.env.DOTENV_CONFIG_PATH) { diff --git a/src/cli/config/options.ts b/src/cli/config/options.ts index 4fcf1b86..7c684599 100644 --- a/src/cli/config/options.ts +++ b/src/cli/config/options.ts @@ -7,10 +7,10 @@ import type { IExecutorArgsInput, IGasEstimationArgsInput, ILogArgsInput, + IMempoolArgsInput, IOptionsInput, IRpcArgsInput, - IServerArgsInput, - IMempoolArgsInput + IServerArgsInput } from "./bundler" export const bundlerOptions: CliCommandOptions = { @@ -100,7 +100,8 @@ export const bundlerOptions: CliCommandOptions = { default: "20000000" }, "max-bundle-count": { - description: "Maximum number of UserOperations to include in a bundle. If not set, no limit is applied.", + description: + "Maximum number of UserOperations to include in a bundle. If not set, no limit is applied.", type: "number", require: false }, @@ -407,7 +408,14 @@ export const compatibilityOptions: CliCommandOptions = description: "Indicates what type of chain the bundler is running on", type: "string", - choices: ["default", "op-stack", "arbitrum", "hedera", "mantle", "abstract"], + choices: [ + "default", + "op-stack", + "arbitrum", + "hedera", + "mantle", + "abstract" + ], default: "default" }, "legacy-transactions": { diff --git a/src/cli/customTransport.ts b/src/cli/customTransport.ts index 49aa1f16..550432b9 100644 --- a/src/cli/customTransport.ts +++ b/src/cli/customTransport.ts @@ -1,15 +1,15 @@ import type { Logger } from "@alto/utils" import { + type Hex, type HttpTransport, type HttpTransportConfig, RpcRequestError, UrlRequiredError, createTransport, - toFunctionSelector, getAbiItem, isHex, slice, - Hex + toFunctionSelector } from "viem" import { formatAbiItem, rpc } from "viem/utils" import { diff --git a/src/cli/deploySimulationsContract.ts b/src/cli/deploySimulationsContract.ts index 2f0164ca..bfb6a34b 100644 --- a/src/cli/deploySimulationsContract.ts +++ b/src/cli/deploySimulationsContract.ts @@ -1,22 +1,22 @@ +import type { IOptions } from "@alto/cli" import { DETERMINISTIC_DEPLOYER_TRANSACTION, - pimlicoEntrypointSimulationsV7DeployBytecode, pimlicoEntrypointSimulationsSalt, + pimlicoEntrypointSimulationsV7DeployBytecode, pimlicoEntrypointSimulationsV8DeployBytecode } from "@alto/types" +import type { Logger } from "pino" import { + http, type Chain, - createWalletClient, - getContractAddress, type Hex, - http, type PublicClient, type Transport, - concat + concat, + createWalletClient, + getContractAddress } from "viem" import type { CamelCasedProperties } from "./parseArgs" -import type { IOptions } from "@alto/cli" -import type { Logger } from "pino" const isContractDeployed = async ({ publicClient, diff --git a/src/cli/handler.ts b/src/cli/handler.ts index 218db2ca..7ee313a5 100644 --- a/src/cli/handler.ts +++ b/src/cli/handler.ts @@ -6,22 +6,22 @@ import { } from "@alto/utils" import { Registry } from "prom-client" import { + type CallParameters, type Chain, createPublicClient, createWalletClient, - formatEther, fallback, - type CallParameters, + formatEther, publicActions } from "viem" -import type { IOptionsInput } from "./config" -import { customTransport } from "./customTransport" -import { setupServer } from "./setupServer" import { type AltoConfig, createConfig } from "../createConfig" -import { parseArgs } from "./parseArgs" -import { deploySimulationsContract } from "./deploySimulationsContract" import { getSenderManager } from "../executor/senderManager/index" import { UtilityWalletMonitor } from "../executor/utilityWalletMonitor" +import type { IOptionsInput } from "./config" +import { customTransport } from "./customTransport" +import { deploySimulationsContract } from "./deploySimulationsContract" +import { parseArgs } from "./parseArgs" +import { setupServer } from "./setupServer" const preFlightChecks = async (config: AltoConfig): Promise => { for (const entrypoint of config.entrypoints) { diff --git a/src/cli/instrumentation.ts b/src/cli/instrumentation.ts index 54e67fe6..f40acb15 100644 --- a/src/cli/instrumentation.ts +++ b/src/cli/instrumentation.ts @@ -4,7 +4,6 @@ import { FastifyInstrumentation } from "@opentelemetry/instrumentation-fastify" import { HttpInstrumentation } from "@opentelemetry/instrumentation-http" import { PinoInstrumentation } from "@opentelemetry/instrumentation-pino" import { UndiciInstrumentation } from "@opentelemetry/instrumentation-undici" -import { ViemInstrumentation } from "@pimlico/opentelemetry-instrumentation-viem" import { NodeSDK } from "@opentelemetry/sdk-node" import { ParentBasedSampler, @@ -12,6 +11,7 @@ import { SamplingDecision } from "@opentelemetry/sdk-trace-base" import { SemanticAttributes } from "@opentelemetry/semantic-conventions" +import { ViemInstrumentation } from "@pimlico/opentelemetry-instrumentation-viem" class CustomSampler implements Sampler { shouldSample( diff --git a/src/cli/parseArgs.ts b/src/cli/parseArgs.ts index dcf02526..5f9b7156 100644 --- a/src/cli/parseArgs.ts +++ b/src/cli/parseArgs.ts @@ -1,4 +1,4 @@ -import { type IOptions, optionArgsSchema, type IOptionsInput } from "@alto/cli" +import { type IOptions, type IOptionsInput, optionArgsSchema } from "@alto/cli" import { fromZodError } from "zod-validation-error" type CamelCase = diff --git a/src/cli/setupServer.ts b/src/cli/setupServer.ts index e236c3fb..145fa690 100644 --- a/src/cli/setupServer.ts +++ b/src/cli/setupServer.ts @@ -12,8 +12,8 @@ import type { InterfaceValidator } from "@alto/types" import type { Metrics } from "@alto/utils" import type { Registry } from "prom-client" import type { AltoConfig } from "../createConfig" -import { validateAndRefillWallets } from "../executor/senderManager/validateAndRefill" import { flushOnStartUp } from "../executor/senderManager/flushOnStartUp" +import { validateAndRefillWallets } from "../executor/senderManager/validateAndRefill" import { createMempoolStore } from "../store/createMempoolStore" const getReputationManager = ( diff --git a/src/createConfig.ts b/src/createConfig.ts index 5c3ce2ff..8410247b 100644 --- a/src/createConfig.ts +++ b/src/createConfig.ts @@ -1,7 +1,7 @@ import type { IOptions } from "@alto/cli" -import type { CamelCasedProperties } from "./cli/parseArgs" import type { Bindings, ChildLoggerOptions, Logger } from "pino" import type { Chain, PublicClient, Transport, WalletClient } from "viem" +import type { CamelCasedProperties } from "./cli/parseArgs" export type AltoConfig = Readonly> & { getLogger: ( diff --git a/src/executor/executor.ts b/src/executor/executor.ts index 61f0ee12..116fca2a 100644 --- a/src/executor/executor.ts +++ b/src/executor/executor.ts @@ -3,24 +3,29 @@ import type { InterfaceReputationManager, Mempool } from "@alto/mempool" import type { Address, BundleResult, + GasPriceParameters, HexData32, + UserOpInfo, UserOperation, - GasPriceParameters, - UserOperationBundle, - UserOpInfo + UserOperationBundle } from "@alto/types" import type { Logger, Metrics } from "@alto/utils" import { maxBigInt, parseViemError, scaleBigIntByPercent } from "@alto/utils" import * as sentry from "@sentry/node" import { - IntrinsicGasTooLowError, - NonceTooLowError, - TransactionExecutionError, type Account, + BaseError, type Hex, + IntrinsicGasTooLowError, NonceTooHighError, - BaseError + NonceTooLowError, + TransactionExecutionError } from "viem" +import type { SendTransactionErrorType } from "viem" +import type { SignedAuthorizationList } from "viem" +import type { AltoConfig } from "../createConfig" +import { sendPflConditional } from "./fastlane" +import { filterOpsAndEstimateGas } from "./filterOpsAndEStimateGas" import { calculateAA95GasFloor, encodeHandleOpsCalldata, @@ -28,11 +33,6 @@ import { getUserOpHashes, isTransactionUnderpricedError } from "./utils" -import type { SendTransactionErrorType } from "viem" -import type { AltoConfig } from "../createConfig" -import { sendPflConditional } from "./fastlane" -import type { SignedAuthorizationList } from "viem" -import { filterOpsAndEstimateGas } from "./filterOpsAndEStimateGas" type HandleOpsTxParams = { gas: bigint @@ -274,7 +274,7 @@ export class Executor { entryPoint }) - let estimateResult = await filterOpsAndEstimateGas({ + const estimateResult = await filterOpsAndEstimateGas({ userOpBundle, executor, nonce, diff --git a/src/executor/executorManager.ts b/src/executor/executorManager.ts index 4045c45a..cdbb9788 100644 --- a/src/executor/executorManager.ts +++ b/src/executor/executorManager.ts @@ -8,11 +8,11 @@ import { type BundlingMode, EntryPointV06Abi, type HexData32, + type RejectedUserOp, type SubmittedUserOp, type TransactionInfo, - RejectedUserOp, - UserOperationBundle, - UserOpInfo + type UserOpInfo, + type UserOperationBundle } from "@alto/types" import type { BundlingStatus, Logger, Metrics } from "@alto/utils" import { @@ -22,23 +22,23 @@ import { parseUserOperationReceipt, scaleBigIntByPercent } from "@alto/utils" +import { BaseError } from "abitype" import { type Address, type Block, type Hash, + type Hex, + InsufficientFundsError, + NonceTooLowError, type TransactionReceipt, TransactionReceiptNotFoundError, type WatchBlocksReturnType, formatEther, - getAbiItem, - Hex, - InsufficientFundsError, - NonceTooLowError + getAbiItem } from "viem" -import type { Executor } from "./executor" import type { AltoConfig } from "../createConfig" -import { SenderManager } from "./senderManager" -import { BaseError } from "abitype" +import type { Executor } from "./executor" +import type { SenderManager } from "./senderManager" import { getUserOpHashes } from "./utils" function getTransactionsFromUserOperationEntries( @@ -137,7 +137,9 @@ export class ExecutorManager { (timestamp) => now - timestamp < RPM_WINDOW ) - const bundles = await this.mempool.getBundles(this.config.maxBundleCount) + const bundles = await this.mempool.getBundles( + this.config.maxBundleCount + ) if (bundles.length > 0) { const opsCount: number = bundles @@ -434,7 +436,7 @@ export class ExecutorManager { blockNumber: bigint // block number is undefined only if transaction is not found transactionHash: `0x${string}` } - + // Track transaction costs for both included and reverted transactions if ( bundlingStatus.status === "included" || diff --git a/src/executor/fastlane.ts b/src/executor/fastlane.ts index 0f8b2156..de2d8360 100644 --- a/src/executor/fastlane.ts +++ b/src/executor/fastlane.ts @@ -1,14 +1,14 @@ -import { Logger } from "@alto/utils" +import type { Logger } from "@alto/utils" import { - Hex, - createClient, http, - SendRawTransactionReturnType, - Hash, - WalletClient, - PublicClient, - toHex, - BaseError + BaseError, + type Hash, + type Hex, + type PublicClient, + type SendRawTransactionReturnType, + type WalletClient, + createClient, + toHex } from "viem" const pflClient = createClient({ diff --git a/src/executor/filterOpsAndEStimateGas.ts b/src/executor/filterOpsAndEStimateGas.ts index 3ddfd4a0..ecdf2788 100644 --- a/src/executor/filterOpsAndEStimateGas.ts +++ b/src/executor/filterOpsAndEStimateGas.ts @@ -1,35 +1,35 @@ -import { InterfaceReputationManager } from "@alto/mempool" +import type { InterfaceReputationManager } from "@alto/mempool" import { EntryPointV06Abi, EntryPointV07Abi, - FailedOpWithRevert, - RejectedUserOp, - UserOpInfo, - UserOperationBundle, + type FailedOpWithRevert, + type RejectedUserOp, + type UserOpInfo, + type UserOperationBundle, failedOpErrorSchema, failedOpWithRevertErrorSchema } from "@alto/types" import { - Account, + type Logger, + getRevertErrorData, + parseViemError, + scaleBigIntByPercent +} from "@alto/utils" +import * as sentry from "@sentry/node" +import { + type Account, ContractFunctionRevertedError, EstimateGasExecutionError, FeeCapTooLowError, - Hex, - StateOverride, + type Hex, + type StateOverride, decodeErrorResult, getContract } from "viem" -import { AltoConfig } from "../createConfig" -import { - Logger, - getRevertErrorData, - parseViemError, - scaleBigIntByPercent -} from "@alto/utils" import { z } from "zod" -import { packUserOps } from "./utils" -import * as sentry from "@sentry/node" +import type { AltoConfig } from "../createConfig" import { getEip7702DelegationOverrides } from "../utils/eip7702" +import { packUserOps } from "./utils" export type FilterOpsAndEstimateGasResult = | { @@ -172,7 +172,7 @@ export async function filterOpsAndEstimateGas({ const e = parseViemError(err) if (e instanceof ContractFunctionRevertedError) { - let parseResult = z + const parseResult = z .union([failedOpErrorSchema, failedOpWithRevertErrorSchema]) .safeParse(e.data) @@ -213,15 +213,20 @@ export async function filterOpsAndEstimateGas({ userOpsToBundle.splice(failingOpIndex, 1) const innerError = (errorData as FailedOpWithRevert)?.inner - const revertReason = innerError ? `${errorData.reason} - ${innerError}` : errorData.reason - logger.warn({ - event: "userOpSimulationFailedInBundle", - userOpHash: failingUserOp.userOpHash, - sender: failingUserOp.userOp.sender, - reason: revertReason, - opIndex: failingOpIndex, - bundleSize: userOpsToBundle.length + 1 // size before removal - }, `UserOp ${failingUserOp.userOpHash} failed simulation in bundle: ${revertReason}`); + const revertReason = innerError + ? `${errorData.reason} - ${innerError}` + : errorData.reason + logger.warn( + { + event: "userOpSimulationFailedInBundle", + userOpHash: failingUserOp.userOpHash, + sender: failingUserOp.userOp.sender, + reason: revertReason, + opIndex: failingOpIndex, + bundleSize: userOpsToBundle.length + 1 // size before removal + }, + `UserOp ${failingUserOp.userOpHash} failed simulation in bundle: ${revertReason}` + ) reputationManager.crashedHandleOps( failingUserOp.userOp, diff --git a/src/executor/senderManager/createMemorySenderManager.ts b/src/executor/senderManager/createMemorySenderManager.ts index 06e5b99c..ed30b9c4 100644 --- a/src/executor/senderManager/createMemorySenderManager.ts +++ b/src/executor/senderManager/createMemorySenderManager.ts @@ -1,8 +1,8 @@ -import { Metrics } from "@alto/utils" -import { SenderManager, getAvailableWallets } from "." -import { AltoConfig } from "../../createConfig" +import type { Metrics } from "@alto/utils" import { Semaphore } from "async-mutex" -import { Account } from "viem" +import type { Account } from "viem" +import { type SenderManager, getAvailableWallets } from "." +import type { AltoConfig } from "../../createConfig" export const createMemorySenderManager = ({ config, diff --git a/src/executor/senderManager/createRedisSenderManager.ts b/src/executor/senderManager/createRedisSenderManager.ts index f5492701..49f84cc7 100644 --- a/src/executor/senderManager/createRedisSenderManager.ts +++ b/src/executor/senderManager/createRedisSenderManager.ts @@ -1,9 +1,9 @@ -import { Metrics } from "@alto/utils" -import { AltoConfig } from "../../createConfig" -import { SenderManager } from "../senderManager" -import { getAvailableWallets } from "." -import { Account } from "viem" +import type { Metrics } from "@alto/utils" import Redis from "ioredis" +import type { Account } from "viem" +import { getAvailableWallets } from "." +import type { AltoConfig } from "../../createConfig" +import type { SenderManager } from "../senderManager" async function createRedisQueue({ redis, diff --git a/src/executor/senderManager/flushOnStartUp.ts b/src/executor/senderManager/flushOnStartUp.ts index c77c4ee2..1a903b35 100644 --- a/src/executor/senderManager/flushOnStartUp.ts +++ b/src/executor/senderManager/flushOnStartUp.ts @@ -1,6 +1,6 @@ -import { SenderManager } from "." -import { AltoConfig } from "../../createConfig" -import { GasPriceManager } from "../../handlers/gasPriceManager" +import type { SenderManager } from "." +import type { AltoConfig } from "../../createConfig" +import type { GasPriceManager } from "../../handlers/gasPriceManager" import { flushStuckTransaction } from "../utils" export const flushOnStartUp = async ({ diff --git a/src/executor/senderManager/index.ts b/src/executor/senderManager/index.ts index c973f64a..aa5ff9f6 100644 --- a/src/executor/senderManager/index.ts +++ b/src/executor/senderManager/index.ts @@ -1,7 +1,7 @@ -import { Account } from "viem" -import { AltoConfig } from "../../createConfig" +import type { Metrics } from "@alto/utils" +import type { Account } from "viem" +import type { AltoConfig } from "../../createConfig" import { createMemorySenderManager } from "./createMemorySenderManager" -import { Metrics } from "@alto/utils" import { createRedisSenderManager } from "./createRedisSenderManager" export const getAvailableWallets = (config: AltoConfig) => { diff --git a/src/executor/senderManager/validateAndRefill.ts b/src/executor/senderManager/validateAndRefill.ts index 7822e7ae..2bade336 100644 --- a/src/executor/senderManager/validateAndRefill.ts +++ b/src/executor/senderManager/validateAndRefill.ts @@ -1,9 +1,9 @@ -import { Address, formatEther, getContract } from "viem" -import { AltoConfig } from "../../createConfig" -import { Metrics } from "@alto/utils" -import { GasPriceManager } from "../../handlers/gasPriceManager" -import { CallEngineAbi, HexData } from "@alto/types" -import { SenderManager } from "." +import { CallEngineAbi, type HexData } from "@alto/types" +import type { Metrics } from "@alto/utils" +import { type Address, formatEther, getContract } from "viem" +import type { SenderManager } from "." +import type { AltoConfig } from "../../createConfig" +import type { GasPriceManager } from "../../handlers/gasPriceManager" // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: export const validateAndRefillWallets = async ({ diff --git a/src/executor/utilityWalletMonitor.ts b/src/executor/utilityWalletMonitor.ts index 41f92ae7..fb17a440 100644 --- a/src/executor/utilityWalletMonitor.ts +++ b/src/executor/utilityWalletMonitor.ts @@ -1,7 +1,7 @@ import type { Logger, Metrics } from "@alto/utils" +import type { Address } from "abitype" import { type Hex, formatEther } from "viem" import type { AltoConfig } from "../createConfig" -import type { Address } from "abitype" export class UtilityWalletMonitor { private config: AltoConfig diff --git a/src/executor/utils.ts b/src/executor/utils.ts index 4256db5c..3ccdfa5e 100644 --- a/src/executor/utils.ts +++ b/src/executor/utils.ts @@ -6,22 +6,22 @@ import { type UserOperationV07 } from "@alto/types" import { - isVersion06, - toPackedUserOperation, type Logger, - isVersion07 + isVersion06, + isVersion07, + toPackedUserOperation } from "@alto/utils" import * as sentry from "@sentry/node" import { type Account, - type BaseError, - encodeFunctionData, type Address, + type BaseError, type Hex, + encodeFunctionData, toBytes } from "viem" -import type { AltoConfig } from "../createConfig" import type { SignedAuthorizationList } from "viem" +import type { AltoConfig } from "../createConfig" export const isTransactionUnderpricedError = (e: BaseError) => { const transactionUnderPriceError = e.walk((e: any) => diff --git a/src/handlers/abstractGasPriceManager.ts b/src/handlers/abstractGasPriceManager.ts index 797b7bbd..dc5f6f99 100644 --- a/src/handlers/abstractGasPriceManager.ts +++ b/src/handlers/abstractGasPriceManager.ts @@ -1,22 +1,22 @@ // src/gas/abstractGasPriceManager.ts -import type { AltoConfig } from "../createConfig"; -import { createMinMaxQueue, MinMaxQueue } from "../utils/minMaxQueue"; +import type { AltoConfig } from "../createConfig" +import { type MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" export class AbstractManager { - private pubdataPriceQueue: MinMaxQueue; + private pubdataPriceQueue: MinMaxQueue - constructor({ config }: { config: AltoConfig }) { - this.pubdataPriceQueue = createMinMaxQueue({ - keyPrefix: "abstract-pubdata-price-queue", - config - }); - } + constructor({ config }: { config: AltoConfig }) { + this.pubdataPriceQueue = createMinMaxQueue({ + keyPrefix: "abstract-pubdata-price-queue", + config + }) + } - public async getMinPubdataPrice(): Promise { - return (await this.pubdataPriceQueue.getMinValue()) || 1n; - } + public async getMinPubdataPrice(): Promise { + return (await this.pubdataPriceQueue.getMinValue()) || 1n + } - public savePubdataPrice(value: bigint) { - this.pubdataPriceQueue.saveValue(value); - } -} \ No newline at end of file + public savePubdataPrice(value: bigint) { + this.pubdataPriceQueue.saveValue(value) + } +} diff --git a/src/handlers/arbitrumGasPriceManager.ts b/src/handlers/arbitrumGasPriceManager.ts index de4f0f78..648e092e 100644 --- a/src/handlers/arbitrumGasPriceManager.ts +++ b/src/handlers/arbitrumGasPriceManager.ts @@ -1,6 +1,6 @@ import { maxUint128 } from "viem" -import { MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" -import { AltoConfig } from "../createConfig" +import type { AltoConfig } from "../createConfig" +import { type MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" export class ArbitrumManager { private l1BaseFeeQueue: MinMaxQueue @@ -26,17 +26,17 @@ export class ArbitrumManager { } public async getMinL1BaseFee() { - let minL1BaseFee = await this.l1BaseFeeQueue.getMinValue() + const minL1BaseFee = await this.l1BaseFeeQueue.getMinValue() return minL1BaseFee || 1n } public async getMaxL1BaseFee() { - let maxL1BaseFee = await this.l1BaseFeeQueue.getMaxValue() + const maxL1BaseFee = await this.l1BaseFeeQueue.getMaxValue() return maxL1BaseFee || maxUint128 } public async getMaxL2BaseFee() { - let maxL2BaseFee = await this.l2BaseFeeQueue.getMaxValue() + const maxL2BaseFee = await this.l2BaseFeeQueue.getMaxValue() return maxL2BaseFee || maxUint128 } } diff --git a/src/handlers/eventManager.ts b/src/handlers/eventManager.ts index 2b81447e..ad44b0c3 100644 --- a/src/handlers/eventManager.ts +++ b/src/handlers/eventManager.ts @@ -1,10 +1,10 @@ import type { Logger, Metrics } from "@alto/utils" import * as sentry from "@sentry/node" +import Queue, { type Queue as QueueType } from "bull" import Redis from "ioredis" import type { Hex } from "viem" -import type { OpEventType } from "../types/schemas" import type { AltoConfig } from "../createConfig" -import Queue, { type Queue as QueueType } from "bull" +import type { OpEventType } from "../types/schemas" type QueueMessage = OpEventType & { userOperationHash: Hex diff --git a/src/handlers/gasPriceManager.ts b/src/handlers/gasPriceManager.ts index 22a06c2e..7bd18197 100644 --- a/src/handlers/gasPriceManager.ts +++ b/src/handlers/gasPriceManager.ts @@ -15,11 +15,11 @@ import { polygonMumbai } from "viem/chains" import type { AltoConfig } from "../createConfig" -import { MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" +import { type MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" +import { AbstractManager } from "./abstractGasPriceManager" import { ArbitrumManager } from "./arbitrumGasPriceManager" import { MantleManager } from "./mantleGasPriceManager" import { OptimismManager } from "./optimismManager" -import { AbstractManager } from "./abstractGasPriceManager"; enum ChainId { Goerli = 5, diff --git a/src/handlers/mantleGasPriceManager.ts b/src/handlers/mantleGasPriceManager.ts index a2ae26c4..c723480b 100644 --- a/src/handlers/mantleGasPriceManager.ts +++ b/src/handlers/mantleGasPriceManager.ts @@ -1,5 +1,5 @@ -import { AltoConfig } from "../createConfig" -import { MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" +import type { AltoConfig } from "../createConfig" +import { type MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" export class MantleManager { private tokenRatioQueue: MinMaxQueue diff --git a/src/handlers/optimismManager.ts b/src/handlers/optimismManager.ts index 705f7077..688ebbff 100644 --- a/src/handlers/optimismManager.ts +++ b/src/handlers/optimismManager.ts @@ -1,5 +1,5 @@ -import { AltoConfig } from "../createConfig" -import { MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" +import type { AltoConfig } from "../createConfig" +import { type MinMaxQueue, createMinMaxQueue } from "../utils/minMaxQueue" export class OptimismManager { private l1FeeQueue: MinMaxQueue diff --git a/src/mempool/mempool.ts b/src/mempool/mempool.ts index b86f29c9..a21470df 100644 --- a/src/mempool/mempool.ts +++ b/src/mempool/mempool.ts @@ -1,5 +1,7 @@ import type { EventManager } from "@alto/handlers" +import type { MempoolStore } from "@alto/store" import { + type Address, EntryPointV06Abi, EntryPointV07Abi, type InterfaceValidator, @@ -8,12 +10,11 @@ import { type StorageMap, type SubmittedUserOp, type TransactionInfo, + type UserOpInfo, type UserOperation, type UserOperationBundle, - type UserOpInfo, ValidationErrors, - type ValidationResult, - type Address + type ValidationResult } from "@alto/types" import type { Logger } from "@alto/utils" import { @@ -24,13 +25,12 @@ import { scaleBigIntByPercent } from "@alto/utils" import { getAddress, getContract } from "viem" +import type { AltoConfig } from "../createConfig" import type { Monitor } from "./monitoring" import { type InterfaceReputationManager, ReputationStatuses } from "./reputationManager" -import type { AltoConfig } from "../createConfig" -import type { MempoolStore } from "@alto/store" export class Mempool { private config: AltoConfig @@ -320,21 +320,26 @@ export class Mempool { return [false, `${message}, bump the gas price by minimum 10%`] } - this.logger.info({ - event: "userOpReplaced", - reason: "Higher gas fees", - replacedUserOpHash: userOpInfo.userOpHash, - newUserOpHash: userOpHash, - sender: userOp.sender, - oldFees: { - maxFeePerGas: conflictingUserOp.maxFeePerGas.toString(), - maxPriorityFeePerGas: conflictingUserOp.maxPriorityFeePerGas.toString() + this.logger.info( + { + event: "userOpReplaced", + reason: "Higher gas fees", + replacedUserOpHash: userOpInfo.userOpHash, + newUserOpHash: userOpHash, + sender: userOp.sender, + oldFees: { + maxFeePerGas: conflictingUserOp.maxFeePerGas.toString(), + maxPriorityFeePerGas: + conflictingUserOp.maxPriorityFeePerGas.toString() + }, + newFees: { + maxFeePerGas: userOp.maxFeePerGas.toString(), + maxPriorityFeePerGas: + userOp.maxPriorityFeePerGas.toString() + } }, - newFees: { - maxFeePerGas: userOp.maxFeePerGas.toString(), - maxPriorityFeePerGas: userOp.maxPriorityFeePerGas.toString() - } - }, `Replacing user operation ${userOpInfo.userOpHash} due to higher gas fees.`) + `Replacing user operation ${userOpInfo.userOpHash} due to higher gas fees.` + ) await this.reputationManager.replaceUserOperationSeenStatus( conflictingUserOp, @@ -435,16 +440,19 @@ export class Mempool { paymasterStatus === ReputationStatuses.banned || factoryStatus === ReputationStatuses.banned ) { - this.logger.warn({ - event: "userOpSkipped", - reason: "Entity banned", - userOpHash: userOpHash, - sender: userOp.sender, - paymaster: paymaster, - factory: factory, - paymasterStatus: paymasterStatus.toString(), - factoryStatus: factoryStatus.toString() - }, `Skipping userOp ${userOpHash}: associated entity is banned.`); + this.logger.warn( + { + event: "userOpSkipped", + reason: "Entity banned", + userOpHash: userOpHash, + sender: userOp.sender, + paymaster: paymaster, + factory: factory, + paymasterStatus: paymasterStatus.toString(), + factoryStatus: factoryStatus.toString() + }, + `Skipping userOp ${userOpHash}: associated entity is banned.` + ) return { skip: true, removeOutstanding: true, @@ -461,13 +469,16 @@ export class Mempool { paymaster && stakedEntityCount[paymaster] >= this.throttledEntityBundleCount ) { - this.logger.info({ - event: "userOpSkipped", - reason: "Paymaster throttled", - userOpHash: userOpHash, - sender: userOp.sender, - paymaster: paymaster - }, `Skipping userOp ${userOpHash}: paymaster is throttled.`) + this.logger.info( + { + event: "userOpSkipped", + reason: "Paymaster throttled", + userOpHash: userOpHash, + sender: userOp.sender, + paymaster: paymaster + }, + `Skipping userOp ${userOpHash}: paymaster is throttled.` + ) return { skip: true, paymasterDeposit, @@ -483,13 +494,16 @@ export class Mempool { factory && stakedEntityCount[factory] >= this.throttledEntityBundleCount ) { - this.logger.info({ - event: "userOpSkipped", - reason: "Factory throttled", - userOpHash: userOpHash, - sender: userOp.sender, - factory: factory - }, `Skipping userOp ${userOpHash}: factory is throttled.`) + this.logger.info( + { + event: "userOpSkipped", + reason: "Factory throttled", + userOpHash: userOpHash, + sender: userOp.sender, + factory: factory + }, + `Skipping userOp ${userOpHash}: factory is throttled.` + ) return { skip: true, paymasterDeposit, @@ -765,14 +779,24 @@ export class Mempool { gasUsed > maxGasLimit && currentBundle.userOps.length >= minOpsPerBundle ) { - this.logger.debug({ - event: "userOpSkipped", - reason: "Bundle gas limit exceeded", - userOpHash: userOpInfo.userOpHash, - userOpGas: (userOp.callGasLimit + userOp.verificationGasLimit).toString(), - currentBundleGas: (gasUsed - userOp.callGasLimit - userOp.verificationGasLimit).toString(), - maxBundleGas: maxGasLimit.toString() - }, `Skipping userOp ${userOpInfo.userOpHash}, would exceed bundle gas limit.`); + this.logger.debug( + { + event: "userOpSkipped", + reason: "Bundle gas limit exceeded", + userOpHash: userOpInfo.userOpHash, + userOpGas: ( + userOp.callGasLimit + + userOp.verificationGasLimit + ).toString(), + currentBundleGas: ( + gasUsed - + userOp.callGasLimit - + userOp.verificationGasLimit + ).toString(), + maxBundleGas: maxGasLimit.toString() + }, + `Skipping userOp ${userOpInfo.userOpHash}, would exceed bundle gas limit.` + ) // Put the operation back in the store await this.store.addOutstanding({ entryPoint, userOpInfo }) diff --git a/src/mempool/monitoring.ts b/src/mempool/monitoring.ts index 6bf56e44..24e7dedb 100644 --- a/src/mempool/monitoring.ts +++ b/src/mempool/monitoring.ts @@ -1,6 +1,6 @@ import type { HexData32, UserOperationStatus } from "@alto/types" -import { AltoConfig } from "../createConfig" import { Redis } from "ioredis" +import type { AltoConfig } from "../createConfig" import { userOperationStatusSchema } from "../types/schemas" interface UserOperationStatusStore { diff --git a/src/mempool/reputationManager.ts b/src/mempool/reputationManager.ts index 48c7955a..51ddbf59 100644 --- a/src/mempool/reputationManager.ts +++ b/src/mempool/reputationManager.ts @@ -12,9 +12,9 @@ import { getAddressFromInitCodeOrPaymasterAndData, isVersion06 } from "@alto/utils" +import type { ReadonlyDeep } from "type-fest" import { type Address, getAddress, getContract } from "viem" import type { AltoConfig } from "../createConfig" -import { ReadonlyDeep } from "type-fest" export interface InterfaceReputationManager { checkReputation( diff --git a/src/rpc/createMethodHandler.ts b/src/rpc/createMethodHandler.ts index 45cf6704..a81b22b6 100644 --- a/src/rpc/createMethodHandler.ts +++ b/src/rpc/createMethodHandler.ts @@ -1,7 +1,7 @@ -import type { z } from "zod" -import type { RpcHandler } from "./rpcHandler" import type { ApiVersion } from "@alto/types" import type { ReadonlyDeep } from "type-fest" +import type { z } from "zod" +import type { RpcHandler } from "./rpcHandler" export type MethodHandler = { schema: T diff --git a/src/rpc/estimation/gasEstimationHandler.ts b/src/rpc/estimation/gasEstimationHandler.ts index 9666695f..a3e01002 100644 --- a/src/rpc/estimation/gasEstimationHandler.ts +++ b/src/rpc/estimation/gasEstimationHandler.ts @@ -1,12 +1,12 @@ import type { UserOperation } from "@alto/types" import type { StateOverrides, UserOperationV07 } from "@alto/types" import { deepHexlify, isVersion06 } from "@alto/utils" -import { parseEther, toHex, type Hex } from "viem" +import { type Hex, parseEther, toHex } from "viem" import type { Address } from "viem" +import type { AltoConfig } from "../../createConfig" import { GasEstimatorV06 } from "./gasEstimationsV06" import { GasEstimatorV07 } from "./gasEstimationsV07" import type { SimulateHandleOpResult } from "./types" -import type { AltoConfig } from "../../createConfig" function getStateOverrides({ addSenderBalanceOverride, diff --git a/src/rpc/estimation/gasEstimationsV06.ts b/src/rpc/estimation/gasEstimationsV06.ts index b3f1dfd5..138becc2 100644 --- a/src/rpc/estimation/gasEstimationsV06.ts +++ b/src/rpc/estimation/gasEstimationsV06.ts @@ -8,19 +8,19 @@ import { hexDataSchema } from "@alto/types" import type { StateOverrides, UserOperationV06 } from "@alto/types" +import { deepHexlify, getAuthorizationStateOverrides } from "@alto/utils" import type { Hex, RpcRequestErrorType } from "viem" import { type Address, + RpcRequestError, decodeErrorResult, encodeFunctionData, - toHex, - RpcRequestError + toHex } from "viem" import { z } from "zod" -import type { SimulateHandleOpResult } from "./types" import type { AltoConfig } from "../../createConfig" import { parseFailedOpWithRevert } from "./gasEstimationsV07" -import { deepHexlify, getAuthorizationStateOverrides } from "@alto/utils" +import type { SimulateHandleOpResult } from "./types" export class GasEstimatorV06 { private config: AltoConfig diff --git a/src/rpc/estimation/gasEstimationsV07.ts b/src/rpc/estimation/gasEstimationsV07.ts index 598feedb..1eb1380f 100644 --- a/src/rpc/estimation/gasEstimationsV07.ts +++ b/src/rpc/estimation/gasEstimationsV07.ts @@ -1,4 +1,5 @@ import { + type BinarySearchCallResult, EntryPointV07Abi, EntryPointV07SimulationsAbi, ExecutionErrors, @@ -6,7 +7,6 @@ import { PimlicoEntryPointSimulationsAbi, RpcError, type StateOverrides, - type BinarySearchCallResult, type UserOperationV07, ValidationErrors, type ValidationResultV07, @@ -31,13 +31,13 @@ import { toHex, zeroAddress } from "viem" +import type { AltoConfig } from "../../createConfig" import { AccountExecuteAbi } from "../../types/contracts/IAccountExecute" import { type SimulateBinarySearchRetryResult, type SimulateHandleOpResult, simulationValidationResultStruct } from "./types" -import type { AltoConfig } from "../../createConfig" export class GasEstimatorV07 { private config: AltoConfig diff --git a/src/rpc/estimation/types.ts b/src/rpc/estimation/types.ts index 9a8d4ffb..f6e6aa63 100644 --- a/src/rpc/estimation/types.ts +++ b/src/rpc/estimation/types.ts @@ -1,8 +1,8 @@ import type { Address, + BinarySearchCallResult, ExecutionResult, - PackedUserOperation, - BinarySearchCallResult + PackedUserOperation } from "@alto/types" import type { Hex } from "viem" diff --git a/src/rpc/methods/debug_bundler_clearReputation.ts b/src/rpc/methods/debug_bundler_clearReputation.ts index d7566ebc..f3b9f157 100644 --- a/src/rpc/methods/debug_bundler_clearReputation.ts +++ b/src/rpc/methods/debug_bundler_clearReputation.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugClearReputationSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugClearReputationHandler = createMethodHandler({ schema: debugClearReputationSchema, diff --git a/src/rpc/methods/debug_bundler_clearState.ts b/src/rpc/methods/debug_bundler_clearState.ts index cda9ed81..96e3ac72 100644 --- a/src/rpc/methods/debug_bundler_clearState.ts +++ b/src/rpc/methods/debug_bundler_clearState.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugClearStateSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugBundlerClearStateHandler = createMethodHandler({ schema: debugClearStateSchema, diff --git a/src/rpc/methods/debug_bundler_dumpMempool.ts b/src/rpc/methods/debug_bundler_dumpMempool.ts index 8ece9a76..30ffb544 100644 --- a/src/rpc/methods/debug_bundler_dumpMempool.ts +++ b/src/rpc/methods/debug_bundler_dumpMempool.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugDumpMempoolSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugBundlerDumpMempoolHandler = createMethodHandler({ schema: debugDumpMempoolSchema, diff --git a/src/rpc/methods/debug_bundler_dumpReputation.ts b/src/rpc/methods/debug_bundler_dumpReputation.ts index fabd3201..834cd57c 100644 --- a/src/rpc/methods/debug_bundler_dumpReputation.ts +++ b/src/rpc/methods/debug_bundler_dumpReputation.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugDumpReputationSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugBundlerDumpReputationHandler = createMethodHandler({ schema: debugDumpReputationSchema, diff --git a/src/rpc/methods/debug_bundler_getStakeStatus.ts b/src/rpc/methods/debug_bundler_getStakeStatus.ts index 3d296567..258a8e55 100644 --- a/src/rpc/methods/debug_bundler_getStakeStatus.ts +++ b/src/rpc/methods/debug_bundler_getStakeStatus.ts @@ -1,5 +1,5 @@ +import { RpcError, debugGetStakeStatusSchema } from "@alto/types" import { createMethodHandler } from "../createMethodHandler" -import { debugGetStakeStatusSchema, RpcError } from "@alto/types" export const debugGetStakeStatusHandler = createMethodHandler({ schema: debugGetStakeStatusSchema, diff --git a/src/rpc/methods/debug_bundler_sendBundleNow.ts b/src/rpc/methods/debug_bundler_sendBundleNow.ts index 2107121a..9ebb9060 100644 --- a/src/rpc/methods/debug_bundler_sendBundleNow.ts +++ b/src/rpc/methods/debug_bundler_sendBundleNow.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugSendBundleNowSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugBundlerSendBundleNowHandler = createMethodHandler({ method: "debug_bundler_sendBundleNow", diff --git a/src/rpc/methods/debug_bundler_setBundlingMode.ts b/src/rpc/methods/debug_bundler_setBundlingMode.ts index d58fe2f4..8513c2d0 100644 --- a/src/rpc/methods/debug_bundler_setBundlingMode.ts +++ b/src/rpc/methods/debug_bundler_setBundlingMode.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugSetBundlingModeSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugBundlerSetBundlingModeHandler = createMethodHandler({ method: "debug_bundler_setBundlingMode", diff --git a/src/rpc/methods/debug_bundler_setReputation.ts b/src/rpc/methods/debug_bundler_setReputation.ts index c00121a6..50a9d69d 100644 --- a/src/rpc/methods/debug_bundler_setReputation.ts +++ b/src/rpc/methods/debug_bundler_setReputation.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { debugSetReputationSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const debugSetReputationHandler = createMethodHandler({ method: "debug_bundler_setReputation", diff --git a/src/rpc/methods/eth_chainId.ts b/src/rpc/methods/eth_chainId.ts index 99dd5145..a417d1a6 100644 --- a/src/rpc/methods/eth_chainId.ts +++ b/src/rpc/methods/eth_chainId.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { chainIdSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const ethChainIdHandler = createMethodHandler({ method: "eth_chainId", diff --git a/src/rpc/methods/eth_estimateUserOperationGas.ts b/src/rpc/methods/eth_estimateUserOperationGas.ts index ca050496..d4c41164 100644 --- a/src/rpc/methods/eth_estimateUserOperationGas.ts +++ b/src/rpc/methods/eth_estimateUserOperationGas.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { estimateUserOperationGasSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const ethEstimateUserOperationGasHandler = createMethodHandler({ method: "eth_estimateUserOperationGas", diff --git a/src/rpc/methods/eth_getUserOperationByHash.ts b/src/rpc/methods/eth_getUserOperationByHash.ts index ff2ffd74..9e55d37f 100644 --- a/src/rpc/methods/eth_getUserOperationByHash.ts +++ b/src/rpc/methods/eth_getUserOperationByHash.ts @@ -1,14 +1,3 @@ -import { - getAbiItem, - type Transaction, - TransactionNotFoundError, - decodeFunctionData, - toFunctionSelector, - slice, - getAddress -} from "viem" -import { toUnpackedUserOperation } from "../../utils/userop" -import { createMethodHandler } from "../createMethodHandler" import { EntryPointV06Abi, EntryPointV07Abi, @@ -19,6 +8,17 @@ import { type UserOperationV07, getUserOperationByHashSchema } from "@alto/types" +import { + type Transaction, + TransactionNotFoundError, + decodeFunctionData, + getAbiItem, + getAddress, + slice, + toFunctionSelector +} from "viem" +import { toUnpackedUserOperation } from "../../utils/userop" +import { createMethodHandler } from "../createMethodHandler" const userOperationEventAbiItem = getAbiItem({ abi: EntryPointV06Abi, diff --git a/src/rpc/methods/eth_getUserOperationReceipt.ts b/src/rpc/methods/eth_getUserOperationReceipt.ts index 783ded5e..c96fb176 100644 --- a/src/rpc/methods/eth_getUserOperationReceipt.ts +++ b/src/rpc/methods/eth_getUserOperationReceipt.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { getUserOperationReceiptSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const ethGetUserOperationReceiptHandler = createMethodHandler({ method: "eth_getUserOperationReceipt", diff --git a/src/rpc/methods/eth_sendUserOperation.ts b/src/rpc/methods/eth_sendUserOperation.ts index f4b39b39..042249ef 100644 --- a/src/rpc/methods/eth_sendUserOperation.ts +++ b/src/rpc/methods/eth_sendUserOperation.ts @@ -1,6 +1,6 @@ +import { sendUserOperationSchema } from "@alto/types" import { getUserOperationHash } from "../../utils/userop" import { createMethodHandler } from "../createMethodHandler" -import { sendUserOperationSchema } from "@alto/types" export const ethSendUserOperationHandler = createMethodHandler({ method: "eth_sendUserOperation", diff --git a/src/rpc/methods/eth_supportedEntryPoints.ts b/src/rpc/methods/eth_supportedEntryPoints.ts index e5d0ab39..a5332f30 100644 --- a/src/rpc/methods/eth_supportedEntryPoints.ts +++ b/src/rpc/methods/eth_supportedEntryPoints.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { supportedEntryPointsSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const ethSupportedEntryPointsHandler = createMethodHandler({ method: "eth_supportedEntryPoints", diff --git a/src/rpc/methods/index.ts b/src/rpc/methods/index.ts index 8704b837..a3f97986 100644 --- a/src/rpc/methods/index.ts +++ b/src/rpc/methods/index.ts @@ -1,10 +1,4 @@ import type { RpcHandler } from "../rpcHandler" -import { ethChainIdHandler } from "./eth_chainId" -import { ethEstimateUserOperationGasHandler } from "./eth_estimateUserOperationGas" -import { ethGetUserOperationByHashHandler } from "./eth_getUserOperationByHash" -import { ethGetUserOperationReceiptHandler } from "./eth_getUserOperationReceipt" -import { ethSendUserOperationHandler } from "./eth_sendUserOperation" -import { ethSupportedEntryPointsHandler } from "./eth_supportedEntryPoints" import { debugClearReputationHandler } from "./debug_bundler_clearReputation" import { debugBundlerClearStateHandler } from "./debug_bundler_clearState" import { debugBundlerDumpMempoolHandler } from "./debug_bundler_dumpMempool" @@ -13,6 +7,12 @@ import { debugGetStakeStatusHandler } from "./debug_bundler_getStakeStatus" import { debugBundlerSendBundleNowHandler } from "./debug_bundler_sendBundleNow" import { debugBundlerSetBundlingModeHandler } from "./debug_bundler_setBundlingMode" import { debugSetReputationHandler } from "./debug_bundler_setReputation" +import { ethChainIdHandler } from "./eth_chainId" +import { ethEstimateUserOperationGasHandler } from "./eth_estimateUserOperationGas" +import { ethGetUserOperationByHashHandler } from "./eth_getUserOperationByHash" +import { ethGetUserOperationReceiptHandler } from "./eth_getUserOperationReceipt" +import { ethSendUserOperationHandler } from "./eth_sendUserOperation" +import { ethSupportedEntryPointsHandler } from "./eth_supportedEntryPoints" import { pimlicoGetUserOperationGasPriceHandler } from "./pimlico_getUserOperationGasPrice" import { pimlicoGetUserOperationStatusHandler } from "./pimlico_getUserOperationStatus" import { pimlicoSendUserOperationNowHandler } from "./pimlico_sendUserOperationNow" diff --git a/src/rpc/methods/pimlico_getUserOperationGasPrice.ts b/src/rpc/methods/pimlico_getUserOperationGasPrice.ts index e21b087d..9bffb987 100644 --- a/src/rpc/methods/pimlico_getUserOperationGasPrice.ts +++ b/src/rpc/methods/pimlico_getUserOperationGasPrice.ts @@ -1,6 +1,6 @@ +import { pimlicoGetUserOperationGasPriceSchema } from "@alto/types" import { scaleBigIntByPercent } from "../../utils/bigInt" import { createMethodHandler } from "../createMethodHandler" -import { pimlicoGetUserOperationGasPriceSchema } from "@alto/types" export const pimlicoGetUserOperationGasPriceHandler = createMethodHandler({ method: "pimlico_getUserOperationGasPrice", diff --git a/src/rpc/methods/pimlico_getUserOperationStatus.ts b/src/rpc/methods/pimlico_getUserOperationStatus.ts index f6e8f2a9..20529371 100644 --- a/src/rpc/methods/pimlico_getUserOperationStatus.ts +++ b/src/rpc/methods/pimlico_getUserOperationStatus.ts @@ -1,5 +1,5 @@ -import { createMethodHandler } from "../createMethodHandler" import { pimlicoGetUserOperationStatusSchema } from "@alto/types" +import { createMethodHandler } from "../createMethodHandler" export const pimlicoGetUserOperationStatusHandler = createMethodHandler({ method: "pimlico_getUserOperationStatus", diff --git a/src/rpc/methods/pimlico_sendUserOperationNow.ts b/src/rpc/methods/pimlico_sendUserOperationNow.ts index 346fd93b..10c14eca 100644 --- a/src/rpc/methods/pimlico_sendUserOperationNow.ts +++ b/src/rpc/methods/pimlico_sendUserOperationNow.ts @@ -1,9 +1,3 @@ -import { - getUserOperationHash, - isVersion06, - parseUserOperationReceipt -} from "@alto/utils" -import { createMethodHandler } from "../createMethodHandler" import { RpcError, type UserOpInfo, @@ -11,6 +5,12 @@ import { ValidationErrors, pimlicoSendUserOperationNowSchema } from "@alto/types" +import { + getUserOperationHash, + isVersion06, + parseUserOperationReceipt +} from "@alto/utils" +import { createMethodHandler } from "../createMethodHandler" export const pimlicoSendUserOperationNowHandler = createMethodHandler({ method: "pimlico_sendUserOperationNow", diff --git a/src/rpc/rpcHandler.ts b/src/rpc/rpcHandler.ts index ec7d17a7..6602ff53 100644 --- a/src/rpc/rpcHandler.ts +++ b/src/rpc/rpcHandler.ts @@ -30,10 +30,10 @@ import { } from "@alto/utils" import { type Hex, getContract, zeroAddress } from "viem" import { base, baseSepolia, optimism } from "viem/chains" +import { recoverAuthorizationAddress } from "viem/utils" import type { AltoConfig } from "../createConfig" import type { MethodHandler } from "./createMethodHandler" import { registerHandlers } from "./methods" -import { recoverAuthorizationAddress } from "viem/utils" export class RpcHandler { public config: AltoConfig diff --git a/src/rpc/validation/SafeValidator.ts b/src/rpc/validation/SafeValidator.ts index 9214d26a..cc38d7b9 100644 --- a/src/rpc/validation/SafeValidator.ts +++ b/src/rpc/validation/SafeValidator.ts @@ -27,13 +27,13 @@ import { } from "@alto/types" import type { Metrics } from "@alto/utils" import { - getAuthorizationStateOverrides, calcVerificationGasAndCallGasLimit, getAddressFromInitCodeOrPaymasterAndData, + getAuthorizationStateOverrides, isVersion06, isVersion07, - toPackedUserOperation, - isVersion08 + isVersion08, + toPackedUserOperation } from "@alto/utils" import { type ExecutionRevertedError, @@ -43,6 +43,7 @@ import { encodeFunctionData, zeroAddress } from "viem" +import type { AltoConfig } from "../../createConfig" import { getSimulateValidationResult } from "../estimation/gasEstimationsV07" import { type BundlerTracerResult, @@ -53,7 +54,6 @@ import { tracerResultParserV06 } from "./TracerResultParserV06" import { tracerResultParserV07 } from "./TracerResultParserV07" import { UnsafeValidator } from "./UnsafeValidator" import { debug_traceCall } from "./tracer" -import type { AltoConfig } from "../../createConfig" export class SafeValidator extends UnsafeValidator diff --git a/src/rpc/validation/TracerResultParserV07.ts b/src/rpc/validation/TracerResultParserV07.ts index a13403d4..2ee429e7 100644 --- a/src/rpc/validation/TracerResultParserV07.ts +++ b/src/rpc/validation/TracerResultParserV07.ts @@ -9,6 +9,7 @@ import { ValidationErrors, type ValidationResultV07 } from "@alto/types" +import { areAddressesEqual, isVersion08 } from "@alto/utils" import type { Abi, AbiFunction } from "abitype" // This file contains references to validation rules, in the format [xxx-###] // where xxx is OP/STO/COD/EP/SREP/EREP/UREP/ALT, and ### is a number @@ -24,7 +25,6 @@ import { toFunctionSelector } from "viem" import type { BundlerTracerResult } from "./BundlerCollectorTracerV07" -import { areAddressesEqual, isVersion08 } from "@alto/utils" interface CallEntry { to: string diff --git a/src/rpc/validation/UnsafeValidator.ts b/src/rpc/validation/UnsafeValidator.ts index e5cbc459..5d0d64c8 100644 --- a/src/rpc/validation/UnsafeValidator.ts +++ b/src/rpc/validation/UnsafeValidator.ts @@ -35,18 +35,18 @@ import * as sentry from "@sentry/node" import { BaseError, ContractFunctionExecutionError, + type Hex, decodeAbiParameters, getContract, - type Hex, pad, slice, toHex, zeroAddress } from "viem" import { fromZodError } from "zod-validation-error" +import type { AltoConfig } from "../../createConfig" import { GasEstimationHandler } from "../estimation/gasEstimationHandler" import type { SimulateHandleOpResult } from "../estimation/types" -import type { AltoConfig } from "../../createConfig" function decodeRevertReason(errorData: string): string { // Try to decode hex-encoded revert data if it looks like Error(string) selector (0x08c379a0) diff --git a/src/rpc/validation/tracer.ts b/src/rpc/validation/tracer.ts index 282e2695..7a842488 100644 --- a/src/rpc/validation/tracer.ts +++ b/src/rpc/validation/tracer.ts @@ -1,5 +1,5 @@ // biome-ignore lint/style/noNamespaceImport: explicitly make it clear when sentry is used -import { StateOverrides } from "@alto/types" +import type { StateOverrides } from "@alto/types" import * as sentry from "@sentry/node" import { type Account, diff --git a/src/store/createMemoryOutstandingStore.ts b/src/store/createMemoryOutstandingStore.ts index 264af45b..36e421c9 100644 --- a/src/store/createMemoryOutstandingStore.ts +++ b/src/store/createMemoryOutstandingStore.ts @@ -1,12 +1,12 @@ +import type { HexData32, UserOpInfo, UserOperation } from "@alto/types" +import type { Logger } from "@alto/utils" +import type { ConflictingOutstandingType, OutstandingStore } from "." +import type { AltoConfig } from "../createConfig" import { getNonceKeyAndSequence, isVersion06, isVersion07 } from "../utils/userop" -import { AltoConfig } from "../createConfig" -import { HexData32, UserOpInfo, UserOperation } from "@alto/types" -import { ConflictingOutstandingType, OutstandingStore } from "." -import { Logger } from "@alto/utils" const senderNonceSlot = (userOp: UserOperation) => { const sender = userOp.sender diff --git a/src/store/createMempoolStore.ts b/src/store/createMempoolStore.ts index 7804828a..1540e6dd 100644 --- a/src/store/createMempoolStore.ts +++ b/src/store/createMempoolStore.ts @@ -1,32 +1,32 @@ -import { - UserOperation, - type HexData32, - type SubmittedUserOp, - type UserOpInfo +import type { + HexData32, + SubmittedUserOp, + UserOpInfo, + UserOperation } from "@alto/types" -import { type Metrics } from "@alto/utils" +import type { Metrics } from "@alto/utils" import type { Logger } from "@alto/utils" -import { - Store, +import type { Address } from "viem" +import type { + EntryPointSubmittedUserOpParam, + EntryPointUserOpHashParam, + EntryPointUserOpInfoParam, MempoolStore, OutstandingStore, - StoreType, - EntryPointUserOpHashParam, - EntryPointSubmittedUserOpParam, - EntryPointUserOpInfoParam + Store, + StoreType } from "." -import { AltoConfig } from "../createConfig" +import type { AltoConfig } from "../createConfig" import { createMemoryOutstandingQueue } from "./createMemoryOutstandingStore" -import { createMemoryStore } from "./createStore" -import { Address } from "viem" import { createRedisOutstandingQueue } from "./createRedisOutstandingStore" import { createRedisStore } from "./createRedisStore" +import { createMemoryStore } from "./createStore" export const createMempoolStore = ({ config, metrics }: { config: AltoConfig; metrics: Metrics }): MempoolStore => { - let logger: Logger = config.getLogger( + const logger: Logger = config.getLogger( { module: "mempool-store" }, { level: config.logLevel diff --git a/src/store/createRedisOutstandingStore.ts b/src/store/createRedisOutstandingStore.ts index 403db24d..015d8a59 100644 --- a/src/store/createRedisOutstandingStore.ts +++ b/src/store/createRedisOutstandingStore.ts @@ -1,19 +1,19 @@ +import { + type Address, + type HexData32, + type UserOpInfo, + type UserOperation, + userOpInfoSchema +} from "@alto/types" +import { type ChainableCommander, Redis } from "ioredis" +import { toHex } from "viem/utils" +import type { OutstandingStore } from "." +import type { AltoConfig } from "../createConfig" import { getNonceKeyAndSequence, isVersion06, isVersion07 } from "../utils/userop" -import { AltoConfig } from "../createConfig" -import { - Address, - HexData32, - UserOperation, - UserOpInfo, - userOpInfoSchema -} from "@alto/types" -import { OutstandingStore } from "." -import { ChainableCommander, Redis } from "ioredis" -import { toHex } from "viem/utils" const serializeUserOpInfo = (userOpInfo: UserOpInfo): string => { return JSON.stringify(userOpInfo, (_, value) => diff --git a/src/store/createRedisStore.ts b/src/store/createRedisStore.ts index 7b559f00..e24e78c9 100644 --- a/src/store/createRedisStore.ts +++ b/src/store/createRedisStore.ts @@ -1,9 +1,13 @@ import Redis from "ioredis" -import { Store, UserOpType } from "." -import { AltoConfig } from "../createConfig" -import { HexData32, UserOperation, userOperationSchema } from "../types/schemas" +import { type Address, toHex } from "viem" +import type { Store, UserOpType } from "." +import type { AltoConfig } from "../createConfig" +import { + type HexData32, + type UserOperation, + userOperationSchema +} from "../types/schemas" import { isVersion06, isVersion07 } from "../utils/userop" -import { Address, toHex } from "viem" import { RedisHash } from "./createRedisOutstandingStore" import { createMemoryStore } from "./createStore" diff --git a/src/store/createStore.ts b/src/store/createStore.ts index d3db14a3..a67d3b8e 100644 --- a/src/store/createStore.ts +++ b/src/store/createStore.ts @@ -1,6 +1,6 @@ -import { Store, UserOpType } from "." -import { AltoConfig } from "../createConfig" -import { HexData32, UserOperation } from "../types/schemas" +import type { Store, UserOpType } from "." +import type { AltoConfig } from "../createConfig" +import type { HexData32, UserOperation } from "../types/schemas" import { isVersion06, isVersion07 } from "../utils/userop" export const createMemoryStore = ({ diff --git a/src/types/utils.ts b/src/types/utils.ts index 6ade6051..21d1a022 100644 --- a/src/types/utils.ts +++ b/src/types/utils.ts @@ -39,4 +39,4 @@ export type ChainType = | "arbitrum" | "hedera" | "mantle" - | "abstract" \ No newline at end of file + | "abstract" diff --git a/src/utils/eip7702.ts b/src/utils/eip7702.ts index 98690f2a..0584ab4c 100644 --- a/src/utils/eip7702.ts +++ b/src/utils/eip7702.ts @@ -1,8 +1,8 @@ -import { StateOverride, concat } from "viem" -import { UserOperation } from "../types/schemas" +import { type StateOverride, concat } from "viem" +import type { UserOperation } from "../types/schemas" export const getEip7702DelegationOverrides = (userOps: UserOperation[]) => { - let stateOverride: StateOverride = [] + const stateOverride: StateOverride = [] for (const userOp of userOps) { if (userOp.eip7702Auth) { diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 07c7ce8a..b12ea857 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,5 +1,5 @@ import type { StateOverrides, UserOperation } from "@alto/types" -import { BaseError, type RawContractError, getAddress, concat } from "viem" +import { BaseError, type RawContractError, concat, getAddress } from "viem" import type { SignedAuthorization } from "viem" /// Ensure proper equality by converting both addresses into their checksum type @@ -71,5 +71,5 @@ export function getAuthorizationStateOverrides({ /** Integer-ceil division for bigint — equivalent to Math.ceil(a / b). */ export function ceilDiv(a: bigint, b: bigint): bigint { - return (a + b - 1n) / b; -} \ No newline at end of file + return (a + b - 1n) / b +} diff --git a/src/utils/minMaxQueue/createMemoryMinMaxQueue.ts b/src/utils/minMaxQueue/createMemoryMinMaxQueue.ts index c6acd78f..bc8425d8 100644 --- a/src/utils/minMaxQueue/createMemoryMinMaxQueue.ts +++ b/src/utils/minMaxQueue/createMemoryMinMaxQueue.ts @@ -1,5 +1,5 @@ -import { MinMaxQueue } from "." -import { AltoConfig } from "../../createConfig" +import type { MinMaxQueue } from "." +import type { AltoConfig } from "../../createConfig" type QueueEntry = { timestamp: number; value: bigint } diff --git a/src/utils/minMaxQueue/createRedisMinMaxQueue.ts b/src/utils/minMaxQueue/createRedisMinMaxQueue.ts index a2c4f909..51c2d8ed 100644 --- a/src/utils/minMaxQueue/createRedisMinMaxQueue.ts +++ b/src/utils/minMaxQueue/createRedisMinMaxQueue.ts @@ -1,7 +1,7 @@ import Redis from "ioredis" -import { MinMaxQueue } from "." -import { AltoConfig } from "../../createConfig" +import type { MinMaxQueue } from "." +import type { AltoConfig } from "../../createConfig" // Sorted TTL queue, one queue to keep track of values and other queue to keep track of TTL. class SortedTtlSet { diff --git a/src/utils/minMaxQueue/index.ts b/src/utils/minMaxQueue/index.ts index e66224e9..9e49dee3 100644 --- a/src/utils/minMaxQueue/index.ts +++ b/src/utils/minMaxQueue/index.ts @@ -1,4 +1,4 @@ -import { AltoConfig } from "../../createConfig" +import type { AltoConfig } from "../../createConfig" import { createMemoryMinMaxQueue } from "./createMemoryMinMaxQueue" import { createRedisMinMaxQueue } from "./createRedisMinMaxQueue" diff --git a/src/utils/userop.ts b/src/utils/userop.ts index 4a4d8c4f..0f5b6650 100644 --- a/src/utils/userop.ts +++ b/src/utils/userop.ts @@ -3,12 +3,12 @@ import { EntryPointV07Abi, type PackedUserOperation, type UserOperation, + type UserOperationBundle, + type UserOperationReceipt, type UserOperationV06, type UserOperationV07, logSchema, - receiptSchema, - type UserOperationBundle, - type UserOperationReceipt + receiptSchema } from "@alto/types" import * as sentry from "@sentry/node" import type { Logger } from "pino" diff --git a/src/utils/validation.ts b/src/utils/validation.ts index 4dbddc68..f9604617 100644 --- a/src/utils/validation.ts +++ b/src/utils/validation.ts @@ -1,14 +1,15 @@ +import crypto from "crypto" import type { GasPriceManager } from "@alto/handlers" import { type Address, EntryPointV06Abi, EntryPointV07Abi, + MantleBvmGasPriceOracleAbi, + OpL1FeeAbi, type PackedUserOperation, type UserOperation, type UserOperationV06, - type UserOperationV07, - MantleBvmGasPriceOracleAbi, - OpL1FeeAbi + type UserOperationV07 } from "@alto/types" import { type Chain, @@ -17,33 +18,32 @@ import { EstimateGasExecutionError, FeeCapTooLowError, InsufficientFundsError, + InternalRpcError, IntrinsicGasTooLowError, NonceTooLowError, type PublicClient, TransactionExecutionError, type Transport, bytesToHex, + concat, encodeAbiParameters, + encodeFunctionData, getContract, - serializeTransaction, - toBytes, - InternalRpcError, maxUint64, - encodeFunctionData, - parseGwei, maxUint256, - toHex, + parseGwei, + serializeTransaction, size, - concat, - slice + slice, + toBytes, + toHex } from "viem" import { base, baseGoerli, baseSepolia, lineaSepolia } from "viem/chains" -import { maxBigInt, minBigInt, scaleBigIntByPercent } from "./bigInt" -import { isVersion06, isVersion07, toPackedUserOperation } from "./userop" import type { AltoConfig } from "../createConfig" import { ArbitrumL1FeeAbi } from "../types/contracts/ArbitrumL1FeeAbi" -import crypto from "crypto" -import { ceilDiv } from "./helpers"; +import { maxBigInt, minBigInt, scaleBigIntByPercent } from "./bigInt" +import { ceilDiv } from "./helpers" +import { isVersion06, isVersion07, toPackedUserOperation } from "./userop" export interface GasOverheads { /** @@ -310,7 +310,7 @@ export async function calcPreVerificationGas({ validate: boolean // when calculating preVerificationGas for validation overheads?: GasOverheads }): Promise { - let preVerificationGas = calcDefaultPreVerificationGas( + const preVerificationGas = calcDefaultPreVerificationGas( userOperation, overheads ) @@ -731,66 +731,74 @@ export async function calcArbitrumPreVerificationGas( /* ------------------------------------------------------------------ */ /** Constants from zkSync fee-model */ -const OFFCHAIN_FIXED_GAS = 10_000n; // TX_OVERHEAD_GAS -const MEMORY_GAS_PER_BYTE = 10n; // TX_MEMORY_OVERHEAD_GAS +const OFFCHAIN_FIXED_GAS = 10_000n // TX_OVERHEAD_GAS +const MEMORY_GAS_PER_BYTE = 10n // TX_MEMORY_OVERHEAD_GAS /** Local knob for Interpreter premium (numerator, denominator) * * Example: { num: 3n, den: 1n } ==> +200 % extra compute */ -const INTERPRETER_FACTOR = { num: 8n, den: 1n }; // <-- tweak here - +const INTERPRETER_FACTOR = { num: 8n, den: 1n } // <-- tweak here export async function calcAbstractPreVerificationGas( - publicClient: PublicClient, - op: UserOperation, - entryPoint: Address, - staticFee: bigint, // from calcDefaultPreVerificationGas(...) - gasPriceManager: GasPriceManager, - validate: boolean + publicClient: PublicClient, + op: UserOperation, + entryPoint: Address, + staticFee: bigint, // from calcDefaultPreVerificationGas(...) + gasPriceManager: GasPriceManager, + validate: boolean ): Promise { - - /* ① count bytes copied into bootloader memory */ - const data = getHandleOpsCallData(op, entryPoint); - const serTx = serializeTransaction( - { to: entryPoint, chainId: publicClient.chain.id, - gasLimit: maxUint64, maxFeePerGas: maxUint256, data }, - { - r: "0x123451234512345123451234512345123451234512345123451234512345", - s: "0x123451234512345123451234512345123451234512345123451234512345", - v: 28n + /* ① count bytes copied into bootloader memory */ + const data = getHandleOpsCallData(op, entryPoint) + const serTx = serializeTransaction( + { + to: entryPoint, + chainId: publicClient.chain.id, + gasLimit: maxUint64, + maxFeePerGas: maxUint256, + data + }, + { + r: "0x123451234512345123451234512345123451234512345123451234512345", + s: "0x123451234512345123451234512345123451234512345123451234512345", + v: 28n + } + ) + const bytes = BigInt((serTx.length - 2) / 2) + + /* ② l1_pubdata_price (wei / byte) */ + let l1PriceWei: bigint + if (!validate) { + const fp: any = await publicClient.request({ + method: "zks_getFeeParams" as any, + params: [] as any + }) + l1PriceWei = BigInt(fp.V2.l1_pubdata_price) + gasPriceManager.abstractManager.savePubdataPrice(l1PriceWei) + } else { + l1PriceWei = await gasPriceManager.abstractManager.getMinPubdataPrice() } - ); - const bytes = BigInt((serTx.length - 2) / 2); - - /* ② l1_pubdata_price (wei / byte) */ - let l1PriceWei: bigint; - if (!validate) { - // @ts-ignore - const fp: any = await publicClient.request({ method: "zks_getFeeParams", params: [] }); - l1PriceWei = BigInt(fp.V2.l1_pubdata_price); - gasPriceManager.abstractManager.savePubdataPrice(l1PriceWei); - } else { - l1PriceWei = await gasPriceManager.abstractManager.getMinPubdataPrice(); - } - - /* ③ pub-data gas component */ - const baseFee = await gasPriceManager.getBaseFee(); // wei / gas - const gasPerPub = ceilDiv(l1PriceWei, baseFee); // ceil() - const pubdataGas = bytes * gasPerPub; - - /* ④ bootloader memory copy */ - const memoryGas = bytes * MEMORY_GAS_PER_BYTE; - - /* ⑤ interpreter premium (local bump) */ - const computeGas = staticFee + memoryGas; // compute part - const extraInterpreter = (computeGas * (INTERPRETER_FACTOR.num - INTERPRETER_FACTOR.den)) - / INTERPRETER_FACTOR.den; // e.g. ×2 or ×3 - - /* ⑥ return full PVG */ - return staticFee - + memoryGas - + OFFCHAIN_FIXED_GAS - + pubdataGas - + extraInterpreter; + + /* ③ pub-data gas component */ + const baseFee = await gasPriceManager.getBaseFee() // wei / gas + const gasPerPub = ceilDiv(l1PriceWei, baseFee) // ceil() + const pubdataGas = bytes * gasPerPub + + /* ④ bootloader memory copy */ + const memoryGas = bytes * MEMORY_GAS_PER_BYTE + + /* ⑤ interpreter premium (local bump) */ + const computeGas = staticFee + memoryGas // compute part + const extraInterpreter = + (computeGas * (INTERPRETER_FACTOR.num - INTERPRETER_FACTOR.den)) / + INTERPRETER_FACTOR.den // e.g. ×2 or ×3 + + /* ⑥ return full PVG */ + return ( + staticFee + + memoryGas + + OFFCHAIN_FIXED_GAS + + pubdataGas + + extraInterpreter + ) } export function parseViemError(err: unknown) { diff --git a/test/e2e/deploy-contracts/index.ts b/test/e2e/deploy-contracts/index.ts index 6bd8b7e9..458cad45 100644 --- a/test/e2e/deploy-contracts/index.ts +++ b/test/e2e/deploy-contracts/index.ts @@ -1,9 +1,9 @@ import { http, type Address, + type PublicClient, createPublicClient, - createWalletClient, - type PublicClient + createWalletClient } from "viem" import { mnemonicToAccount } from "viem/accounts" import { foundry } from "viem/chains" diff --git a/test/e2e/setup.ts b/test/e2e/setup.ts index f1fe2ffc..6e70d8d9 100644 --- a/test/e2e/setup.ts +++ b/test/e2e/setup.ts @@ -1,10 +1,10 @@ -import { anvil } from "prool/instances" import { resolve } from "node:path" +import { defineInstance } from "prool" +import { anvil } from "prool/instances" import { foundry } from "viem/chains" +import altoConfig from "./alto-config.json" import { setupContracts } from "./deploy-contracts/index.js" -import { defineInstance } from "prool" import { execa } from "./src/utils/execa.js" -import altoConfig from "./alto-config.json" export const ENTRY_POINT_SIMULATIONS_ADDRESS = "0x74Cb5e4eE81b86e70f9045036a1C5477de69eE87" @@ -109,9 +109,8 @@ export const alto = defineInstance( } ) -// biome-ignore lint/style/noDefaultExport: vitest needs this export default async function setup({ provide }) { - const anvilPrivateKey = + const _anvilPrivateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" const anvilInstance = anvil({ diff --git a/test/e2e/src/utils/clients.ts b/test/e2e/src/utils/clients.ts index 4f3bed8a..4f36444d 100644 --- a/test/e2e/src/utils/clients.ts +++ b/test/e2e/src/utils/clients.ts @@ -1,7 +1,7 @@ import { toSimpleSmartAccount } from "permissionless/accounts" import { createSmartAccountClient } from "permissionless/clients" import { createPimlicoClient } from "permissionless/clients/pimlico" -import { http, Hex, createPublicClient } from "viem" +import { http, type Hex, createPublicClient } from "viem" import { entryPoint06Address, entryPoint07Address diff --git a/test/e2e/src/utils/execa.ts b/test/e2e/src/utils/execa.ts index f1b93c1c..f6b3f605 100644 --- a/test/e2e/src/utils/execa.ts +++ b/test/e2e/src/utils/execa.ts @@ -1,6 +1,6 @@ -import { EventEmitter } from "eventemitter3" +import type { EventEmitter } from "eventemitter3" import { type ResultPromise, execa as exec } from "execa" -import { Instance } from "prool" +import type { Instance } from "prool" export type Process_internal = ResultPromise<{ cleanup: true; reject: false }> diff --git a/test/e2e/tests/eth_estimateUserOperationGas.test.ts b/test/e2e/tests/eth_estimateUserOperationGas.test.ts index 5382879b..725aaf62 100644 --- a/test/e2e/tests/eth_estimateUserOperationGas.test.ts +++ b/test/e2e/tests/eth_estimateUserOperationGas.test.ts @@ -1,19 +1,19 @@ +import { deepHexlify } from "permissionless" +import { http, type Address, type Hex, zeroAddress } from "viem" import { - UserOperation, - createBundlerClient, type EntryPointVersion, + type UserOperation, + createBundlerClient, entryPoint06Address, entryPoint07Address } from "viem/account-abstraction" +import { foundry } from "viem/chains" import { beforeEach, describe, expect, inject, test } from "vitest" -import { beforeEachCleanUp, getSmartAccountClient } from "../src/utils/index.js" import { - getRevertCall, - deployRevertingContract + deployRevertingContract, + getRevertCall } from "../src/revertingContract.js" -import { type Address, BaseError, Hex, http, zeroAddress } from "viem" -import { deepHexlify } from "permissionless" -import { foundry } from "viem/chains" +import { beforeEachCleanUp, getSmartAccountClient } from "../src/utils/index.js" describe.each([ { diff --git a/test/e2e/tests/eth_getUserOperationReceipt.test.ts b/test/e2e/tests/eth_getUserOperationReceipt.test.ts index f407d6f8..253f84ca 100644 --- a/test/e2e/tests/eth_getUserOperationReceipt.test.ts +++ b/test/e2e/tests/eth_getUserOperationReceipt.test.ts @@ -1,11 +1,13 @@ -import { parseGwei, type Address, type Hex, concat } from "viem" +import { deepHexlify } from "permissionless" +import { type Address, type Hex, concat, parseGwei } from "viem" import { type EntryPointVersion, + type UserOperation, entryPoint06Address, entryPoint07Address, - type UserOperation, getUserOperationHash } from "viem/account-abstraction" +import { foundry } from "viem/chains" import { beforeAll, beforeEach, describe, expect, inject, test } from "vitest" import { decodeRevert, @@ -14,8 +16,6 @@ import { } from "../src/revertingContract.js" import { deployPaymaster } from "../src/testPaymaster.js" import { beforeEachCleanUp, getSmartAccountClient } from "../src/utils/index.js" -import { deepHexlify } from "permissionless" -import { foundry } from "viem/chains" describe.each([ { diff --git a/test/e2e/tests/eth_sendUserOperation.test.ts b/test/e2e/tests/eth_sendUserOperation.test.ts index c0bfad73..11c960f6 100644 --- a/test/e2e/tests/eth_sendUserOperation.test.ts +++ b/test/e2e/tests/eth_sendUserOperation.test.ts @@ -1,34 +1,34 @@ import { encodeNonce } from "permissionless/utils" import { http, + type Address, type Hex, + concat, createPublicClient, createTestClient, getContract, parseEther, - parseGwei, - type Address, - concat + parseGwei } from "viem" import { type EntryPointVersion, + type UserOperation, UserOperationReceiptNotFoundError, entryPoint06Address, - entryPoint07Address, - type UserOperation + entryPoint07Address } from "viem/account-abstraction" import { generatePrivateKey } from "viem/accounts" import { foundry } from "viem/chains" import { beforeEach, describe, expect, inject, test } from "vitest" +import { deployPaymaster } from "../src/testPaymaster.js" +import { ENTRYPOINT_V06_ABI, ENTRYPOINT_V07_ABI } from "../src/utils/abi.js" import { beforeEachCleanUp, getSmartAccountClient, sendBundleNow, setBundlingMode } from "../src/utils/index.js" -import { ENTRYPOINT_V06_ABI, ENTRYPOINT_V07_ABI } from "../src/utils/abi.js" import { getNonceKeyAndValue } from "../src/utils/userop.js" -import { deployPaymaster } from "../src/testPaymaster.js" describe.each([ { diff --git a/test/e2e/vitest.config.ts b/test/e2e/vitest.config.ts index e8b8ab06..dd6076dd 100644 --- a/test/e2e/vitest.config.ts +++ b/test/e2e/vitest.config.ts @@ -1,6 +1,6 @@ -import { defineConfig } from "vitest/config" import { join } from "node:path" import { config } from "dotenv" +import { defineConfig } from "vitest/config" export default defineConfig({ test: {