Skip to content

Commit 37c33c7

Browse files
committed
add missing awaits
1 parent 7b17ccd commit 37c33c7

File tree

1 file changed

+118
-99
lines changed

1 file changed

+118
-99
lines changed

src/executor/executorManager.ts

+118-99
Original file line numberDiff line numberDiff line change
@@ -412,21 +412,21 @@ export class ExecutorManager {
412412

413413
if (bundlingStatus.status === "reverted") {
414414
await Promise.all(
415-
userOps.map((userOpInfo) => {
415+
userOps.map(async (userOpInfo) => {
416416
const { userOpHash } = userOpInfo
417-
this.checkFrontrun({
417+
await this.checkFrontrun({
418418
entryPoint,
419419
userOpHash,
420420
transactionHash,
421421
blockNumber
422422
})
423423
})
424424
)
425-
this.removeSubmitted(entryPoint, userOps)
425+
await this.removeSubmitted(entryPoint, userOps)
426426
}
427427
}
428428

429-
checkFrontrun({
429+
async checkFrontrun({
430430
userOpHash,
431431
entryPoint,
432432
transactionHash,
@@ -454,12 +454,15 @@ export class ExecutorManager {
454454
entryPoint,
455455
userOpHash
456456
})
457-
this.monitor.setUserOperationStatus(userOpHash, {
458-
status: "included",
459-
transactionHash
460-
})
457+
await this.monitor.setUserOperationStatus(
458+
userOpHash,
459+
{
460+
status: "included",
461+
transactionHash
462+
}
463+
)
461464

462-
this.eventManager.emitFrontranOnChain(
465+
await this.eventManager.emitFrontranOnChain(
463466
userOpHash,
464467
transactionHash,
465468
blockNumber
@@ -477,11 +480,14 @@ export class ExecutorManager {
477480
.labels({ status: "frontran" })
478481
.inc(1)
479482
} else {
480-
this.monitor.setUserOperationStatus(userOpHash, {
481-
status: "failed",
482-
transactionHash
483-
})
484-
this.eventManager.emitFailedOnChain(
483+
await this.monitor.setUserOperationStatus(
484+
userOpHash,
485+
{
486+
status: "failed",
487+
transactionHash
488+
}
489+
)
490+
await this.eventManager.emitFailedOnChain(
485491
userOpHash,
486492
transactionHash,
487493
blockNumber
@@ -508,7 +514,7 @@ export class ExecutorManager {
508514
)
509515

510516
// Still mark as failed since we couldn't verify inclusion
511-
this.monitor.setUserOperationStatus(userOpHash, {
517+
await this.monitor.setUserOperationStatus(userOpHash, {
512518
status: "failed",
513519
transactionHash
514520
})
@@ -894,12 +900,14 @@ export class ExecutorManager {
894900
}
895901
}
896902

897-
userOpsReplaced.map(async (userOpInfo) => {
898-
await this.mempool.replaceSubmitted({
899-
userOpInfo,
900-
transactionInfo: newTxInfo
903+
await Promise.all(
904+
userOpsReplaced.map(async (userOpInfo) => {
905+
await this.mempool.replaceSubmitted({
906+
userOpInfo,
907+
transactionInfo: newTxInfo
908+
})
901909
})
902-
})
910+
)
903911

904912
// Drop all userOperations that were rejected during simulation.
905913
await this.dropUserOps(entryPoint, rejectedUserOps)
@@ -920,14 +928,19 @@ export class ExecutorManager {
920928
userOpInfos: UserOpInfo[],
921929
transactionInfo: TransactionInfo
922930
) {
923-
userOpInfos.map(async (userOpInfo) => {
924-
const { userOpHash } = userOpInfo
925-
await this.mempool.markSubmitted({ userOpHash, transactionInfo })
926-
this.startWatchingBlocks(this.handleBlock.bind(this))
927-
this.metrics.userOperationsSubmitted
928-
.labels({ status: "success" })
929-
.inc()
930-
})
931+
await Promise.all(
932+
userOpInfos.map(async (userOpInfo) => {
933+
const { userOpHash } = userOpInfo
934+
await this.mempool.markSubmitted({
935+
userOpHash,
936+
transactionInfo
937+
})
938+
this.startWatchingBlocks(this.handleBlock.bind(this))
939+
this.metrics.userOperationsSubmitted
940+
.labels({ status: "success" })
941+
.inc()
942+
})
943+
)
931944
}
932945

933946
async resubmitUserOperations(
@@ -968,10 +981,12 @@ export class ExecutorManager {
968981
}
969982

970983
async removeSubmitted(entryPoint: Address, userOps: UserOpInfo[]) {
971-
userOps.map(async (userOpInfo) => {
972-
const { userOpHash } = userOpInfo
973-
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
974-
})
984+
await Promise.all(
985+
userOps.map(async (userOpInfo) => {
986+
const { userOpHash } = userOpInfo
987+
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
988+
})
989+
)
975990
}
976991

977992
async markUserOpsIncluded(
@@ -981,83 +996,87 @@ export class ExecutorManager {
981996
transactionHash: Hash,
982997
userOperationDetails: Record<string, any>
983998
) {
984-
userOps.map(async (userOpInfo) => {
985-
this.metrics.userOperationsOnChain
986-
.labels({ status: "included" })
987-
.inc()
988-
989-
const { userOpHash, userOp } = userOpInfo
990-
const opDetails = userOperationDetails[userOpHash]
991-
992-
const firstSubmitted = userOpInfo.addedToMempool
993-
this.metrics.userOperationInclusionDuration.observe(
994-
(Date.now() - firstSubmitted) / 1000
995-
)
999+
await Promise.all(
1000+
userOps.map(async (userOpInfo) => {
1001+
this.metrics.userOperationsOnChain
1002+
.labels({ status: "included" })
1003+
.inc()
9961004

997-
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
998-
this.reputationManager.updateUserOperationIncludedStatus(
999-
userOp,
1000-
entryPoint,
1001-
opDetails.accountDeployed
1002-
)
1005+
const { userOpHash, userOp } = userOpInfo
1006+
const opDetails = userOperationDetails[userOpHash]
10031007

1004-
if (opDetails.status === "succesful") {
1005-
this.eventManager.emitIncludedOnChain(
1006-
userOpHash,
1007-
transactionHash,
1008-
blockNumber as bigint
1008+
const firstSubmitted = userOpInfo.addedToMempool
1009+
this.metrics.userOperationInclusionDuration.observe(
1010+
(Date.now() - firstSubmitted) / 1000
10091011
)
1010-
} else {
1011-
this.eventManager.emitExecutionRevertedOnChain(
1012-
userOpHash,
1013-
transactionHash,
1014-
opDetails.revertReason || "0x",
1015-
blockNumber as bigint
1012+
1013+
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
1014+
await this.reputationManager.updateUserOperationIncludedStatus(
1015+
userOp,
1016+
entryPoint,
1017+
opDetails.accountDeployed
10161018
)
1017-
}
10181019

1019-
this.monitor.setUserOperationStatus(userOpHash, {
1020-
status: "included",
1021-
transactionHash
1022-
})
1020+
if (opDetails.status === "succesful") {
1021+
await this.eventManager.emitIncludedOnChain(
1022+
userOpHash,
1023+
transactionHash,
1024+
blockNumber as bigint
1025+
)
1026+
} else {
1027+
await this.eventManager.emitExecutionRevertedOnChain(
1028+
userOpHash,
1029+
transactionHash,
1030+
opDetails.revertReason || "0x",
1031+
blockNumber as bigint
1032+
)
1033+
}
10231034

1024-
this.logger.info(
1025-
{
1026-
opHash: userOpHash,
1035+
await this.monitor.setUserOperationStatus(userOpHash, {
1036+
status: "included",
10271037
transactionHash
1028-
},
1029-
"user op included"
1030-
)
1031-
})
1038+
})
1039+
1040+
this.logger.info(
1041+
{
1042+
opHash: userOpHash,
1043+
transactionHash
1044+
},
1045+
"user op included"
1046+
)
1047+
})
1048+
)
10321049
}
10331050

10341051
async dropUserOps(entryPoint: Address, rejectedUserOps: RejectedUserOp[]) {
1035-
rejectedUserOps.map(async (rejectedUserOp) => {
1036-
const { userOp, reason, userOpHash } = rejectedUserOp
1037-
await this.mempool.removeProcessing({ entryPoint, userOpHash })
1038-
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
1039-
await this.eventManager.emitDropped(
1040-
userOpHash,
1041-
reason,
1042-
getAAError(reason)
1043-
)
1044-
this.monitor.setUserOperationStatus(userOpHash, {
1045-
status: "rejected",
1046-
transactionHash: null
1047-
})
1048-
this.logger.warn(
1049-
{
1050-
userOperation: JSON.stringify(userOp, (_k, v) =>
1051-
typeof v === "bigint" ? v.toString() : v
1052-
),
1052+
await Promise.all(
1053+
rejectedUserOps.map(async (rejectedUserOp) => {
1054+
const { userOp, reason, userOpHash } = rejectedUserOp
1055+
await this.mempool.removeProcessing({ entryPoint, userOpHash })
1056+
await this.mempool.removeSubmitted({ entryPoint, userOpHash })
1057+
await this.eventManager.emitDropped(
10531058
userOpHash,
1054-
reason
1055-
},
1056-
"user operation rejected"
1057-
)
1058-
this.metrics.userOperationsSubmitted
1059-
.labels({ status: "failed" })
1060-
.inc()
1061-
})
1059+
reason,
1060+
getAAError(reason)
1061+
)
1062+
await this.monitor.setUserOperationStatus(userOpHash, {
1063+
status: "rejected",
1064+
transactionHash: null
1065+
})
1066+
this.logger.warn(
1067+
{
1068+
userOperation: JSON.stringify(userOp, (_k, v) =>
1069+
typeof v === "bigint" ? v.toString() : v
1070+
),
1071+
userOpHash,
1072+
reason
1073+
},
1074+
"user operation rejected"
1075+
)
1076+
this.metrics.userOperationsSubmitted
1077+
.labels({ status: "failed" })
1078+
.inc()
1079+
})
1080+
)
10621081
}
10631082
}

0 commit comments

Comments
 (0)