@mikeatlast/ponder 0.16.1-fork.1

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 (619) hide show
  1. package/CHANGELOG.md +3415 -0
  2. package/README.md +186 -0
  3. package/dist/esm/bin/commands/codegen.js +46 -0
  4. package/dist/esm/bin/commands/codegen.js.map +1 -0
  5. package/dist/esm/bin/commands/createViews.js +196 -0
  6. package/dist/esm/bin/commands/createViews.js.map +1 -0
  7. package/dist/esm/bin/commands/dev.js +430 -0
  8. package/dist/esm/bin/commands/dev.js.map +1 -0
  9. package/dist/esm/bin/commands/list.js +148 -0
  10. package/dist/esm/bin/commands/list.js.map +1 -0
  11. package/dist/esm/bin/commands/prune.js +223 -0
  12. package/dist/esm/bin/commands/prune.js.map +1 -0
  13. package/dist/esm/bin/commands/serve.js +198 -0
  14. package/dist/esm/bin/commands/serve.js.map +1 -0
  15. package/dist/esm/bin/commands/start.js +253 -0
  16. package/dist/esm/bin/commands/start.js.map +1 -0
  17. package/dist/esm/bin/isolatedController.js +200 -0
  18. package/dist/esm/bin/isolatedController.js.map +1 -0
  19. package/dist/esm/bin/isolatedWorker.js +146 -0
  20. package/dist/esm/bin/isolatedWorker.js.map +1 -0
  21. package/dist/esm/bin/ponder.js +137 -0
  22. package/dist/esm/bin/ponder.js.map +1 -0
  23. package/dist/esm/bin/utils/codegen.js +25 -0
  24. package/dist/esm/bin/utils/codegen.js.map +1 -0
  25. package/dist/esm/bin/utils/exit.js +100 -0
  26. package/dist/esm/bin/utils/exit.js.map +1 -0
  27. package/dist/esm/build/config.js +745 -0
  28. package/dist/esm/build/config.js.map +1 -0
  29. package/dist/esm/build/factory.js +82 -0
  30. package/dist/esm/build/factory.js.map +1 -0
  31. package/dist/esm/build/index.js +567 -0
  32. package/dist/esm/build/index.js.map +1 -0
  33. package/dist/esm/build/plugin.js +53 -0
  34. package/dist/esm/build/plugin.js.map +1 -0
  35. package/dist/esm/build/pre.js +83 -0
  36. package/dist/esm/build/pre.js.map +1 -0
  37. package/dist/esm/build/schema.js +202 -0
  38. package/dist/esm/build/schema.js.map +1 -0
  39. package/dist/esm/build/stacktrace.js +137 -0
  40. package/dist/esm/build/stacktrace.js.map +1 -0
  41. package/dist/esm/client/index.js +441 -0
  42. package/dist/esm/client/index.js.map +1 -0
  43. package/dist/esm/config/address.js +2 -0
  44. package/dist/esm/config/address.js.map +1 -0
  45. package/dist/esm/config/eventFilter.js +2 -0
  46. package/dist/esm/config/eventFilter.js.map +1 -0
  47. package/dist/esm/config/index.js +2 -0
  48. package/dist/esm/config/index.js.map +1 -0
  49. package/dist/esm/config/utilityTypes.js +2 -0
  50. package/dist/esm/config/utilityTypes.js.map +1 -0
  51. package/dist/esm/database/actions.js +445 -0
  52. package/dist/esm/database/actions.js.map +1 -0
  53. package/dist/esm/database/index.js +604 -0
  54. package/dist/esm/database/index.js.map +1 -0
  55. package/dist/esm/database/queryBuilder.js +314 -0
  56. package/dist/esm/database/queryBuilder.js.map +1 -0
  57. package/dist/esm/drizzle/bigint.js +38 -0
  58. package/dist/esm/drizzle/bigint.js.map +1 -0
  59. package/dist/esm/drizzle/bytes.js +47 -0
  60. package/dist/esm/drizzle/bytes.js.map +1 -0
  61. package/dist/esm/drizzle/hex.js +40 -0
  62. package/dist/esm/drizzle/hex.js.map +1 -0
  63. package/dist/esm/drizzle/index.js +28 -0
  64. package/dist/esm/drizzle/index.js.map +1 -0
  65. package/dist/esm/drizzle/json.js +123 -0
  66. package/dist/esm/drizzle/json.js.map +1 -0
  67. package/dist/esm/drizzle/kit/index.js +927 -0
  68. package/dist/esm/drizzle/kit/index.js.map +1 -0
  69. package/dist/esm/drizzle/onchain.js +184 -0
  70. package/dist/esm/drizzle/onchain.js.map +1 -0
  71. package/dist/esm/drizzle/text.js +61 -0
  72. package/dist/esm/drizzle/text.js.map +1 -0
  73. package/dist/esm/graphql/graphiql.html.js +59 -0
  74. package/dist/esm/graphql/graphiql.html.js.map +1 -0
  75. package/dist/esm/graphql/index.js +934 -0
  76. package/dist/esm/graphql/index.js.map +1 -0
  77. package/dist/esm/graphql/json.js +42 -0
  78. package/dist/esm/graphql/json.js.map +1 -0
  79. package/dist/esm/graphql/middleware.js +83 -0
  80. package/dist/esm/graphql/middleware.js.map +1 -0
  81. package/dist/esm/index.js +9 -0
  82. package/dist/esm/index.js.map +1 -0
  83. package/dist/esm/indexing/addStackTrace.js +54 -0
  84. package/dist/esm/indexing/addStackTrace.js.map +1 -0
  85. package/dist/esm/indexing/client.js +675 -0
  86. package/dist/esm/indexing/client.js.map +1 -0
  87. package/dist/esm/indexing/index.js +663 -0
  88. package/dist/esm/indexing/index.js.map +1 -0
  89. package/dist/esm/indexing/profile.js +584 -0
  90. package/dist/esm/indexing/profile.js.map +1 -0
  91. package/dist/esm/indexing-store/cache.js +666 -0
  92. package/dist/esm/indexing-store/cache.js.map +1 -0
  93. package/dist/esm/indexing-store/index.js +461 -0
  94. package/dist/esm/indexing-store/index.js.map +1 -0
  95. package/dist/esm/indexing-store/profile.js +428 -0
  96. package/dist/esm/indexing-store/profile.js.map +1 -0
  97. package/dist/esm/indexing-store/utils.js +111 -0
  98. package/dist/esm/indexing-store/utils.js.map +1 -0
  99. package/dist/esm/internal/common.js +2 -0
  100. package/dist/esm/internal/common.js.map +1 -0
  101. package/dist/esm/internal/errors.js +300 -0
  102. package/dist/esm/internal/errors.js.map +1 -0
  103. package/dist/esm/internal/logger.js +178 -0
  104. package/dist/esm/internal/logger.js.map +1 -0
  105. package/dist/esm/internal/metrics.js +1049 -0
  106. package/dist/esm/internal/metrics.js.map +1 -0
  107. package/dist/esm/internal/options.js +73 -0
  108. package/dist/esm/internal/options.js.map +1 -0
  109. package/dist/esm/internal/shutdown.js +24 -0
  110. package/dist/esm/internal/shutdown.js.map +1 -0
  111. package/dist/esm/internal/telemetry.js +200 -0
  112. package/dist/esm/internal/telemetry.js.map +1 -0
  113. package/dist/esm/internal/types.js +2 -0
  114. package/dist/esm/internal/types.js.map +1 -0
  115. package/dist/esm/rpc/actions.js +988 -0
  116. package/dist/esm/rpc/actions.js.map +1 -0
  117. package/dist/esm/rpc/http.js +130 -0
  118. package/dist/esm/rpc/http.js.map +1 -0
  119. package/dist/esm/rpc/index.js +749 -0
  120. package/dist/esm/rpc/index.js.map +1 -0
  121. package/dist/esm/runtime/events.js +664 -0
  122. package/dist/esm/runtime/events.js.map +1 -0
  123. package/dist/esm/runtime/filter.js +476 -0
  124. package/dist/esm/runtime/filter.js.map +1 -0
  125. package/dist/esm/runtime/fragments.js +478 -0
  126. package/dist/esm/runtime/fragments.js.map +1 -0
  127. package/dist/esm/runtime/historical.js +954 -0
  128. package/dist/esm/runtime/historical.js.map +1 -0
  129. package/dist/esm/runtime/index.js +316 -0
  130. package/dist/esm/runtime/index.js.map +1 -0
  131. package/dist/esm/runtime/init.js +12 -0
  132. package/dist/esm/runtime/init.js.map +1 -0
  133. package/dist/esm/runtime/isolated.js +464 -0
  134. package/dist/esm/runtime/isolated.js.map +1 -0
  135. package/dist/esm/runtime/multichain.js +511 -0
  136. package/dist/esm/runtime/multichain.js.map +1 -0
  137. package/dist/esm/runtime/omnichain.js +546 -0
  138. package/dist/esm/runtime/omnichain.js.map +1 -0
  139. package/dist/esm/runtime/realtime.js +722 -0
  140. package/dist/esm/runtime/realtime.js.map +1 -0
  141. package/dist/esm/server/error.js +56 -0
  142. package/dist/esm/server/error.js.map +1 -0
  143. package/dist/esm/server/index.js +121 -0
  144. package/dist/esm/server/index.js.map +1 -0
  145. package/dist/esm/sync-historical/index.js +703 -0
  146. package/dist/esm/sync-historical/index.js.map +1 -0
  147. package/dist/esm/sync-realtime/bloom.js +76 -0
  148. package/dist/esm/sync-realtime/bloom.js.map +1 -0
  149. package/dist/esm/sync-realtime/index.js +918 -0
  150. package/dist/esm/sync-realtime/index.js.map +1 -0
  151. package/dist/esm/sync-store/encode.js +105 -0
  152. package/dist/esm/sync-store/encode.js.map +1 -0
  153. package/dist/esm/sync-store/index.js +885 -0
  154. package/dist/esm/sync-store/index.js.map +1 -0
  155. package/dist/esm/sync-store/migrations.js +1595 -0
  156. package/dist/esm/sync-store/migrations.js.map +1 -0
  157. package/dist/esm/sync-store/schema.js +181 -0
  158. package/dist/esm/sync-store/schema.js.map +1 -0
  159. package/dist/esm/types/db.js +2 -0
  160. package/dist/esm/types/db.js.map +1 -0
  161. package/dist/esm/types/eth.js +2 -0
  162. package/dist/esm/types/eth.js.map +1 -0
  163. package/dist/esm/types/utils.js +2 -0
  164. package/dist/esm/types/utils.js.map +1 -0
  165. package/dist/esm/types/virtual.js +2 -0
  166. package/dist/esm/types/virtual.js.map +1 -0
  167. package/dist/esm/ui/app.js +157 -0
  168. package/dist/esm/ui/app.js.map +1 -0
  169. package/dist/esm/ui/index.js +29 -0
  170. package/dist/esm/ui/index.js.map +1 -0
  171. package/dist/esm/ui/patch.js +140 -0
  172. package/dist/esm/ui/patch.js.map +1 -0
  173. package/dist/esm/utils/abi.js +55 -0
  174. package/dist/esm/utils/abi.js.map +1 -0
  175. package/dist/esm/utils/bigint.js +37 -0
  176. package/dist/esm/utils/bigint.js.map +1 -0
  177. package/dist/esm/utils/chains.js +21 -0
  178. package/dist/esm/utils/chains.js.map +1 -0
  179. package/dist/esm/utils/checkpoint.js +139 -0
  180. package/dist/esm/utils/checkpoint.js.map +1 -0
  181. package/dist/esm/utils/chunk.js +8 -0
  182. package/dist/esm/utils/chunk.js.map +1 -0
  183. package/dist/esm/utils/copy.js +129 -0
  184. package/dist/esm/utils/copy.js.map +1 -0
  185. package/dist/esm/utils/date.js +27 -0
  186. package/dist/esm/utils/date.js.map +1 -0
  187. package/dist/esm/utils/debug.js +2 -0
  188. package/dist/esm/utils/debug.js.map +1 -0
  189. package/dist/esm/utils/decodeAbiParameters.js +290 -0
  190. package/dist/esm/utils/decodeAbiParameters.js.map +1 -0
  191. package/dist/esm/utils/decodeEventLog.js +75 -0
  192. package/dist/esm/utils/decodeEventLog.js.map +1 -0
  193. package/dist/esm/utils/dedupe.js +29 -0
  194. package/dist/esm/utils/dedupe.js.map +1 -0
  195. package/dist/esm/utils/duplicates.js +19 -0
  196. package/dist/esm/utils/duplicates.js.map +1 -0
  197. package/dist/esm/utils/estimate.js +6 -0
  198. package/dist/esm/utils/estimate.js.map +1 -0
  199. package/dist/esm/utils/finality.js +38 -0
  200. package/dist/esm/utils/finality.js.map +1 -0
  201. package/dist/esm/utils/format.js +20 -0
  202. package/dist/esm/utils/format.js.map +1 -0
  203. package/dist/esm/utils/generators.js +121 -0
  204. package/dist/esm/utils/generators.js.map +1 -0
  205. package/dist/esm/utils/hash.js +11 -0
  206. package/dist/esm/utils/hash.js.map +1 -0
  207. package/dist/esm/utils/interval.js +171 -0
  208. package/dist/esm/utils/interval.js.map +1 -0
  209. package/dist/esm/utils/lowercase.js +7 -0
  210. package/dist/esm/utils/lowercase.js.map +1 -0
  211. package/dist/esm/utils/mutex.js +26 -0
  212. package/dist/esm/utils/mutex.js.map +1 -0
  213. package/dist/esm/utils/never.js +4 -0
  214. package/dist/esm/utils/never.js.map +1 -0
  215. package/dist/esm/utils/offset.js +101 -0
  216. package/dist/esm/utils/offset.js.map +1 -0
  217. package/dist/esm/utils/order.js +18 -0
  218. package/dist/esm/utils/order.js.map +1 -0
  219. package/dist/esm/utils/partition.js +46 -0
  220. package/dist/esm/utils/partition.js.map +1 -0
  221. package/dist/esm/utils/pg.js +175 -0
  222. package/dist/esm/utils/pg.js.map +1 -0
  223. package/dist/esm/utils/pglite.js +80 -0
  224. package/dist/esm/utils/pglite.js.map +1 -0
  225. package/dist/esm/utils/port.js +30 -0
  226. package/dist/esm/utils/port.js.map +1 -0
  227. package/dist/esm/utils/print.js +23 -0
  228. package/dist/esm/utils/print.js.map +1 -0
  229. package/dist/esm/utils/promiseAllSettledWithThrow.js +19 -0
  230. package/dist/esm/utils/promiseAllSettledWithThrow.js.map +1 -0
  231. package/dist/esm/utils/promiseWithResolvers.js +13 -0
  232. package/dist/esm/utils/promiseWithResolvers.js.map +1 -0
  233. package/dist/esm/utils/queue.js +150 -0
  234. package/dist/esm/utils/queue.js.map +1 -0
  235. package/dist/esm/utils/range.js +8 -0
  236. package/dist/esm/utils/range.js.map +1 -0
  237. package/dist/esm/utils/result.js +10 -0
  238. package/dist/esm/utils/result.js.map +1 -0
  239. package/dist/esm/utils/sql-parse.js +1326 -0
  240. package/dist/esm/utils/sql-parse.js.map +1 -0
  241. package/dist/esm/utils/timer.js +9 -0
  242. package/dist/esm/utils/timer.js.map +1 -0
  243. package/dist/esm/utils/truncate.js +15 -0
  244. package/dist/esm/utils/truncate.js.map +1 -0
  245. package/dist/esm/utils/wait.js +10 -0
  246. package/dist/esm/utils/wait.js.map +1 -0
  247. package/dist/esm/utils/zipper.js +67 -0
  248. package/dist/esm/utils/zipper.js.map +1 -0
  249. package/dist/types/bin/commands/codegen.d.ts +5 -0
  250. package/dist/types/bin/commands/codegen.d.ts.map +1 -0
  251. package/dist/types/bin/commands/createViews.d.ts +8 -0
  252. package/dist/types/bin/commands/createViews.d.ts.map +1 -0
  253. package/dist/types/bin/commands/dev.d.ts +5 -0
  254. package/dist/types/bin/commands/dev.d.ts.map +1 -0
  255. package/dist/types/bin/commands/list.d.ts +5 -0
  256. package/dist/types/bin/commands/list.d.ts.map +1 -0
  257. package/dist/types/bin/commands/prune.d.ts +5 -0
  258. package/dist/types/bin/commands/prune.d.ts.map +1 -0
  259. package/dist/types/bin/commands/serve.d.ts +5 -0
  260. package/dist/types/bin/commands/serve.d.ts.map +1 -0
  261. package/dist/types/bin/commands/start.d.ts +19 -0
  262. package/dist/types/bin/commands/start.d.ts.map +1 -0
  263. package/dist/types/bin/isolatedController.d.ts +13 -0
  264. package/dist/types/bin/isolatedController.d.ts.map +1 -0
  265. package/dist/types/bin/isolatedWorker.d.ts +9 -0
  266. package/dist/types/bin/isolatedWorker.d.ts.map +1 -0
  267. package/dist/types/bin/ponder.d.ts +37 -0
  268. package/dist/types/bin/ponder.d.ts.map +1 -0
  269. package/dist/types/bin/utils/codegen.d.ts +6 -0
  270. package/dist/types/bin/utils/codegen.d.ts.map +1 -0
  271. package/dist/types/bin/utils/exit.d.ts +10 -0
  272. package/dist/types/bin/utils/exit.d.ts.map +1 -0
  273. package/dist/types/build/config.d.ts +97 -0
  274. package/dist/types/build/config.d.ts.map +1 -0
  275. package/dist/types/build/factory.d.ts +15 -0
  276. package/dist/types/build/factory.d.ts.map +1 -0
  277. package/dist/types/build/index.d.ts +84 -0
  278. package/dist/types/build/index.d.ts.map +1 -0
  279. package/dist/types/build/plugin.d.ts +4 -0
  280. package/dist/types/build/plugin.d.ts.map +1 -0
  281. package/dist/types/build/pre.d.ts +29 -0
  282. package/dist/types/build/pre.d.ts.map +1 -0
  283. package/dist/types/build/schema.d.ts +20 -0
  284. package/dist/types/build/schema.d.ts.map +1 -0
  285. package/dist/types/build/stacktrace.d.ts +13 -0
  286. package/dist/types/build/stacktrace.d.ts.map +1 -0
  287. package/dist/types/client/index.d.ts +27 -0
  288. package/dist/types/client/index.d.ts.map +1 -0
  289. package/dist/types/config/address.d.ts +34 -0
  290. package/dist/types/config/address.d.ts.map +1 -0
  291. package/dist/types/config/eventFilter.d.ts +18 -0
  292. package/dist/types/config/eventFilter.d.ts.map +1 -0
  293. package/dist/types/config/index.d.ts +144 -0
  294. package/dist/types/config/index.d.ts.map +1 -0
  295. package/dist/types/config/utilityTypes.d.ts +43 -0
  296. package/dist/types/config/utilityTypes.d.ts.map +1 -0
  297. package/dist/types/database/actions.d.ts +99 -0
  298. package/dist/types/database/actions.d.ts.map +1 -0
  299. package/dist/types/database/index.d.ts +493 -0
  300. package/dist/types/database/index.d.ts.map +1 -0
  301. package/dist/types/database/queryBuilder.d.ts +65 -0
  302. package/dist/types/database/queryBuilder.d.ts.map +1 -0
  303. package/dist/types/drizzle/bigint.d.ts +25 -0
  304. package/dist/types/drizzle/bigint.d.ts.map +1 -0
  305. package/dist/types/drizzle/bytes.d.ts +31 -0
  306. package/dist/types/drizzle/bytes.d.ts.map +1 -0
  307. package/dist/types/drizzle/hex.d.ts +25 -0
  308. package/dist/types/drizzle/hex.d.ts.map +1 -0
  309. package/dist/types/drizzle/index.d.ts +6 -0
  310. package/dist/types/drizzle/index.d.ts.map +1 -0
  311. package/dist/types/drizzle/json.d.ts +51 -0
  312. package/dist/types/drizzle/json.d.ts.map +1 -0
  313. package/dist/types/drizzle/kit/index.d.ts +187 -0
  314. package/dist/types/drizzle/kit/index.d.ts.map +1 -0
  315. package/dist/types/drizzle/onchain.d.ts +298 -0
  316. package/dist/types/drizzle/onchain.d.ts.map +1 -0
  317. package/dist/types/drizzle/text.d.ts +29 -0
  318. package/dist/types/drizzle/text.d.ts.map +1 -0
  319. package/dist/types/graphql/graphiql.html.d.ts +2 -0
  320. package/dist/types/graphql/graphiql.html.d.ts.map +1 -0
  321. package/dist/types/graphql/index.d.ts +12 -0
  322. package/dist/types/graphql/index.d.ts.map +1 -0
  323. package/dist/types/graphql/json.d.ts +3 -0
  324. package/dist/types/graphql/json.d.ts.map +1 -0
  325. package/dist/types/graphql/middleware.d.ts +29 -0
  326. package/dist/types/graphql/middleware.d.ts.map +1 -0
  327. package/dist/types/index.d.ts +23 -0
  328. package/dist/types/index.d.ts.map +1 -0
  329. package/dist/types/indexing/addStackTrace.d.ts +3 -0
  330. package/dist/types/indexing/addStackTrace.d.ts.map +1 -0
  331. package/dist/types/indexing/client.d.ts +154 -0
  332. package/dist/types/indexing/client.d.ts.map +1 -0
  333. package/dist/types/indexing/index.d.ts +72 -0
  334. package/dist/types/indexing/index.d.ts.map +1 -0
  335. package/dist/types/indexing/profile.d.ts +16 -0
  336. package/dist/types/indexing/profile.d.ts.map +1 -0
  337. package/dist/types/indexing-store/cache.d.ts +115 -0
  338. package/dist/types/indexing-store/cache.d.ts.map +1 -0
  339. package/dist/types/indexing-store/index.d.ts +24 -0
  340. package/dist/types/indexing-store/index.d.ts.map +1 -0
  341. package/dist/types/indexing-store/profile.d.ts +7 -0
  342. package/dist/types/indexing-store/profile.d.ts.map +1 -0
  343. package/dist/types/indexing-store/utils.d.ts +19 -0
  344. package/dist/types/indexing-store/utils.d.ts.map +1 -0
  345. package/dist/types/internal/common.d.ts +15 -0
  346. package/dist/types/internal/common.d.ts.map +1 -0
  347. package/dist/types/internal/errors.d.ts +101 -0
  348. package/dist/types/internal/errors.d.ts.map +1 -0
  349. package/dist/types/internal/logger.d.ts +37 -0
  350. package/dist/types/internal/logger.d.ts.map +1 -0
  351. package/dist/types/internal/metrics.d.ts +120 -0
  352. package/dist/types/internal/metrics.d.ts.map +1 -0
  353. package/dist/types/internal/options.d.ts +62 -0
  354. package/dist/types/internal/options.d.ts.map +1 -0
  355. package/dist/types/internal/shutdown.d.ts +8 -0
  356. package/dist/types/internal/shutdown.d.ts.map +1 -0
  357. package/dist/types/internal/telemetry.d.ts +43 -0
  358. package/dist/types/internal/telemetry.d.ts.map +1 -0
  359. package/dist/types/internal/types.d.ts +443 -0
  360. package/dist/types/internal/types.d.ts.map +1 -0
  361. package/dist/types/rpc/actions.d.ts +360 -0
  362. package/dist/types/rpc/actions.d.ts.map +1 -0
  363. package/dist/types/rpc/http.d.ts +17 -0
  364. package/dist/types/rpc/http.d.ts.map +1 -0
  365. package/dist/types/rpc/index.d.ts +43 -0
  366. package/dist/types/rpc/index.d.ts.map +1 -0
  367. package/dist/types/runtime/events.d.ts +40 -0
  368. package/dist/types/runtime/events.d.ts.map +1 -0
  369. package/dist/types/runtime/filter.d.ts +96 -0
  370. package/dist/types/runtime/filter.d.ts.map +1 -0
  371. package/dist/types/runtime/fragments.d.ts +30 -0
  372. package/dist/types/runtime/fragments.d.ts.map +1 -0
  373. package/dist/types/runtime/historical.d.ts +123 -0
  374. package/dist/types/runtime/historical.d.ts.map +1 -0
  375. package/dist/types/runtime/index.d.ts +89 -0
  376. package/dist/types/runtime/index.d.ts.map +1 -0
  377. package/dist/types/runtime/init.d.ts +28 -0
  378. package/dist/types/runtime/init.d.ts.map +1 -0
  379. package/dist/types/runtime/isolated.d.ts +14 -0
  380. package/dist/types/runtime/isolated.d.ts.map +1 -0
  381. package/dist/types/runtime/multichain.d.ts +13 -0
  382. package/dist/types/runtime/multichain.d.ts.map +1 -0
  383. package/dist/types/runtime/omnichain.d.ts +23 -0
  384. package/dist/types/runtime/omnichain.d.ts.map +1 -0
  385. package/dist/types/runtime/realtime.d.ts +93 -0
  386. package/dist/types/runtime/realtime.d.ts.map +1 -0
  387. package/dist/types/server/error.d.ts +5 -0
  388. package/dist/types/server/error.d.ts.map +1 -0
  389. package/dist/types/server/index.d.ts +13 -0
  390. package/dist/types/server/index.d.ts.map +1 -0
  391. package/dist/types/sync-historical/index.d.ts +36 -0
  392. package/dist/types/sync-historical/index.d.ts.map +1 -0
  393. package/dist/types/sync-realtime/bloom.d.ts +18 -0
  394. package/dist/types/sync-realtime/bloom.d.ts.map +1 -0
  395. package/dist/types/sync-realtime/index.d.ts +48 -0
  396. package/dist/types/sync-realtime/index.d.ts.map +1 -0
  397. package/dist/types/sync-store/encode.d.ts +25 -0
  398. package/dist/types/sync-store/encode.d.ts.map +1 -0
  399. package/dist/types/sync-store/index.d.ts +135 -0
  400. package/dist/types/sync-store/index.d.ts.map +1 -0
  401. package/dist/types/sync-store/migrations.d.ts +8 -0
  402. package/dist/types/sync-store/migrations.d.ts.map +1 -0
  403. package/dist/types/sync-store/schema.d.ts +1828 -0
  404. package/dist/types/sync-store/schema.d.ts.map +1 -0
  405. package/dist/types/types/db.d.ts +213 -0
  406. package/dist/types/types/db.d.ts.map +1 -0
  407. package/dist/types/types/eth.d.ts +196 -0
  408. package/dist/types/types/eth.d.ts.map +1 -0
  409. package/dist/types/types/utils.d.ts +38 -0
  410. package/dist/types/types/utils.d.ts.map +1 -0
  411. package/dist/types/types/virtual.d.ts +99 -0
  412. package/dist/types/types/virtual.d.ts.map +1 -0
  413. package/dist/types/ui/app.d.ts +22 -0
  414. package/dist/types/ui/app.d.ts.map +1 -0
  415. package/dist/types/ui/index.d.ts +5 -0
  416. package/dist/types/ui/index.d.ts.map +1 -0
  417. package/dist/types/ui/patch.d.ts +7 -0
  418. package/dist/types/ui/patch.d.ts.map +1 -0
  419. package/dist/types/utils/abi.d.ts +23 -0
  420. package/dist/types/utils/abi.d.ts.map +1 -0
  421. package/dist/types/utils/bigint.d.ts +15 -0
  422. package/dist/types/utils/bigint.d.ts.map +1 -0
  423. package/dist/types/utils/chains.d.ts +42 -0
  424. package/dist/types/utils/chains.d.ts.map +1 -0
  425. package/dist/types/utils/checkpoint.d.ts +52 -0
  426. package/dist/types/utils/checkpoint.d.ts.map +1 -0
  427. package/dist/types/utils/chunk.d.ts +2 -0
  428. package/dist/types/utils/chunk.d.ts.map +1 -0
  429. package/dist/types/utils/copy.d.ts +16 -0
  430. package/dist/types/utils/copy.d.ts.map +1 -0
  431. package/dist/types/utils/date.d.ts +7 -0
  432. package/dist/types/utils/date.d.ts.map +1 -0
  433. package/dist/types/utils/debug.d.ts +105 -0
  434. package/dist/types/utils/debug.d.ts.map +1 -0
  435. package/dist/types/utils/decodeAbiParameters.d.ts +28 -0
  436. package/dist/types/utils/decodeAbiParameters.d.ts.map +1 -0
  437. package/dist/types/utils/decodeEventLog.d.ts +12 -0
  438. package/dist/types/utils/decodeEventLog.d.ts.map +1 -0
  439. package/dist/types/utils/dedupe.d.ts +20 -0
  440. package/dist/types/utils/dedupe.d.ts.map +1 -0
  441. package/dist/types/utils/duplicates.d.ts +7 -0
  442. package/dist/types/utils/duplicates.d.ts.map +1 -0
  443. package/dist/types/utils/estimate.d.ts +11 -0
  444. package/dist/types/utils/estimate.d.ts.map +1 -0
  445. package/dist/types/utils/finality.d.ts +12 -0
  446. package/dist/types/utils/finality.d.ts.map +1 -0
  447. package/dist/types/utils/format.d.ts +3 -0
  448. package/dist/types/utils/format.d.ts.map +1 -0
  449. package/dist/types/utils/generators.d.ts +42 -0
  450. package/dist/types/utils/generators.d.ts.map +1 -0
  451. package/dist/types/utils/hash.d.ts +11 -0
  452. package/dist/types/utils/hash.d.ts.map +1 -0
  453. package/dist/types/utils/interval.d.ts +53 -0
  454. package/dist/types/utils/interval.d.ts.map +1 -0
  455. package/dist/types/utils/lowercase.d.ts +5 -0
  456. package/dist/types/utils/lowercase.d.ts.map +1 -0
  457. package/dist/types/utils/mutex.d.ts +5 -0
  458. package/dist/types/utils/mutex.d.ts.map +1 -0
  459. package/dist/types/utils/never.d.ts +2 -0
  460. package/dist/types/utils/never.d.ts.map +1 -0
  461. package/dist/types/utils/offset.d.ts +8 -0
  462. package/dist/types/utils/offset.d.ts.map +1 -0
  463. package/dist/types/utils/order.d.ts +2 -0
  464. package/dist/types/utils/order.d.ts.map +1 -0
  465. package/dist/types/utils/partition.d.ts +22 -0
  466. package/dist/types/utils/partition.d.ts.map +1 -0
  467. package/dist/types/utils/pg.d.ts +8 -0
  468. package/dist/types/utils/pg.d.ts.map +1 -0
  469. package/dist/types/utils/pglite.d.ts +25 -0
  470. package/dist/types/utils/pglite.d.ts.map +1 -0
  471. package/dist/types/utils/port.d.ts +5 -0
  472. package/dist/types/utils/port.d.ts.map +1 -0
  473. package/dist/types/utils/print.d.ts +2 -0
  474. package/dist/types/utils/print.d.ts.map +1 -0
  475. package/dist/types/utils/promiseAllSettledWithThrow.d.ts +8 -0
  476. package/dist/types/utils/promiseAllSettledWithThrow.d.ts.map +1 -0
  477. package/dist/types/utils/promiseWithResolvers.d.ts +10 -0
  478. package/dist/types/utils/promiseWithResolvers.d.ts.map +1 -0
  479. package/dist/types/utils/queue.d.ts +33 -0
  480. package/dist/types/utils/queue.d.ts.map +1 -0
  481. package/dist/types/utils/range.d.ts +8 -0
  482. package/dist/types/utils/range.d.ts.map +1 -0
  483. package/dist/types/utils/result.d.ts +17 -0
  484. package/dist/types/utils/result.d.ts.map +1 -0
  485. package/dist/types/utils/sql-parse.d.ts +21 -0
  486. package/dist/types/utils/sql-parse.d.ts.map +1 -0
  487. package/dist/types/utils/timer.d.ts +6 -0
  488. package/dist/types/utils/timer.d.ts.map +1 -0
  489. package/dist/types/utils/truncate.d.ts +9 -0
  490. package/dist/types/utils/truncate.d.ts.map +1 -0
  491. package/dist/types/utils/wait.d.ts +6 -0
  492. package/dist/types/utils/wait.d.ts.map +1 -0
  493. package/dist/types/utils/zipper.d.ts +36 -0
  494. package/dist/types/utils/zipper.d.ts.map +1 -0
  495. package/package.json +114 -0
  496. package/src/bin/commands/codegen.ts +56 -0
  497. package/src/bin/commands/createViews.ts +318 -0
  498. package/src/bin/commands/dev.ts +490 -0
  499. package/src/bin/commands/list.ts +208 -0
  500. package/src/bin/commands/prune.ts +322 -0
  501. package/src/bin/commands/serve.ts +236 -0
  502. package/src/bin/commands/start.ts +319 -0
  503. package/src/bin/isolatedController.ts +300 -0
  504. package/src/bin/isolatedWorker.ts +192 -0
  505. package/src/bin/ponder.ts +208 -0
  506. package/src/bin/utils/codegen.ts +32 -0
  507. package/src/bin/utils/exit.ts +112 -0
  508. package/src/build/config.ts +1141 -0
  509. package/src/build/factory.ts +147 -0
  510. package/src/build/index.ts +790 -0
  511. package/src/build/plugin.ts +58 -0
  512. package/src/build/pre.ts +114 -0
  513. package/src/build/schema.ts +358 -0
  514. package/src/build/stacktrace.ts +137 -0
  515. package/src/client/index.ts +551 -0
  516. package/src/config/address.ts +45 -0
  517. package/src/config/eventFilter.ts +33 -0
  518. package/src/config/index.ts +240 -0
  519. package/src/config/utilityTypes.ts +152 -0
  520. package/src/database/actions.ts +873 -0
  521. package/src/database/index.ts +1029 -0
  522. package/src/database/queryBuilder.ts +537 -0
  523. package/src/drizzle/bigint.ts +57 -0
  524. package/src/drizzle/bytes.ts +68 -0
  525. package/src/drizzle/hex.ts +58 -0
  526. package/src/drizzle/index.ts +40 -0
  527. package/src/drizzle/json.ts +159 -0
  528. package/src/drizzle/kit/index.ts +1348 -0
  529. package/src/drizzle/onchain.ts +476 -0
  530. package/src/drizzle/text.ts +77 -0
  531. package/src/graphql/graphiql.html.ts +59 -0
  532. package/src/graphql/index.ts +1351 -0
  533. package/src/graphql/json.ts +62 -0
  534. package/src/graphql/middleware.ts +115 -0
  535. package/src/index.ts +139 -0
  536. package/src/indexing/addStackTrace.ts +69 -0
  537. package/src/indexing/client.ts +1184 -0
  538. package/src/indexing/index.ts +976 -0
  539. package/src/indexing/profile.ts +771 -0
  540. package/src/indexing-store/cache.ts +1057 -0
  541. package/src/indexing-store/index.ts +628 -0
  542. package/src/indexing-store/profile.ts +557 -0
  543. package/src/indexing-store/utils.ts +162 -0
  544. package/src/internal/common.ts +15 -0
  545. package/src/internal/errors.ts +228 -0
  546. package/src/internal/logger.ts +252 -0
  547. package/src/internal/metrics.ts +1030 -0
  548. package/src/internal/options.ts +130 -0
  549. package/src/internal/shutdown.ts +32 -0
  550. package/src/internal/telemetry.ts +303 -0
  551. package/src/internal/types.ts +611 -0
  552. package/src/rpc/actions.ts +1344 -0
  553. package/src/rpc/http.ts +164 -0
  554. package/src/rpc/index.ts +959 -0
  555. package/src/runtime/events.ts +875 -0
  556. package/src/runtime/filter.ts +705 -0
  557. package/src/runtime/fragments.ts +674 -0
  558. package/src/runtime/historical.ts +1522 -0
  559. package/src/runtime/index.ts +569 -0
  560. package/src/runtime/init.ts +49 -0
  561. package/src/runtime/isolated.ts +775 -0
  562. package/src/runtime/multichain.ts +860 -0
  563. package/src/runtime/omnichain.ts +920 -0
  564. package/src/runtime/realtime.ts +1164 -0
  565. package/src/server/error.ts +68 -0
  566. package/src/server/index.ts +173 -0
  567. package/src/sync-historical/index.ts +1065 -0
  568. package/src/sync-realtime/bloom.ts +102 -0
  569. package/src/sync-realtime/index.ts +1304 -0
  570. package/src/sync-store/encode.ts +153 -0
  571. package/src/sync-store/index.ts +1633 -0
  572. package/src/sync-store/migrations.ts +1801 -0
  573. package/src/sync-store/schema.ts +248 -0
  574. package/src/types/db.ts +292 -0
  575. package/src/types/eth.ts +216 -0
  576. package/src/types/utils.ts +47 -0
  577. package/src/types/virtual.ts +244 -0
  578. package/src/types.d.ts +38 -0
  579. package/src/ui/app.ts +207 -0
  580. package/src/ui/index.ts +37 -0
  581. package/src/ui/patch.ts +204 -0
  582. package/src/utils/abi.ts +103 -0
  583. package/src/utils/bigint.ts +41 -0
  584. package/src/utils/chains.ts +22 -0
  585. package/src/utils/checkpoint.ts +203 -0
  586. package/src/utils/chunk.ts +7 -0
  587. package/src/utils/copy.ts +151 -0
  588. package/src/utils/date.ts +26 -0
  589. package/src/utils/debug.ts +110 -0
  590. package/src/utils/decodeAbiParameters.ts +428 -0
  591. package/src/utils/decodeEventLog.ts +100 -0
  592. package/src/utils/dedupe.ts +32 -0
  593. package/src/utils/duplicates.ts +19 -0
  594. package/src/utils/estimate.ts +27 -0
  595. package/src/utils/finality.ts +40 -0
  596. package/src/utils/format.ts +22 -0
  597. package/src/utils/generators.ts +157 -0
  598. package/src/utils/hash.ts +22 -0
  599. package/src/utils/interval.ts +212 -0
  600. package/src/utils/lowercase.ts +6 -0
  601. package/src/utils/mutex.ts +33 -0
  602. package/src/utils/never.ts +3 -0
  603. package/src/utils/offset.ts +133 -0
  604. package/src/utils/order.ts +16 -0
  605. package/src/utils/partition.ts +53 -0
  606. package/src/utils/pg.ts +230 -0
  607. package/src/utils/pglite.ts +97 -0
  608. package/src/utils/port.ts +34 -0
  609. package/src/utils/print.ts +31 -0
  610. package/src/utils/promiseAllSettledWithThrow.ts +27 -0
  611. package/src/utils/promiseWithResolvers.ts +20 -0
  612. package/src/utils/queue.ts +258 -0
  613. package/src/utils/range.ts +8 -0
  614. package/src/utils/result.ts +26 -0
  615. package/src/utils/sql-parse.ts +1477 -0
  616. package/src/utils/timer.ts +8 -0
  617. package/src/utils/truncate.ts +15 -0
  618. package/src/utils/wait.ts +8 -0
  619. package/src/utils/zipper.ts +80 -0
@@ -0,0 +1,1065 @@
1
+ import type { Common } from "@/internal/common.js";
2
+ import type {
3
+ BlockFilter,
4
+ Chain,
5
+ Factory,
6
+ FactoryId,
7
+ LogFilter,
8
+ SyncBlock,
9
+ SyncLog,
10
+ SyncTrace,
11
+ SyncTransaction,
12
+ SyncTransactionReceipt,
13
+ TraceFilter,
14
+ TransactionFilter,
15
+ TransferFilter,
16
+ } from "@/internal/types.js";
17
+ import {
18
+ debug_traceBlockByNumber,
19
+ eth_getBlockByNumber,
20
+ eth_getBlockReceipts,
21
+ eth_getLogs,
22
+ eth_getTransactionReceipt,
23
+ validateLogsAndBlock,
24
+ validateReceiptsAndBlock,
25
+ validateTracesAndBlock,
26
+ validateTransactionsAndBlock,
27
+ } from "@/rpc/actions.js";
28
+ import type { Rpc } from "@/rpc/index.js";
29
+ import {
30
+ getChildAddress,
31
+ getChildStartBlock,
32
+ isAddressFactory,
33
+ isAddressMatched,
34
+ isBlockFilterMatched,
35
+ isBlockInFilter,
36
+ isLogFactoryMatched,
37
+ isLogFilterMatched,
38
+ isTraceFilterMatched,
39
+ isTransactionFilterMatched,
40
+ isTransferFilterMatched,
41
+ } from "@/runtime/filter.js";
42
+ import type {
43
+ ChildAddresses,
44
+ IntervalWithFactory,
45
+ IntervalWithFilter,
46
+ } from "@/runtime/index.js";
47
+ import type { SyncStore } from "@/sync-store/index.js";
48
+ import { dedupe } from "@/utils/dedupe.js";
49
+ import {
50
+ type Interval,
51
+ getChunks,
52
+ intervalBounds,
53
+ intervalRange,
54
+ } from "@/utils/interval.js";
55
+ import { promiseAllSettledWithThrow } from "@/utils/promiseAllSettledWithThrow.js";
56
+ import { createQueue } from "@/utils/queue.js";
57
+ import { startClock } from "@/utils/timer.js";
58
+ import { getLogsRetryHelper } from "@ponder/utils";
59
+ import {
60
+ type Address,
61
+ type Hash,
62
+ type Hex,
63
+ type LogTopic,
64
+ type RpcError,
65
+ hexToNumber,
66
+ numberToHex,
67
+ toHex,
68
+ zeroHash,
69
+ } from "viem";
70
+
71
+ export type HistoricalSync = {
72
+ /**
73
+ * Sync block data that can be queried for a range of blocks (logs).
74
+ */
75
+ syncBlockRangeData(params: {
76
+ interval: Interval;
77
+ requiredIntervals: IntervalWithFilter[];
78
+ requiredFactoryIntervals: IntervalWithFactory[];
79
+ syncStore: SyncStore;
80
+ }): Promise<SyncLog[]>;
81
+ /**
82
+ * Sync block data that must be queried for a single block (block, transactions, receipts, traces).
83
+ */
84
+ syncBlockData(params: {
85
+ interval: Interval;
86
+ requiredIntervals: IntervalWithFilter[];
87
+ logs: SyncLog[];
88
+ syncStore: SyncStore;
89
+ }): Promise<SyncBlock | undefined>;
90
+ };
91
+
92
+ type CreateHistoricalSyncParameters = {
93
+ common: Common;
94
+ chain: Chain;
95
+ rpc: Rpc;
96
+ childAddresses: Map<FactoryId, Map<Address, number>>;
97
+ };
98
+
99
+ export const createHistoricalSync = (
100
+ args: CreateHistoricalSyncParameters,
101
+ ): HistoricalSync => {
102
+ /**
103
+ * Flag to fetch transaction receipts through eth_getBlockReceipts (true) or eth_getTransactionReceipt (false)
104
+ */
105
+ let isBlockReceipts = true;
106
+
107
+ /**
108
+ * Data about the range passed to "eth_getLogs" share among all log
109
+ * filters and log factories.
110
+ */
111
+ let logsRequestMetadata: {
112
+ /** Estimate optimal range to use for "eth_getLogs" requests */
113
+ estimatedRange: number;
114
+ /** Range suggested by an error message */
115
+ confirmedRange?: number;
116
+ } = {
117
+ estimatedRange: 500,
118
+ };
119
+
120
+ ////////
121
+ // Helper functions for sync tasks
122
+ ////////
123
+
124
+ type EthGetLogsParams = {
125
+ address: Address | Address[] | undefined;
126
+ topic0?: LogTopic;
127
+ topic1?: LogTopic;
128
+ topic2?: LogTopic;
129
+ topic3?: LogTopic;
130
+ interval: Interval;
131
+ };
132
+
133
+ /**
134
+ * Split "eth_getLogs" requests into ranges inferred from errors
135
+ * and batch requests.
136
+ */
137
+ const syncLogsDynamic = async (
138
+ { address, topic0, topic1, topic2, topic3, interval }: EthGetLogsParams,
139
+ context?: Parameters<Rpc["request"]>[1],
140
+ ): Promise<SyncLog[]> => {
141
+ const intervals = getChunks({
142
+ interval,
143
+ maxChunkSize:
144
+ args.chain.ethGetLogsBlockRange ??
145
+ logsRequestMetadata.confirmedRange ??
146
+ logsRequestMetadata.estimatedRange,
147
+ });
148
+
149
+ const topics = [
150
+ topic0 ?? null,
151
+ topic1 ?? null,
152
+ topic2 ?? null,
153
+ topic3 ?? null,
154
+ ];
155
+
156
+ // Note: the `topics` field is very fragile for many rpc providers, and
157
+ // cannot handle extra "null" topics
158
+
159
+ if (topics[3] === null) {
160
+ topics.pop();
161
+ if (topics[2] === null) {
162
+ topics.pop();
163
+ if (topics[1] === null) {
164
+ topics.pop();
165
+ if (topics[0] === null) {
166
+ topics.pop();
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ // Batch large arrays of addresses, handling arrays that are empty
173
+
174
+ let addressBatches: (Address | Address[] | undefined)[];
175
+
176
+ if (address === undefined) {
177
+ // no address (match all)
178
+ addressBatches = [undefined];
179
+ } else if (typeof address === "string") {
180
+ // single address
181
+ addressBatches = [address];
182
+ } else if (address.length === 0) {
183
+ // no address (factory with no children)
184
+ return [];
185
+ } else {
186
+ // many addresses
187
+ // Note: it is assumed that `address` is deduplicated
188
+ addressBatches = [];
189
+ for (let i = 0; i < address.length; i += 50) {
190
+ addressBatches.push(address.slice(i, i + 50));
191
+ }
192
+ }
193
+
194
+ const logs = await Promise.all(
195
+ intervals.flatMap((interval) =>
196
+ addressBatches.map((address) =>
197
+ eth_getLogs(
198
+ args.rpc,
199
+ [
200
+ {
201
+ address,
202
+ topics,
203
+ fromBlock: numberToHex(interval[0]),
204
+ toBlock: numberToHex(interval[1]),
205
+ },
206
+ ],
207
+ context,
208
+ ).catch((error) => {
209
+ // Note: skip eth_getLogs range retry logic if the chain
210
+ // has a custom block range.
211
+ if (args.chain.ethGetLogsBlockRange !== undefined) {
212
+ throw error;
213
+ }
214
+
215
+ const getLogsErrorResponse = getLogsRetryHelper({
216
+ params: [
217
+ {
218
+ address,
219
+ topics,
220
+ fromBlock: toHex(interval[0]),
221
+ toBlock: toHex(interval[1]),
222
+ },
223
+ ],
224
+ error: error as RpcError,
225
+ });
226
+
227
+ if (getLogsErrorResponse.shouldRetry === false) throw error;
228
+
229
+ const range =
230
+ hexToNumber(getLogsErrorResponse.ranges[0]!.toBlock) -
231
+ hexToNumber(getLogsErrorResponse.ranges[0]!.fromBlock);
232
+
233
+ args.common.logger.debug({
234
+ msg: "Updated eth_getLogs range",
235
+ chain: args.chain.name,
236
+ chain_id: args.chain.id,
237
+ range,
238
+ });
239
+
240
+ logsRequestMetadata = {
241
+ estimatedRange: range,
242
+ confirmedRange: getLogsErrorResponse.isSuggestedRange
243
+ ? range
244
+ : undefined,
245
+ };
246
+
247
+ return syncLogsDynamic(
248
+ { address, topic0, topic1, topic2, topic3, interval },
249
+ context,
250
+ );
251
+ }),
252
+ ),
253
+ ),
254
+ ).then((logs) => logs.flat());
255
+
256
+ /**
257
+ * Dynamically increase the range used in "eth_getLogs" if an
258
+ * error has been received but the error didn't suggest a range.
259
+ */
260
+
261
+ if (logsRequestMetadata.confirmedRange === undefined) {
262
+ logsRequestMetadata.estimatedRange = Math.round(
263
+ logsRequestMetadata.estimatedRange * 1.05,
264
+ );
265
+ }
266
+
267
+ return logs;
268
+ };
269
+
270
+ const syncTransactionReceipts = async (
271
+ block: SyncBlock,
272
+ transactionHashes: Set<Hash>,
273
+ context?: Parameters<Rpc["request"]>[1],
274
+ ): Promise<SyncTransactionReceipt[]> => {
275
+ if (transactionHashes.size === 0) {
276
+ return [];
277
+ }
278
+
279
+ if (isBlockReceipts === false) {
280
+ const transactionReceipts = await Promise.all(
281
+ Array.from(transactionHashes).map(async (hash) => {
282
+ const receipt = await eth_getTransactionReceipt(
283
+ args.rpc,
284
+ [hash],
285
+ context,
286
+ );
287
+
288
+ validateReceiptsAndBlock(
289
+ [receipt],
290
+ block,
291
+ {
292
+ method: "eth_getTransactionReceipt",
293
+ params: [hash],
294
+ },
295
+ {
296
+ method: "eth_getBlockByNumber",
297
+ params: [block.number, true],
298
+ },
299
+ );
300
+
301
+ return receipt;
302
+ }),
303
+ );
304
+
305
+ return transactionReceipts;
306
+ }
307
+
308
+ let blockReceipts: SyncTransactionReceipt[];
309
+ try {
310
+ blockReceipts = await eth_getBlockReceipts(
311
+ args.rpc,
312
+ [block.hash],
313
+ context,
314
+ );
315
+ } catch (_error) {
316
+ const error = _error as Error;
317
+ args.common.logger.warn({
318
+ msg: "Caught eth_getBlockReceipts error, switching to eth_getTransactionReceipt method",
319
+ action: "fetch_block_data",
320
+ chain: args.chain.name,
321
+ chain_id: args.chain.id,
322
+ error,
323
+ });
324
+
325
+ isBlockReceipts = false;
326
+ return syncTransactionReceipts(block, transactionHashes, context);
327
+ }
328
+
329
+ validateReceiptsAndBlock(
330
+ blockReceipts,
331
+ block,
332
+ {
333
+ method: "eth_getBlockReceipts",
334
+ params: [block.hash],
335
+ },
336
+ {
337
+ method: "eth_getBlockByNumber",
338
+ params: [block.number, true],
339
+ },
340
+ );
341
+
342
+ const transactionReceipts = blockReceipts.filter((receipt) =>
343
+ transactionHashes.has(receipt.transactionHash),
344
+ );
345
+
346
+ return transactionReceipts;
347
+ };
348
+
349
+ /**
350
+ * Fetch child addresses for `factory` within `interval`
351
+ *
352
+ * @dev Newly fetched child addresses are added into `args.childAddresses`
353
+ */
354
+ const syncAddressFactory = async (
355
+ factory: Factory,
356
+ interval: Interval,
357
+ context?: Parameters<Rpc["request"]>[1],
358
+ ): Promise<Map<Address, number>> => {
359
+ const logs = await syncLogsDynamic(
360
+ {
361
+ address: factory.address,
362
+ topic0: factory.eventSelector,
363
+ interval,
364
+ },
365
+ context,
366
+ );
367
+
368
+ const childAddresses = new Map<Address, number>();
369
+ const childAddressesRecord = args.childAddresses.get(factory.id)!;
370
+
371
+ const childAddressDecodeFailureIds = new Set<string>();
372
+ let childAddressDecodeFailureCount = 0;
373
+ let childAddressDecodeSuccessCount = 0;
374
+
375
+ for (const log of logs) {
376
+ if (isLogFactoryMatched({ factory, log })) {
377
+ let address: Address;
378
+ try {
379
+ address = getChildAddress({ log, factory });
380
+ childAddressDecodeSuccessCount++;
381
+ } catch (error) {
382
+ if (factory.address === undefined) {
383
+ childAddressDecodeFailureCount++;
384
+ if (childAddressDecodeFailureIds.has(factory.id) === false) {
385
+ childAddressDecodeFailureIds.add(factory.id);
386
+ args.common.logger.debug({
387
+ msg: "Failed to extract child address from log matched by factory using the provided ABI item",
388
+ chain: args.chain.name,
389
+ chain_id: args.chain.id,
390
+ factory: factory.sourceId,
391
+ block_number: hexToNumber(log.blockNumber),
392
+ log_index: hexToNumber(log.logIndex),
393
+ data: log.data,
394
+ topics: JSON.stringify(log.topics),
395
+ });
396
+ }
397
+ continue;
398
+ } else {
399
+ throw error;
400
+ }
401
+ }
402
+ const existingBlockNumber = childAddressesRecord.get(address);
403
+ // Use childStartBlock from event field or static config, fall back to log's block number
404
+ const childStartBlock = getChildStartBlock({ log, factory });
405
+ const newBlockNumber = childStartBlock ?? hexToNumber(log.blockNumber);
406
+
407
+ if (
408
+ existingBlockNumber === undefined ||
409
+ existingBlockNumber > newBlockNumber
410
+ ) {
411
+ childAddresses.set(address, newBlockNumber);
412
+ childAddressesRecord.set(address, newBlockNumber);
413
+ }
414
+ }
415
+ }
416
+
417
+ if (childAddressDecodeFailureCount > 0) {
418
+ args.common.logger.debug({
419
+ msg: "Logs matched by factory contained child addresses that could not be extracted",
420
+ failure_count: childAddressDecodeFailureCount,
421
+ success_count: childAddressDecodeSuccessCount,
422
+ });
423
+ }
424
+
425
+ return childAddresses;
426
+ };
427
+
428
+ return {
429
+ async syncBlockRangeData({
430
+ interval,
431
+ requiredIntervals,
432
+ requiredFactoryIntervals,
433
+ syncStore,
434
+ }) {
435
+ const context = {
436
+ logger: args.common.logger.child({ action: "fetch_block_data" }),
437
+ };
438
+ const endClock = startClock();
439
+ const childAddresses: ChildAddresses = new Map();
440
+
441
+ // Dedupe factory intervals by factory id
442
+
443
+ const factoryIntervalsById: Map<
444
+ Factory["id"],
445
+ { factory: Factory; interval: Interval }
446
+ > = new Map();
447
+
448
+ for (const { factory, interval } of requiredFactoryIntervals) {
449
+ if (factoryIntervalsById.has(factory.id)) {
450
+ const existingInterval = factoryIntervalsById.get(
451
+ factory.id,
452
+ )!.interval;
453
+
454
+ factoryIntervalsById.get(factory.id)!.interval = intervalBounds([
455
+ existingInterval,
456
+ interval,
457
+ ]);
458
+ } else {
459
+ factoryIntervalsById.set(factory.id, { factory, interval });
460
+ }
461
+ }
462
+
463
+ requiredFactoryIntervals = Array.from(factoryIntervalsById.values());
464
+
465
+ await Promise.all(
466
+ requiredFactoryIntervals.map(async ({ factory, interval }) => {
467
+ childAddresses.set(
468
+ factory.id,
469
+ await syncAddressFactory(factory, interval, context)!,
470
+ );
471
+ }),
472
+ );
473
+
474
+ const mergedEthGetLogsParams: Map<string, EthGetLogsParams> = new Map();
475
+ const singleEthGetLogsParams: EthGetLogsParams[] = [];
476
+
477
+ for (const { filter, interval } of requiredIntervals) {
478
+ if (filter.type !== "log") continue;
479
+
480
+ const hasAddress = filter.address !== undefined;
481
+ const hasTopic1 = filter.topic1 !== undefined;
482
+ const hasTopic2 = filter.topic2 !== undefined;
483
+ const hasTopic3 = filter.topic3 !== undefined;
484
+
485
+ if (hasAddress === false || hasTopic1 || hasTopic2 || hasTopic3) {
486
+ if (isAddressFactory(filter.address)) {
487
+ const childAddresses = args.childAddresses.get(filter.address.id)!;
488
+ singleEthGetLogsParams.push({
489
+ address:
490
+ childAddresses.size >=
491
+ args.common.options.factoryAddressCountThreshold
492
+ ? undefined
493
+ : Array.from(childAddresses.keys()),
494
+ topic0: filter.topic0,
495
+ topic1: filter.topic1,
496
+ topic2: filter.topic2,
497
+ topic3: filter.topic3,
498
+ interval,
499
+ });
500
+ } else {
501
+ singleEthGetLogsParams.push({
502
+ address: filter.address,
503
+ topic0: filter.topic0,
504
+ topic1: filter.topic1,
505
+ topic2: filter.topic2,
506
+ topic3: filter.topic3,
507
+ interval,
508
+ });
509
+ }
510
+
511
+ continue;
512
+ }
513
+
514
+ let addressKey: string;
515
+ if (isAddressFactory(filter.address)) {
516
+ addressKey = filter.address.id;
517
+ } else if (Array.isArray(filter.address)) {
518
+ addressKey = filter.address.join("_");
519
+ } else {
520
+ addressKey = filter.address as Address;
521
+ }
522
+
523
+ if (mergedEthGetLogsParams.has(addressKey) === false) {
524
+ if (isAddressFactory(filter.address)) {
525
+ const childAddresses = args.childAddresses.get(filter.address.id)!;
526
+ mergedEthGetLogsParams.set(addressKey, {
527
+ address:
528
+ childAddresses.size >=
529
+ args.common.options.factoryAddressCountThreshold
530
+ ? undefined
531
+ : Array.from(childAddresses.keys()),
532
+ topic0: filter.topic0,
533
+ topic1: filter.topic1,
534
+ topic2: filter.topic2,
535
+ topic3: filter.topic3,
536
+ interval,
537
+ });
538
+ } else {
539
+ mergedEthGetLogsParams.set(addressKey, {
540
+ address: filter.address,
541
+ topic0: filter.topic0,
542
+ topic1: filter.topic1,
543
+ topic2: filter.topic2,
544
+ topic3: filter.topic3,
545
+ interval,
546
+ });
547
+ }
548
+ } else {
549
+ const existingInterval =
550
+ mergedEthGetLogsParams.get(addressKey)!.interval;
551
+ const existingTopic0 = mergedEthGetLogsParams.get(addressKey)!
552
+ .topic0 as Hex | Hex[];
553
+
554
+ if (Array.isArray(existingTopic0)) {
555
+ if (existingTopic0.includes(filter.topic0) === false) {
556
+ mergedEthGetLogsParams.get(addressKey)!.topic0 = [
557
+ ...existingTopic0,
558
+ filter.topic0,
559
+ ];
560
+ }
561
+ } else {
562
+ if (existingTopic0 !== filter.topic0) {
563
+ mergedEthGetLogsParams.get(addressKey)!.topic0 = [
564
+ existingTopic0,
565
+ filter.topic0,
566
+ ];
567
+ }
568
+ }
569
+
570
+ mergedEthGetLogsParams.get(addressKey)!.interval = intervalBounds([
571
+ existingInterval,
572
+ interval,
573
+ ]);
574
+ }
575
+ }
576
+
577
+ const ethGetLogsParams = dedupe(
578
+ [
579
+ ...singleEthGetLogsParams,
580
+ ...Array.from(mergedEthGetLogsParams.values()),
581
+ ],
582
+ (params) => JSON.stringify(params),
583
+ );
584
+
585
+ let logs: SyncLog[] = [];
586
+
587
+ await Promise.all(
588
+ ethGetLogsParams.map(async (params) => {
589
+ const _logs = await syncLogsDynamic(params, context);
590
+ logs.push(..._logs);
591
+ }),
592
+ );
593
+
594
+ // Remove duplicate logs that may have resulted from intersecting
595
+ // filters.
596
+ logs = dedupe(logs, (log) => `${log.blockNumber}_${log.logIndex}`);
597
+
598
+ for (const log of logs) {
599
+ if (log.transactionHash === zeroHash) {
600
+ args.common.logger.warn({
601
+ msg: "Detected log with empty transaction hash. This is expected for some chains like ZKsync.",
602
+ action: "fetch_block_data",
603
+ chain: args.chain.name,
604
+ chain_id: args.chain.id,
605
+ number: hexToNumber(log.blockNumber),
606
+ hash: log.blockHash,
607
+ logIndex: hexToNumber(log.logIndex),
608
+ });
609
+ }
610
+ }
611
+
612
+ let childAddressCount = 0;
613
+ for (const { size } of childAddresses.values()) {
614
+ childAddressCount += size;
615
+ }
616
+
617
+ args.common.logger.debug(
618
+ {
619
+ msg: "Fetched block range data",
620
+ chain: args.chain.name,
621
+ chain_id: args.chain.id,
622
+ block_range: JSON.stringify(interval),
623
+ log_count: logs.length,
624
+ child_address_count: childAddressCount,
625
+ duration: endClock(),
626
+ },
627
+ ["chain", "block_range"],
628
+ );
629
+
630
+ await promiseAllSettledWithThrow(
631
+ Array.from(childAddresses.entries()).map(
632
+ ([factoryId, childAddresses]) =>
633
+ syncStore.insertChildAddresses(
634
+ {
635
+ factory: factoryIntervalsById.get(factoryId)!.factory,
636
+ childAddresses,
637
+ chainId: args.chain.id,
638
+ },
639
+ context,
640
+ ),
641
+ ),
642
+ );
643
+
644
+ return logs;
645
+ },
646
+ async syncBlockData({ syncStore, interval, requiredIntervals, logs }) {
647
+ const context = {
648
+ logger: args.common.logger.child({ action: "fetch_block_data" }),
649
+ };
650
+ const endClock = startClock();
651
+
652
+ const blockFilters: BlockFilter[] = [];
653
+ const transactionFilters: TransactionFilter[] = [];
654
+ const traceFilters: TraceFilter[] = [];
655
+ const logFilters: LogFilter[] = [];
656
+ const transferFilters: TransferFilter[] = [];
657
+
658
+ for (const { filter } of requiredIntervals) {
659
+ switch (filter.type) {
660
+ case "block": {
661
+ blockFilters.push(filter as BlockFilter);
662
+ break;
663
+ }
664
+ case "transaction": {
665
+ transactionFilters.push(filter as TransactionFilter);
666
+ break;
667
+ }
668
+ case "trace": {
669
+ traceFilters.push(filter as TraceFilter);
670
+ break;
671
+ }
672
+ case "log": {
673
+ logFilters.push(filter as LogFilter);
674
+ break;
675
+ }
676
+ case "transfer": {
677
+ transferFilters.push(filter as TransferFilter);
678
+ break;
679
+ }
680
+ }
681
+ }
682
+
683
+ const perBlockLogs = new Map<number, SyncLog[]>();
684
+ for (const log of logs) {
685
+ const blockNumber = hexToNumber(log.blockNumber);
686
+ if (perBlockLogs.has(blockNumber) === false) {
687
+ perBlockLogs.set(blockNumber, []);
688
+ }
689
+ perBlockLogs.get(blockNumber)!.push(log);
690
+ }
691
+
692
+ let closestToTipBlock: SyncBlock | undefined;
693
+
694
+ const syncBlockData = async (blockNumber: number) => {
695
+ let block: SyncBlock | undefined;
696
+
697
+ const requiredTransactions = new Set<Hash>();
698
+ const requiredTransactionReceipts = new Set<Hash>();
699
+
700
+ ////////
701
+ // Logs
702
+ ////////
703
+
704
+ let logs: SyncLog[] = [];
705
+ if (perBlockLogs.has(blockNumber)) {
706
+ block = await eth_getBlockByNumber(
707
+ args.rpc,
708
+ [numberToHex(blockNumber), true],
709
+ context,
710
+ );
711
+
712
+ logs = perBlockLogs.get(blockNumber)!.filter((log) => {
713
+ let isMatched = false;
714
+
715
+ for (const filter of logFilters) {
716
+ if (
717
+ isLogFilterMatched({ filter, log }) &&
718
+ (isAddressFactory(filter.address)
719
+ ? isAddressMatched({
720
+ address: log.address,
721
+ blockNumber,
722
+ childAddresses: args.childAddresses.get(
723
+ filter.address.id,
724
+ )!,
725
+ })
726
+ : true)
727
+ ) {
728
+ isMatched = true;
729
+
730
+ requiredTransactions.add(log.transactionHash);
731
+ if (filter.hasTransactionReceipt) {
732
+ requiredTransactionReceipts.add(log.transactionHash);
733
+
734
+ // skip to next log
735
+ break;
736
+ }
737
+ }
738
+ }
739
+
740
+ return isMatched;
741
+ });
742
+
743
+ if (logs.length > 0) {
744
+ // Note: `logsRequest` could be more accurate by tracking the exact
745
+ // request made to include `address` and `topics`.
746
+ validateLogsAndBlock(
747
+ logs,
748
+ block,
749
+ {
750
+ method: "eth_getLogs",
751
+ params: [
752
+ {
753
+ fromBlock: toHex(blockNumber),
754
+ toBlock: toHex(blockNumber),
755
+ },
756
+ ],
757
+ },
758
+ {
759
+ method: "eth_getBlockByNumber",
760
+ params: [toHex(blockNumber), true],
761
+ },
762
+ );
763
+ }
764
+ }
765
+
766
+ ////////
767
+ // Traces
768
+ ////////
769
+
770
+ const shouldRequestTraces =
771
+ traceFilters.some((filter) => isBlockInFilter(filter, blockNumber)) ||
772
+ transferFilters.some((filter) =>
773
+ isBlockInFilter(filter, blockNumber),
774
+ );
775
+
776
+ let traces: SyncTrace[] = [];
777
+ if (shouldRequestTraces) {
778
+ if (block === undefined) {
779
+ [block, traces] = await Promise.all([
780
+ eth_getBlockByNumber(
781
+ args.rpc,
782
+ [numberToHex(blockNumber), true],
783
+ context,
784
+ ),
785
+ debug_traceBlockByNumber(
786
+ args.rpc,
787
+ [numberToHex(blockNumber), { tracer: "callTracer" }],
788
+ context,
789
+ ),
790
+ ]);
791
+ } else {
792
+ traces = await debug_traceBlockByNumber(
793
+ args.rpc,
794
+ [numberToHex(blockNumber), { tracer: "callTracer" }],
795
+ context,
796
+ );
797
+ }
798
+
799
+ traces = traces.filter((trace) => {
800
+ let isMatched = false;
801
+ for (const filter of transferFilters) {
802
+ if (
803
+ isTransferFilterMatched({
804
+ filter,
805
+ trace: trace.trace,
806
+ block: { number: BigInt(blockNumber) },
807
+ }) &&
808
+ (isAddressFactory(filter.fromAddress)
809
+ ? isAddressMatched({
810
+ address: trace.trace.from,
811
+ blockNumber,
812
+ childAddresses: args.childAddresses.get(
813
+ filter.fromAddress.id,
814
+ )!,
815
+ })
816
+ : true) &&
817
+ (isAddressFactory(filter.toAddress)
818
+ ? isAddressMatched({
819
+ address: trace.trace.to,
820
+ blockNumber,
821
+ childAddresses: args.childAddresses.get(
822
+ filter.toAddress.id,
823
+ )!,
824
+ })
825
+ : true)
826
+ ) {
827
+ isMatched = true;
828
+ requiredTransactions.add(trace.transactionHash);
829
+ if (filter.hasTransactionReceipt) {
830
+ requiredTransactionReceipts.add(trace.transactionHash);
831
+ // skip to next trace
832
+ break;
833
+ }
834
+ }
835
+ }
836
+
837
+ for (const filter of traceFilters) {
838
+ if (
839
+ isTraceFilterMatched({
840
+ filter,
841
+ trace: trace.trace,
842
+ block: { number: BigInt(blockNumber) },
843
+ }) &&
844
+ (isAddressFactory(filter.fromAddress)
845
+ ? isAddressMatched({
846
+ address: trace.trace.from,
847
+ blockNumber,
848
+ childAddresses: args.childAddresses.get(
849
+ filter.fromAddress.id,
850
+ )!,
851
+ })
852
+ : true) &&
853
+ (isAddressFactory(filter.toAddress)
854
+ ? isAddressMatched({
855
+ address: trace.trace.to,
856
+ blockNumber,
857
+ childAddresses: args.childAddresses.get(
858
+ filter.toAddress.id,
859
+ )!,
860
+ })
861
+ : true)
862
+ ) {
863
+ isMatched = true;
864
+ requiredTransactions.add(trace.transactionHash);
865
+ if (filter.hasTransactionReceipt) {
866
+ requiredTransactionReceipts.add(trace.transactionHash);
867
+ // skip to next trace
868
+ break;
869
+ }
870
+ }
871
+ }
872
+
873
+ return isMatched;
874
+ });
875
+
876
+ if (traces.length > 0) {
877
+ validateTracesAndBlock(
878
+ traces,
879
+ block,
880
+ {
881
+ method: "debug_traceBlockByNumber",
882
+ params: [toHex(blockNumber), { tracer: "callTracer" }],
883
+ },
884
+ {
885
+ method: "eth_getBlockByNumber",
886
+ params: [toHex(blockNumber), true],
887
+ },
888
+ );
889
+ }
890
+ }
891
+
892
+ ////////
893
+ // Block
894
+ ////////
895
+
896
+ if (
897
+ block === undefined &&
898
+ blockFilters.some((filter) =>
899
+ isBlockFilterMatched({
900
+ filter,
901
+ block: { number: BigInt(blockNumber) },
902
+ }),
903
+ )
904
+ ) {
905
+ block = await eth_getBlockByNumber(
906
+ args.rpc,
907
+ [numberToHex(blockNumber), true],
908
+ context,
909
+ );
910
+ }
911
+
912
+ ////////
913
+ // Transactions
914
+ ////////
915
+
916
+ // Return early if no data is fetched
917
+ if (
918
+ block === undefined &&
919
+ transactionFilters.some((filter) =>
920
+ isBlockInFilter(filter, blockNumber),
921
+ ) === false
922
+ ) {
923
+ return;
924
+ }
925
+
926
+ if (block === undefined) {
927
+ block = await eth_getBlockByNumber(
928
+ args.rpc,
929
+ [numberToHex(blockNumber), true],
930
+ context,
931
+ );
932
+ }
933
+
934
+ if (
935
+ closestToTipBlock === undefined ||
936
+ hexToNumber(block.number) > hexToNumber(closestToTipBlock.number)
937
+ ) {
938
+ closestToTipBlock = block;
939
+ }
940
+
941
+ const transactions = block.transactions.filter((transaction) => {
942
+ let isMatched = requiredTransactions.has(transaction.hash);
943
+ for (const filter of transactionFilters) {
944
+ if (
945
+ isTransactionFilterMatched({ filter, transaction }) &&
946
+ (isAddressFactory(filter.fromAddress)
947
+ ? isAddressMatched({
948
+ address: transaction.from,
949
+ blockNumber,
950
+ childAddresses: args.childAddresses.get(
951
+ filter.fromAddress.id,
952
+ )!,
953
+ })
954
+ : true) &&
955
+ (isAddressFactory(filter.toAddress)
956
+ ? isAddressMatched({
957
+ address: transaction.to ?? undefined,
958
+ blockNumber,
959
+ childAddresses: args.childAddresses.get(
960
+ filter.toAddress.id,
961
+ )!,
962
+ })
963
+ : true)
964
+ ) {
965
+ requiredTransactionReceipts.add(transaction.hash);
966
+ isMatched = true;
967
+ }
968
+ }
969
+ return isMatched;
970
+ });
971
+
972
+ if (transactions.length > 0) {
973
+ validateTransactionsAndBlock(block, {
974
+ method: "eth_getBlockByNumber",
975
+ params: [toHex(blockNumber), true],
976
+ });
977
+ }
978
+
979
+ const transactionsByHash = new Map<Hash, SyncTransaction>();
980
+ for (const transaction of transactions) {
981
+ transactionsByHash.set(transaction.hash, transaction);
982
+ }
983
+
984
+ ////////
985
+ // Transaction Receipts
986
+ ////////
987
+
988
+ const transactionReceipts = await syncTransactionReceipts(
989
+ block,
990
+ requiredTransactionReceipts,
991
+ );
992
+
993
+ blockCount += 1;
994
+ transactionCount += transactions.length;
995
+ receiptCount += transactionReceipts.length;
996
+ traceCount += traces.length;
997
+
998
+ // Free memory of all unused transactions
999
+ block.transactions = transactions;
1000
+
1001
+ await promiseAllSettledWithThrow([
1002
+ syncStore.insertBlocks({ blocks: [block], chainId: args.chain.id }),
1003
+ syncStore.insertTransactions({
1004
+ transactions,
1005
+ chainId: args.chain.id,
1006
+ }),
1007
+ syncStore.insertTransactionReceipts({
1008
+ transactionReceipts,
1009
+ chainId: args.chain.id,
1010
+ }),
1011
+ syncStore.insertTraces({
1012
+ traces: traces.map((trace) => ({
1013
+ trace,
1014
+ block: block!,
1015
+ transaction: transactionsByHash.get(trace.transactionHash)!,
1016
+ })),
1017
+ chainId: args.chain.id,
1018
+ }),
1019
+ syncStore.insertLogs({ logs, chainId: args.chain.id }),
1020
+ ]);
1021
+ };
1022
+
1023
+ let blockCount = 0;
1024
+ let transactionCount = 0;
1025
+ let receiptCount = 0;
1026
+ let traceCount = 0;
1027
+
1028
+ // Same memory usage as `sync-realtime`.
1029
+ const MAX_BLOCKS_IN_MEM = Math.max(
1030
+ args.chain.finalityBlockCount * 2,
1031
+ 100,
1032
+ );
1033
+
1034
+ if (requiredIntervals.length > 0) {
1035
+ const queue = createQueue({
1036
+ browser: false,
1037
+ initialStart: true,
1038
+ concurrency: MAX_BLOCKS_IN_MEM,
1039
+ worker: syncBlockData,
1040
+ });
1041
+
1042
+ await Promise.all(
1043
+ intervalRange(interval).map((blockNumber) => queue.add(blockNumber)),
1044
+ );
1045
+ }
1046
+
1047
+ args.common.logger.debug(
1048
+ {
1049
+ msg: "Fetched block data",
1050
+ chain: args.chain.name,
1051
+ chain_id: args.chain.id,
1052
+ block_range: JSON.stringify(interval),
1053
+ block_count: blockCount,
1054
+ transaction_count: transactionCount,
1055
+ receipt_count: receiptCount,
1056
+ trace_count: traceCount,
1057
+ duration: endClock(),
1058
+ },
1059
+ ["chain", "block_range"],
1060
+ );
1061
+
1062
+ return closestToTipBlock;
1063
+ },
1064
+ };
1065
+ };