@pimlico/alto 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/contracts/EIP712.sol/EIP712.json +1 -1
  2. package/contracts/ERC165.sol/ERC165.json +1 -1
  3. package/contracts/ERC20.sol/ERC20.json +1 -1
  4. package/contracts/Eip7702Support.sol/Eip7702Support.json +1 -1
  5. package/contracts/EntryPoint.sol/EntryPoint.json +1 -1
  6. package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
  7. package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
  8. package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
  9. package/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
  10. package/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
  11. package/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
  12. package/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
  13. package/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
  14. package/contracts/Exec.sol/Exec.json +1 -1
  15. package/contracts/IAccount.sol/IAccount.json +1 -1
  16. package/contracts/IAccountExecute.sol/IAccountExecute.json +1 -1
  17. package/contracts/IAggregator.sol/IAggregator.json +1 -1
  18. package/contracts/IERC165.sol/IERC165.json +1 -1
  19. package/contracts/IERC5267.sol/IERC5267.json +1 -1
  20. package/contracts/IEntryPoint.sol/IEntryPoint.json +1 -1
  21. package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride08.json +1 -0
  22. package/contracts/IEntryPointFilterOpsOverride.sol/IEntryPointFilterOpsOverride09.json +1 -0
  23. package/contracts/IEntryPointSimulations.sol/IEntryPointSimulations.json +1 -1
  24. package/contracts/INonceManager.sol/INonceManager.json +1 -1
  25. package/contracts/IPaymaster.sol/IPaymaster.json +1 -1
  26. package/contracts/ISenderCreator.sol/ISenderCreator.json +1 -1
  27. package/contracts/IStakeManager.sol/IStakeManager.json +1 -1
  28. package/contracts/LibBytes.sol/LibBytes.json +1 -1
  29. package/contracts/Math.sol/Math.json +1 -1
  30. package/contracts/MessageHashUtils.sol/MessageHashUtils.json +1 -1
  31. package/contracts/NonceManager.sol/NonceManager.json +1 -1
  32. package/contracts/Panic.sol/Panic.json +1 -1
  33. package/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
  34. package/contracts/ReentrancyGuard.sol/ReentrancyGuard.json +1 -1
  35. package/contracts/ReentrancyGuardTransient.sol/ReentrancyGuardTransient.json +1 -1
  36. package/contracts/SafeCast.sol/SafeCast.json +1 -1
  37. package/contracts/SenderCreator.sol/SenderCreator.json +1 -1
  38. package/contracts/ShortStrings.sol/ShortStrings.json +1 -1
  39. package/contracts/SignedMath.sol/SignedMath.json +1 -1
  40. package/contracts/SimulationOverrideHelper.sol/SimulationOverrideHelper.json +1 -0
  41. package/contracts/StakeManager.sol/StakeManager.json +1 -1
  42. package/contracts/StorageSlot.sol/StorageSlot.json +1 -1
  43. package/contracts/Strings.sol/Strings.json +1 -1
  44. package/contracts/TransientSlot.sol/TransientSlot.json +1 -1
  45. package/contracts/UserOperation.sol/UserOperationLib.json +1 -1
  46. package/contracts/UserOperationLib.sol/UserOperationLib.json +1 -1
  47. package/contracts/account-abstraction-v9/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -0
  48. package/contracts/account-abstraction-v9/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -0
  49. package/contracts/account-abstraction-v9/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -0
  50. package/contracts/account-abstraction-v9/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -0
  51. package/contracts/build-info/{880955d5786bfdae.json → 031b289b93191224.json} +1 -1
  52. package/contracts/build-info/181f3522c3744403.json +1 -0
  53. package/contracts/build-info/a2db592afab5c9de.json +1 -0
  54. package/contracts/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
  55. package/contracts/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
  56. package/contracts/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
  57. package/contracts/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
  58. package/contracts/core/Eip7702Support.sol/Eip7702Support.json +1 -0
  59. package/contracts/core/NonceManager.sol/NonceManager.json +1 -0
  60. package/contracts/core/SenderCreator.sol/SenderCreator.json +1 -0
  61. package/contracts/core/StakeManager.sol/StakeManager.json +1 -0
  62. package/contracts/core/UserOperationLib.sol/UserOperationLib.json +1 -0
  63. package/contracts/interfaces/IAccount.sol/IAccount.json +1 -0
  64. package/contracts/interfaces/IAccountExecute.sol/IAccountExecute.json +1 -0
  65. package/contracts/interfaces/IAggregator.sol/IAggregator.json +1 -1
  66. package/contracts/interfaces/IEntryPoint.sol/IEntryPoint.json +1 -1
  67. package/contracts/interfaces/INonceManager.sol/INonceManager.json +1 -1
  68. package/contracts/interfaces/IPaymaster.sol/IPaymaster.json +1 -0
  69. package/contracts/interfaces/ISenderCreator.sol/ISenderCreator.json +1 -0
  70. package/contracts/interfaces/IStakeManager.sol/IStakeManager.json +1 -1
  71. package/contracts/overrides/Eip7702Support.sol/Eip7702Support.json +1 -0
  72. package/contracts/overrides/NonceManager.sol/NonceManager.json +1 -0
  73. package/contracts/overrides/SenderCreator.sol/SenderCreator.json +1 -0
  74. package/contracts/overrides/StakeManager.sol/StakeManager.json +1 -0
  75. package/contracts/overrides/UserOperationLib.sol/UserOperationLib.json +1 -0
  76. package/contracts/utils/Exec.sol/Exec.json +1 -1
  77. package/contracts/utils/StorageSlot.sol/StorageSlot.json +1 -0
  78. package/contracts/v09/EntryPoint.sol/EntryPoint.json +1 -0
  79. package/esm/cli/alto.js +17 -6
  80. package/esm/cli/alto.js.map +1 -1
  81. package/esm/cli/config/bundler.d.ts +459 -321
  82. package/esm/cli/config/bundler.js +125 -91
  83. package/esm/cli/config/bundler.js.map +1 -1
  84. package/esm/cli/config/options.d.ts +4 -1
  85. package/esm/cli/config/options.js +233 -106
  86. package/esm/cli/config/options.js.map +1 -1
  87. package/esm/cli/customTransport.d.ts +3 -3
  88. package/esm/cli/deploySimulationsContract.d.ts +1 -0
  89. package/esm/cli/deploySimulationsContract.js +41 -5
  90. package/esm/cli/deploySimulationsContract.js.map +1 -1
  91. package/esm/cli/handler.js +76 -80
  92. package/esm/cli/handler.js.map +1 -1
  93. package/esm/cli/multiRpcTransport.d.ts +7 -0
  94. package/esm/cli/multiRpcTransport.js +52 -0
  95. package/esm/cli/multiRpcTransport.js.map +1 -0
  96. package/esm/cli/setupServer.js +92 -70
  97. package/esm/cli/setupServer.js.map +1 -1
  98. package/esm/cli/shutDown.d.ts +20 -0
  99. package/esm/cli/shutDown.js +285 -0
  100. package/esm/cli/shutDown.js.map +1 -0
  101. package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride06.json +1 -1
  102. package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride07.json +1 -1
  103. package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride08.json +1 -1
  104. package/esm/contracts/EntryPointFilterOpsOverride.sol/EntryPointFilterOpsOverride09.json +1 -0
  105. package/esm/contracts/EntryPointGasEstimationOverride.sol/EntryPointGasEstimationOverride06.json +1 -1
  106. package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations07.json +1 -1
  107. package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations08.json +1 -1
  108. package/esm/contracts/EntryPointSimulations.sol/EntryPointSimulations09.json +1 -0
  109. package/esm/contracts/PimlicoSimulations.sol/PimlicoSimulations.json +1 -1
  110. package/esm/createConfig.d.ts +9 -2
  111. package/esm/createConfig.js.map +1 -1
  112. package/esm/executor/{userOpMonitor.d.ts → bundleManager.d.ts} +56 -37
  113. package/esm/executor/bundleManager.js +393 -0
  114. package/esm/executor/bundleManager.js.map +1 -0
  115. package/esm/executor/executor.d.ts +4 -3
  116. package/esm/executor/executor.js +47 -23
  117. package/esm/executor/executor.js.map +1 -1
  118. package/esm/executor/executorManager.d.ts +20 -15
  119. package/esm/executor/executorManager.js +248 -67
  120. package/esm/executor/executorManager.js.map +1 -1
  121. package/esm/executor/filterOpsAndEstimateGas.d.ts +17 -2
  122. package/esm/executor/filterOpsAndEstimateGas.js +100 -77
  123. package/esm/executor/filterOpsAndEstimateGas.js.map +1 -1
  124. package/esm/executor/getBundleStatus.d.ts +5 -1
  125. package/esm/executor/getBundleStatus.js.map +1 -1
  126. package/esm/executor/index.d.ts +1 -0
  127. package/esm/executor/index.js +1 -0
  128. package/esm/executor/index.js.map +1 -1
  129. package/esm/executor/senderManager/createMemorySenderManager.js +13 -0
  130. package/esm/executor/senderManager/createMemorySenderManager.js.map +1 -1
  131. package/esm/executor/senderManager/createRedisSenderManager.d.ts +2 -1
  132. package/esm/executor/senderManager/createRedisSenderManager.js +45 -26
  133. package/esm/executor/senderManager/createRedisSenderManager.js.map +1 -1
  134. package/esm/executor/senderManager/flushOnStartUp.js +7 -5
  135. package/esm/executor/senderManager/flushOnStartUp.js.map +1 -1
  136. package/esm/executor/senderManager/index.d.ts +1 -0
  137. package/esm/executor/senderManager/index.js +6 -2
  138. package/esm/executor/senderManager/index.js.map +1 -1
  139. package/esm/executor/senderManager/validateAndRefill.js +268 -85
  140. package/esm/executor/senderManager/validateAndRefill.js.map +1 -1
  141. package/esm/executor/utils.d.ts +8 -3
  142. package/esm/executor/utils.js +59 -27
  143. package/esm/executor/utils.js.map +1 -1
  144. package/esm/handlers/arbitrumGasPriceManager.d.ts +3 -2
  145. package/esm/handlers/arbitrumGasPriceManager.js +6 -2
  146. package/esm/handlers/arbitrumGasPriceManager.js.map +1 -1
  147. package/esm/handlers/citreaManager.d.ts +10 -0
  148. package/esm/handlers/citreaManager.js +17 -0
  149. package/esm/handlers/citreaManager.js.map +1 -0
  150. package/esm/handlers/eventManager.d.ts +9 -9
  151. package/esm/handlers/eventManager.js +59 -60
  152. package/esm/handlers/eventManager.js.map +1 -1
  153. package/esm/handlers/gasPriceManager.d.ts +17 -10
  154. package/esm/handlers/gasPriceManager.js +245 -99
  155. package/esm/handlers/gasPriceManager.js.map +1 -1
  156. package/esm/handlers/mantleGasPriceManager.d.ts +4 -4
  157. package/esm/handlers/mantleGasPriceManager.js +4 -4
  158. package/esm/handlers/mantleGasPriceManager.js.map +1 -1
  159. package/esm/handlers/optimismManager.d.ts +1 -1
  160. package/esm/handlers/optimismManager.js +1 -1
  161. package/esm/handlers/optimismManager.js.map +1 -1
  162. package/esm/mempool/index.d.ts +1 -1
  163. package/esm/mempool/index.js +1 -1
  164. package/esm/mempool/index.js.map +1 -1
  165. package/esm/mempool/mempool.d.ts +61 -22
  166. package/esm/mempool/mempool.js +223 -133
  167. package/esm/mempool/mempool.js.map +1 -1
  168. package/esm/mempool/reputationManager.d.ts +14 -14
  169. package/esm/mempool/reputationManager.js +36 -39
  170. package/esm/mempool/reputationManager.js.map +1 -1
  171. package/esm/mempool/statusManager.d.ts +20 -0
  172. package/esm/mempool/statusManager.js +143 -0
  173. package/esm/mempool/statusManager.js.map +1 -0
  174. package/esm/receiptCache/createMemoryReceiptCache.d.ts +3 -0
  175. package/esm/receiptCache/createMemoryReceiptCache.js +30 -0
  176. package/esm/receiptCache/createMemoryReceiptCache.js.map +1 -0
  177. package/esm/receiptCache/createRedisReceiptCache.d.ts +10 -0
  178. package/esm/receiptCache/createRedisReceiptCache.js +56 -0
  179. package/esm/receiptCache/createRedisReceiptCache.js.map +1 -0
  180. package/esm/receiptCache/index.d.ts +11 -0
  181. package/esm/receiptCache/index.js +21 -0
  182. package/esm/receiptCache/index.js.map +1 -0
  183. package/esm/rpc/createMethodHandler.js.map +1 -1
  184. package/esm/rpc/estimation/gasEstimationHandler.d.ts +2 -4
  185. package/esm/rpc/estimation/gasEstimationHandler.js.map +1 -1
  186. package/esm/rpc/estimation/gasEstimations06.d.ts +6 -7
  187. package/esm/rpc/estimation/gasEstimations06.js +1 -5
  188. package/esm/rpc/estimation/gasEstimations06.js.map +1 -1
  189. package/esm/rpc/estimation/gasEstimations07.d.ts +13 -41
  190. package/esm/rpc/estimation/gasEstimations07.js +27 -34
  191. package/esm/rpc/estimation/gasEstimations07.js.map +1 -1
  192. package/esm/{utils/preVerificationGasCalulator.d.ts → rpc/estimation/preVerificationGasCalculator.d.ts} +20 -6
  193. package/esm/{utils/preVerificationGasCalulator.js → rpc/estimation/preVerificationGasCalculator.js} +134 -48
  194. package/esm/rpc/estimation/preVerificationGasCalculator.js.map +1 -0
  195. package/esm/rpc/estimation/types.d.ts +4 -2
  196. package/esm/rpc/estimation/utils.d.ts +10 -8
  197. package/esm/rpc/estimation/utils.js +56 -53
  198. package/esm/rpc/estimation/utils.js.map +1 -1
  199. package/esm/rpc/methods/boost_sendUserOperation.d.ts +304 -0
  200. package/esm/rpc/methods/boost_sendUserOperation.js +1 -1
  201. package/esm/rpc/methods/boost_sendUserOperation.js.map +1 -1
  202. package/esm/rpc/methods/debug_bundler_clearReputation.js +1 -1
  203. package/esm/rpc/methods/debug_bundler_clearReputation.js.map +1 -1
  204. package/esm/rpc/methods/debug_bundler_clearState.js +1 -1
  205. package/esm/rpc/methods/debug_bundler_clearState.js.map +1 -1
  206. package/esm/rpc/methods/debug_bundler_dumpMempool.d.ts +338 -0
  207. package/esm/rpc/methods/debug_bundler_dumpReputation.js +1 -1
  208. package/esm/rpc/methods/debug_bundler_dumpReputation.js.map +1 -1
  209. package/esm/rpc/methods/eth_estimateUserOperationGas.d.ts +622 -14
  210. package/esm/rpc/methods/eth_estimateUserOperationGas.js +61 -30
  211. package/esm/rpc/methods/eth_estimateUserOperationGas.js.map +1 -1
  212. package/esm/rpc/methods/eth_getUserOperationByHash.d.ts +621 -11
  213. package/esm/rpc/methods/eth_getUserOperationByHash.js.map +1 -1
  214. package/esm/rpc/methods/eth_getUserOperationReceipt.d.ts +34 -34
  215. package/esm/rpc/methods/eth_getUserOperationReceipt.js +1 -1
  216. package/esm/rpc/methods/eth_sendUserOperation.d.ts +307 -3
  217. package/esm/rpc/methods/eth_sendUserOperation.js +153 -48
  218. package/esm/rpc/methods/eth_sendUserOperation.js.map +1 -1
  219. package/esm/rpc/methods/pimlico_getUserOperationStatus.js +1 -1
  220. package/esm/rpc/methods/pimlico_getUserOperationStatus.js.map +1 -1
  221. package/esm/rpc/methods/pimlico_sendUserOperationNow.d.ts +338 -34
  222. package/esm/rpc/methods/pimlico_sendUserOperationNow.js +26 -29
  223. package/esm/rpc/methods/pimlico_sendUserOperationNow.js.map +1 -1
  224. package/esm/rpc/methods/pimlico_simulateAssetChange.d.ts +620 -12
  225. package/esm/rpc/methods/pimlico_simulateAssetChange.js +14 -19
  226. package/esm/rpc/methods/pimlico_simulateAssetChange.js.map +1 -1
  227. package/esm/rpc/rpcHandler.d.ts +38 -26
  228. package/esm/rpc/rpcHandler.js +97 -44
  229. package/esm/rpc/rpcHandler.js.map +1 -1
  230. package/esm/rpc/server.d.ts +5 -5
  231. package/esm/rpc/server.js +15 -11
  232. package/esm/rpc/server.js.map +1 -1
  233. package/esm/rpc/validation/BundlerCollectorTracerV06.js +1 -1
  234. package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +1 -1
  235. package/esm/rpc/validation/BundlerCollectorTracerV07.js +1 -1
  236. package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +1 -1
  237. package/esm/rpc/validation/SafeValidator.d.ts +13 -14
  238. package/esm/rpc/validation/SafeValidator.js +24 -24
  239. package/esm/rpc/validation/SafeValidator.js.map +1 -1
  240. package/esm/rpc/validation/TracerResultParserV06.d.ts +2 -2
  241. package/esm/rpc/validation/TracerResultParserV06.js +11 -11
  242. package/esm/rpc/validation/TracerResultParserV06.js.map +1 -1
  243. package/esm/rpc/validation/TracerResultParserV07.d.ts +2 -2
  244. package/esm/rpc/validation/TracerResultParserV07.js +13 -13
  245. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -1
  246. package/esm/rpc/validation/UnsafeValidator.d.ts +18 -14
  247. package/esm/rpc/validation/UnsafeValidator.js +76 -41
  248. package/esm/rpc/validation/UnsafeValidator.js.map +1 -1
  249. package/esm/store/createMempoolStore.d.ts +1 -1
  250. package/esm/store/createMempoolStore.js +79 -140
  251. package/esm/store/createMempoolStore.js.map +1 -1
  252. package/esm/store/index.d.ts +4 -75
  253. package/esm/store/index.js +4 -1
  254. package/esm/store/index.js.map +1 -1
  255. package/esm/store/outstanding/index.d.ts +13 -0
  256. package/esm/store/outstanding/index.js +16 -0
  257. package/esm/store/outstanding/index.js.map +1 -0
  258. package/esm/store/{createMemoryOutstandingStore.d.ts → outstanding/memory.d.ts} +14 -13
  259. package/esm/store/outstanding/memory.js +263 -0
  260. package/esm/store/outstanding/memory.js.map +1 -0
  261. package/esm/store/outstanding/redis.d.ts +11 -0
  262. package/esm/store/outstanding/redis.js +229 -0
  263. package/esm/store/outstanding/redis.js.map +1 -0
  264. package/esm/store/outstanding/types.d.ts +19 -0
  265. package/esm/store/outstanding/types.js +2 -0
  266. package/esm/store/outstanding/types.js.map +1 -0
  267. package/esm/store/processing/index.d.ts +11 -0
  268. package/esm/store/processing/index.js +17 -0
  269. package/esm/store/processing/index.js.map +1 -0
  270. package/esm/store/processing/memory.d.ts +19 -0
  271. package/esm/store/processing/memory.js +83 -0
  272. package/esm/store/processing/memory.js.map +1 -0
  273. package/esm/store/processing/redis.d.ts +26 -0
  274. package/esm/store/processing/redis.js +123 -0
  275. package/esm/store/processing/redis.js.map +1 -0
  276. package/esm/store/processing/types.d.ts +12 -0
  277. package/esm/store/processing/types.js +2 -0
  278. package/esm/store/processing/types.js.map +1 -0
  279. package/esm/store/types.d.ts +52 -0
  280. package/esm/store/types.js +2 -0
  281. package/esm/store/types.js.map +1 -0
  282. package/esm/types/contracts/Multicall3.d.ts +34 -0
  283. package/esm/types/contracts/Multicall3.js +31 -0
  284. package/esm/types/contracts/Multicall3.js.map +1 -0
  285. package/esm/types/contracts/PimlicoSimulations.d.ts +81 -0
  286. package/esm/types/contracts/PimlicoSimulations.js +105 -0
  287. package/esm/types/contracts/PimlicoSimulations.js.map +1 -1
  288. package/esm/types/contracts/index.d.ts +1 -1
  289. package/esm/types/contracts/index.js +1 -1
  290. package/esm/types/contracts/index.js.map +1 -1
  291. package/esm/types/gasPrice.js +0 -18
  292. package/esm/types/gasPrice.js.map +1 -1
  293. package/esm/types/interfaces.d.ts +15 -10
  294. package/esm/types/mempool.d.ts +3 -0
  295. package/esm/types/schemas.d.ts +13184 -4741
  296. package/esm/types/schemas.js +116 -27
  297. package/esm/types/schemas.js.map +1 -1
  298. package/esm/types/utils.d.ts +2 -5
  299. package/esm/types/utils.js +16 -18
  300. package/esm/types/utils.js.map +1 -1
  301. package/esm/types/validation.d.ts +7646 -6912
  302. package/esm/types/validation.js +122 -152
  303. package/esm/types/validation.js.map +1 -1
  304. package/esm/utils/eip7702.d.ts +2 -1
  305. package/esm/utils/eip7702.js +14 -8
  306. package/esm/utils/eip7702.js.map +1 -1
  307. package/esm/utils/entryPointOverrides.js +18 -4
  308. package/esm/utils/entryPointOverrides.js.map +1 -1
  309. package/esm/utils/helpers.d.ts +7 -1
  310. package/esm/utils/helpers.js +36 -11
  311. package/esm/utils/helpers.js.map +1 -1
  312. package/esm/utils/index.d.ts +0 -1
  313. package/esm/utils/index.js +0 -1
  314. package/esm/utils/index.js.map +1 -1
  315. package/esm/utils/metrics.d.ts +4 -1
  316. package/esm/utils/metrics.js +34 -7
  317. package/esm/utils/metrics.js.map +1 -1
  318. package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js +8 -9
  319. package/esm/utils/minMaxQueue/createMemoryMinMaxQueue.js.map +1 -1
  320. package/esm/utils/minMaxQueue/createRedisMinMaxQueue.d.ts +24 -2
  321. package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js +85 -64
  322. package/esm/utils/minMaxQueue/createRedisMinMaxQueue.js.map +1 -1
  323. package/esm/utils/minMaxQueue/index.d.ts +2 -2
  324. package/esm/utils/minMaxQueue/index.js +4 -3
  325. package/esm/utils/minMaxQueue/index.js.map +1 -1
  326. package/esm/utils/rpc-reply.d.ts +3 -3
  327. package/esm/utils/rpc-reply.js.map +1 -1
  328. package/esm/utils/toViemStateOverrides.js +7 -7
  329. package/esm/utils/toViemStateOverrides.js.map +1 -1
  330. package/esm/utils/userop.d.ts +110 -56
  331. package/esm/utils/userop.js +161 -249
  332. package/esm/utils/userop.js.map +1 -1
  333. package/package.json +4 -2
  334. package/contracts/build-info/7710b5a048396e70.json +0 -1
  335. package/esm/executor/userOpMonitor.js +0 -326
  336. package/esm/executor/userOpMonitor.js.map +0 -1
  337. package/esm/executor/utilityWalletMonitor.d.ts +0 -19
  338. package/esm/executor/utilityWalletMonitor.js +0 -38
  339. package/esm/executor/utilityWalletMonitor.js.map +0 -1
  340. package/esm/mempool/monitoring.d.ts +0 -15
  341. package/esm/mempool/monitoring.js +0 -118
  342. package/esm/mempool/monitoring.js.map +0 -1
  343. package/esm/store/createMemoryOutstandingStore.js +0 -240
  344. package/esm/store/createMemoryOutstandingStore.js.map +0 -1
  345. package/esm/store/createRedisOutstandingStore.d.ts +0 -27
  346. package/esm/store/createRedisOutstandingStore.js +0 -344
  347. package/esm/store/createRedisOutstandingStore.js.map +0 -1
  348. package/esm/store/createRedisStore.d.ts +0 -9
  349. package/esm/store/createRedisStore.js +0 -131
  350. package/esm/store/createRedisStore.js.map +0 -1
  351. package/esm/store/createStore.d.ts +0 -6
  352. package/esm/store/createStore.js +0 -66
  353. package/esm/store/createStore.js.map +0 -1
  354. package/esm/types/contracts/CallEngine.d.ts +0 -28
  355. package/esm/types/contracts/CallEngine.js +0 -37
  356. package/esm/types/contracts/CallEngine.js.map +0 -1
  357. package/esm/utils/preVerificationGasCalulator.js.map +0 -1
@@ -1,25 +1,26 @@
1
- import { EntryPointV06Abi, EntryPointV07Abi, RpcError, ValidationErrors } from "../types/index.js";
2
- import { getAAError, getAddressFromInitCodeOrPaymasterAndData, getUserOpHash, isVersion06, isVersion07, isVersion08, jsonStringifyWithBigint, scaleBigIntByPercent } from "../utils/index.js";
1
+ import { ERC7769Errors, EntryPointV06Abi, EntryPointV07Abi, RpcError } from "../types/index.js";
2
+ import { getAAError, getAddressFromInitCodeOrPaymasterAndData, getViemEntryPointVersion, isVersion06, isVersion07, jsonStringifyWithBigint, scaleBigIntByPercent } from "../utils/index.js";
3
3
  import { getAddress, getContract } from "viem";
4
- import { generatePrivateKey, privateKeyToAddress } from "viem/accounts";
5
4
  import { calculateAA95GasFloor } from "../executor/utils.js";
5
+ import { getEip7702AuthAddress } from "../utils/eip7702.js";
6
6
  import { ReputationStatuses } from "./reputationManager.js";
7
7
  export class Mempool {
8
8
  config;
9
9
  metrics;
10
- monitor;
10
+ statusManager;
11
11
  reputationManager;
12
- store;
13
12
  throttledEntityBundleCount;
14
13
  logger;
15
14
  validator;
16
15
  eventManager;
17
- constructor({ config, metrics, monitor, reputationManager, validator, store, eventManager }) {
16
+ isShuttingDown = false;
17
+ store;
18
+ constructor({ config, metrics, statusManager, reputationManager, validator, store, eventManager }) {
18
19
  this.metrics = metrics;
19
20
  this.store = store;
20
21
  this.config = config;
21
22
  this.reputationManager = reputationManager;
22
- this.monitor = monitor;
23
+ this.statusManager = statusManager;
23
24
  this.validator = validator;
24
25
  this.logger = config.getLogger({ module: "mempool" }, {
25
26
  level: config.logLevel
@@ -28,34 +29,59 @@ export class Mempool {
28
29
  this.eventManager = eventManager;
29
30
  }
30
31
  // === Methods for handling changing userOp state === //
31
- async markUserOpsAsSubmitted({ userOps, entryPoint, transactionHash }) {
32
- await Promise.all(userOps.map(async (userOpInfo) => {
33
- const { userOpHash } = userOpInfo;
34
- await this.store.removeProcessing({ entryPoint, userOpHash });
35
- await this.store.addSubmitted({ entryPoint, userOpInfo });
36
- await this.monitor.setUserOpStatus(userOpHash, {
37
- status: "submitted",
38
- transactionHash
39
- });
40
- }));
32
+ async markUserOpsAsSubmitted({ userOps, transactionHash }) {
33
+ const userOpHashes = userOps.map((userOpInfo) => userOpInfo.userOpHash);
34
+ await this.statusManager.set(userOpHashes, {
35
+ status: "submitted",
36
+ transactionHash
37
+ });
41
38
  this.metrics.userOpsSubmitted
42
39
  .labels({ status: "success" })
43
40
  .inc(userOps.length);
44
41
  }
45
42
  async resubmitUserOps({ userOps, entryPoint, reason }) {
46
43
  await Promise.all(userOps.map(async (userOpInfo) => {
47
- const { userOpHash, userOp } = userOpInfo;
44
+ const { userOpHash, submissionAttempts } = userOpInfo;
45
+ const maxResubmits = this.config.maxResubmits;
46
+ // Check if max resubmits has been reached
47
+ if (maxResubmits !== undefined &&
48
+ submissionAttempts >= maxResubmits) {
49
+ this.logger.warn({
50
+ userOpHash,
51
+ submissionAttempts,
52
+ maxResubmits
53
+ }, "dropping userOp: max resubmits reached");
54
+ const rejectedUserOp = {
55
+ ...userOpInfo,
56
+ reason: "max resubmits reached"
57
+ };
58
+ await this.dropUserOps(entryPoint, [rejectedUserOp]);
59
+ return;
60
+ }
48
61
  this.logger.warn({
49
62
  userOpHash,
63
+ submissionAttempts,
50
64
  reason
51
65
  }, "resubmitting user operation");
52
- await this.store.removeProcessing({ entryPoint, userOpHash });
53
- await this.store.removeSubmitted({ entryPoint, userOpHash });
54
- const [success, failureReason] = await this.add(userOp, entryPoint);
66
+ // Complete processing before re-adding to outstanding pool.
67
+ await this.store.removeProcessing({
68
+ entryPoint,
69
+ userOpInfos: [userOpInfo]
70
+ });
71
+ // Count this resubmit cycle, otherwise userOps that keep
72
+ // failing before being broadcast never hit maxResubmits.
73
+ const resubmittedUserOp = {
74
+ ...userOpInfo,
75
+ submissionAttempts: submissionAttempts + 1
76
+ };
77
+ const [success, failureReason] = await this.add({
78
+ userOpInfo: resubmittedUserOp,
79
+ entryPoint
80
+ });
55
81
  if (!success) {
56
82
  this.logger.error({ userOpHash, failureReason }, "Failed to resubmit user operation");
57
83
  const rejectedUserOp = {
58
- ...userOpInfo,
84
+ ...resubmittedUserOp,
59
85
  reason: failureReason
60
86
  };
61
87
  this.dropUserOps(entryPoint, [rejectedUserOp]);
@@ -66,13 +92,17 @@ export class Mempool {
66
92
  async dropUserOps(entryPoint, rejectedUserOps) {
67
93
  await Promise.all(rejectedUserOps.map(async (rejectedUserOp) => {
68
94
  const { userOp, reason, userOpHash } = rejectedUserOp;
69
- await this.store.removeProcessing({ entryPoint, userOpHash });
70
- await this.store.removeSubmitted({ entryPoint, userOpHash });
95
+ // Complete processing since userOp is dropped.
96
+ await this.store.removeProcessing({
97
+ entryPoint,
98
+ userOpInfos: [rejectedUserOp]
99
+ });
71
100
  this.eventManager.emitDropped(userOpHash, reason, getAAError(reason));
72
- await this.monitor.setUserOpStatus(userOpHash, {
101
+ await this.statusManager.set([userOpHash], {
73
102
  status: "rejected",
74
103
  transactionHash: null
75
104
  });
105
+ this.metrics.userOpsDropped.labels({ reason }).inc();
76
106
  this.logger.warn({
77
107
  userOperation: jsonStringifyWithBigint(userOp),
78
108
  userOpHash,
@@ -80,30 +110,34 @@ export class Mempool {
80
110
  }, "user operation rejected");
81
111
  }));
82
112
  }
83
- async removeSubmittedUserOps({ userOps, entryPoint }) {
84
- await Promise.all(userOps.map(async ({ userOpHash }) => {
85
- await this.store.removeSubmitted({ entryPoint, userOpHash });
86
- }));
113
+ // Remove userOps from processing store.
114
+ // should be called when userOps are included onchain.
115
+ async removeProcessing({ userOps, entryPoint }) {
116
+ await this.store.removeProcessing({
117
+ entryPoint,
118
+ userOpInfos: userOps
119
+ });
87
120
  }
88
121
  // === Methods for dropping mempool entries === //
89
122
  async dumpOutstanding(entryPoint) {
90
123
  return await this.store.dumpOutstanding(entryPoint);
91
124
  }
92
- async dumpProcessing(entryPoint) {
93
- return await this.store.dumpProcessing(entryPoint);
125
+ async flushProcessing(entryPoint) {
126
+ return await this.store.flushProcessing(entryPoint);
94
127
  }
95
- async dumpSubmittedOps(entryPoint) {
96
- return await this.store.dumpSubmitted(entryPoint);
128
+ startShutdown() {
129
+ this.isShuttingDown = true;
130
+ this.logger.info("[SHUTDOWN] Mempool entered shutdown mode. No new bundles will be created");
97
131
  }
98
132
  // === Methods for entity management === //
99
133
  async checkEntityMultipleRoleViolation(entryPoint, op) {
100
134
  if (!this.config.safeMode) {
101
- return Promise.resolve();
135
+ return;
102
136
  }
103
137
  const knownEntities = await this.getKnownEntities(entryPoint);
104
138
  if (knownEntities.paymasters.has(op.sender) ||
105
139
  knownEntities.factories.has(op.sender)) {
106
- throw new RpcError(`The sender address "${op.sender}" is used as a different entity in another UserOperation currently in mempool`, ValidationErrors.OpcodeValidation);
140
+ throw new RpcError(`The sender address "${op.sender}" is used as a different entity in another UserOperation currently in mempool`, ERC7769Errors.OpcodeValidation);
107
141
  }
108
142
  let paymaster = null;
109
143
  let factory = null;
@@ -116,12 +150,11 @@ export class Mempool {
116
150
  factory = op.factory;
117
151
  }
118
152
  if (paymaster && knownEntities.sender.has(paymaster)) {
119
- throw new RpcError(`A Paymaster at ${paymaster} in this UserOperation is used as a sender entity in another UserOperation currently in mempool.`, ValidationErrors.OpcodeValidation);
153
+ throw new RpcError(`A Paymaster at ${paymaster} in this UserOperation is used as a sender entity in another UserOperation currently in mempool.`, ERC7769Errors.OpcodeValidation);
120
154
  }
121
155
  if (factory && knownEntities.sender.has(factory)) {
122
- throw new RpcError(`A Factory at ${factory} in this UserOperation is used as a sender entity in another UserOperation currently in mempool.`, ValidationErrors.OpcodeValidation);
156
+ throw new RpcError(`A Factory at ${factory} in this UserOperation is used as a sender entity in another UserOperation currently in mempool.`, ERC7769Errors.OpcodeValidation);
123
157
  }
124
- return Promise.resolve();
125
158
  }
126
159
  async getKnownEntities(entryPoint) {
127
160
  // TODO: this won't work with redis
@@ -151,21 +184,13 @@ export class Mempool {
151
184
  return entities;
152
185
  }
153
186
  // === Methods for adding userOps / creating bundles === //
154
- async add(userOp, entryPoint, referencedContracts) {
155
- const userOpHash = await getUserOpHash({
156
- userOp,
157
- entryPointAddress: entryPoint,
158
- chainId: this.config.chainId,
159
- publicClient: this.config.publicClient
160
- });
161
- // Check if the exact same userOperation is already in the mempool.
162
- if (await this.store.isInMempool({ userOpHash, entryPoint })) {
163
- return [false, "Already known"];
164
- }
165
- // Check if there is a conflicting userOp already being processed
166
- const validation = await this.store.validateSubmittedOrProcessing({
187
+ async add({ userOpInfo, entryPoint }) {
188
+ const { userOp, userOpHash } = userOpInfo;
189
+ // Check if the userOp is already known or conflicts with existing operations
190
+ const validation = await this.store.checkDuplicatesAndConflicts({
167
191
  entryPoint,
168
- userOp
192
+ userOp,
193
+ userOpHash
169
194
  });
170
195
  if (!validation.valid) {
171
196
  return [false, validation.reason];
@@ -176,7 +201,7 @@ export class Mempool {
176
201
  userOp
177
202
  });
178
203
  if (conflicting) {
179
- const { userOpInfo, reason } = conflicting;
204
+ const { userOpInfo, conflictReason } = conflicting;
180
205
  const conflictingUserOp = userOpInfo.userOp;
181
206
  const hasHigherPriorityFee = userOp.maxPriorityFeePerGas >=
182
207
  scaleBigIntByPercent(conflictingUserOp.maxPriorityFeePerGas, 110n);
@@ -184,13 +209,23 @@ export class Mempool {
184
209
  scaleBigIntByPercent(conflictingUserOp.maxFeePerGas, 110n);
185
210
  const hasHigherFees = hasHigherPriorityFee && hasHigherMaxFee;
186
211
  if (!hasHigherFees) {
187
- const message = reason === "conflicting_deployment"
188
- ? "AA10 sender already constructed: A conflicting userOperation with initCode for this sender is already in the mempool"
189
- : "AA25 invalid account nonce: User operation already present in mempool";
212
+ let message;
213
+ if (conflictReason === "conflicting_deployment") {
214
+ message =
215
+ "AA10 sender already constructed: A conflicting userOperation with initCode for this sender is already in the mempool";
216
+ }
217
+ else if (conflictReason === "conflicting_7702_auth") {
218
+ message =
219
+ "AA10 sender already constructed: Sender already has an inflight EIP-7702 authorization";
220
+ }
221
+ else {
222
+ message =
223
+ "AA25 invalid account nonce: User operation already present in mempool";
224
+ }
190
225
  // Re-add to outstanding as it wasn't replaced
191
226
  await this.store.addOutstanding({
192
227
  entryPoint,
193
- userOpInfo: conflicting.userOpInfo
228
+ userOpInfos: [conflicting.userOpInfo]
194
229
  });
195
230
  return [false, `${message}, bump the gas price by minimum 10%`];
196
231
  }
@@ -199,15 +234,9 @@ export class Mempool {
199
234
  await this.reputationManager.increaseUserOpSeenStatus(userOp, entryPoint);
200
235
  await this.store.addOutstanding({
201
236
  entryPoint,
202
- userOpInfo: {
203
- userOp,
204
- userOpHash,
205
- referencedContracts,
206
- addedToMempool: Date.now(),
207
- submissionAttempts: 0
208
- }
237
+ userOpInfos: [userOpInfo]
209
238
  });
210
- await this.monitor.setUserOpStatus(userOpHash, {
239
+ await this.statusManager.set([userOpHash], {
211
240
  status: "not_submitted",
212
241
  transactionHash: null
213
242
  });
@@ -215,7 +244,33 @@ export class Mempool {
215
244
  return [true, ""];
216
245
  }
217
246
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
218
- async shouldSkip({ userOpInfo, paymasterDeposit, stakedEntityCount, knownEntities, senders, storageMap, entryPoint }) {
247
+ async shouldSkip({ userOpInfo, paymasterDeposit, touchedEip7702Auth, stakedEntityCount, knownEntities, senders, storageMap, entryPoint }) {
248
+ const { userOp, userOpHash, referencedContracts } = userOpInfo;
249
+ // Check conflicting EIP-7702 auths (same sender, different delegate address)
250
+ if (userOp.eip7702Auth) {
251
+ const auth = getEip7702AuthAddress(userOp.eip7702Auth);
252
+ const existingAuth = touchedEip7702Auth.get(userOp.sender);
253
+ if (existingAuth && existingAuth !== auth) {
254
+ this.logger.warn({
255
+ userOpHash,
256
+ conflictingAuth: auth,
257
+ existingAuth
258
+ }, "Conflicting EIP-7702 auths");
259
+ return {
260
+ skip: true,
261
+ removeOutstanding: false,
262
+ paymasterDeposit,
263
+ touchedEip7702Auth,
264
+ stakedEntityCount,
265
+ knownEntities,
266
+ senders,
267
+ storageMap
268
+ };
269
+ }
270
+ if (!existingAuth) {
271
+ touchedEip7702Auth.set(userOp.sender, auth);
272
+ }
273
+ }
219
274
  if (!this.config.safeMode) {
220
275
  return {
221
276
  skip: false,
@@ -223,10 +278,10 @@ export class Mempool {
223
278
  stakedEntityCount,
224
279
  knownEntities,
225
280
  senders,
226
- storageMap
281
+ storageMap,
282
+ touchedEip7702Auth
227
283
  };
228
284
  }
229
- const { userOp, userOpHash, referencedContracts } = userOpInfo;
230
285
  const isUserOpV06 = isVersion06(userOp);
231
286
  const paymaster = isUserOpV06
232
287
  ? getAddressFromInitCodeOrPaymasterAndData(userOp.paymasterAndData)
@@ -245,7 +300,8 @@ export class Mempool {
245
300
  stakedEntityCount,
246
301
  knownEntities,
247
302
  senders,
248
- storageMap
303
+ storageMap,
304
+ touchedEip7702Auth
249
305
  };
250
306
  }
251
307
  if (paymasterStatus === ReputationStatuses.throttled &&
@@ -261,7 +317,8 @@ export class Mempool {
261
317
  stakedEntityCount,
262
318
  knownEntities,
263
319
  senders,
264
- storageMap
320
+ storageMap,
321
+ touchedEip7702Auth
265
322
  };
266
323
  }
267
324
  if (factoryStatus === ReputationStatuses.throttled &&
@@ -277,7 +334,8 @@ export class Mempool {
277
334
  stakedEntityCount,
278
335
  knownEntities,
279
336
  senders,
280
- storageMap
337
+ storageMap,
338
+ touchedEip7702Auth
281
339
  };
282
340
  }
283
341
  if (senders.has(userOp.sender) &&
@@ -292,14 +350,15 @@ export class Mempool {
292
350
  stakedEntityCount,
293
351
  knownEntities,
294
352
  senders,
295
- storageMap
353
+ storageMap,
354
+ touchedEip7702Auth
296
355
  };
297
356
  }
298
357
  let validationResult;
299
358
  try {
300
359
  let queuedUserOps = [];
301
360
  if (!isUserOpV06) {
302
- queuedUserOps = await this.getQueuedOustandingUserOps({
361
+ queuedUserOps = await this.getQueuedOutstandingUserOps({
303
362
  userOp,
304
363
  entryPoint
305
364
  });
@@ -316,7 +375,7 @@ export class Mempool {
316
375
  userOpHash,
317
376
  error: JSON.stringify(e)
318
377
  }, "2nd Validation error");
319
- this.store.removeOutstanding({ entryPoint, userOpHash });
378
+ await this.store.removeOutstanding({ entryPoint, userOpHash });
320
379
  this.reputationManager.decreaseUserOpSeenStatus(userOp, entryPoint, e instanceof RpcError ? e.message : JSON.stringify(e));
321
380
  return {
322
381
  skip: true,
@@ -324,7 +383,8 @@ export class Mempool {
324
383
  stakedEntityCount,
325
384
  knownEntities,
326
385
  senders,
327
- storageMap
386
+ storageMap,
387
+ touchedEip7702Auth
328
388
  };
329
389
  }
330
390
  for (const storageAddress of Object.keys(validationResult.storageMap)) {
@@ -341,7 +401,8 @@ export class Mempool {
341
401
  stakedEntityCount,
342
402
  knownEntities,
343
403
  senders,
344
- storageMap
404
+ storageMap,
405
+ touchedEip7702Auth
345
406
  };
346
407
  }
347
408
  }
@@ -369,7 +430,8 @@ export class Mempool {
369
430
  stakedEntityCount,
370
431
  knownEntities,
371
432
  senders,
372
- storageMap
433
+ storageMap,
434
+ touchedEip7702Auth
373
435
  };
374
436
  }
375
437
  stakedEntityCount[paymaster] =
@@ -386,15 +448,18 @@ export class Mempool {
386
448
  stakedEntityCount,
387
449
  knownEntities,
388
450
  senders,
389
- storageMap
451
+ storageMap,
452
+ touchedEip7702Auth
390
453
  };
391
454
  }
392
455
  async getBundles(maxBundleCount) {
456
+ if (this.isShuttingDown) {
457
+ return [];
458
+ }
393
459
  const bundlePromises = this.config.entrypoints.map(async (entryPoint) => {
394
460
  return await this.process({
395
461
  entryPoint,
396
462
  maxGasLimit: this.config.maxGasPerBundle,
397
- minOpsPerBundle: 1,
398
463
  maxBundleCount
399
464
  });
400
465
  });
@@ -403,34 +468,48 @@ export class Mempool {
403
468
  return bundles;
404
469
  }
405
470
  // Returns a bundle of userOperations in array format.
406
- async process({ maxGasLimit, entryPoint, minOpsPerBundle, maxBundleCount }) {
407
- // Check if there are any operations in the store
408
- const firstOp = await this.store.peekOutstanding(entryPoint);
409
- if (!firstOp) {
471
+ async process({ maxGasLimit, entryPoint, maxBundleCount }) {
472
+ if (this.isShuttingDown) {
410
473
  return [];
411
474
  }
412
- // Get EntryPoint version
413
475
  const bundles = [];
414
- const seenOps = new Set();
415
- let breakLoop = false;
416
- // Process operations until no more are available or we hit maxBundleCount
417
- while (await this.store.peekOutstanding(entryPoint)) {
418
- // If maxBundles is set and we reached the limit, break
476
+ const batchSize = this.config.mempoolPopBatchSize;
477
+ // Pop batch of userOps.
478
+ const poppedUserOps = await this.store.popOutstanding(entryPoint, batchSize);
479
+ if (poppedUserOps.length === 0) {
480
+ return [];
481
+ }
482
+ // Track popped userOps as processing immediately to prevent loss on shutdown
483
+ await this.store.addProcessing({
484
+ entryPoint,
485
+ userOpInfos: poppedUserOps
486
+ });
487
+ // Keep track of unused ops from the batch
488
+ const unusedUserOps = [...poppedUserOps];
489
+ while (unusedUserOps.length > 0) {
490
+ // If maxBundles is set and we reached the limit, put back all unused ops and break.
419
491
  if (maxBundleCount && bundles.length >= maxBundleCount) {
492
+ if (unusedUserOps.length > 0) {
493
+ // Remove from processing before putting back to outstanding
494
+ await this.store.removeProcessing({
495
+ entryPoint,
496
+ userOpInfos: unusedUserOps
497
+ });
498
+ await this.store.addOutstanding({
499
+ entryPoint,
500
+ userOpInfos: unusedUserOps
501
+ });
502
+ unusedUserOps.length = 0;
503
+ }
420
504
  break;
421
505
  }
422
- // Derive version
423
- let version;
424
- if (isVersion08(firstOp.userOp, entryPoint)) {
425
- version = "0.8";
426
- }
427
- else if (isVersion07(firstOp.userOp)) {
428
- version = "0.7";
429
- }
430
- else {
431
- version = "0.6";
432
- }
433
- // Setup for next bundle
506
+ // Peek next userOp from unused batch.
507
+ const nextUserOp = unusedUserOps[0];
508
+ if (!nextUserOp)
509
+ break;
510
+ // Derive version.
511
+ const version = getViemEntryPointVersion(nextUserOp.userOp, entryPoint);
512
+ // Setup next bundle.
434
513
  const currentBundle = {
435
514
  entryPoint,
436
515
  version,
@@ -438,33 +517,21 @@ export class Mempool {
438
517
  submissionAttempts: 0
439
518
  };
440
519
  let gasUsed = 0n;
520
+ let touchedEip7702Auth = new Map();
441
521
  let paymasterDeposit = {};
442
522
  let stakedEntityCount = {};
443
523
  let senders = new Set();
444
524
  let knownEntities = await this.getKnownEntities(entryPoint);
445
525
  let storageMap = {};
446
- if (breakLoop) {
447
- break;
448
- }
449
- // Keep adding ops to current bundle
450
- while (await this.store.peekOutstanding(entryPoint)) {
451
- const userOpInfo = await this.store.popOutstanding(entryPoint);
452
- if (!userOpInfo) {
453
- break;
454
- }
455
- if (seenOps.has(userOpInfo.userOpHash)) {
456
- breakLoop = true;
457
- await this.store.addOutstanding({
458
- entryPoint,
459
- userOpInfo
460
- });
526
+ while (unusedUserOps.length > 0) {
527
+ const currentUserOp = unusedUserOps.shift();
528
+ if (!currentUserOp)
461
529
  break;
462
- }
463
- seenOps.add(userOpInfo.userOpHash);
464
- const { userOp } = userOpInfo;
530
+ const { userOp } = currentUserOp;
465
531
  // Check if we should skip this operation
466
532
  const skipResult = await this.shouldSkip({
467
- userOpInfo,
533
+ userOpInfo: currentUserOp,
534
+ touchedEip7702Auth,
468
535
  paymasterDeposit,
469
536
  stakedEntityCount,
470
537
  knownEntities,
@@ -473,26 +540,33 @@ export class Mempool {
473
540
  entryPoint
474
541
  });
475
542
  if (skipResult.skip) {
543
+ // Remove from processing since it's going back to outstanding or being dropped
544
+ await this.store.removeProcessing({
545
+ entryPoint,
546
+ userOpInfos: [currentUserOp]
547
+ });
476
548
  // Re-add to outstanding
477
549
  if (!skipResult.removeOutstanding) {
478
550
  await this.store.addOutstanding({
479
551
  entryPoint,
480
- userOpInfo
552
+ userOpInfos: [currentUserOp]
481
553
  });
482
554
  }
555
+ // Continue with next op from batch
483
556
  continue;
484
557
  }
485
- const beneficiary = this.config.utilityPrivateKey?.address ||
486
- privateKeyToAddress(generatePrivateKey());
487
558
  gasUsed += calculateAA95GasFloor({
488
559
  userOps: [userOp],
489
- beneficiary
560
+ beneficiary: this.config.utilityWalletAddress
490
561
  });
491
- // Only break on gas limit if we've hit minOpsPerBundle
492
- if (gasUsed > maxGasLimit &&
493
- currentBundle.userOps.length >= minOpsPerBundle) {
494
- // Put the operation back in the store
495
- await this.store.addOutstanding({ entryPoint, userOpInfo });
562
+ // Check bundle gasLimit if bundle is not empty.
563
+ // The executor scales the bundle's tx.gasLimit by
564
+ // executorGasMultiplier, compare against the scaled value
565
+ // so the final transaction stays within maxGasLimit.
566
+ if (currentBundle.userOps.length > 0 &&
567
+ scaleBigIntByPercent(gasUsed, this.config.executorGasMultiplier) > maxGasLimit) {
568
+ // Put current op back to front of unused for next bundle
569
+ unusedUserOps.unshift(currentUserOp);
496
570
  break;
497
571
  }
498
572
  // Update state based on skip result
@@ -501,10 +575,20 @@ export class Mempool {
501
575
  knownEntities = skipResult.knownEntities;
502
576
  senders = skipResult.senders;
503
577
  storageMap = skipResult.storageMap;
578
+ touchedEip7702Auth = skipResult.touchedEip7702Auth;
504
579
  this.reputationManager.decreaseUserOpCount(userOp);
505
- this.store.addProcessing({ entryPoint, userOpInfo });
506
- // Add op to current bundle
507
- currentBundle.userOps.push(userOpInfo);
580
+ // Add userOp to current bundle.
581
+ currentBundle.userOps.push(currentUserOp);
582
+ // Try to fetch more userOps if we've exhausted this batch.
583
+ if (unusedUserOps.length === 0) {
584
+ const morePoppedOps = await this.store.popOutstanding(entryPoint, batchSize);
585
+ // Track newly popped userOps as processing immediately
586
+ await this.store.addProcessing({
587
+ entryPoint,
588
+ userOpInfos: morePoppedOps
589
+ });
590
+ unusedUserOps.push(...morePoppedOps);
591
+ }
508
592
  }
509
593
  if (currentBundle.userOps.length > 0) {
510
594
  bundles.push(currentBundle);
@@ -512,12 +596,18 @@ export class Mempool {
512
596
  }
513
597
  return bundles;
514
598
  }
599
+ async clearProcessing() {
600
+ for (const entryPoint of this.config.entrypoints) {
601
+ await this.store.clearAllProcessing(entryPoint);
602
+ this.logger.info({ entryPoint }, "[SHUTDOWN] Cleared processing state during startup");
603
+ }
604
+ }
515
605
  clear() {
516
606
  for (const entryPoint of this.config.entrypoints) {
517
607
  this.store.clearOutstanding(entryPoint);
518
608
  }
519
609
  }
520
- async getQueuedOustandingUserOps(args) {
610
+ async getQueuedOutstandingUserOps(args) {
521
611
  return await this.store.getQueuedOutstandingUserOps(args);
522
612
  }
523
613
  }