Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Jan 23, 2025
1 parent 913786a commit 80f7b97
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 46 deletions.
24 changes: 12 additions & 12 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ export class Executor {
)

const [isUserOpVersion06, entryPoint] = opsWithHashes.reduce(
(acc, op) => {
(acc, owh) => {
if (
acc[0] !== isVersion06(op.userOperation) ||
acc[1] !== op.entryPoint
acc[0] !== isVersion06(owh.userOperation) ||
acc[1] !== owh.entryPoint
) {
throw new Error(
"All user operations must be of the same version"
Expand Down Expand Up @@ -672,13 +672,13 @@ export class Executor {
"Failed to get parameters for bundling"
)
this.markWalletProcessed(wallet)
return opsWithHashes.map(({ userOperation, userOperationHash }) => {
return opsWithHashes.map((owh) => {
return {
status: "resubmit",
info: {
entryPoint,
userOpHash: userOperationHash,
userOperation,
userOpHash: owh.userOperationHash,
userOperation: owh.userOperation,
reason: "Failed to get parameters for bundling"
}
}
Expand Down Expand Up @@ -708,13 +708,13 @@ export class Executor {
"gas limit simulation encountered unexpected failure"
)
this.markWalletProcessed(wallet)
return opsWithHashes.map(({ userOperationHash, userOperation }) => {
return opsWithHashes.map((owh) => {
return {
status: "failure",
error: {
entryPoint,
userOpHash: userOperationHash,
userOperation,
userOpHash: owh.userOperationHash,
userOperation: owh.userOperation,
reason: "INTERNAL FAILURE"
}
}
Expand Down Expand Up @@ -871,13 +871,13 @@ export class Executor {
"error submitting bundle transaction"
)
this.markWalletProcessed(wallet)
return opsWithHashes.map(({ userOperationHash, userOperation }) => {
return opsWithHashes.map((owh) => {
return {
status: "failure",
error: {
entryPoint,
userOpHash: userOperationHash,
userOperation,
userOpHash: owh.userOperationHash,
userOperation: owh.userOperation,
reason: "INTERNAL FAILURE"
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/executor/executorManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,43 +462,43 @@ export class ExecutorManager {
const { userOperationDetails } = bundlingStatus
opInfos.map((opInfo) => {
const {
userOperation: mUserOperation,
userOperationHash: userOpHash,
userOperation,
userOperationHash,
entryPoint,
firstSubmitted
} = opInfo
const opDetails = userOperationDetails[userOpHash]
const opDetails = userOperationDetails[userOperationHash]

this.metrics.userOperationInclusionDuration.observe(
(Date.now() - firstSubmitted) / 1000
)
this.mempool.removeSubmitted(userOpHash)
this.mempool.removeSubmitted(userOperationHash)
this.reputationManager.updateUserOperationIncludedStatus(
mUserOperation,
userOperation,
entryPoint,
opDetails.accountDeployed
)
if (opDetails.status === "succesful") {
this.eventManager.emitIncludedOnChain(
userOpHash,
userOperationHash,
transactionHash,
blockNumber as bigint
)
} else {
this.eventManager.emitExecutionRevertedOnChain(
userOpHash,
userOperationHash,
transactionHash,
opDetails.revertReason || "0x",
blockNumber as bigint
)
}
this.monitor.setUserOperationStatus(userOpHash, {
this.monitor.setUserOperationStatus(userOperationHash, {
status: "included",
transactionHash
})
this.logger.info(
{
userOpHash,
userOperationHash,
transactionHash
},
"user op included"
Expand Down
2 changes: 1 addition & 1 deletion src/executor/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getAuthorizationList = (
): SignedAuthorizationList | undefined => {
const authorizationList = userOperations
.map((op) => {
if (isVersion07(op) && op.eip7702Auth) {
if (op.eip7702Auth) {
return op.eip7702Auth
}
return undefined
Expand Down
41 changes: 21 additions & 20 deletions src/mempool/mempool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,13 @@ export class MemoryMempool {
}

if (
processedOrSubmittedOps.find(
({ userOperation: existingUserOperation }) => {
return (
existingUserOperation.sender === userOperation.sender &&
existingUserOperation.nonce === userOperation.nonce
)
}
)
processedOrSubmittedOps.find((opInfo) => {
const mempoolUserOp = opInfo.userOperation
return (
mempoolUserOp.sender === userOperation.sender &&
mempoolUserOp.nonce === userOperation.nonce
)
})
) {
return [
false,
Expand All @@ -286,42 +285,44 @@ export class MemoryMempool {
entryPoint
)
const oldUserOp = [...outstandingOps, ...processedOrSubmittedOps].find(
({ userOperation: existingUserOperation }) => {
(opInfo) => {
const mempoolUserOp = opInfo.userOperation

const isSameSender =
existingUserOperation.sender === userOperation.sender
mempoolUserOp.sender === userOperation.sender

if (
isSameSender &&
existingUserOperation.nonce === userOperation.nonce
mempoolUserOp.nonce === userOperation.nonce
) {
return true
}

// Check if there is already a userOperation with initCode + same sender (stops rejected ops due to AA10).
if (
isVersion06(existingUserOperation) &&
isVersion06(mempoolUserOp) &&
isVersion06(userOperation) &&
userOperation.initCode &&
userOperation.initCode !== "0x"
) {
return (
isSameSender &&
existingUserOperation.initCode &&
existingUserOperation.initCode !== "0x"
mempoolUserOp.initCode &&
mempoolUserOp.initCode !== "0x"
)
}

// Check if there is already a userOperation with factory + same sender (stops rejected ops due to AA10).
if (
isVersion07(existingUserOperation) &&
isVersion07(mempoolUserOp) &&
isVersion07(userOperation) &&
userOperation.factory &&
userOperation.factory !== "0x"
) {
return (
isSameSender &&
existingUserOperation.factory &&
existingUserOperation.factory !== "0x"
mempoolUserOp.factory &&
mempoolUserOp.factory !== "0x"
)
}

Expand Down Expand Up @@ -813,13 +814,13 @@ export class MemoryMempool {
const outstanding = this.store
.dumpOutstanding()
.map(({ userOperation }) => userOperation)
.filter((existingUserOperation: UserOperation) => {
.filter((mempoolUserOp) => {
const [opNonceKey, opNonceValue] = getNonceKeyAndValue(
existingUserOperation.nonce
mempoolUserOp.nonce
)

return (
existingUserOperation.sender === userOperation.sender &&
mempoolUserOp.sender === userOperation.sender &&
opNonceKey === nonceKey &&
opNonceValue >= currentNonceValue &&
opNonceValue < userOperationNonceValue
Expand Down
10 changes: 9 additions & 1 deletion src/rpc/estimation/gasEstimationsV06.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
import { z } from "zod"
import type { SimulateHandleOpResult } from "./types"
import type { AltoConfig } from "../../createConfig"
import { deepHexlify } from "../../utils/userop"
import { parseFailedOpWithRevert } from "./gasEstimationsV07"
import { deepHexlify, addAuthorizationStateOverrides } from "@alto/utils"

export class GasEstimatorV06 {
private config: AltoConfig
Expand Down Expand Up @@ -147,6 +147,14 @@ export class GasEstimatorV06 {
stateOverrides = undefined
}

if (userOperation.eip7702Auth) {
stateOverrides = await addAuthorizationStateOverrides({
stateOverrides,
authorizationList: [userOperation.eip7702Auth],
publicClient
})
}

try {
await publicClient.request({
method: "eth_call",
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/nonceQueuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class NonceQueuer {
this.queuedUserOperations.push({
entryPoint,
userOperationHash,
userOperation: userOperation,
userOperation,
nonceKey,
nonceSequence,
addedAt: Date.now()
Expand Down
6 changes: 4 additions & 2 deletions src/types/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const userOperationV06Schema = z
maxPriorityFeePerGas: hexNumberSchema,
maxFeePerGas: hexNumberSchema,
paymasterAndData: hexDataSchema,
signature: hexDataSchema
signature: hexDataSchema,
eip7702Auth: signedAuthorizationSchema.optional()
})
.strict()
.transform((val) => {
Expand Down Expand Up @@ -115,7 +116,8 @@ const partialUserOperationV06Schema = z
maxPriorityFeePerGas: hexNumberSchema.default(1n),
maxFeePerGas: hexNumberSchema.default(1n),
paymasterAndData: hexDataSchema,
signature: hexDataSchema
signature: hexDataSchema,
eip7702Auth: signedAuthorizationSchema.optional()
})
.strict()
.transform((val) => {
Expand Down

0 comments on commit 80f7b97

Please sign in to comment.