@pimlico/alto 0.0.0-staging.20240606T101741 → 0.0.0-staging.20240606T102147

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