Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mouseless0x committed Jan 26, 2025
1 parent 48e1bcb commit 24facc0
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 141 deletions.
52 changes: 27 additions & 25 deletions src/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class Executor {
isVersion06,
entryPoint,
transactionRequest,
executor,
userOperationInfos
} = transactionInfo

Expand All @@ -152,7 +151,6 @@ export class Executor {

const newRequest = {
...transactionRequest,
account: executor,
maxFeePerGas: scaleBigIntByPercent(
gasPriceParameters.maxFeePerGas,
115n
Expand All @@ -178,7 +176,7 @@ export class Executor {

const childLogger = this.logger.child({
transactionHash: transactionInfo.transactionHash,
executor: transactionInfo.executor.address
executor: transactionInfo.transactionRequest.account.address
})

let bundleResult = await filterOpsAndEstimateGas({
Expand Down Expand Up @@ -273,10 +271,10 @@ export class Executor {
}
})

this.eventManager.emitSubmitted(
this.getOpHashes(opsToBundle),
txHash
)
this.eventManager.emitSubmitted({
userOpHashes: this.getOpHashes(opsToBundle),
transactionHash: txHash
})

const newTxInfo: TransactionInfo = {
...transactionInfo,
Expand Down Expand Up @@ -546,9 +544,10 @@ export class Executor {
const conflictingOps = submitted
.filter((submitted) => {
const tx = submitted.transactionInfo
const txSender = tx.transactionRequest.account.address

return (
tx.executor.address === executor.address &&
txSender === executor.address &&
tx.transactionRequest.nonce === nonce
)
})
Expand Down Expand Up @@ -616,9 +615,9 @@ export class Executor {
)
this.markWalletProcessed(wallet)
return {
status: "resubmit",
status: "bundle_resubmit",
reason: "Failed to get parameters for bundling",
userOperations: ops
userOpsBundled: ops
}
}

Expand All @@ -641,9 +640,9 @@ export class Executor {
)
this.markWalletProcessed(wallet)
return {
status: "failure",
status: "bundle_failure",
reason: "INTERNAL FAILURE",
userOperations: ops
userOpsBundled: ops
}
}

Expand All @@ -653,13 +652,14 @@ export class Executor {
childLogger.warn("all ops failed simulation")
this.markWalletProcessed(wallet)
return {
status: "failure",
status: "bundle_failure",
reason: "INTERNAL FAILURE",
// TODO: we want to log the failure reason
userOperations: ops
userOpsBundled: ops
}
}

// Update child logger with userOperations being sent for bundling.
childLogger = this.logger.child({
userOperations: this.getOpHashes(opsToBundle),
entryPoint
Expand Down Expand Up @@ -723,10 +723,10 @@ export class Executor {
opts
})

this.eventManager.emitSubmitted(
this.getOpHashes(opsToBundle),
this.eventManager.emitSubmitted({
userOpHashes: this.getOpHashes(opsToBundle),
transactionHash
)
})
} catch (err: unknown) {
const e = parseViemError(err)
if (e instanceof InsufficientFundsError) {
Expand All @@ -736,9 +736,9 @@ export class Executor {
)
this.markWalletProcessed(wallet)
return {
status: "resubmit",
status: "bundle_resubmit",
reason: InsufficientFundsError.name,
userOperations: ops
userOpsBundled: ops
}
}

Expand All @@ -749,9 +749,9 @@ export class Executor {
)
this.markWalletProcessed(wallet)
return {
status: "failure",
status: "bundle_failure",
reason: "INTERNAL FAILURE",
userOperations: ops
userOpsBundled: ops
}
}

Expand Down Expand Up @@ -779,17 +779,19 @@ export class Executor {
maxPriorityFeePerGas: gasPriceParameters.maxPriorityFeePerGas,
nonce: nonce
},
executor: wallet,
userOperationInfos,
lastReplaced: Date.now(),
firstSubmitted: Date.now(),
timesPotentiallyIncluded: 0
}

const userOperationResults: BundleResult = {
status: "success",
userOperations: opsToBundle,
rejectedUserOperations: failedOps.map((sop) => sop.userOperation),
status: "bundle_success",
userOpsBundled: opsToBundle,
rejectedUserOperations: failedOps.map((sop) => ({
userOperation: sop.userOperation,
reason: sop.reason
})),
transactionInfo
}

Expand Down
Loading

0 comments on commit 24facc0

Please sign in to comment.