@pimlico/alto 0.0.0-staging.20240606T115633 → 0.0.2

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 (228) hide show
  1. package/LICENSE +674 -0
  2. package/lib/executor/executor.js +6 -0
  3. package/lib/executor/executor.js.map +1 -1
  4. package/lib/executor/executorManager.js +1 -0
  5. package/lib/executor/executorManager.js.map +1 -1
  6. package/lib/executor/utils.js +3 -1
  7. package/lib/executor/utils.js.map +1 -1
  8. package/lib/types/mempool.d.ts +2 -1
  9. package/package.json +10 -11
  10. package/esm/cli/alto.d.ts +0 -6
  11. package/esm/cli/alto.js +0 -92
  12. package/esm/cli/alto.js.map +0 -1
  13. package/esm/cli/config/bundler.d.ts +0 -391
  14. package/esm/cli/config/bundler.js +0 -132
  15. package/esm/cli/config/bundler.js.map +0 -1
  16. package/esm/cli/config/index.d.ts +0 -3
  17. package/esm/cli/config/index.js +0 -3
  18. package/esm/cli/config/index.js.map +0 -1
  19. package/esm/cli/config/options.d.ts +0 -11
  20. package/esm/cli/config/options.js +0 -336
  21. package/esm/cli/config/options.js.map +0 -1
  22. package/esm/cli/customTransport.d.ts +0 -14
  23. package/esm/cli/customTransport.js +0 -53
  24. package/esm/cli/customTransport.js.map +0 -1
  25. package/esm/cli/handler.d.ts +0 -3
  26. package/esm/cli/handler.js +0 -116
  27. package/esm/cli/handler.js.map +0 -1
  28. package/esm/cli/index.d.ts +0 -4
  29. package/esm/cli/index.js +0 -4
  30. package/esm/cli/index.js.map +0 -1
  31. package/esm/cli/instrumentation.d.ts +0 -2
  32. package/esm/cli/instrumentation.js +0 -39
  33. package/esm/cli/instrumentation.js.map +0 -1
  34. package/esm/cli/setupServer.d.ts +0 -17
  35. package/esm/cli/setupServer.js +0 -155
  36. package/esm/cli/setupServer.js.map +0 -1
  37. package/esm/cli/util.d.ts +0 -22
  38. package/esm/cli/util.js +0 -30
  39. package/esm/cli/util.js.map +0 -1
  40. package/esm/executor/executor.d.ts +0 -54
  41. package/esm/executor/executor.js +0 -637
  42. package/esm/executor/executor.js.map +0 -1
  43. package/esm/executor/executorManager.d.ts +0 -34
  44. package/esm/executor/executorManager.js +0 -401
  45. package/esm/executor/executorManager.js.map +0 -1
  46. package/esm/executor/index.d.ts +0 -5
  47. package/esm/executor/index.js +0 -5
  48. package/esm/executor/index.js.map +0 -1
  49. package/esm/executor/senderManager.d.ts +0 -17
  50. package/esm/executor/senderManager.js +0 -160
  51. package/esm/executor/senderManager.js.map +0 -1
  52. package/esm/executor/test/utils.d.ts +0 -13
  53. package/esm/executor/test/utils.js +0 -75
  54. package/esm/executor/test/utils.js.map +0 -1
  55. package/esm/executor/utils.d.ts +0 -32
  56. package/esm/executor/utils.js +0 -239
  57. package/esm/executor/utils.js.map +0 -1
  58. package/esm/index.d.ts +0 -2
  59. package/esm/index.js +0 -2
  60. package/esm/index.js.map +0 -1
  61. package/esm/mempool/index.d.ts +0 -5
  62. package/esm/mempool/index.js +0 -5
  63. package/esm/mempool/index.js.map +0 -1
  64. package/esm/mempool/mempool.d.ts +0 -64
  65. package/esm/mempool/mempool.js +0 -489
  66. package/esm/mempool/mempool.js.map +0 -1
  67. package/esm/mempool/monitoring.d.ts +0 -10
  68. package/esm/mempool/monitoring.js +0 -34
  69. package/esm/mempool/monitoring.js.map +0 -1
  70. package/esm/mempool/nullMempool.d.ts +0 -15
  71. package/esm/mempool/nullMempool.js +0 -36
  72. package/esm/mempool/nullMempool.js.map +0 -1
  73. package/esm/mempool/reputationManager.d.ts +0 -115
  74. package/esm/mempool/reputationManager.js +0 -397
  75. package/esm/mempool/reputationManager.js.map +0 -1
  76. package/esm/mempool/store.d.ts +0 -22
  77. package/esm/mempool/store.js +0 -123
  78. package/esm/mempool/store.js.map +0 -1
  79. package/esm/rpc/EntryPointSimulationsV07.d.ts +0 -58
  80. package/esm/rpc/EntryPointSimulationsV07.js +0 -407
  81. package/esm/rpc/EntryPointSimulationsV07.js.map +0 -1
  82. package/esm/rpc/ExecuteSimulator.d.ts +0 -37
  83. package/esm/rpc/ExecuteSimulator.js +0 -48
  84. package/esm/rpc/ExecuteSimulator.js.map +0 -1
  85. package/esm/rpc/gasEstimation.d.ts +0 -17
  86. package/esm/rpc/gasEstimation.js +0 -410
  87. package/esm/rpc/gasEstimation.js.map +0 -1
  88. package/esm/rpc/index.d.ts +0 -5
  89. package/esm/rpc/index.js +0 -5
  90. package/esm/rpc/index.js.map +0 -1
  91. package/esm/rpc/nonceQueuer.d.ts +0 -25
  92. package/esm/rpc/nonceQueuer.js +0 -135
  93. package/esm/rpc/nonceQueuer.js.map +0 -1
  94. package/esm/rpc/rpcHandler.d.ts +0 -64
  95. package/esm/rpc/rpcHandler.js +0 -727
  96. package/esm/rpc/rpcHandler.js.map +0 -1
  97. package/esm/rpc/server.d.ts +0 -31
  98. package/esm/rpc/server.js +0 -239
  99. package/esm/rpc/server.js.map +0 -1
  100. package/esm/rpc/validation/BundlerCollectorTracerV06.d.ts +0 -102
  101. package/esm/rpc/validation/BundlerCollectorTracerV06.js +0 -255
  102. package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +0 -1
  103. package/esm/rpc/validation/BundlerCollectorTracerV07.d.ts +0 -102
  104. package/esm/rpc/validation/BundlerCollectorTracerV07.js +0 -254
  105. package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +0 -1
  106. package/esm/rpc/validation/SafeValidator.d.ts +0 -35
  107. package/esm/rpc/validation/SafeValidator.js +0 -487
  108. package/esm/rpc/validation/SafeValidator.js.map +0 -1
  109. package/esm/rpc/validation/TracerResultParserV06.d.ts +0 -13
  110. package/esm/rpc/validation/TracerResultParserV06.js +0 -578
  111. package/esm/rpc/validation/TracerResultParserV06.js.map +0 -1
  112. package/esm/rpc/validation/TracerResultParserV07.d.ts +0 -33
  113. package/esm/rpc/validation/TracerResultParserV07.js +0 -557
  114. package/esm/rpc/validation/TracerResultParserV07.js.map +0 -1
  115. package/esm/rpc/validation/UnsafeValidator.d.ts +0 -63
  116. package/esm/rpc/validation/UnsafeValidator.js +0 -257
  117. package/esm/rpc/validation/UnsafeValidator.js.map +0 -1
  118. package/esm/rpc/validation/index.d.ts +0 -3
  119. package/esm/rpc/validation/index.js +0 -3
  120. package/esm/rpc/validation/index.js.map +0 -1
  121. package/esm/rpc/validation/tracer.d.ts +0 -122
  122. package/esm/rpc/validation/tracer.js +0 -82
  123. package/esm/rpc/validation/tracer.js.map +0 -1
  124. package/esm/types/contracts/BundleBulker.d.ts +0 -120
  125. package/esm/types/contracts/BundleBulker.js +0 -157
  126. package/esm/types/contracts/BundleBulker.js.map +0 -1
  127. package/esm/types/contracts/CallEngine.d.ts +0 -28
  128. package/esm/types/contracts/CallEngine.js +0 -37
  129. package/esm/types/contracts/CallEngine.js.map +0 -1
  130. package/esm/types/contracts/CodeHashGetter.d.ts +0 -37
  131. package/esm/types/contracts/CodeHashGetter.js +0 -45
  132. package/esm/types/contracts/CodeHashGetter.js.map +0 -1
  133. package/esm/types/contracts/EntryPoint.d.ts +0 -1789
  134. package/esm/types/contracts/EntryPoint.js +0 -2304
  135. package/esm/types/contracts/EntryPoint.js.map +0 -1
  136. package/esm/types/contracts/EntryPointSimulations.d.ts +0 -153
  137. package/esm/types/contracts/EntryPointSimulations.js +0 -15
  138. package/esm/types/contracts/EntryPointSimulations.js.map +0 -1
  139. package/esm/types/contracts/IOpInflator.d.ts +0 -61
  140. package/esm/types/contracts/IOpInflator.js +0 -80
  141. package/esm/types/contracts/IOpInflator.js.map +0 -1
  142. package/esm/types/contracts/IPaymaster.d.ts +0 -3
  143. package/esm/types/contracts/IPaymaster.js +0 -117
  144. package/esm/types/contracts/IPaymaster.js.map +0 -1
  145. package/esm/types/contracts/Inflator.d.ts +0 -65
  146. package/esm/types/contracts/Inflator.js +0 -84
  147. package/esm/types/contracts/Inflator.js.map +0 -1
  148. package/esm/types/contracts/PerOpInflator.d.ts +0 -176
  149. package/esm/types/contracts/PerOpInflator.js +0 -229
  150. package/esm/types/contracts/PerOpInflator.js.map +0 -1
  151. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +0 -23
  152. package/esm/types/contracts/PimlicoEntryPointSimulations.js +0 -33
  153. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +0 -1
  154. package/esm/types/contracts/SenderCreator.d.ts +0 -4
  155. package/esm/types/contracts/SenderCreator.js +0 -23
  156. package/esm/types/contracts/SenderCreator.js.map +0 -1
  157. package/esm/types/contracts/SimpleAccountFactory.d.ts +0 -57
  158. package/esm/types/contracts/SimpleAccountFactory.js +0 -76
  159. package/esm/types/contracts/SimpleAccountFactory.js.map +0 -1
  160. package/esm/types/contracts/TestOpcodesAccount.d.ts +0 -4
  161. package/esm/types/contracts/TestOpcodesAccount.js +0 -281
  162. package/esm/types/contracts/TestOpcodesAccount.js.map +0 -1
  163. package/esm/types/contracts/TestOpcodesAccountFactory.d.ts +0 -4
  164. package/esm/types/contracts/TestOpcodesAccountFactory.js +0 -23
  165. package/esm/types/contracts/TestOpcodesAccountFactory.js.map +0 -1
  166. package/esm/types/contracts/TestStorageAccount.d.ts +0 -4
  167. package/esm/types/contracts/TestStorageAccount.js +0 -313
  168. package/esm/types/contracts/TestStorageAccount.js.map +0 -1
  169. package/esm/types/contracts/index.d.ts +0 -17
  170. package/esm/types/contracts/index.js +0 -17
  171. package/esm/types/contracts/index.js.map +0 -1
  172. package/esm/types/gasPrice.d.ts +0 -110
  173. package/esm/types/gasPrice.js +0 -52
  174. package/esm/types/gasPrice.js.map +0 -1
  175. package/esm/types/index.d.ts +0 -11
  176. package/esm/types/index.js +0 -11
  177. package/esm/types/index.js.map +0 -1
  178. package/esm/types/interfaces.d.ts +0 -26
  179. package/esm/types/interfaces.js +0 -2
  180. package/esm/types/interfaces.js.map +0 -1
  181. package/esm/types/mempool.d.ts +0 -78
  182. package/esm/types/mempool.js +0 -16
  183. package/esm/types/mempool.js.map +0 -1
  184. package/esm/types/schemas.d.ts +0 -4791
  185. package/esm/types/schemas.js +0 -497
  186. package/esm/types/schemas.js.map +0 -1
  187. package/esm/types/test/validationTestErrors.d.ts +0 -3
  188. package/esm/types/test/validationTestErrors.js +0 -229
  189. package/esm/types/test/validationTestErrors.js.map +0 -1
  190. package/esm/types/utils.d.ts +0 -24
  191. package/esm/types/utils.js +0 -30
  192. package/esm/types/utils.js.map +0 -1
  193. package/esm/types/validation.d.ts +0 -14327
  194. package/esm/types/validation.js +0 -304
  195. package/esm/types/validation.js.map +0 -1
  196. package/esm/utils/bigInt.d.ts +0 -3
  197. package/esm/utils/bigInt.js +0 -9
  198. package/esm/utils/bigInt.js.map +0 -1
  199. package/esm/utils/compressionHandler.d.ts +0 -11
  200. package/esm/utils/compressionHandler.js +0 -39
  201. package/esm/utils/compressionHandler.js.map +0 -1
  202. package/esm/utils/gasPriceManager.d.ts +0 -34
  203. package/esm/utils/gasPriceManager.js +0 -338
  204. package/esm/utils/gasPriceManager.js.map +0 -1
  205. package/esm/utils/helpers.d.ts +0 -4
  206. package/esm/utils/helpers.js +0 -13
  207. package/esm/utils/helpers.js.map +0 -1
  208. package/esm/utils/index.d.ts +0 -11
  209. package/esm/utils/index.js +0 -10
  210. package/esm/utils/index.js.map +0 -1
  211. package/esm/utils/logger.d.ts +0 -6
  212. package/esm/utils/logger.js +0 -76
  213. package/esm/utils/logger.js.map +0 -1
  214. package/esm/utils/metrics.d.ts +0 -22
  215. package/esm/utils/metrics.js +0 -150
  216. package/esm/utils/metrics.js.map +0 -1
  217. package/esm/utils/rpc-reply.d.ts +0 -17
  218. package/esm/utils/rpc-reply.js +0 -41
  219. package/esm/utils/rpc-reply.js.map +0 -1
  220. package/esm/utils/test.d.ts +0 -17
  221. package/esm/utils/test.js +0 -130
  222. package/esm/utils/test.js.map +0 -1
  223. package/esm/utils/userop.d.ts +0 -49
  224. package/esm/utils/userop.js +0 -408
  225. package/esm/utils/userop.js.map +0 -1
  226. package/esm/utils/validation.d.ts +0 -65
  227. package/esm/utils/validation.js +0 -461
  228. package/esm/utils/validation.js.map +0 -1
@@ -1,34 +0,0 @@
1
- import type { Metrics, Logger, GasPriceManager } from "../utils/index.js";
2
- import type { InterfaceReputationManager, MemoryMempool, Monitor } from "../mempool/index.js";
3
- import { type BundlingMode, type MempoolUserOperation, type TransactionInfo } from "../types/index.js";
4
- import type { Address, Block, Chain, Hash, PublicClient, Transport } from "viem";
5
- import type { Executor } from "./executor.js";
6
- export declare class ExecutorManager {
7
- private entryPoints;
8
- private executor;
9
- private mempool;
10
- private monitor;
11
- private publicClient;
12
- private pollingInterval;
13
- private logger;
14
- private metrics;
15
- private reputationManager;
16
- private unWatch;
17
- private currentlyHandlingBlock;
18
- private timer?;
19
- private bundlerFrequency;
20
- private maxGasLimitPerBundle;
21
- private gasPriceManager;
22
- constructor(executor: Executor, entryPoints: Address[], mempool: MemoryMempool, monitor: Monitor, reputationManager: InterfaceReputationManager, publicClient: PublicClient<Transport, Chain>, pollingInterval: number, logger: Logger, metrics: Metrics, bundleMode: BundlingMode, bundlerFrequency: number, maxGasLimitPerBundle: bigint, gasPriceManager: GasPriceManager);
23
- setBundlingMode(bundleMode: BundlingMode): void;
24
- bundleNow(): Promise<Hash[]>;
25
- sendToExecutor(entryPoint: Address, mempoolOps: MempoolUserOperation[]): Promise<`0x${string}` | undefined>;
26
- bundle(): Promise<void>;
27
- startWatchingBlocks(handleBlock: (block: Block) => void): void;
28
- stopWatchingBlocks(): void;
29
- private refreshTransactionStatus;
30
- refreshUserOperationStatuses(): Promise<void>;
31
- handleBlock(block: Block): Promise<void>;
32
- replaceTransaction(txInfo: TransactionInfo, reason: string): Promise<void>;
33
- }
34
- //# sourceMappingURL=executorManager.d.ts.map
@@ -1,401 +0,0 @@
1
- import { deriveUserOperation, isCompressedType } from "../types/index.js";
2
- import { transactionIncluded } from "../utils/index.js";
3
- function getTransactionsFromUserOperationEntries(entries) {
4
- return Array.from(new Set(entries.map((entry) => {
5
- return entry.transactionInfo;
6
- })));
7
- }
8
- export class ExecutorManager {
9
- entryPoints;
10
- executor;
11
- mempool;
12
- monitor;
13
- publicClient;
14
- pollingInterval;
15
- logger;
16
- metrics;
17
- reputationManager;
18
- unWatch;
19
- currentlyHandlingBlock = false;
20
- timer;
21
- bundlerFrequency;
22
- maxGasLimitPerBundle;
23
- gasPriceManager;
24
- constructor(executor, entryPoints, mempool, monitor, reputationManager, publicClient, pollingInterval, logger, metrics, bundleMode, bundlerFrequency, maxGasLimitPerBundle, gasPriceManager) {
25
- this.entryPoints = entryPoints;
26
- this.reputationManager = reputationManager;
27
- this.executor = executor;
28
- this.mempool = mempool;
29
- this.monitor = monitor;
30
- this.publicClient = publicClient;
31
- this.pollingInterval = pollingInterval;
32
- this.logger = logger;
33
- this.metrics = metrics;
34
- this.bundlerFrequency = bundlerFrequency;
35
- this.maxGasLimitPerBundle = maxGasLimitPerBundle;
36
- this.gasPriceManager = gasPriceManager;
37
- if (bundleMode === "auto") {
38
- this.timer = setInterval(async () => {
39
- await this.bundle();
40
- }, bundlerFrequency);
41
- }
42
- }
43
- setBundlingMode(bundleMode) {
44
- if (bundleMode === "auto" && !this.timer) {
45
- this.timer = setInterval(async () => {
46
- await this.bundle();
47
- }, this.bundlerFrequency);
48
- }
49
- else if (bundleMode === "manual" && this.timer) {
50
- clearInterval(this.timer);
51
- this.timer = undefined;
52
- }
53
- }
54
- async bundleNow() {
55
- const ops = await this.mempool.process(this.maxGasLimitPerBundle, 1);
56
- if (ops.length === 0) {
57
- throw new Error("no ops to bundle");
58
- }
59
- const opEntryPointMap = new Map();
60
- for (const op of ops) {
61
- if (!opEntryPointMap.has(op.entryPoint)) {
62
- opEntryPointMap.set(op.entryPoint, []);
63
- }
64
- opEntryPointMap.get(op.entryPoint)?.push(op.mempoolUserOperation);
65
- }
66
- const txHashes = [];
67
- await Promise.all(this.entryPoints.map(async (entryPoint) => {
68
- const ops = opEntryPointMap.get(entryPoint);
69
- if (ops) {
70
- const txHash = await this.sendToExecutor(entryPoint, ops);
71
- if (!txHash) {
72
- throw new Error("no tx hash");
73
- }
74
- txHashes.push(txHash);
75
- }
76
- else {
77
- this.logger.warn({ entryPoint }, "no user operations for entry point");
78
- }
79
- }));
80
- return txHashes;
81
- }
82
- async sendToExecutor(entryPoint, mempoolOps) {
83
- const ops = mempoolOps
84
- .filter((op) => !isCompressedType(op))
85
- .map((op) => op);
86
- const compressedOps = mempoolOps
87
- .filter((op) => isCompressedType(op))
88
- .map((op) => op);
89
- const bundles = [];
90
- if (ops.length > 0) {
91
- bundles.push(await this.executor.bundle(entryPoint, ops));
92
- }
93
- if (compressedOps.length > 0) {
94
- bundles.push(await this.executor.bundleCompressed(entryPoint, compressedOps));
95
- }
96
- for (const bundle of bundles) {
97
- const isBundleSuccess = bundle.every((result) => result.status === "success");
98
- if (isBundleSuccess) {
99
- this.metrics.bundlesSubmitted
100
- .labels({ status: "success" })
101
- .inc();
102
- }
103
- else {
104
- this.metrics.bundlesSubmitted.labels({ status: "failed" }).inc();
105
- }
106
- }
107
- const results = bundles.flat();
108
- const filteredOutOps = mempoolOps.length - results.length;
109
- if (filteredOutOps > 0) {
110
- this.logger.debug({ filteredOutOps }, "user operations filtered out");
111
- this.metrics.userOperationsSubmitted
112
- .labels({ status: "filtered" })
113
- .inc(filteredOutOps);
114
- }
115
- let txHash = undefined;
116
- for (const result of results) {
117
- if (result.status === "success") {
118
- const res = result.value;
119
- this.mempool.markSubmitted(res.userOperation.userOperationHash, res.transactionInfo);
120
- // this.monitoredTransactions.set(result.transactionInfo.transactionHash, result.transactionInfo)
121
- this.monitor.setUserOperationStatus(res.userOperation.userOperationHash, {
122
- status: "submitted",
123
- transactionHash: res.transactionInfo.transactionHash
124
- });
125
- txHash = res.transactionInfo.transactionHash;
126
- this.startWatchingBlocks(this.handleBlock.bind(this));
127
- this.metrics.userOperationsSubmitted
128
- .labels({ status: "success" })
129
- .inc();
130
- }
131
- if (result.status === "failure") {
132
- this.mempool.removeProcessing(result.error.userOpHash);
133
- this.monitor.setUserOperationStatus(result.error.userOpHash, {
134
- status: "rejected",
135
- transactionHash: null
136
- });
137
- this.logger.warn({
138
- userOpHash: result.error.userOpHash,
139
- reason: result.error.reason
140
- }, "user operation rejected");
141
- this.metrics.userOperationsSubmitted
142
- .labels({ status: "failed" })
143
- .inc();
144
- }
145
- if (result.status === "resubmit") {
146
- this.logger.info({
147
- userOpHash: result.info.userOpHash,
148
- reason: result.info.reason
149
- }, "resubmitting user operation");
150
- this.mempool.removeProcessing(result.info.userOpHash);
151
- this.mempool.add(result.info.userOperation, result.info.entryPoint);
152
- this.metrics.userOperationsResubmitted.inc();
153
- }
154
- }
155
- return txHash;
156
- }
157
- async bundle() {
158
- const opsToBundle = [];
159
- while (true) {
160
- const ops = await this.mempool.process(5000000n, 1);
161
- if (ops?.length > 0) {
162
- opsToBundle.push(ops);
163
- }
164
- else {
165
- break;
166
- }
167
- }
168
- if (opsToBundle.length === 0) {
169
- return;
170
- }
171
- await Promise.all(opsToBundle.map(async (ops) => {
172
- const opEntryPointMap = new Map();
173
- for (const op of ops) {
174
- if (!opEntryPointMap.has(op.entryPoint)) {
175
- opEntryPointMap.set(op.entryPoint, []);
176
- }
177
- opEntryPointMap
178
- .get(op.entryPoint)
179
- ?.push(op.mempoolUserOperation);
180
- }
181
- await Promise.all(this.entryPoints.map(async (entryPoint) => {
182
- const userOperations = opEntryPointMap.get(entryPoint);
183
- if (userOperations) {
184
- await this.sendToExecutor(entryPoint, userOperations);
185
- }
186
- else {
187
- this.logger.warn({ entryPoint }, "no user operations for entry point");
188
- }
189
- }));
190
- }));
191
- }
192
- startWatchingBlocks(handleBlock) {
193
- if (this.unWatch) {
194
- return;
195
- }
196
- this.unWatch = this.publicClient.watchBlocks({
197
- onBlock: handleBlock,
198
- // onBlock: async (block) => {
199
- // // Use an arrow function to ensure correct binding of `this`
200
- // this.checkAndReplaceTransactions(block)
201
- // .then(() => {
202
- // this.logger.trace("block handled")
203
- // // Handle the resolution of the promise here, if needed
204
- // })
205
- // .catch((error) => {
206
- // // Handle any errors that occur during the execution of the promise
207
- // this.logger.error({ error }, "error while handling block")
208
- // })
209
- // },
210
- onError: (error) => {
211
- this.logger.error({ error }, "error while watching blocks");
212
- },
213
- emitMissed: false,
214
- includeTransactions: false,
215
- pollingInterval: this.pollingInterval
216
- });
217
- this.logger.debug("started watching blocks");
218
- }
219
- stopWatchingBlocks() {
220
- if (this.unWatch) {
221
- this.logger.debug("stopped watching blocks");
222
- this.unWatch();
223
- this.unWatch = undefined;
224
- }
225
- }
226
- async refreshTransactionStatus(entryPoint, transactionInfo) {
227
- const hashesToCheck = [
228
- transactionInfo.transactionHash,
229
- ...transactionInfo.previousTransactionHashes
230
- ];
231
- const opInfos = transactionInfo.userOperationInfos;
232
- // const opHashes = transactionInfo.userOperationInfos.map((opInfo) => opInfo.userOperationHash)
233
- const transactionStatuses = await Promise.all(hashesToCheck.map(async (hash) => {
234
- return {
235
- hash: hash,
236
- transactionStatuses: await transactionIncluded(transactionInfo.isVersion06, hash, this.publicClient, entryPoint)
237
- };
238
- }));
239
- const status = transactionStatuses.find((status) => status.transactionStatuses.status === "included" ||
240
- status.transactionStatuses.status === "failed" ||
241
- status.transactionStatuses.status === "reverted");
242
- if (!status) {
243
- opInfos.map((info) => {
244
- this.logger.trace({
245
- userOpHash: info.userOperationHash,
246
- transactionHash: transactionInfo.transactionHash
247
- }, "user op still pending");
248
- });
249
- return;
250
- }
251
- this.metrics.userOperationsOnChain
252
- .labels({ status: status.transactionStatuses.status })
253
- .inc(opInfos.length);
254
- if (status.transactionStatuses.status === "included") {
255
- opInfos.map((info) => {
256
- this.metrics.userOperationInclusionDuration.observe((Date.now() - info.firstSubmitted) / 1000);
257
- this.reputationManager.updateUserOperationIncludedStatus(deriveUserOperation(info.mempoolUserOperation), info.entryPoint, status.transactionStatuses[info.userOperationHash]
258
- .accountDeployed);
259
- this.mempool.removeSubmitted(info.userOperationHash);
260
- this.monitor.setUserOperationStatus(info.userOperationHash, {
261
- status: "included",
262
- transactionHash: status.hash
263
- });
264
- this.logger.info({
265
- userOpHash: info.userOperationHash,
266
- transactionHash: status.hash
267
- }, "user op included");
268
- });
269
- this.executor.markWalletProcessed(transactionInfo.executor);
270
- }
271
- else if (status.transactionStatuses.status === "failed" ||
272
- status.transactionStatuses.status === "reverted") {
273
- opInfos.map((info) => {
274
- this.mempool.removeSubmitted(info.userOperationHash);
275
- this.monitor.setUserOperationStatus(info.userOperationHash, {
276
- status: "rejected",
277
- transactionHash: status.hash
278
- });
279
- this.logger.info({
280
- userOpHash: info.userOperationHash,
281
- transactionHash: status.hash
282
- }, "user op rejected");
283
- });
284
- this.executor.markWalletProcessed(transactionInfo.executor);
285
- }
286
- }
287
- async refreshUserOperationStatuses() {
288
- const ops = this.mempool.dumpSubmittedOps();
289
- const opEntryPointMap = new Map();
290
- for (const op of ops) {
291
- if (!opEntryPointMap.has(op.userOperation.entryPoint)) {
292
- opEntryPointMap.set(op.userOperation.entryPoint, []);
293
- }
294
- opEntryPointMap.get(op.userOperation.entryPoint)?.push(op);
295
- }
296
- await Promise.all(this.entryPoints.map(async (entryPoint) => {
297
- const ops = opEntryPointMap.get(entryPoint);
298
- if (ops) {
299
- const txs = getTransactionsFromUserOperationEntries(ops);
300
- await Promise.all(txs.map(async (txInfo) => {
301
- await this.refreshTransactionStatus(entryPoint, txInfo);
302
- }));
303
- }
304
- else {
305
- this.logger.warn({ entryPoint }, "no user operations for entry point");
306
- }
307
- }));
308
- }
309
- async handleBlock(block) {
310
- if (this.currentlyHandlingBlock) {
311
- return;
312
- }
313
- this.currentlyHandlingBlock = true;
314
- this.logger.debug({ blockNumber: block.number }, "handling block");
315
- const submittedEntries = this.mempool.dumpSubmittedOps();
316
- if (submittedEntries.length === 0) {
317
- this.stopWatchingBlocks();
318
- this.currentlyHandlingBlock = false;
319
- return;
320
- }
321
- // refresh op statuses
322
- await this.refreshUserOperationStatuses();
323
- // for all still not included check if needs to be replaced (based on gas price)
324
- const gasPriceParameters = await this.gasPriceManager.getGasPrice();
325
- this.logger.trace({ gasPriceParameters }, "fetched gas price parameters");
326
- const transactionInfos = getTransactionsFromUserOperationEntries(this.mempool.dumpSubmittedOps());
327
- await Promise.all(transactionInfos.map(async (txInfo) => {
328
- if (txInfo.transactionRequest.maxFeePerGas >=
329
- gasPriceParameters.maxFeePerGas &&
330
- txInfo.transactionRequest.maxPriorityFeePerGas >=
331
- gasPriceParameters.maxPriorityFeePerGas) {
332
- return;
333
- }
334
- await this.replaceTransaction(txInfo, "gas_price");
335
- }));
336
- // for any left check if enough time has passed, if so replace
337
- const transactionInfos2 = getTransactionsFromUserOperationEntries(this.mempool.dumpSubmittedOps());
338
- await Promise.all(transactionInfos2.map(async (txInfo) => {
339
- if (Date.now() - txInfo.lastReplaced < 5 * 60 * 1000) {
340
- return;
341
- }
342
- await this.replaceTransaction(txInfo, "stuck");
343
- }));
344
- this.currentlyHandlingBlock = false;
345
- }
346
- async replaceTransaction(txInfo, reason) {
347
- let replaceResult = undefined;
348
- try {
349
- replaceResult = await this.executor.replaceTransaction(txInfo);
350
- }
351
- finally {
352
- this.metrics.replacedTransactions
353
- .labels({ reason, status: replaceResult?.status || "failed" })
354
- .inc();
355
- }
356
- if (replaceResult.status === "failed") {
357
- txInfo.userOperationInfos.map((opInfo) => {
358
- this.mempool.removeSubmitted(opInfo.userOperationHash);
359
- });
360
- this.logger.warn({ oldTxHash: txInfo.transactionHash, reason }, "failed to replace transaction");
361
- return;
362
- }
363
- if (replaceResult.status === "potentially_already_included") {
364
- this.logger.info({ oldTxHash: txInfo.transactionHash, reason }, "transaction potentially already included");
365
- txInfo.timesPotentiallyIncluded += 1;
366
- if (txInfo.timesPotentiallyIncluded >= 3) {
367
- txInfo.userOperationInfos.map((opInfo) => {
368
- this.mempool.removeSubmitted(opInfo.userOperationHash);
369
- });
370
- this.executor.markWalletProcessed(txInfo.executor);
371
- this.logger.warn({ oldTxHash: txInfo.transactionHash, reason }, "transaction potentially already included too many times, removing");
372
- }
373
- return;
374
- }
375
- const newTxInfo = replaceResult.transactionInfo;
376
- const missingOps = txInfo.userOperationInfos.filter((info) => !newTxInfo.userOperationInfos
377
- .map((ni) => ni.userOperationHash)
378
- .includes(info.userOperationHash));
379
- const matchingOps = txInfo.userOperationInfos.filter((info) => newTxInfo.userOperationInfos
380
- .map((ni) => ni.userOperationHash)
381
- .includes(info.userOperationHash));
382
- matchingOps.map((opInfo) => {
383
- this.mempool.replaceSubmitted(opInfo, newTxInfo);
384
- });
385
- missingOps.map((opInfo) => {
386
- this.mempool.removeSubmitted(opInfo.userOperationHash);
387
- this.logger.warn({
388
- oldTxHash: txInfo.transactionHash,
389
- newTxHash: newTxInfo.transactionHash,
390
- reason
391
- }, "missing op in new tx");
392
- });
393
- this.logger.info({
394
- oldTxHash: txInfo.transactionHash,
395
- newTxHash: newTxInfo.transactionHash,
396
- reason
397
- }, "replaced transaction");
398
- return;
399
- }
400
- }
401
- //# sourceMappingURL=executorManager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executorManager.js","sourceRoot":"","sources":["../../executor/executorManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAOH,mBAAmB,EACnB,gBAAgB,EAInB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAYjD,SAAS,uCAAuC,CAC5C,OAAiC;IAEjC,OAAO,KAAK,CAAC,IAAI,CACb,IAAI,GAAG,CACH,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAClB,OAAO,KAAK,CAAC,eAAe,CAAA;IAChC,CAAC,CAAC,CACL,CACJ,CAAA;AACL,CAAC;AAED,MAAM,OAAO,eAAe;IAChB,WAAW,CAAW;IACtB,QAAQ,CAAU;IAClB,OAAO,CAAe;IACtB,OAAO,CAAS;IAChB,YAAY,CAAgC;IAC5C,eAAe,CAAQ;IACvB,MAAM,CAAQ;IACd,OAAO,CAAS;IAChB,iBAAiB,CAA4B;IAC7C,OAAO,CAAmC;IAC1C,sBAAsB,GAAG,KAAK,CAAA;IAC9B,KAAK,C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AE,CAC1D,SAAS,CAAC,kBAAkB;aACvB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,iBAAiB,CAAC;aACjC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CACxC,CAAA;QAED,WAAW,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACvB,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;QACpD,CAAC,CAAC,CAAA;QAEF,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAA;YACtD,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ;gBACI,SAAS,EAAE,MAAM,CAAC,eAAe;gBACjC,SAAS,EAAE,SAAS,CAAC,eAAe;gBACpC,MAAM;aACT,EACD,sBAAsB,CACzB,CAAA;QACL,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ;YACI,SAAS,EAAE,MAAM,CAAC,eAAe;YACjC,SAAS,EAAE,SAAS,CAAC,eAAe;YACpC,MAAM;SACT,EACD,sBAAsB,CACzB,CAAA;QAED,OAAM;IACV,CAAC;CACJ"}
@@ -1,5 +0,0 @@
1
- export * from "./senderManager.js";
2
- export * from "./executor.js";
3
- export * from "./executorManager.js";
4
- export * from "./utils.js";
5
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- export * from "./senderManager.js";
2
- export * from "./executor.js";
3
- export * from "./executorManager.js";
4
- export * from "./utils.js";
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../executor/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA"}
@@ -1,17 +0,0 @@
1
- import type { GasPriceManager, Logger, Metrics } from "../utils/index.js";
2
- import { type Account, type Chain, type PublicClient, type Transport, type WalletClient } from "viem";
3
- export declare class SenderManager {
4
- wallets: Account[];
5
- utilityAccount: Account | undefined;
6
- availableWallets: Account[];
7
- private logger;
8
- private metrics;
9
- private legacyTransactions;
10
- private semaphore;
11
- private gasPriceManager;
12
- constructor(wallets: Account[], utilityAccount: Account | undefined, logger: Logger, metrics: Metrics, legacyTransactions: boolean, gasPriceManager: GasPriceManager, maxSigners?: number);
13
- validateAndRefillWallets(publicClient: PublicClient, walletClient: WalletClient<Transport, Chain>, minBalance?: bigint): Promise<void>;
14
- getWallet(): Promise<Account>;
15
- pushWallet(wallet: Account): void;
16
- }
17
- //# sourceMappingURL=senderManager.d.ts.map
@@ -1,160 +0,0 @@
1
- import { CallEngineAbi } from "../types/index.js";
2
- import { Semaphore } from "async-mutex";
3
- import { formatEther, getContract } from "viem";
4
- const waitForTransactionReceipt = async (publicClient, tx) => {
5
- try {
6
- return await publicClient.waitForTransactionReceipt({ hash: tx });
7
- }
8
- catch {
9
- return await waitForTransactionReceipt(publicClient, tx);
10
- }
11
- };
12
- export class SenderManager {
13
- wallets;
14
- utilityAccount;
15
- availableWallets;
16
- logger;
17
- metrics;
18
- legacyTransactions;
19
- semaphore;
20
- gasPriceManager;
21
- constructor(wallets, utilityAccount, logger, metrics, legacyTransactions, gasPriceManager, maxSigners) {
22
- if (maxSigners !== undefined && wallets.length > maxSigners) {
23
- this.wallets = wallets.slice(0, maxSigners);
24
- this.availableWallets = wallets.slice(0, maxSigners);
25
- }
26
- else {
27
- this.wallets = wallets;
28
- this.availableWallets = wallets;
29
- }
30
- this.utilityAccount = utilityAccount;
31
- this.logger = logger;
32
- this.metrics = metrics;
33
- this.legacyTransactions = legacyTransactions;
34
- metrics.walletsAvailable.set(this.availableWallets.length);
35
- metrics.walletsTotal.set(this.wallets.length);
36
- this.semaphore = new Semaphore(this.availableWallets.length);
37
- this.gasPriceManager = gasPriceManager;
38
- }
39
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: <explanation>
40
- async validateAndRefillWallets(publicClient, walletClient, minBalance) {
41
- if (!(minBalance && this.utilityAccount)) {
42
- return;
43
- }
44
- const utilityWalletBalance = await publicClient.getBalance({
45
- address: this.utilityAccount.address
46
- });
47
- const balancesMissing = {};
48
- const balanceRequestPromises = this.availableWallets.map(async (wallet) => {
49
- const balance = await publicClient.getBalance({
50
- address: wallet.address
51
- });
52
- if (balance < minBalance) {
53
- const missingBalance = (minBalance * 6n) / 5n - balance;
54
- balancesMissing[wallet.address] = missingBalance;
55
- }
56
- });
57
- await Promise.all(balanceRequestPromises);
58
- const totalBalanceMissing = Object.values(balancesMissing).reduce((a, b) => a + b, 0n);
59
- if (utilityWalletBalance < (totalBalanceMissing * 11n) / 10n) {
60
- this.logger.info({ balancesMissing, totalBalanceMissing }, "balances missing");
61
- this.logger.error({
62
- minBalance,
63
- utilityWalletBalance,
64
- totalBalanceMissing,
65
- utilityAccount: this.utilityAccount.address
66
- }, "utility wallet has insufficient balance to refill wallets");
67
- throw new Error(`utility wallet ${this.utilityAccount.address} has insufficient balance ${formatEther(utilityWalletBalance)} < ${formatEther(totalBalanceMissing)}`);
68
- }
69
- if (Object.keys(balancesMissing).length > 0) {
70
- const { maxFeePerGas, maxPriorityFeePerGas } = await this.gasPriceManager.getGasPrice();
71
- if (walletClient.chain.id === 59140 ||
72
- walletClient.chain.id === 137 ||
73
- walletClient.chain.id === 10) {
74
- const instructions = [];
75
- for (const [address, missingBalance] of Object.entries(balancesMissing)) {
76
- instructions.push({
77
- to: address,
78
- value: missingBalance,
79
- data: "0x"
80
- });
81
- }
82
- let refillAddress;
83
- if (walletClient.chain.id === 59140) {
84
- refillAddress = "0xEad1aC3DF6F96b91491d6396F4d1610C5638B4Db";
85
- }
86
- else if (walletClient.chain.id === 137) {
87
- refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822";
88
- }
89
- else {
90
- refillAddress = "0x3402DB43152dAB9ab72fa805fdD5f391cD3E3822";
91
- }
92
- const callEngine = getContract({
93
- abi: CallEngineAbi,
94
- address: refillAddress,
95
- client: {
96
- public: publicClient,
97
- wallet: walletClient
98
- }
99
- });
100
- const tx = await callEngine.write.execute([instructions], {
101
- account: this.utilityAccount,
102
- value: totalBalanceMissing,
103
- maxFeePerGas: maxFeePerGas * 2n,
104
- maxPriorityFeePerGas: maxPriorityFeePerGas * 2n
105
- });
106
- await waitForTransactionReceipt(publicClient, tx);
107
- for (const [address, missingBalance] of Object.entries(balancesMissing)) {
108
- this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
109
- }
110
- }
111
- else {
112
- for (const [address, missingBalance] of Object.entries(balancesMissing)) {
113
- const tx = await walletClient.sendTransaction({
114
- account: this.utilityAccount,
115
- // @ts-ignore
116
- to: address,
117
- value: missingBalance,
118
- maxFeePerGas: this.legacyTransactions
119
- ? undefined
120
- : maxFeePerGas,
121
- maxPriorityFeePerGas: this.legacyTransactions
122
- ? undefined
123
- : maxPriorityFeePerGas,
124
- gasPrice: this.legacyTransactions
125
- ? maxFeePerGas
126
- : undefined
127
- });
128
- await waitForTransactionReceipt(publicClient, tx);
129
- this.logger.info({ tx, executor: address, missingBalance }, "refilled wallet");
130
- }
131
- }
132
- }
133
- else {
134
- this.logger.info("no wallets need to be refilled");
135
- }
136
- }
137
- async getWallet() {
138
- this.logger.trace(`waiting for semaphore with count ${this.semaphore.getValue()}`);
139
- await this.semaphore.waitForUnlock();
140
- await this.semaphore.acquire();
141
- const wallet = this.availableWallets.shift();
142
- // should never happen because of semaphore
143
- if (!wallet) {
144
- this.semaphore.release();
145
- this.logger.error("no more wallets");
146
- throw new Error("no more wallets");
147
- }
148
- this.logger.trace({ executor: wallet.address }, "got wallet from sender manager");
149
- this.metrics.walletsAvailable.set(this.availableWallets.length);
150
- return wallet;
151
- }
152
- pushWallet(wallet) {
153
- this.availableWallets.push(wallet);
154
- this.semaphore.release();
155
- this.logger.trace({ executor: wallet.address }, "pushed wallet to sender manager");
156
- this.metrics.walletsAvailable.set(this.availableWallets.length);
157
- return;
158
- }
159
- }
160
- //# sourceMappingURL=senderManager.js.map