@@ -412,21 +412,21 @@ export class ExecutorManager {
412
412
413
413
if ( bundlingStatus . status === "reverted" ) {
414
414
await Promise . all (
415
- userOps . map ( ( userOpInfo ) => {
415
+ userOps . map ( async ( userOpInfo ) => {
416
416
const { userOpHash } = userOpInfo
417
- this . checkFrontrun ( {
417
+ await this . checkFrontrun ( {
418
418
entryPoint,
419
419
userOpHash,
420
420
transactionHash,
421
421
blockNumber
422
422
} )
423
423
} )
424
424
)
425
- this . removeSubmitted ( entryPoint , userOps )
425
+ await this . removeSubmitted ( entryPoint , userOps )
426
426
}
427
427
}
428
428
429
- checkFrontrun ( {
429
+ async checkFrontrun ( {
430
430
userOpHash,
431
431
entryPoint,
432
432
transactionHash,
@@ -454,12 +454,15 @@ export class ExecutorManager {
454
454
entryPoint,
455
455
userOpHash
456
456
} )
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
+ )
461
464
462
- this . eventManager . emitFrontranOnChain (
465
+ await this . eventManager . emitFrontranOnChain (
463
466
userOpHash ,
464
467
transactionHash ,
465
468
blockNumber
@@ -477,11 +480,14 @@ export class ExecutorManager {
477
480
. labels ( { status : "frontran" } )
478
481
. inc ( 1 )
479
482
} 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 (
485
491
userOpHash ,
486
492
transactionHash ,
487
493
blockNumber
@@ -508,7 +514,7 @@ export class ExecutorManager {
508
514
)
509
515
510
516
// Still mark as failed since we couldn't verify inclusion
511
- this . monitor . setUserOperationStatus ( userOpHash , {
517
+ await this . monitor . setUserOperationStatus ( userOpHash , {
512
518
status : "failed" ,
513
519
transactionHash
514
520
} )
@@ -894,12 +900,14 @@ export class ExecutorManager {
894
900
}
895
901
}
896
902
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
+ } )
901
909
} )
902
- } )
910
+ )
903
911
904
912
// Drop all userOperations that were rejected during simulation.
905
913
await this . dropUserOps ( entryPoint , rejectedUserOps )
@@ -920,14 +928,19 @@ export class ExecutorManager {
920
928
userOpInfos : UserOpInfo [ ] ,
921
929
transactionInfo : TransactionInfo
922
930
) {
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
+ )
931
944
}
932
945
933
946
async resubmitUserOperations (
@@ -968,10 +981,12 @@ export class ExecutorManager {
968
981
}
969
982
970
983
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
+ )
975
990
}
976
991
977
992
async markUserOpsIncluded (
@@ -981,83 +996,87 @@ export class ExecutorManager {
981
996
transactionHash : Hash ,
982
997
userOperationDetails : Record < string , any >
983
998
) {
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 ( )
996
1004
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 ]
1003
1007
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
1009
1011
)
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
1016
1018
)
1017
- }
1018
1019
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
+ }
1023
1034
1024
- this . logger . info (
1025
- {
1026
- opHash : userOpHash ,
1035
+ await this . monitor . setUserOperationStatus ( userOpHash , {
1036
+ status : "included" ,
1027
1037
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
+ )
1032
1049
}
1033
1050
1034
1051
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 (
1053
1058
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
+ )
1062
1081
}
1063
1082
}
0 commit comments