@pimlico/alto 0.0.0-staging.20240606T101054 → 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 -2
@@ -0,0 +1,255 @@
1
+ // javascript code of tracer function
2
+ // NOTE: we process this locally for hardhat, but send to geth for remote tracing.
3
+ // should NOT "require" anything, or use logs.
4
+ // see LogTrace for valid types (but alas, this one must be javascript, not typescript).
5
+ /**
6
+ * tracer to collect data for opcode banning.
7
+ * this method is passed as the "tracer" for eth_traceCall (note, the function itself)
8
+ *
9
+ * returned data:
10
+ * numberLevels: opcodes and memory access, split on execution of "number" opcode.
11
+ * keccak: input data of keccak opcode.
12
+ * calls: for each call, an array of [type, from, to, value]
13
+ * slots: accessed slots (on any address)
14
+ */
15
+ export function bundlerCollectorTracer() {
16
+ return {
17
+ callsFromEntryPoint: [],
18
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
19
+ currentLevel: null,
20
+ keccak: [],
21
+ calls: [],
22
+ logs: [],
23
+ debug: [],
24
+ lastOp: "",
25
+ lastThreeOpcodes: [],
26
+ // event sent after all validations are done: keccak("BeforeExecution()")
27
+ stopCollectingTopic: "bb47ee3e183a558b1a2ff0874b079f3fc5478b7454eacf2bfc5af2ff5878f972",
28
+ stopCollecting: false,
29
+ topLevelCallCounter: 0,
30
+ fault(log, _db) {
31
+ this.debug.push(JSON.stringify({
32
+ type: "fault",
33
+ depth: log.getDepth(),
34
+ gas: log.getGas(),
35
+ cost: log.getCost(),
36
+ err: log.getError()
37
+ }));
38
+ },
39
+ result(_ctx, _db) {
40
+ return {
41
+ callsFromEntryPoint: this.callsFromEntryPoint,
42
+ keccak: this.keccak,
43
+ logs: this.logs,
44
+ calls: this.calls,
45
+ debug: this.debug // for internal debugging.
46
+ };
47
+ },
48
+ enter(frame) {
49
+ if (this.stopCollecting) {
50
+ return;
51
+ }
52
+ this.calls.push({
53
+ type: frame.getType(),
54
+ from: toHex(frame.getFrom()),
55
+ to: toHex(frame.getTo()),
56
+ method: toHex(frame.getInput()).slice(0, 10),
57
+ gas: frame.getGas(),
58
+ value: frame.getValue()
59
+ });
60
+ },
61
+ exit(frame) {
62
+ if (this.stopCollecting) {
63
+ return;
64
+ }
65
+ this.calls.push({
66
+ type: frame.getError() != null ? "REVERT" : "RETURN",
67
+ gasUsed: frame.getGasUsed(),
68
+ data: toHex(frame.getOutput()).slice(0, 4000)
69
+ });
70
+ },
71
+ // increment the "key" in the list. if the key is not defined yet, then set it to "1"
72
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
73
+ countSlot(list, key) {
74
+ if (list[key]) {
75
+ // @ts-ignore
76
+ list[key] += 1;
77
+ }
78
+ else {
79
+ list[key] = 1;
80
+ }
81
+ },
82
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
83
+ step(log, db) {
84
+ if (this.stopCollecting) {
85
+ return;
86
+ }
87
+ const opcode = log.op.toString();
88
+ const stackSize = log.stack.length();
89
+ const stackTop3 = [];
90
+ for (let i = 0; i < 3 && i < stackSize; i++) {
91
+ stackTop3.push(log.stack.peek(i));
92
+ }
93
+ this.lastThreeOpcodes.push({ opcode, stackTop3 });
94
+ if (this.lastThreeOpcodes.length > 3) {
95
+ this.lastThreeOpcodes.shift();
96
+ }
97
+ if (log.getGas() < log.getCost() ||
98
+ // special rule for SSTORE with gas metering
99
+ (opcode === "SSTORE" && log.getGas() < 2300)) {
100
+ this.currentLevel.oog = true;
101
+ }
102
+ if (opcode === "REVERT" || opcode === "RETURN") {
103
+ if (log.getDepth() === 1) {
104
+ // exit() is not called on top-level return/revent, so we reconstruct it
105
+ // from opcode
106
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
107
+ const len = Number.parseInt(log.stack.peek(1).toString());
108
+ const data = toHex(log.memory.slice(ofs, ofs + len)).slice(0, 4000);
109
+ // this.debug.push(opcode + ' ' + data)
110
+ this.calls.push({
111
+ type: opcode,
112
+ gasUsed: 0,
113
+ data
114
+ });
115
+ }
116
+ // NOTE: flushing all history after RETURN
117
+ this.lastThreeOpcodes = [];
118
+ }
119
+ if (log.getDepth() === 1) {
120
+ if (opcode === "CALL" || opcode === "STATICCALL") {
121
+ // stack.peek(0) - gas
122
+ const addr = toAddress(log.stack.peek(1).toString(16));
123
+ const topLevelTargetAddress = toHex(addr);
124
+ // stack.peek(2) - value
125
+ const ofs = Number.parseInt(log.stack.peek(3).toString());
126
+ // stack.peek(4) - len
127
+ const topLevelMethodSig = toHex(log.memory.slice(ofs, ofs + 4));
128
+ this.currentLevel = this.callsFromEntryPoint[this.topLevelCallCounter] = {
129
+ topLevelMethodSig,
130
+ topLevelTargetAddress,
131
+ access: {},
132
+ opcodes: {},
133
+ extCodeAccessInfo: {},
134
+ contractSize: {}
135
+ };
136
+ this.topLevelCallCounter++;
137
+ }
138
+ else if (opcode === "LOG1") {
139
+ // ignore log data ofs, len
140
+ const topic = log.stack.peek(2).toString(16);
141
+ if (topic === this.stopCollectingTopic) {
142
+ this.stopCollecting = true;
143
+ }
144
+ }
145
+ this.lastOp = "";
146
+ return;
147
+ }
148
+ const lastOpInfo = this.lastThreeOpcodes[this.lastThreeOpcodes.length - 2];
149
+ // store all addresses touched by EXTCODE* opcodes
150
+ if (lastOpInfo &&
151
+ lastOpInfo.opcode &&
152
+ lastOpInfo.opcode.match(/^(EXT.*)$/) != null) {
153
+ const addr = toAddress(lastOpInfo.stackTop3[0].toString(16));
154
+ const addrHex = toHex(addr);
155
+ // [OP-051]
156
+ if (!(this.lastThreeOpcodes[0].opcode.match(/\w+/) !== null &&
157
+ this.lastThreeOpcodes[1].opcode === "EXTCODESIZE" &&
158
+ this.lastThreeOpcodes[2].opcode === "ISZERO")) {
159
+ this.currentLevel.extCodeAccessInfo[addrHex] = opcode;
160
+ }
161
+ // this.debug.push({
162
+ // last3opcodes: JSON.stringify(this.lastThreeOpcodes.map(x => x.opcode)),
163
+ // extCodeAccessInfo: this.currentLevel.extCodeAccessInfo
164
+ // })
165
+ }
166
+ // not using 'isPrecompiled' to only allow the ones defined by the ERC-4337 as stateless precompiles
167
+ // [OP-062]
168
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
169
+ const isAllowedPrecompiled = (address) => {
170
+ const addrHex = toHex(address);
171
+ const addressInt = Number.parseInt(addrHex);
172
+ // this.debug.push(`isPrecompiled address=${addrHex} addressInt=${addressInt}`)
173
+ return addressInt > 0 && addressInt < 10;
174
+ };
175
+ // [OP-041]
176
+ if (opcode.match(/^(EXT.*|CALL|CALLCODE|DELEGATECALL|STATICCALL)$/) != null) {
177
+ const idx = opcode.startsWith("EXT") ? 0 : 1;
178
+ const addr = toAddress(log.stack.peek(idx).toString(16));
179
+ const addrHex = toHex(addr);
180
+ // this.debug.push('op=' + opcode + ' last=' + this.lastOp + ' stacksize=' + log.stack.length() + ' addr=' + addrHex)
181
+ if (this.currentLevel.contractSize[addrHex] == null &&
182
+ !isAllowedPrecompiled(addr)) {
183
+ this.currentLevel.contractSize[addrHex] = {
184
+ contractSize: db.getCode(addr).length,
185
+ opcode
186
+ };
187
+ }
188
+ }
189
+ // [OP-012]
190
+ if (this.lastOp === "GAS" && !opcode.includes("CALL")) {
191
+ // count "GAS" opcode only if not followed by "CALL"
192
+ this.countSlot(this.currentLevel.opcodes, "GAS");
193
+ }
194
+ if (opcode !== "GAS") {
195
+ // ignore "unimportant" opcodes:
196
+ if (opcode.match(/^(DUP\d+|PUSH\d+|SWAP\d+|POP|ADD|SUB|MUL|DIV|EQ|LTE?|S?GTE?|SLT|SH[LR]|AND|OR|NOT|ISZERO)$/) == null) {
197
+ this.countSlot(this.currentLevel.opcodes, opcode);
198
+ }
199
+ }
200
+ this.lastOp = opcode;
201
+ if (opcode === "SLOAD" || opcode === "SSTORE") {
202
+ const slot = toWord(log.stack.peek(0).toString(16));
203
+ const slotHex = toHex(slot);
204
+ const addr = log.contract.getAddress();
205
+ const addrHex = toHex(addr);
206
+ let access = this.currentLevel.access[addrHex];
207
+ if (access == null) {
208
+ access = {
209
+ reads: {},
210
+ writes: {}
211
+ };
212
+ this.currentLevel.access[addrHex] = access;
213
+ }
214
+ if (opcode === "SLOAD") {
215
+ // read slot values before this UserOp was created
216
+ // (so saving it if it was written before the first read)
217
+ if (access.reads[slotHex] == null &&
218
+ access.writes[slotHex] == null) {
219
+ access.reads[slotHex] = toHex(db.getState(addr, slot));
220
+ }
221
+ }
222
+ else {
223
+ this.countSlot(access.writes, slotHex);
224
+ }
225
+ }
226
+ if (opcode === "KECCAK256") {
227
+ // collect keccak on 64-byte blocks
228
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
229
+ const len = Number.parseInt(log.stack.peek(1).toString());
230
+ // currently, solidity uses only 2-word (6-byte) for a key. this might change..
231
+ // still, no need to return too much
232
+ if (len > 20 && len < 512) {
233
+ // if (len === 64) {
234
+ this.keccak.push(toHex(log.memory.slice(ofs, ofs + len)));
235
+ }
236
+ }
237
+ else if (opcode.startsWith("LOG")) {
238
+ const count = Number.parseInt(opcode.substring(3));
239
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
240
+ const len = Number.parseInt(log.stack.peek(1).toString());
241
+ const topics = [];
242
+ for (let i = 0; i < count; i++) {
243
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
244
+ topics.push("0x" + log.stack.peek(2 + i).toString(16));
245
+ }
246
+ const data = toHex(log.memory.slice(ofs, ofs + len));
247
+ this.logs.push({
248
+ topics,
249
+ data
250
+ });
251
+ }
252
+ }
253
+ };
254
+ }
255
+ //# sourceMappingURL=BundlerCollectorTracerV06.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BundlerCollectorTracerV06.js","sourceRoot":"","sources":["../../../rpc/validation/BundlerCollectorTracerV06.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,kFAAkF;AAClF,8CAA8C;AAC9C,wFAAwF;AAkHxF;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB;IAClC,OAAO;QACH,mBAAmB,EAAE,EAAE;QACvB,kEAAkE;QAClE,YAAY,EAAE,IAAW;QACzB,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,yEAAyE;QACzE,mBAAmB,EACf,kEAAkE;QACtE,cAAc,EAAE,KAAK;QACrB,mBAAmB,EAAE,CAAC;QAEtB,KAAK,CAAC,GAAY,EAAE,GAAU;YAC1B,IAAI,CAAC,KAAK,CAAC,IA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,CAAC;KACJ,CAAA;AACL,CAAC"}
@@ -0,0 +1,102 @@
1
+ import type { Address, Hex } from "viem";
2
+ import type { LogTracer } from "./tracer.js";
3
+ /**
4
+ * return type of our BundlerCollectorTracer.
5
+ * collect access and opcodes, split into "levels" based on NUMBER opcode
6
+ * keccak, calls and logs are collected globally, since the levels are unimportant for them.
7
+ */
8
+ export interface BundlerTracerResult {
9
+ /**
10
+ * storage and opcode info, collected on top-level calls from EntryPoint
11
+ */
12
+ callsFromEntryPoint: TopLevelCallInfo[];
13
+ /**
14
+ * values passed into KECCAK opcode
15
+ */
16
+ keccak: Hex[];
17
+ calls: Array<ExitInfo | MethodInfo>;
18
+ logs: LogInfo[];
19
+ debug: any[];
20
+ }
21
+ export interface MethodInfo {
22
+ type: string;
23
+ from: Address;
24
+ to: Address;
25
+ method: string;
26
+ value: bigint;
27
+ gas: number;
28
+ }
29
+ export interface ExitInfo {
30
+ type: "REVERT" | "RETURN";
31
+ gasUsed: number;
32
+ data: Hex;
33
+ }
34
+ export interface TopLevelCallInfo {
35
+ topLevelMethodSig: Hex;
36
+ topLevelTargetAddress: Address;
37
+ opcodes: {
38
+ [opcode: string]: number;
39
+ };
40
+ access: {
41
+ [address: string]: AccessInfo;
42
+ };
43
+ contractSize: {
44
+ [addr: string]: ContractSizeInfo;
45
+ };
46
+ extCodeAccessInfo: {
47
+ [addr: string]: string;
48
+ };
49
+ oog?: boolean;
50
+ }
51
+ /**
52
+ * It is illegal to access contracts with no code in validation even if it gets deployed later.
53
+ * This means we need to store the {@link contractSize} of accessed addresses at the time of access.
54
+ */
55
+ export interface ContractSizeInfo {
56
+ opcode: string;
57
+ contractSize: number;
58
+ }
59
+ export interface AccessInfo {
60
+ reads: {
61
+ [slot: string]: string;
62
+ };
63
+ writes: {
64
+ [slot: string]: number;
65
+ };
66
+ }
67
+ export interface LogInfo {
68
+ topics: string[];
69
+ data: string;
70
+ }
71
+ interface RelevantStepData {
72
+ opcode: string;
73
+ stackTop3: any[];
74
+ }
75
+ /**
76
+ * type-safe local storage of our collector. contains all return-value properties.
77
+ * (also defines all "trace-local" variables and functions)
78
+ */
79
+ interface BundlerCollectorTracer extends LogTracer, BundlerTracerResult {
80
+ lastOp: string;
81
+ lastThreeOpcodes: RelevantStepData[];
82
+ stopCollectingTopic: string;
83
+ stopCollecting: boolean;
84
+ currentLevel: TopLevelCallInfo;
85
+ topLevelCallCounter: number;
86
+ countSlot: (list: {
87
+ [key: string]: number | undefined;
88
+ }, key: any) => void;
89
+ }
90
+ /**
91
+ * tracer to collect data for opcode banning.
92
+ * this method is passed as the "tracer" for eth_traceCall (note, the function itself)
93
+ *
94
+ * returned data:
95
+ * numberLevels: opcodes and memory access, split on execution of "number" opcode.
96
+ * keccak: input data of keccak opcode.
97
+ * calls: for each call, an array of [type, from, to, value]
98
+ * slots: accessed slots (on any address)
99
+ */
100
+ export declare function bundlerCollectorTracer(): BundlerCollectorTracer;
101
+ export {};
102
+ //# sourceMappingURL=BundlerCollectorTracerV07.d.ts.map
@@ -0,0 +1,254 @@
1
+ // javascript code of tracer function
2
+ // NOTE: we process this locally for hardhat, but send to geth for remote tracing.
3
+ // should NOT "require" anything, or use logs.
4
+ // see LogTrace for valid types (but alas, this one must be javascript, not typescript).
5
+ /**
6
+ * tracer to collect data for opcode banning.
7
+ * this method is passed as the "tracer" for eth_traceCall (note, the function itself)
8
+ *
9
+ * returned data:
10
+ * numberLevels: opcodes and memory access, split on execution of "number" opcode.
11
+ * keccak: input data of keccak opcode.
12
+ * calls: for each call, an array of [type, from, to, value]
13
+ * slots: accessed slots (on any address)
14
+ */
15
+ export function bundlerCollectorTracer() {
16
+ return {
17
+ callsFromEntryPoint: [],
18
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
19
+ currentLevel: null,
20
+ keccak: [],
21
+ calls: [],
22
+ logs: [],
23
+ debug: [],
24
+ lastOp: "",
25
+ lastThreeOpcodes: [],
26
+ // event sent after all validations are done: keccak("BeforeExecution()")
27
+ stopCollectingTopic: "bb47ee3e183a558b1a2ff0874b079f3fc5478b7454eacf2bfc5af2ff5878f972",
28
+ stopCollecting: false,
29
+ topLevelCallCounter: 0,
30
+ fault(log, _db) {
31
+ this.debug.push(JSON.stringify({
32
+ type: "fault",
33
+ depth: log.getDepth(),
34
+ gas: log.getGas(),
35
+ cost: log.getCost(),
36
+ err: log.getError()
37
+ }));
38
+ },
39
+ result(_ctx, _db) {
40
+ return {
41
+ callsFromEntryPoint: this.callsFromEntryPoint,
42
+ keccak: this.keccak,
43
+ logs: this.logs,
44
+ calls: this.calls,
45
+ debug: this.debug // for internal debugging.
46
+ };
47
+ },
48
+ enter(frame) {
49
+ if (this.stopCollecting) {
50
+ return;
51
+ }
52
+ this.calls.push({
53
+ type: frame.getType(),
54
+ from: toHex(frame.getFrom()),
55
+ to: toHex(frame.getTo()),
56
+ method: toHex(frame.getInput()).slice(0, 10),
57
+ gas: frame.getGas(),
58
+ value: frame.getValue()
59
+ });
60
+ },
61
+ exit(frame) {
62
+ if (this.stopCollecting) {
63
+ return;
64
+ }
65
+ this.calls.push({
66
+ type: frame.getError() != null ? "REVERT" : "RETURN",
67
+ gasUsed: frame.getGasUsed(),
68
+ data: toHex(frame.getOutput()).slice(0, 4000)
69
+ });
70
+ },
71
+ // increment the "key" in the list. if the key is not defined yet, then set it to "1"
72
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
73
+ countSlot(list, key) {
74
+ if (list[key]) {
75
+ // @ts-ignore
76
+ list[key] += 1;
77
+ }
78
+ else {
79
+ list[key] = 1;
80
+ }
81
+ },
82
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
83
+ step(log, db) {
84
+ if (log.getDepth() < 3) {
85
+ return;
86
+ }
87
+ if (this.stopCollecting) {
88
+ return;
89
+ }
90
+ const opcode = log.op.toString();
91
+ const stackSize = log.stack.length();
92
+ const stackTop3 = [];
93
+ for (let i = 0; i < 3 && i < stackSize; i++) {
94
+ stackTop3.push(log.stack.peek(i));
95
+ }
96
+ this.lastThreeOpcodes.push({ opcode, stackTop3 });
97
+ if (this.lastThreeOpcodes.length > 3) {
98
+ this.lastThreeOpcodes.shift();
99
+ }
100
+ if (log.getGas() < log.getCost() ||
101
+ // special rule for SSTORE with gas metering
102
+ (opcode === "SSTORE" && log.getGas() < 2300)) {
103
+ this.currentLevel.oog = true;
104
+ }
105
+ if (opcode === "REVERT" || opcode === "RETURN") {
106
+ if (log.getDepth() === 3) {
107
+ // exit() is not called on top-level return/revent, so we reconstruct it
108
+ // from opcode
109
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
110
+ const len = Number.parseInt(log.stack.peek(1).toString());
111
+ const data = toHex(log.memory.slice(ofs, ofs + len)).slice(0, 4000);
112
+ // this.debug.push(opcode + ' ' + data)
113
+ this.calls.push({
114
+ type: opcode,
115
+ gasUsed: 0,
116
+ data
117
+ });
118
+ }
119
+ // NOTE: flushing all history after RETURN
120
+ this.lastThreeOpcodes = [];
121
+ }
122
+ if (log.getDepth() === 3) {
123
+ if (opcode === "CALL" || opcode === "STATICCALL") {
124
+ // stack.peek(0) - gas
125
+ const addr = toAddress(log.stack.peek(1).toString(16));
126
+ const topLevelTargetAddress = toHex(addr);
127
+ // stack.peek(2) - value
128
+ const ofs = Number.parseInt(log.stack.peek(3).toString());
129
+ // stack.peek(4) - len
130
+ const topLevelMethodSig = toHex(log.memory.slice(ofs, ofs + 4));
131
+ this.currentLevel = this.callsFromEntryPoint[this.topLevelCallCounter] = {
132
+ topLevelMethodSig,
133
+ topLevelTargetAddress,
134
+ access: {},
135
+ opcodes: {},
136
+ extCodeAccessInfo: {},
137
+ contractSize: {}
138
+ };
139
+ this.topLevelCallCounter++;
140
+ }
141
+ else if (opcode === "LOG1") {
142
+ // ignore log data ofs, len
143
+ const topic = log.stack.peek(2).toString(16);
144
+ if (topic === this.stopCollectingTopic) {
145
+ this.stopCollecting = true;
146
+ }
147
+ }
148
+ this.lastOp = "";
149
+ return;
150
+ }
151
+ const lastOpInfo = this.lastThreeOpcodes[this.lastThreeOpcodes.length - 2];
152
+ // store all addresses touched by EXTCODE* opcodes
153
+ if (lastOpInfo &&
154
+ lastOpInfo.opcode &&
155
+ lastOpInfo.opcode.match(/^(EXT.*)$/) != null) {
156
+ const addr = toAddress(lastOpInfo.stackTop3[0].toString(16));
157
+ const addrHex = toHex(addr);
158
+ // [OP-051]
159
+ if (!(this.lastThreeOpcodes[0].opcode.match(/\w+/) !== null &&
160
+ this.lastThreeOpcodes[1].opcode === "EXTCODESIZE" &&
161
+ this.lastThreeOpcodes[2].opcode === "ISZERO")) {
162
+ this.currentLevel.extCodeAccessInfo[addrHex] = opcode;
163
+ }
164
+ }
165
+ // not using 'isPrecompiled' to only allow the ones defined by the ERC-4337 as stateless precompiles
166
+ // [OP-062]
167
+ // biome-ignore lint/suspicious/noExplicitAny: it's a generic type
168
+ const isAllowedPrecompiled = (address) => {
169
+ const addrHex = toHex(address);
170
+ const addressInt = Number.parseInt(addrHex);
171
+ // this.debug.push(`isPrecompiled address=${addrHex} addressInt=${addressInt}`)
172
+ return addressInt > 0 && addressInt < 10;
173
+ };
174
+ // [OP-041]
175
+ if (opcode.match(/^(EXT.*|CALL|CALLCODE|DELEGATECALL|STATICCALL)$/) != null) {
176
+ const idx = opcode.startsWith("EXT") ? 0 : 1;
177
+ const addr = toAddress(log.stack.peek(idx).toString(16));
178
+ const addrHex = toHex(addr);
179
+ // this.debug.push('op=' + opcode + ' last=' + this.lastOp + ' stacksize=' + log.stack.length() + ' addr=' + addrHex)
180
+ if (this.currentLevel.contractSize[addrHex] == null &&
181
+ !isAllowedPrecompiled(addr)) {
182
+ this.currentLevel.contractSize[addrHex] = {
183
+ contractSize: db.getCode(addr).length,
184
+ opcode
185
+ };
186
+ }
187
+ }
188
+ // [OP-012]
189
+ if (this.lastOp === "GAS" && !opcode.includes("CALL")) {
190
+ // count "GAS" opcode only if not followed by "CALL"
191
+ this.countSlot(this.currentLevel.opcodes, "GAS");
192
+ }
193
+ if (opcode !== "GAS") {
194
+ // ignore "unimportant" opcodes:
195
+ if (opcode.match(/^(DUP\d+|PUSH\d+|SWAP\d+|POP|ADD|SUB|MUL|DIV|EQ|LTE?|S?GTE?|SLT|SH[LR]|AND|OR|NOT|ISZERO)$/) == null) {
196
+ this.countSlot(this.currentLevel.opcodes, opcode);
197
+ }
198
+ }
199
+ this.lastOp = opcode;
200
+ if (opcode === "SLOAD" || opcode === "SSTORE") {
201
+ const slot = toWord(log.stack.peek(0).toString(16));
202
+ const slotHex = toHex(slot);
203
+ const addr = log.contract.getAddress();
204
+ const addrHex = toHex(addr);
205
+ let access = this.currentLevel.access[addrHex];
206
+ if (access == null) {
207
+ access = {
208
+ reads: {},
209
+ writes: {}
210
+ };
211
+ this.currentLevel.access[addrHex] = access;
212
+ }
213
+ if (opcode === "SLOAD") {
214
+ // read slot values before this UserOp was created
215
+ // (so saving it if it was written before the first read)
216
+ if (access.reads[slotHex] == null &&
217
+ access.writes[slotHex] == null) {
218
+ access.reads[slotHex] = toHex(db.getState(addr, slot));
219
+ }
220
+ }
221
+ else {
222
+ this.countSlot(access.writes, slotHex);
223
+ }
224
+ }
225
+ if (opcode === "KECCAK256") {
226
+ // collect keccak on 64-byte blocks
227
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
228
+ const len = Number.parseInt(log.stack.peek(1).toString());
229
+ // currently, solidity uses only 2-word (6-byte) for a key. this might change..
230
+ // still, no need to return too much
231
+ if (len > 20 && len < 512) {
232
+ // if (len === 64) {
233
+ this.keccak.push(toHex(log.memory.slice(ofs, ofs + len)));
234
+ }
235
+ }
236
+ else if (opcode.startsWith("LOG")) {
237
+ const count = Number.parseInt(opcode.substring(3));
238
+ const ofs = Number.parseInt(log.stack.peek(0).toString());
239
+ const len = Number.parseInt(log.stack.peek(1).toString());
240
+ const topics = [];
241
+ for (let i = 0; i < count; i++) {
242
+ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
243
+ topics.push(`0x${log.stack.peek(2 + i).toString(16)}`);
244
+ }
245
+ const data = toHex(log.memory.slice(ofs, ofs + len));
246
+ this.logs.push({
247
+ topics,
248
+ data
249
+ });
250
+ }
251
+ }
252
+ };
253
+ }
254
+ //# sourceMappingURL=BundlerCollectorTracerV07.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BundlerCollectorTracerV07.js","sourceRoot":"","sources":["../../../rpc/validation/BundlerCollectorTracerV07.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,kFAAkF;AAClF,8CAA8C;AAC9C,wFAAwF;AAkHxF;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB;IAClC,OAAO;QACH,mBAAmB,EAAE,EAAE;QACvB,kEAAkE;QAClE,YAAY,EAAE,IAAW;QACzB,MAAM,EAAE,EAAE;QACV,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,gBAAgB,EAAE,EAAE;QACpB,yEAAyE;QACzE,mBAAmB,EACf,kEAAkE;QACtE,cAAc,EAAE,KAAK;QACrB,mBAAmB,EAAE,CAAC;QAEtB,KAAK,CAAC,GAAY,EAAE,GAAU;YAC1B,IAAI,CAAC,KAAK,CAAC,IAAI,CACX,IAAI,CAAC,SAAS,CAAC;gBACX,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,GAAG,CAAC,QAAQ,EAAE;gBACrB,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE;gBACjB,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE;gBACnB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;aACtB,CAAC,CACL,CAAA;QACL,CAAC;QAED,MAAM,CAAC,IAAgB,EAAE,GAAU;YAC/B,OAAO;gBACH,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;gBAC7C,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,I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