@pimlico/alto 0.0.2 → 0.0.3

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 (233) hide show
  1. package/esm/cli/alto.d.ts +6 -0
  2. package/esm/cli/alto.js +92 -0
  3. package/esm/cli/alto.js.map +1 -0
  4. package/esm/cli/config/bundler.d.ts +397 -0
  5. package/esm/cli/config/bundler.js +133 -0
  6. package/esm/cli/config/bundler.js.map +1 -0
  7. package/esm/cli/config/index.d.ts +3 -0
  8. package/esm/cli/config/index.js +3 -0
  9. package/esm/cli/config/index.js.map +1 -0
  10. package/esm/cli/config/options.d.ts +11 -0
  11. package/esm/cli/config/options.js +342 -0
  12. package/esm/cli/config/options.js.map +1 -0
  13. package/esm/cli/customTransport.d.ts +14 -0
  14. package/esm/cli/customTransport.js +53 -0
  15. package/esm/cli/customTransport.js.map +1 -0
  16. package/esm/cli/handler.d.ts +3 -0
  17. package/esm/cli/handler.js +116 -0
  18. package/esm/cli/handler.js.map +1 -0
  19. package/esm/cli/index.d.ts +4 -0
  20. package/esm/cli/index.js +4 -0
  21. package/esm/cli/index.js.map +1 -0
  22. package/esm/cli/instrumentation.d.ts +2 -0
  23. package/esm/cli/instrumentation.js +39 -0
  24. package/esm/cli/instrumentation.js.map +1 -0
  25. package/esm/cli/setupServer.d.ts +17 -0
  26. package/esm/cli/setupServer.js +155 -0
  27. package/esm/cli/setupServer.js.map +1 -0
  28. package/esm/cli/util.d.ts +22 -0
  29. package/esm/cli/util.js +30 -0
  30. package/esm/cli/util.js.map +1 -0
  31. package/esm/executor/executor.d.ts +55 -0
  32. package/esm/executor/executor.js +645 -0
  33. package/esm/executor/executor.js.map +1 -0
  34. package/esm/executor/executorManager.d.ts +34 -0
  35. package/esm/executor/executorManager.js +402 -0
  36. package/esm/executor/executorManager.js.map +1 -0
  37. package/esm/executor/index.d.ts +5 -0
  38. package/esm/executor/index.js +5 -0
  39. package/esm/executor/index.js.map +1 -0
  40. package/esm/executor/senderManager.d.ts +17 -0
  41. package/esm/executor/senderManager.js +160 -0
  42. package/esm/executor/senderManager.js.map +1 -0
  43. package/esm/executor/test/utils.d.ts +13 -0
  44. package/esm/executor/test/utils.js +75 -0
  45. package/esm/executor/test/utils.js.map +1 -0
  46. package/esm/executor/utils.d.ts +32 -0
  47. package/esm/executor/utils.js +241 -0
  48. package/esm/executor/utils.js.map +1 -0
  49. package/esm/index.d.ts +2 -0
  50. package/esm/index.js +2 -0
  51. package/esm/index.js.map +1 -0
  52. package/esm/mempool/index.d.ts +5 -0
  53. package/esm/mempool/index.js +5 -0
  54. package/esm/mempool/index.js.map +1 -0
  55. package/esm/mempool/mempool.d.ts +64 -0
  56. package/esm/mempool/mempool.js +489 -0
  57. package/esm/mempool/mempool.js.map +1 -0
  58. package/esm/mempool/monitoring.d.ts +10 -0
  59. package/esm/mempool/monitoring.js +34 -0
  60. package/esm/mempool/monitoring.js.map +1 -0
  61. package/esm/mempool/nullMempool.d.ts +15 -0
  62. package/esm/mempool/nullMempool.js +36 -0
  63. package/esm/mempool/nullMempool.js.map +1 -0
  64. package/esm/mempool/reputationManager.d.ts +115 -0
  65. package/esm/mempool/reputationManager.js +397 -0
  66. package/esm/mempool/reputationManager.js.map +1 -0
  67. package/esm/mempool/store.d.ts +22 -0
  68. package/esm/mempool/store.js +123 -0
  69. package/esm/mempool/store.js.map +1 -0
  70. package/esm/rpc/EntryPointSimulationsV07.d.ts +58 -0
  71. package/esm/rpc/EntryPointSimulationsV07.js +407 -0
  72. package/esm/rpc/EntryPointSimulationsV07.js.map +1 -0
  73. package/esm/rpc/ExecuteSimulator.d.ts +37 -0
  74. package/esm/rpc/ExecuteSimulator.js +48 -0
  75. package/esm/rpc/ExecuteSimulator.js.map +1 -0
  76. package/esm/rpc/gasEstimation.d.ts +17 -0
  77. package/esm/rpc/gasEstimation.js +410 -0
  78. package/esm/rpc/gasEstimation.js.map +1 -0
  79. package/esm/rpc/index.d.ts +5 -0
  80. package/esm/rpc/index.js +5 -0
  81. package/esm/rpc/index.js.map +1 -0
  82. package/esm/rpc/nonceQueuer.d.ts +25 -0
  83. package/esm/rpc/nonceQueuer.js +135 -0
  84. package/esm/rpc/nonceQueuer.js.map +1 -0
  85. package/esm/rpc/rpcHandler.d.ts +64 -0
  86. package/esm/rpc/rpcHandler.js +727 -0
  87. package/esm/rpc/rpcHandler.js.map +1 -0
  88. package/esm/rpc/server.d.ts +31 -0
  89. package/esm/rpc/server.js +239 -0
  90. package/esm/rpc/server.js.map +1 -0
  91. package/esm/rpc/validation/BundlerCollectorTracerV06.d.ts +102 -0
  92. package/esm/rpc/validation/BundlerCollectorTracerV06.js +255 -0
  93. package/esm/rpc/validation/BundlerCollectorTracerV06.js.map +1 -0
  94. package/esm/rpc/validation/BundlerCollectorTracerV07.d.ts +102 -0
  95. package/esm/rpc/validation/BundlerCollectorTracerV07.js +254 -0
  96. package/esm/rpc/validation/BundlerCollectorTracerV07.js.map +1 -0
  97. package/esm/rpc/validation/SafeValidator.d.ts +35 -0
  98. package/esm/rpc/validation/SafeValidator.js +487 -0
  99. package/esm/rpc/validation/SafeValidator.js.map +1 -0
  100. package/esm/rpc/validation/TracerResultParserV06.d.ts +13 -0
  101. package/esm/rpc/validation/TracerResultParserV06.js +578 -0
  102. package/esm/rpc/validation/TracerResultParserV06.js.map +1 -0
  103. package/esm/rpc/validation/TracerResultParserV07.d.ts +33 -0
  104. package/esm/rpc/validation/TracerResultParserV07.js +557 -0
  105. package/esm/rpc/validation/TracerResultParserV07.js.map +1 -0
  106. package/esm/rpc/validation/UnsafeValidator.d.ts +63 -0
  107. package/esm/rpc/validation/UnsafeValidator.js +257 -0
  108. package/esm/rpc/validation/UnsafeValidator.js.map +1 -0
  109. package/esm/rpc/validation/index.d.ts +3 -0
  110. package/esm/rpc/validation/index.js +3 -0
  111. package/esm/rpc/validation/index.js.map +1 -0
  112. package/esm/rpc/validation/tracer.d.ts +122 -0
  113. package/esm/rpc/validation/tracer.js +82 -0
  114. package/esm/rpc/validation/tracer.js.map +1 -0
  115. package/esm/types/contracts/BundleBulker.d.ts +120 -0
  116. package/esm/types/contracts/BundleBulker.js +157 -0
  117. package/esm/types/contracts/BundleBulker.js.map +1 -0
  118. package/esm/types/contracts/CallEngine.d.ts +28 -0
  119. package/esm/types/contracts/CallEngine.js +37 -0
  120. package/esm/types/contracts/CallEngine.js.map +1 -0
  121. package/esm/types/contracts/CodeHashGetter.d.ts +37 -0
  122. package/esm/types/contracts/CodeHashGetter.js +45 -0
  123. package/esm/types/contracts/CodeHashGetter.js.map +1 -0
  124. package/esm/types/contracts/EntryPoint.d.ts +1789 -0
  125. package/esm/types/contracts/EntryPoint.js +2304 -0
  126. package/esm/types/contracts/EntryPoint.js.map +1 -0
  127. package/esm/types/contracts/EntryPointSimulations.d.ts +153 -0
  128. package/esm/types/contracts/EntryPointSimulations.js +15 -0
  129. package/esm/types/contracts/EntryPointSimulations.js.map +1 -0
  130. package/esm/types/contracts/IOpInflator.d.ts +61 -0
  131. package/esm/types/contracts/IOpInflator.js +80 -0
  132. package/esm/types/contracts/IOpInflator.js.map +1 -0
  133. package/esm/types/contracts/IPaymaster.d.ts +3 -0
  134. package/esm/types/contracts/IPaymaster.js +117 -0
  135. package/esm/types/contracts/IPaymaster.js.map +1 -0
  136. package/esm/types/contracts/Inflator.d.ts +65 -0
  137. package/esm/types/contracts/Inflator.js +84 -0
  138. package/esm/types/contracts/Inflator.js.map +1 -0
  139. package/esm/types/contracts/PerOpInflator.d.ts +176 -0
  140. package/esm/types/contracts/PerOpInflator.js +229 -0
  141. package/esm/types/contracts/PerOpInflator.js.map +1 -0
  142. package/esm/types/contracts/PimlicoEntryPointSimulations.d.ts +23 -0
  143. package/esm/types/contracts/PimlicoEntryPointSimulations.js +33 -0
  144. package/esm/types/contracts/PimlicoEntryPointSimulations.js.map +1 -0
  145. package/esm/types/contracts/SenderCreator.d.ts +4 -0
  146. package/esm/types/contracts/SenderCreator.js +23 -0
  147. package/esm/types/contracts/SenderCreator.js.map +1 -0
  148. package/esm/types/contracts/SimpleAccountFactory.d.ts +57 -0
  149. package/esm/types/contracts/SimpleAccountFactory.js +76 -0
  150. package/esm/types/contracts/SimpleAccountFactory.js.map +1 -0
  151. package/esm/types/contracts/TestOpcodesAccount.d.ts +4 -0
  152. package/esm/types/contracts/TestOpcodesAccount.js +281 -0
  153. package/esm/types/contracts/TestOpcodesAccount.js.map +1 -0
  154. package/esm/types/contracts/TestOpcodesAccountFactory.d.ts +4 -0
  155. package/esm/types/contracts/TestOpcodesAccountFactory.js +23 -0
  156. package/esm/types/contracts/TestOpcodesAccountFactory.js.map +1 -0
  157. package/esm/types/contracts/TestStorageAccount.d.ts +4 -0
  158. package/esm/types/contracts/TestStorageAccount.js +313 -0
  159. package/esm/types/contracts/TestStorageAccount.js.map +1 -0
  160. package/esm/types/contracts/index.d.ts +17 -0
  161. package/esm/types/contracts/index.js +17 -0
  162. package/esm/types/contracts/index.js.map +1 -0
  163. package/esm/types/gasPrice.d.ts +110 -0
  164. package/esm/types/gasPrice.js +52 -0
  165. package/esm/types/gasPrice.js.map +1 -0
  166. package/esm/types/index.d.ts +11 -0
  167. package/esm/types/index.js +11 -0
  168. package/esm/types/index.js.map +1 -0
  169. package/esm/types/interfaces.d.ts +26 -0
  170. package/esm/types/interfaces.js +2 -0
  171. package/esm/types/interfaces.js.map +1 -0
  172. package/esm/types/mempool.d.ts +79 -0
  173. package/esm/types/mempool.js +16 -0
  174. package/esm/types/mempool.js.map +1 -0
  175. package/esm/types/schemas.d.ts +4791 -0
  176. package/esm/types/schemas.js +497 -0
  177. package/esm/types/schemas.js.map +1 -0
  178. package/esm/types/test/validationTestErrors.d.ts +3 -0
  179. package/esm/types/test/validationTestErrors.js +229 -0
  180. package/esm/types/test/validationTestErrors.js.map +1 -0
  181. package/esm/types/utils.d.ts +24 -0
  182. package/esm/types/utils.js +30 -0
  183. package/esm/types/utils.js.map +1 -0
  184. package/esm/types/validation.d.ts +14327 -0
  185. package/esm/types/validation.js +304 -0
  186. package/esm/types/validation.js.map +1 -0
  187. package/esm/utils/bigInt.d.ts +3 -0
  188. package/esm/utils/bigInt.js +9 -0
  189. package/esm/utils/bigInt.js.map +1 -0
  190. package/esm/utils/compressionHandler.d.ts +11 -0
  191. package/esm/utils/compressionHandler.js +39 -0
  192. package/esm/utils/compressionHandler.js.map +1 -0
  193. package/esm/utils/gasPriceManager.d.ts +34 -0
  194. package/esm/utils/gasPriceManager.js +338 -0
  195. package/esm/utils/gasPriceManager.js.map +1 -0
  196. package/esm/utils/helpers.d.ts +4 -0
  197. package/esm/utils/helpers.js +13 -0
  198. package/esm/utils/helpers.js.map +1 -0
  199. package/esm/utils/index.d.ts +11 -0
  200. package/esm/utils/index.js +10 -0
  201. package/esm/utils/index.js.map +1 -0
  202. package/esm/utils/logger.d.ts +6 -0
  203. package/esm/utils/logger.js +76 -0
  204. package/esm/utils/logger.js.map +1 -0
  205. package/esm/utils/metrics.d.ts +22 -0
  206. package/esm/utils/metrics.js +150 -0
  207. package/esm/utils/metrics.js.map +1 -0
  208. package/esm/utils/rpc-reply.d.ts +17 -0
  209. package/esm/utils/rpc-reply.js +41 -0
  210. package/esm/utils/rpc-reply.js.map +1 -0
  211. package/esm/utils/test.d.ts +17 -0
  212. package/esm/utils/test.js +130 -0
  213. package/esm/utils/test.js.map +1 -0
  214. package/esm/utils/userop.d.ts +49 -0
  215. package/esm/utils/userop.js +408 -0
  216. package/esm/utils/userop.js.map +1 -0
  217. package/esm/utils/validation.d.ts +65 -0
  218. package/esm/utils/validation.js +461 -0
  219. package/esm/utils/validation.js.map +1 -0
  220. package/lib/cli/config/bundler.d.ts +6 -0
  221. package/lib/cli/config/bundler.js +2 -1
  222. package/lib/cli/config/bundler.js.map +1 -1
  223. package/lib/cli/config/options.js +6 -0
  224. package/lib/cli/config/options.js.map +1 -1
  225. package/lib/cli/setupServer.js +1 -1
  226. package/lib/cli/setupServer.js.map +1 -1
  227. package/lib/executor/executor.d.ts +2 -1
  228. package/lib/executor/executor.js +6 -4
  229. package/lib/executor/executor.js.map +1 -1
  230. package/lib/executor/utils.d.ts +1 -1
  231. package/lib/executor/utils.js +4 -4
  232. package/lib/executor/utils.js.map +1 -1
  233. package/package.json +1 -1
@@ -0,0 +1,578 @@
1
+ import { EntryPointV06Abi, PaymasterAbi, RpcError, SenderCreatorAbi, ValidationErrors } from "../../types/index.js";
2
+ // This file contains references to validation rules, in the format [xxx-###]
3
+ // where xxx is OP/STO/COD/EP/SREP/EREP/UREP/ALT, and ### is a number
4
+ // the validation rules are defined in erc-aa-validation.md
5
+ import { decodeErrorResult, decodeFunctionResult, getFunctionSelector, hexToBigInt, keccak256, pad } from "viem";
6
+ const abi = [...SenderCreatorAbi, ...EntryPointV06Abi, ...PaymasterAbi];
7
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
8
+ const functionSignatureToMethodName = (hash) => {
9
+ let functionName = undefined;
10
+ for (const item of abi) {
11
+ const signature = getFunctionSelector(item);
12
+ if (signature === hash) {
13
+ functionName = item.name;
14
+ }
15
+ }
16
+ if (functionName === undefined) {
17
+ throw new Error(`Could not find function name for hash ${hash}`);
18
+ }
19
+ return functionName;
20
+ };
21
+ /**
22
+ * parse all call operation in the trace.
23
+ * notes:
24
+ * - entries are ordered by the return (so nested call appears before its outer call
25
+ * - last entry is top-level return from "simulateValidation". it as ret and rettype, but no type or address
26
+ * @param tracerResults
27
+ * @param abi
28
+ */
29
+ function parseCallStack(tracerResults) {
30
+ function callCatch(x, def) {
31
+ try {
32
+ return x();
33
+ }
34
+ catch (_) {
35
+ return def;
36
+ }
37
+ }
38
+ const out = [];
39
+ const stack = [];
40
+ const filteredTracerResultCalls = tracerResults.calls.filter((x) => !x.type.startsWith("depth"));
41
+ for (const c of filteredTracerResultCalls) {
42
+ if (c.type.match(/REVERT|RETURN/) !== null) {
43
+ const top = stack.splice(-1)[0] ?? {
44
+ type: "top",
45
+ method: "validateUserOp"
46
+ };
47
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
48
+ const returnData = c.data;
49
+ if (top.type.match(/CREATE/) !== null) {
50
+ out.push({
51
+ to: top.to,
52
+ from: top.from,
53
+ type: top.type,
54
+ method: "",
55
+ return: `len=${returnData.length}`
56
+ });
57
+ }
58
+ else {
59
+ const method = callCatch(() => functionSignatureToMethodName(top.method), top.method);
60
+ if (c.type === "REVERT") {
61
+ const parsedError = callCatch(() => decodeErrorResult({ abi: abi, data: returnData }), returnData);
62
+ out.push({
63
+ to: top.to,
64
+ from: top.from,
65
+ type: top.type,
66
+ method: method,
67
+ value: top.value,
68
+ revert: parsedError
69
+ });
70
+ }
71
+ else {
72
+ const ret = callCatch(() => decodeFunctionResult({
73
+ abi: abi,
74
+ functionName: method,
75
+ data: returnData
76
+ }), returnData);
77
+ out.push({
78
+ to: top.to,
79
+ from: top.from,
80
+ type: top.type,
81
+ value: top.value,
82
+ method: method,
83
+ return: ret
84
+ });
85
+ }
86
+ }
87
+ }
88
+ else {
89
+ stack.push(c);
90
+ }
91
+ }
92
+ // TODO: verify that stack is empty at the end.
93
+ return out;
94
+ }
95
+ /**
96
+ * slots associated with each entity.
97
+ * keccak( A || ...) is associated with "A"
98
+ * removed rule: keccak( ... || ASSOC ) (for a previously associated hash) is also associated with "A"
99
+ *
100
+ * @param stakeInfoEntities stake info for (factory, account, paymaster). factory and paymaster can be null.
101
+ * @param keccak array of buffers that were given to keccak in the transaction
102
+ */
103
+ function parseEntitySlots(stakeInfoEntities, keccak) {
104
+ // for each entity (sender, factory, paymaster), hold the valid slot addresses
105
+ // valid: the slot was generated by keccak(entity || ...)
106
+ const entitySlots = {};
107
+ for (const k of keccak) {
108
+ const values = Object.values(stakeInfoEntities);
109
+ for (const info of values) {
110
+ const addr = info?.addr?.toLowerCase();
111
+ if (!addr) {
112
+ continue;
113
+ }
114
+ const addrPadded = pad(addr).toLowerCase();
115
+ if (!entitySlots[addr]) {
116
+ entitySlots[addr] = new Set();
117
+ }
118
+ const currentEntitySlots = entitySlots[addr];
119
+ // valid slot: the slot was generated by keccak(entityAddr || ...)
120
+ if (k.startsWith(addrPadded)) {
121
+ currentEntitySlots.add(keccak256(k));
122
+ }
123
+ // disabled 2nd rule: .. or by keccak( ... || OWN) where OWN is previous allowed slot
124
+ // if (k.length === 130 && currentEntitySlots.has(k.slice(-64))) {
125
+ // currentEntitySlots.add(value)
126
+ // }
127
+ }
128
+ }
129
+ return entitySlots;
130
+ }
131
+ // method-signature for calls from entryPoint
132
+ const callsFromEntryPointMethodSigs = {
133
+ factory: getFunctionSelector({
134
+ inputs: [
135
+ {
136
+ internalType: "bytes",
137
+ name: "initCode",
138
+ type: "bytes"
139
+ }
140
+ ],
141
+ name: "createSender",
142
+ outputs: [
143
+ {
144
+ internalType: "address",
145
+ name: "sender",
146
+ type: "address"
147
+ }
148
+ ],
149
+ stateMutability: "nonpayable",
150
+ type: "function"
151
+ }),
152
+ account: getFunctionSelector({
153
+ inputs: [
154
+ {
155
+ components: [
156
+ {
157
+ internalType: "address",
158
+ name: "sender",
159
+ type: "address"
160
+ },
161
+ {
162
+ internalType: "uint256",
163
+ name: "nonce",
164
+ type: "uint256"
165
+ },
166
+ {
167
+ internalType: "bytes",
168
+ name: "initCode",
169
+ type: "bytes"
170
+ },
171
+ {
172
+ internalType: "bytes",
173
+ name: "callData",
174
+ type: "bytes"
175
+ },
176
+ {
177
+ internalType: "uint256",
178
+ name: "callGasLimit",
179
+ type: "uint256"
180
+ },
181
+ {
182
+ internalType: "uint256",
183
+ name: "verificationGasLimit",
184
+ type: "uint256"
185
+ },
186
+ {
187
+ internalType: "uint256",
188
+ name: "preVerificationGas",
189
+ type: "uint256"
190
+ },
191
+ {
192
+ internalType: "uint256",
193
+ name: "maxFeePerGas",
194
+ type: "uint256"
195
+ },
196
+ {
197
+ internalType: "uint256",
198
+ name: "maxPriorityFeePerGas",
199
+ type: "uint256"
200
+ },
201
+ {
202
+ internalType: "bytes",
203
+ name: "paymasterAndData",
204
+ type: "bytes"
205
+ },
206
+ {
207
+ internalType: "bytes",
208
+ name: "signature",
209
+ type: "bytes"
210
+ }
211
+ ],
212
+ internalType: "struct UserOperation",
213
+ name: "userOp",
214
+ type: "tuple"
215
+ },
216
+ {
217
+ internalType: "bytes32",
218
+ name: "",
219
+ type: "bytes32"
220
+ },
221
+ {
222
+ internalType: "uint256",
223
+ name: "missingAccountFunds",
224
+ type: "uint256"
225
+ }
226
+ ],
227
+ name: "validateUserOp",
228
+ outputs: [
229
+ {
230
+ internalType: "uint256",
231
+ name: "",
232
+ type: "uint256"
233
+ }
234
+ ],
235
+ stateMutability: "nonpayable",
236
+ type: "function"
237
+ }),
238
+ paymaster: getFunctionSelector({
239
+ inputs: [
240
+ {
241
+ components: [
242
+ {
243
+ internalType: "address",
244
+ name: "sender",
245
+ type: "address"
246
+ },
247
+ {
248
+ internalType: "uint256",
249
+ name: "nonce",
250
+ type: "uint256"
251
+ },
252
+ {
253
+ internalType: "bytes",
254
+ name: "initCode",
255
+ type: "bytes"
256
+ },
257
+ {
258
+ internalType: "bytes",
259
+ name: "callData",
260
+ type: "bytes"
261
+ },
262
+ {
263
+ internalType: "uint256",
264
+ name: "callGasLimit",
265
+ type: "uint256"
266
+ },
267
+ {
268
+ internalType: "uint256",
269
+ name: "verificationGasLimit",
270
+ type: "uint256"
271
+ },
272
+ {
273
+ internalType: "uint256",
274
+ name: "preVerificationGas",
275
+ type: "uint256"
276
+ },
277
+ {
278
+ internalType: "uint256",
279
+ name: "maxFeePerGas",
280
+ type: "uint256"
281
+ },
282
+ {
283
+ internalType: "uint256",
284
+ name: "maxPriorityFeePerGas",
285
+ type: "uint256"
286
+ },
287
+ {
288
+ internalType: "bytes",
289
+ name: "paymasterAndData",
290
+ type: "bytes"
291
+ },
292
+ {
293
+ internalType: "bytes",
294
+ name: "signature",
295
+ type: "bytes"
296
+ }
297
+ ],
298
+ internalType: "struct UserOperation",
299
+ name: "userOp",
300
+ type: "tuple"
301
+ },
302
+ {
303
+ internalType: "bytes32",
304
+ name: "userOpHash",
305
+ type: "bytes32"
306
+ },
307
+ {
308
+ internalType: "uint256",
309
+ name: "maxCost",
310
+ type: "uint256"
311
+ }
312
+ ],
313
+ name: "validatePaymasterUserOp",
314
+ outputs: [
315
+ {
316
+ internalType: "bytes",
317
+ name: "context",
318
+ type: "bytes"
319
+ },
320
+ {
321
+ internalType: "uint256",
322
+ name: "validationData",
323
+ type: "uint256"
324
+ }
325
+ ],
326
+ stateMutability: "nonpayable",
327
+ type: "function"
328
+ })
329
+ };
330
+ /**
331
+ * parse collected simulation traces and revert if they break our rules
332
+ * @param userOperation the userOperation that was used in this simulation
333
+ * @param tracerResults the tracer return value
334
+ * @param validationResult output from simulateValidation
335
+ * @param entryPoint the entryPoint that hosted the "simulatedValidation" traced call.
336
+ * @return list of contract addresses referenced by this UserOp
337
+ */
338
+ export function tracerResultParserV06(userOperation, tracerResults, validationResult, entryPointAddress) {
339
+ // todo: block access to no-code addresses (might need update to tracer)
340
+ // opcodes from [OP-011]
341
+ const bannedOpCodes = new Set([
342
+ "GASPRICE",
343
+ "GASLIMIT",
344
+ "DIFFICULTY",
345
+ "TIMESTAMP",
346
+ "BASEFEE",
347
+ "BLOCKHASH",
348
+ "NUMBER",
349
+ "SELFBALANCE",
350
+ "BALANCE",
351
+ "ORIGIN",
352
+ "GAS",
353
+ "CREATE",
354
+ "COINBASE",
355
+ "SELFDESTRUCT",
356
+ "RANDOM",
357
+ "PREVRANDAO",
358
+ "INVALID"
359
+ ]);
360
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
361
+ if (Object.values(tracerResults.callsFromEntryPoint).length < 1) {
362
+ throw new Error("Unexpected traceCall result: no calls from entrypoint.");
363
+ }
364
+ const callStack = parseCallStack(tracerResults);
365
+ // [OP-052], [OP-053]
366
+ const callInfoEntryPoint = callStack.find((call) => call.to === entryPointAddress &&
367
+ call.from !== entryPointAddress &&
368
+ call.method !== "0x" &&
369
+ call.method !== "depositTo");
370
+ // [OP-054]
371
+ if (callInfoEntryPoint) {
372
+ throw new RpcError(`illegal call into EntryPoint during validation ${callInfoEntryPoint?.method}`, ValidationErrors.OpcodeValidation);
373
+ }
374
+ // [OP-061]
375
+ const illegalNonZeroValueCall = callStack.find((call) => call.to !== entryPointAddress &&
376
+ hexToBigInt(call.value ?? "0x0") !== 0n);
377
+ if (illegalNonZeroValueCall) {
378
+ throw new RpcError("May not may CALL with value", ValidationErrors.OpcodeValidation);
379
+ }
380
+ const sender = userOperation.sender.toLowerCase();
381
+ // stake info per "number" level (factory, sender, paymaster)
382
+ // we only use stake info if we notice a memory reference that require stake
383
+ const stakeInfoEntities = {
384
+ factory: validationResult.factoryInfo,
385
+ account: validationResult.senderInfo,
386
+ paymaster: validationResult.paymasterInfo
387
+ };
388
+ const entitySlots = parseEntitySlots(stakeInfoEntities, tracerResults.keccak);
389
+ for (const [title, entStakes] of Object.entries(stakeInfoEntities)) {
390
+ const entityTitle = title;
391
+ const entityAddr = (entStakes?.addr ?? "").toLowerCase();
392
+ const currentNumLevel = tracerResults.callsFromEntryPoint.find((info) => info.topLevelMethodSig ===
393
+ callsFromEntryPointMethodSigs[entityTitle]);
394
+ if (!currentNumLevel) {
395
+ if (entityTitle === "account") {
396
+ // should never happen... only factory, paymaster are optional.
397
+ throw new Error("missing trace into validateUserOp");
398
+ }
399
+ continue;
400
+ }
401
+ const opcodes = currentNumLevel.opcodes;
402
+ const access = currentNumLevel.access;
403
+ // [OP-020]
404
+ if (currentNumLevel.oog ?? false) {
405
+ throw new RpcError(`${entityTitle} internally reverts on oog`, ValidationErrors.OpcodeValidation);
406
+ }
407
+ // opcodes from [OP-011]
408
+ for (const opcode of Object.keys(opcodes)) {
409
+ if (bannedOpCodes.has(opcode)) {
410
+ throw new RpcError(`${entityTitle} uses banned opcode: ${opcode}`, ValidationErrors.OpcodeValidation);
411
+ }
412
+ }
413
+ // [OP-031]
414
+ if (entityTitle === "factory") {
415
+ if ((opcodes.CREATE2 ?? 0) > 1) {
416
+ throw new RpcError(`${entityTitle} with too many CREATE2`, ValidationErrors.OpcodeValidation);
417
+ }
418
+ }
419
+ else if (opcodes.CREATE2) {
420
+ throw new RpcError(`${entityTitle} uses banned opcode: CREATE2`, ValidationErrors.OpcodeValidation);
421
+ }
422
+ for (const [addr, { reads, writes }] of Object.entries(access)) {
423
+ // testing read/write access on contract "addr"
424
+ if (addr === sender) {
425
+ // allowed to access sender's storage
426
+ // [STO-010]
427
+ continue;
428
+ }
429
+ if (addr === entryPointAddress) {
430
+ // ignore storage access on entryPoint (balance/deposit of entities.
431
+ // we block them on method calls: only allowed to deposit, never to read
432
+ continue;
433
+ }
434
+ // return true if the given slot is associated with the given address, given the known keccak operations:
435
+ // @param slot the SLOAD/SSTORE slot address we're testing
436
+ // @param addr - the address we try to check for association with
437
+ // @param reverseKeccak - a mapping we built for keccak values that contained the address
438
+ function associatedWith(slot, addr, entitySlots) {
439
+ const addrPadded = pad(addr, {
440
+ size: 32
441
+ }).toLowerCase();
442
+ if (slot.toLowerCase() === addrPadded) {
443
+ return true;
444
+ }
445
+ const k = entitySlots[addr];
446
+ if (!k) {
447
+ return false;
448
+ }
449
+ const slotN = hexToBigInt(slot);
450
+ // scan all slot entries to check of the given slot is within a structure, starting at that offset.
451
+ // assume a maximum size on a (static) structure size.
452
+ for (const k1 of k.keys()) {
453
+ const kn = hexToBigInt(k1);
454
+ if (slotN >= kn && slotN < kn + 128n) {
455
+ return true;
456
+ }
457
+ }
458
+ return false;
459
+ }
460
+ // scan all slots. find a referenced slot
461
+ // at the end of the scan, we will check if the entity has stake, and report that slot if not.
462
+ let requireStakeSlot;
463
+ const slots = [...Object.keys(writes), ...Object.keys(reads)];
464
+ for (const slot of slots) {
465
+ // slot associated with sender is allowed (e.g. token.balanceOf(sender)
466
+ // but during initial UserOp (where there is an initCode), it is allowed only for staked entity
467
+ if (associatedWith(slot, sender, entitySlots)) {
468
+ if (userOperation.initCode.length > 2) {
469
+ // special case: account.validateUserOp is allowed to use assoc storage if factory is staked.
470
+ // [STO-022], [STO-021]
471
+ if (!(entityAddr === sender &&
472
+ isStaked(stakeInfoEntities.factory))) {
473
+ requireStakeSlot = slot;
474
+ }
475
+ }
476
+ }
477
+ else if (associatedWith(slot, entityAddr, entitySlots)) {
478
+ // [STO-032]
479
+ // accessing a slot associated with entityAddr (e.g. token.balanceOf(paymaster)
480
+ requireStakeSlot = slot;
481
+ }
482
+ else if (addr === entityAddr) {
483
+ // [STO-031]
484
+ // accessing storage member of entity itself requires stake.
485
+ requireStakeSlot = slot;
486
+ }
487
+ else if (writes[slot] === undefined) {
488
+ // [STO-033]: staked entity have read-only access to any storage in non-entity contract.
489
+ requireStakeSlot = slot;
490
+ }
491
+ else {
492
+ // accessing arbitrary storage of another contract is not allowed
493
+ const readWrite = Object.keys(writes).includes(addr)
494
+ ? "write to"
495
+ : "read from";
496
+ const message = `${entityTitle} has forbidden ${readWrite} ${nameAddr(addr, entityTitle)} slot ${slot}`;
497
+ throw new RpcError(message, ValidationErrors.OpcodeValidation, {
498
+ [entityTitle]: entStakes?.addr
499
+ });
500
+ }
501
+ }
502
+ // if addr is current account/paymaster/factory, then return that title
503
+ // otherwise, return addr as-is
504
+ function nameAddr(addr, currentEntity) {
505
+ const [title] = Object.entries(stakeInfoEntities).find(([title, info]) => info?.addr?.toLowerCase() === addr.toLowerCase()) ?? [];
506
+ return title ?? addr;
507
+ }
508
+ requireCondAndStake(requireStakeSlot !== undefined, entStakes, `unstaked ${entityTitle} accessed ${nameAddr(addr, entityTitle)} slot ${requireStakeSlot}`);
509
+ }
510
+ // [EREP-050]
511
+ if (entityTitle === "paymaster") {
512
+ const validatePaymasterUserOp = callStack.find((call) => call.method === "validatePaymasterUserOp" &&
513
+ call.to === entityAddr);
514
+ const context = validatePaymasterUserOp?.return
515
+ ? validatePaymasterUserOp?.return[0]
516
+ : undefined;
517
+ requireCondAndStake(context && context !== "0x", entStakes, "unstaked paymaster must not return context");
518
+ }
519
+ // check if the given entity is staked
520
+ function isStaked(entStake) {
521
+ return Boolean(entStake &&
522
+ 1n <= entStake.stake &&
523
+ 1n <= entStake.unstakeDelaySec);
524
+ }
525
+ // helper method: if condition is true, then entity must be staked.
526
+ function requireCondAndStake(cond, entStake, failureMessage) {
527
+ if (!cond) {
528
+ return;
529
+ }
530
+ if (!entStake) {
531
+ throw new Error(`internal: ${entityTitle} not in userOp, but has storage accesses in ${JSON.stringify(access)}`);
532
+ }
533
+ if (!isStaked(entStake)) {
534
+ throw new RpcError(failureMessage, ValidationErrors.OpcodeValidation, {
535
+ [entityTitle]: entStakes?.addr
536
+ });
537
+ }
538
+ // TODO: check real minimum stake values
539
+ }
540
+ // the only contract we allow to access before its deployment is the "sender" itself, which gets created.
541
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
542
+ let illegalZeroCodeAccess;
543
+ for (const addr of Object.keys(currentNumLevel.contractSize)) {
544
+ // [OP-042]
545
+ if (addr !== sender &&
546
+ currentNumLevel.contractSize[addr].contractSize <= 2) {
547
+ illegalZeroCodeAccess = currentNumLevel.contractSize[addr];
548
+ illegalZeroCodeAccess.address = addr;
549
+ break;
550
+ }
551
+ }
552
+ // [OP-041]
553
+ if (illegalZeroCodeAccess) {
554
+ throw new RpcError(`${entityTitle} accesses un-deployed contract address ${illegalZeroCodeAccess?.address} with opcode ${illegalZeroCodeAccess?.opcode}`, ValidationErrors.OpcodeValidation);
555
+ }
556
+ let illegalEntryPointCodeAccess = undefined;
557
+ for (const addr of Object.keys(currentNumLevel.extCodeAccessInfo)) {
558
+ if (addr === entryPointAddress) {
559
+ illegalEntryPointCodeAccess =
560
+ currentNumLevel.extCodeAccessInfo[addr];
561
+ break;
562
+ }
563
+ }
564
+ if (illegalEntryPointCodeAccess) {
565
+ throw new RpcError(`${entityTitle} accesses EntryPoint contract address ${entryPointAddress} with opcode ${illegalEntryPointCodeAccess}`, ValidationErrors.OpcodeValidation);
566
+ }
567
+ }
568
+ // return list of contract addresses by this UserOp. already known not to contain zero-sized addresses.
569
+ const addresses = tracerResults.callsFromEntryPoint.flatMap((level) => Object.keys(level.contractSize));
570
+ const storageMap = {};
571
+ for (const level of tracerResults.callsFromEntryPoint) {
572
+ for (const addr of Object.keys(level.access)) {
573
+ storageMap[addr] = storageMap[addr] ?? level.access[addr].reads;
574
+ }
575
+ }
576
+ return [addresses, storageMap];
577
+ }
578
+ //# sourceMappingURL=TracerResultParserV06.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TracerResultParserV06.js","sourceRoot":"","sources":["../../../rpc/validation/TracerResultParserV06.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAGhB,gBAAgB,EAGnB,MAAM,aAAa,CAAA;AAEpB,6EAA6E;AAC7E,qEAAqE;AACrE,2DAA2D;AAC3D,OAAO,EAGH,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,GAAG,EACN,MAAM,MAAM,CAAA;AAqBb,MAAM,GAAG,GAAG,CAAC,GAAG,gBAAgB,EAAE,GAAG,gBAAgB,EAAE,GAAG,YAAY,CAAQ,CAAA;AAE9E,kEAAkE;AAClE,MAAM,6BAA6B,GAAG,CAAC,IAAS,EAAE,EAAE;IAChD,IAAI,YAAY,GAAuB,SAAS,CAAA;IAChD,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,SAAS,GAAG,mBAAmB,CAAC,IAAmB,CAAC,CAAA;QAC1D,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACrB,YAAY,GAAI,IAAoB,CAAC,IAAI,CAAA;QAC7C,CAAC;IACL,CAAC;IAED,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,EAAE,CAAC,CAAA;IACpE,CAAC;IAED,OAAO,YAAY,CAAA;AACvB,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,aAAkC;IACtD,SAAS,S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EAAE,EACzD,gBAAgB,CAAC,gBAAgB,CACpC,CAAA;QACL,CAAC;QAED,IAAI,2BAA2B,GAAuB,SAAS,CAAA;QAC/D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAChE,IAAI,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBAC7B,2BAA2B;oBACvB,eAAe,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAA;gBAC3C,MAAK;YACT,CAAC;QACL,CAAC;QAED,IAAI,2BAA2B,EAAE,CAAC;YAC9B,MAAM,IAAI,QAAQ,CACd,GAAG,WAAW,yCAAyC,iBAAiB,gBAAgB,2BAA2B,EAAE,EACrH,gBAAgB,CAAC,gBAAgB,CACpC,CAAA;QACL,CAAC;IACL,CAAC;IAED,uGAAuG;IACvG,MAAM,SAAS,GAAG,aAAa,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAClE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAClC,CAAA;IACD,MAAM,UAAU,GAAe,EAAE,CAAA;IACjC,KAAK,MAAM,KAAK,IAAI,aAAa,CAAC,mBAAmB,EAAE,CAAC;QACpD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAC3C,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAA;QACnE,CAAC;IACL,CAAC;IACD,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;AAClC,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { type Address, type Hex } from "viem";
2
+ import type { BundlerTracerResult } from "./BundlerCollectorTracerV07.js";
3
+ import { type UserOperationV07, type StakeInfo, type ValidationResultV07, type StorageMap } from "../../types/index.js";
4
+ export type StakeInfoEntities = {
5
+ factory?: StakeInfo;
6
+ account?: StakeInfo;
7
+ paymaster?: StakeInfo;
8
+ };
9
+ export declare function isStaked(entStake?: StakeInfo): boolean;
10
+ export declare function associatedWith(slot: string, addr: string, entitySlots: {
11
+ [addr: string]: Set<string>;
12
+ }): boolean;
13
+ /**
14
+ * slots associated with each entity.
15
+ * keccak( A || ...) is associated with "A"
16
+ * removed rule: keccak( ... || ASSOC ) (for a previously associated hash) is also associated with "A"
17
+ *
18
+ * @param stakeInfoEntities stake info for (factory, account, paymaster). factory and paymaster can be null.
19
+ * @param keccak array of buffers that were given to keccak in the transaction
20
+ */
21
+ export declare function parseEntitySlots(stakeInfoEntities: StakeInfoEntities, keccak: Hex[]): {
22
+ [addr: string]: Set<string>;
23
+ };
24
+ /**
25
+ * parse collected simulation traces and revert if they break our rules
26
+ * @param userOperation the userOperation that was used in this simulation
27
+ * @param tracerResults the tracer return value
28
+ * @param validationResult output from simulateValidation
29
+ * @param entryPoint the entryPoint that hosted the "simulatedValidation" traced call.
30
+ * @return list of contract addresses referenced by this UserOp
31
+ */
32
+ export declare function tracerResultParserV07(userOperation: UserOperationV07, tracerResults: BundlerTracerResult, validationResult: ValidationResultV07, entryPointAddress: Address): [string[], StorageMap];
33
+ //# sourceMappingURL=TracerResultParserV07.d.ts.map