gate-evm-tools 1.0.26 → 1.0.28

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 (338) hide show
  1. package/README.md +14 -0
  2. package/bin/workflow.cjs +19 -0
  3. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  4. package/dist/core/BytecodeChecker.js +16 -1
  5. package/dist/core/BytecodeChecker.js.map +1 -1
  6. package/dist/core/legacyProxyArtifact.d.ts +6 -0
  7. package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
  8. package/dist/core/legacyProxyArtifact.js +36 -0
  9. package/dist/core/legacyProxyArtifact.js.map +1 -0
  10. package/dist-runtime/config/hardhatAdapters.d.ts +7 -0
  11. package/dist-runtime/config/hardhatAdapters.js +61 -0
  12. package/dist-runtime/config/hardhatAdapters.js.map +1 -0
  13. package/dist-runtime/config/networks.d.ts +32 -0
  14. package/dist-runtime/config/networks.js +275 -0
  15. package/dist-runtime/config/networks.js.map +1 -0
  16. package/dist-runtime/config/openzeppelin.d.ts +28 -0
  17. package/dist-runtime/config/openzeppelin.js +144 -0
  18. package/dist-runtime/config/openzeppelin.js.map +1 -0
  19. package/dist-runtime/config/rpc.d.ts +7 -0
  20. package/dist-runtime/config/rpc.js +19 -0
  21. package/dist-runtime/config/rpc.js.map +1 -0
  22. package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
  23. package/dist-runtime/config/zksyncSolcPath.js +61 -0
  24. package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
  25. package/dist-runtime/migrate.d.ts +13 -0
  26. package/dist-runtime/migrate.js +208 -0
  27. package/dist-runtime/migrate.js.map +1 -0
  28. package/dist-runtime/package.json +1 -0
  29. package/dist-runtime/projectHardhat.d.ts +4 -0
  30. package/dist-runtime/projectHardhat.js +16 -0
  31. package/dist-runtime/projectHardhat.js.map +1 -0
  32. package/dist-runtime/runtime-identity.json +4 -0
  33. package/dist-runtime/template-migration.json +293 -0
  34. package/dist-runtime/workflow/checkCode.d.ts +1 -0
  35. package/dist-runtime/workflow/checkCode.js +16 -0
  36. package/dist-runtime/workflow/checkCode.js.map +1 -0
  37. package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
  38. package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
  39. package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
  40. package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
  41. package/dist-runtime/workflow/checkCodePlan.js +11 -0
  42. package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
  43. package/dist-runtime/workflow/cli.d.ts +1 -0
  44. package/dist-runtime/workflow/cli.js +302 -0
  45. package/dist-runtime/workflow/cli.js.map +1 -0
  46. package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
  47. package/dist-runtime/workflow/commitContractInfo.js +64 -0
  48. package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
  49. package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
  50. package/dist-runtime/workflow/create2Hashes.js +76 -0
  51. package/dist-runtime/workflow/create2Hashes.js.map +1 -0
  52. package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
  53. package/dist-runtime/workflow/forkSourceProxy.js +151 -0
  54. package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
  55. package/dist-runtime/workflow/importState.d.ts +1 -0
  56. package/dist-runtime/workflow/importState.js +193 -0
  57. package/dist-runtime/workflow/importState.js.map +1 -0
  58. package/dist-runtime/workflow/lib/authority.d.ts +28 -0
  59. package/dist-runtime/workflow/lib/authority.js +122 -0
  60. package/dist-runtime/workflow/lib/authority.js.map +1 -0
  61. package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
  62. package/dist-runtime/workflow/lib/calldata.js +8 -0
  63. package/dist-runtime/workflow/lib/calldata.js.map +1 -0
  64. package/dist-runtime/workflow/lib/calls.d.ts +23 -0
  65. package/dist-runtime/workflow/lib/calls.js +316 -0
  66. package/dist-runtime/workflow/lib/calls.js.map +1 -0
  67. package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
  68. package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
  69. package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
  70. package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
  71. package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
  72. package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
  73. package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
  74. package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
  75. package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
  76. package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
  77. package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
  78. package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
  79. package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
  80. package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
  81. package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
  82. package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
  83. package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
  84. package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
  85. package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
  86. package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
  87. package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
  88. package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
  89. package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
  90. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
  91. package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
  92. package/dist-runtime/workflow/lib/cliTool.js +25 -0
  93. package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
  94. package/dist-runtime/workflow/lib/config.d.ts +33 -0
  95. package/dist-runtime/workflow/lib/config.js +100 -0
  96. package/dist-runtime/workflow/lib/config.js.map +1 -0
  97. package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
  98. package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
  99. package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
  100. package/dist-runtime/workflow/lib/controlledMulticallAbi.d.ts +2 -0
  101. package/dist-runtime/workflow/lib/controlledMulticallAbi.js +10 -0
  102. package/dist-runtime/workflow/lib/controlledMulticallAbi.js.map +1 -0
  103. package/dist-runtime/workflow/lib/create2.d.ts +49 -0
  104. package/dist-runtime/workflow/lib/create2.js +194 -0
  105. package/dist-runtime/workflow/lib/create2.js.map +1 -0
  106. package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
  107. package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
  108. package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
  109. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
  110. package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
  111. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
  112. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
  113. package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
  114. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
  115. package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
  116. package/dist-runtime/workflow/lib/deployments.js +240 -0
  117. package/dist-runtime/workflow/lib/deployments.js.map +1 -0
  118. package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
  119. package/dist-runtime/workflow/lib/erc1967.js +29 -0
  120. package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
  121. package/dist-runtime/workflow/lib/errors.d.ts +6 -0
  122. package/dist-runtime/workflow/lib/errors.js +77 -0
  123. package/dist-runtime/workflow/lib/errors.js.map +1 -0
  124. package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
  125. package/dist-runtime/workflow/lib/executionId.js +26 -0
  126. package/dist-runtime/workflow/lib/executionId.js.map +1 -0
  127. package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
  128. package/dist-runtime/workflow/lib/executionPlan.js +450 -0
  129. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
  130. package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
  131. package/dist-runtime/workflow/lib/executionProgress.js +100 -0
  132. package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
  133. package/dist-runtime/workflow/lib/external.d.ts +62 -0
  134. package/dist-runtime/workflow/lib/external.js +282 -0
  135. package/dist-runtime/workflow/lib/external.js.map +1 -0
  136. package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
  137. package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
  138. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
  139. package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
  140. package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
  141. package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
  142. package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
  143. package/dist-runtime/workflow/lib/gateTool.js +177 -0
  144. package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
  145. package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
  146. package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
  147. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
  148. package/dist-runtime/workflow/lib/lock.d.ts +52 -0
  149. package/dist-runtime/workflow/lib/lock.js +269 -0
  150. package/dist-runtime/workflow/lib/lock.js.map +1 -0
  151. package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
  152. package/dist-runtime/workflow/lib/migrationState.js +920 -0
  153. package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
  154. package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
  155. package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
  156. package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
  157. package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
  158. package/dist-runtime/workflow/lib/parameters.js +323 -0
  159. package/dist-runtime/workflow/lib/parameters.js.map +1 -0
  160. package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
  161. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
  162. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
  163. package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
  164. package/dist-runtime/workflow/lib/proxy.js +19 -0
  165. package/dist-runtime/workflow/lib/proxy.js.map +1 -0
  166. package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
  167. package/dist-runtime/workflow/lib/registryCommit.js +319 -0
  168. package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
  169. package/dist-runtime/workflow/lib/release.d.ts +57 -0
  170. package/dist-runtime/workflow/lib/release.js +256 -0
  171. package/dist-runtime/workflow/lib/release.js.map +1 -0
  172. package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
  173. package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
  174. package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
  175. package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
  176. package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
  177. package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
  178. package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
  179. package/dist-runtime/workflow/lib/reporter.js +452 -0
  180. package/dist-runtime/workflow/lib/reporter.js.map +1 -0
  181. package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
  182. package/dist-runtime/workflow/lib/resultPaths.js +29 -0
  183. package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
  184. package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
  185. package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
  186. package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
  187. package/dist-runtime/workflow/lib/signer.d.ts +10 -0
  188. package/dist-runtime/workflow/lib/signer.js +105 -0
  189. package/dist-runtime/workflow/lib/signer.js.map +1 -0
  190. package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
  191. package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
  192. package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
  193. package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
  194. package/dist-runtime/workflow/lib/simulation.js +282 -0
  195. package/dist-runtime/workflow/lib/simulation.js.map +1 -0
  196. package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
  197. package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
  198. package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
  199. package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
  200. package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
  201. package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
  202. package/dist-runtime/workflow/lib/state.d.ts +6 -0
  203. package/dist-runtime/workflow/lib/state.js +25 -0
  204. package/dist-runtime/workflow/lib/state.js.map +1 -0
  205. package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
  206. package/dist-runtime/workflow/lib/staticValidation.js +124 -0
  207. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
  208. package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
  209. package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
  210. package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
  211. package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
  212. package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
  213. package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
  214. package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
  215. package/dist-runtime/workflow/reconcileExternal.js +87 -0
  216. package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
  217. package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
  218. package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
  219. package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
  220. package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
  221. package/dist-runtime/workflow/releaseFinalize.js +11 -0
  222. package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
  223. package/dist-runtime/workflow/run.d.ts +40 -0
  224. package/dist-runtime/workflow/run.js +858 -0
  225. package/dist-runtime/workflow/run.js.map +1 -0
  226. package/dist-runtime/workflow/staticValidate.d.ts +1 -0
  227. package/dist-runtime/workflow/staticValidate.js +26 -0
  228. package/dist-runtime/workflow/staticValidate.js.map +1 -0
  229. package/dist-runtime/workflow/steps/call.d.ts +3 -0
  230. package/dist-runtime/workflow/steps/call.js +9 -0
  231. package/dist-runtime/workflow/steps/call.js.map +1 -0
  232. package/dist-runtime/workflow/steps/check.d.ts +3 -0
  233. package/dist-runtime/workflow/steps/check.js +9 -0
  234. package/dist-runtime/workflow/steps/check.js.map +1 -0
  235. package/dist-runtime/workflow/steps/custom.d.ts +3 -0
  236. package/dist-runtime/workflow/steps/custom.js +33 -0
  237. package/dist-runtime/workflow/steps/custom.js.map +1 -0
  238. package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
  239. package/dist-runtime/workflow/steps/deploy.js +596 -0
  240. package/dist-runtime/workflow/steps/deploy.js.map +1 -0
  241. package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
  242. package/dist-runtime/workflow/steps/upgrade.js +466 -0
  243. package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
  244. package/dist-runtime/workflow/steps/view.d.ts +3 -0
  245. package/dist-runtime/workflow/steps/view.js +9 -0
  246. package/dist-runtime/workflow/steps/view.js.map +1 -0
  247. package/docs/direct-package-acceptance.md +20 -0
  248. package/docs/external-infrastructure-acceptance.md +33 -0
  249. package/docs/network-runtime-acceptance.md +18 -0
  250. package/docs/plans/2026-09-09-workflow-extraction.md +16 -0
  251. package/docs/superpowers/plans/2026-07-22-manifest-bootstrap-transaction.md +50 -0
  252. package/docs/superpowers/plans/2026-07-22-manifest-review-remediation.md +49 -0
  253. package/docs/superpowers/plans/2026-08-17-custody-hardhat-signers.md +227 -0
  254. package/docs/superpowers/plans/2026-09-09-remove-template-infrastructure-contracts.md +11 -0
  255. package/docs/workflow-reference.md +1181 -0
  256. package/docs/workflow-runtime-acceptance.md +17 -0
  257. package/docs/workflow-runtime.md +56 -0
  258. package/package.json +26 -5
  259. package/runtime/config/hardhatAdapters.ts +58 -0
  260. package/runtime/config/networks.ts +305 -0
  261. package/runtime/config/openzeppelin.ts +173 -0
  262. package/runtime/config/rpc.ts +27 -0
  263. package/runtime/config/zksyncSolcPath.ts +59 -0
  264. package/runtime/hardhat-types.d.ts +2 -0
  265. package/runtime/migrate.ts +154 -0
  266. package/runtime/projectHardhat.ts +10 -0
  267. package/runtime/template-migration.json +293 -0
  268. package/runtime/workflow/checkCode.ts +13 -0
  269. package/runtime/workflow/checkCodeFinalize.ts +8 -0
  270. package/runtime/workflow/checkCodePlan.ts +8 -0
  271. package/runtime/workflow/cli.ts +356 -0
  272. package/runtime/workflow/commitContractInfo.ts +63 -0
  273. package/runtime/workflow/create2Hashes.ts +79 -0
  274. package/runtime/workflow/forkSourceProxy.ts +193 -0
  275. package/runtime/workflow/importState.ts +190 -0
  276. package/runtime/workflow/lib/authority.ts +170 -0
  277. package/runtime/workflow/lib/calldata.ts +9 -0
  278. package/runtime/workflow/lib/calls.ts +407 -0
  279. package/runtime/workflow/lib/checkCode/args.ts +76 -0
  280. package/runtime/workflow/lib/checkCode/command.ts +36 -0
  281. package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
  282. package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
  283. package/runtime/workflow/lib/checkCode/index.ts +18 -0
  284. package/runtime/workflow/lib/checkCode/plan.ts +163 -0
  285. package/runtime/workflow/lib/checkCodeReport.ts +133 -0
  286. package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
  287. package/runtime/workflow/lib/cliTool.ts +31 -0
  288. package/runtime/workflow/lib/config.ts +130 -0
  289. package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
  290. package/runtime/workflow/lib/controlledMulticallAbi.ts +6 -0
  291. package/runtime/workflow/lib/create2.ts +278 -0
  292. package/runtime/workflow/lib/create2Hashes.ts +83 -0
  293. package/runtime/workflow/lib/deploymentInfo.ts +286 -0
  294. package/runtime/workflow/lib/deploymentRecords.ts +576 -0
  295. package/runtime/workflow/lib/deployments.ts +276 -0
  296. package/runtime/workflow/lib/erc1967.ts +57 -0
  297. package/runtime/workflow/lib/errors.ts +95 -0
  298. package/runtime/workflow/lib/executionId.ts +35 -0
  299. package/runtime/workflow/lib/executionPlan.ts +550 -0
  300. package/runtime/workflow/lib/executionProgress.ts +127 -0
  301. package/runtime/workflow/lib/external.ts +372 -0
  302. package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
  303. package/runtime/workflow/lib/forkSnapshot.ts +231 -0
  304. package/runtime/workflow/lib/gateTool.ts +261 -0
  305. package/runtime/workflow/lib/gateToolSync.ts +398 -0
  306. package/runtime/workflow/lib/lock.ts +388 -0
  307. package/runtime/workflow/lib/migrationState.ts +1246 -0
  308. package/runtime/workflow/lib/operatorExecution.ts +174 -0
  309. package/runtime/workflow/lib/parameters.ts +438 -0
  310. package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
  311. package/runtime/workflow/lib/proxy.ts +45 -0
  312. package/runtime/workflow/lib/registryCommit.ts +455 -0
  313. package/runtime/workflow/lib/release.ts +329 -0
  314. package/runtime/workflow/lib/releaseFinalize.ts +711 -0
  315. package/runtime/workflow/lib/releaseParameters.ts +248 -0
  316. package/runtime/workflow/lib/reporter.ts +502 -0
  317. package/runtime/workflow/lib/resultPaths.ts +49 -0
  318. package/runtime/workflow/lib/runtimeVersion.ts +28 -0
  319. package/runtime/workflow/lib/signer.ts +124 -0
  320. package/runtime/workflow/lib/signerIdentity.ts +22 -0
  321. package/runtime/workflow/lib/simulation.ts +415 -0
  322. package/runtime/workflow/lib/simulationCallers.ts +335 -0
  323. package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
  324. package/runtime/workflow/lib/state.ts +25 -0
  325. package/runtime/workflow/lib/staticValidation.ts +142 -0
  326. package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
  327. package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
  328. package/runtime/workflow/reconcileExternal.ts +86 -0
  329. package/runtime/workflow/reconcileExternalRun.ts +88 -0
  330. package/runtime/workflow/releaseFinalize.ts +8 -0
  331. package/runtime/workflow/run.ts +1072 -0
  332. package/runtime/workflow/staticValidate.ts +23 -0
  333. package/runtime/workflow/steps/call.ts +10 -0
  334. package/runtime/workflow/steps/check.ts +10 -0
  335. package/runtime/workflow/steps/custom.ts +43 -0
  336. package/runtime/workflow/steps/deploy.ts +772 -0
  337. package/runtime/workflow/steps/upgrade.ts +599 -0
  338. package/runtime/workflow/steps/view.ts +10 -0
@@ -0,0 +1,231 @@
1
+ export type ForkRunnerKind = "hardhat" | "anvil-zksync";
2
+
3
+ interface CapturedChainSnapshotBaseV1 {
4
+ version: 1;
5
+ sourceNetwork: string;
6
+ chainId: number;
7
+ blockNumber: number;
8
+ blockHash: string;
9
+ }
10
+
11
+ export interface CapturedEvmChainSnapshotV1 extends CapturedChainSnapshotBaseV1 {}
12
+
13
+ export interface CapturedZkSyncChainSnapshotV1 extends CapturedChainSnapshotBaseV1 {
14
+ protocolVersion: number;
15
+ l1BatchNumber: number;
16
+ }
17
+
18
+ export type CapturedChainSnapshotV1 =
19
+ | CapturedEvmChainSnapshotV1
20
+ | CapturedZkSyncChainSnapshotV1;
21
+
22
+ export type ForkSnapshotV1 =
23
+ | (CapturedEvmChainSnapshotV1 & {
24
+ runner: { kind: "hardhat"; version: string };
25
+ })
26
+ | (CapturedZkSyncChainSnapshotV1 & {
27
+ runner: { kind: "anvil-zksync"; version: string };
28
+ });
29
+
30
+ const NETWORK_ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/;
31
+ const BLOCK_HASH = /^0x[0-9a-fA-F]{64}$/;
32
+ const RUNNER_VERSION = /^[A-Za-z0-9][A-Za-z0-9.+_-]{0,63}$/;
33
+ const PROTOCOL_VERSION = /^Version([1-9][0-9]*)$/;
34
+ const BASE_KEYS = [
35
+ "version",
36
+ "sourceNetwork",
37
+ "chainId",
38
+ "blockNumber",
39
+ "blockHash",
40
+ ] as const;
41
+ const ZKSYNC_KEYS = [...BASE_KEYS, "protocolVersion", "l1BatchNumber"] as const;
42
+
43
+ const isRecord = (value: unknown): value is Record<string, unknown> => (
44
+ value !== null && typeof value === "object" && !Array.isArray(value)
45
+ );
46
+
47
+ const exactKeys = (
48
+ value: Record<string, unknown>,
49
+ expected: readonly string[],
50
+ label: string,
51
+ ): void => {
52
+ const actual = Object.keys(value).sort();
53
+ const canonical = [...expected].sort();
54
+ if (
55
+ actual.length !== canonical.length
56
+ || actual.some((key, index) => key !== canonical[index])
57
+ ) {
58
+ throw new Error(`${label} fields are invalid`);
59
+ }
60
+ };
61
+
62
+ const positiveSafeInteger = (value: unknown, label: string): number => {
63
+ if (!Number.isSafeInteger(value) || Number(value) <= 0) {
64
+ throw new Error(`${label} must be a positive safe integer`);
65
+ }
66
+ return Number(value);
67
+ };
68
+
69
+ const nonNegativeSafeInteger = (value: unknown, label: string): number => {
70
+ if (!Number.isSafeInteger(value) || Number(value) < 0) {
71
+ throw new Error(`${label} must be a non-negative safe integer`);
72
+ }
73
+ return Number(value);
74
+ };
75
+
76
+ const parseProtocolVersion = (value: unknown): number => {
77
+ if (Number.isSafeInteger(value) && Number(value) > 0) return Number(value);
78
+ if (typeof value !== "string") {
79
+ throw new Error("zkSync protocolVersion is invalid");
80
+ }
81
+ const match = PROTOCOL_VERSION.exec(value);
82
+ if (!match) throw new Error("zkSync protocolVersion is invalid");
83
+ return positiveSafeInteger(Number(match[1]), "zkSync protocolVersion");
84
+ };
85
+
86
+ const parseBaseSnapshot = (
87
+ value: Record<string, unknown>,
88
+ expectedSourceNetwork?: string,
89
+ ): CapturedChainSnapshotBaseV1 => {
90
+ if (value.version !== 1) throw new Error("fork snapshot version is invalid");
91
+ if (typeof value.sourceNetwork !== "string" || !NETWORK_ID.test(value.sourceNetwork)) {
92
+ throw new Error("fork snapshot sourceNetwork is invalid");
93
+ }
94
+ if (expectedSourceNetwork !== undefined && value.sourceNetwork !== expectedSourceNetwork) {
95
+ throw new Error("fork snapshot sourceNetwork does not match the requested target");
96
+ }
97
+ if (!Number.isSafeInteger(value.chainId) || Number(value.chainId) <= 0) {
98
+ throw new Error("fork snapshot chainId must be a positive safe integer");
99
+ }
100
+ if (!Number.isSafeInteger(value.blockNumber) || Number(value.blockNumber) < 0) {
101
+ throw new Error("fork snapshot blockNumber must be a non-negative safe integer");
102
+ }
103
+ if (typeof value.blockHash !== "string" || !BLOCK_HASH.test(value.blockHash)) {
104
+ throw new Error("fork snapshot blockHash must be a 32-byte hash");
105
+ }
106
+ return {
107
+ version: 1,
108
+ sourceNetwork: value.sourceNetwork,
109
+ chainId: Number(value.chainId),
110
+ blockNumber: Number(value.blockNumber),
111
+ blockHash: value.blockHash.toLowerCase(),
112
+ };
113
+ };
114
+
115
+ export const isCapturedZkSyncChainSnapshot = (
116
+ value: CapturedChainSnapshotV1,
117
+ ): value is CapturedZkSyncChainSnapshotV1 => "protocolVersion" in value;
118
+
119
+ export const parseCapturedChainSnapshot = (
120
+ value: unknown,
121
+ expectedSourceNetwork?: string,
122
+ expectedZkSync?: boolean,
123
+ ): CapturedChainSnapshotV1 => {
124
+ if (!isRecord(value)) throw new Error("fork snapshot must be an object");
125
+ const hasZkSyncFields = Object.hasOwn(value, "protocolVersion")
126
+ || Object.hasOwn(value, "l1BatchNumber");
127
+ const zksync = expectedZkSync ?? hasZkSyncFields;
128
+ exactKeys(value, zksync ? ZKSYNC_KEYS : BASE_KEYS, "fork snapshot");
129
+ const base = parseBaseSnapshot(value, expectedSourceNetwork);
130
+ if (!zksync) return base;
131
+ return {
132
+ ...base,
133
+ protocolVersion: parseProtocolVersion(value.protocolVersion),
134
+ l1BatchNumber: nonNegativeSafeInteger(
135
+ value.l1BatchNumber,
136
+ "zkSync l1BatchNumber",
137
+ ),
138
+ };
139
+ };
140
+
141
+ export const parseCapturedChainSnapshotJson = (
142
+ value: string | undefined,
143
+ expectedSourceNetwork?: string,
144
+ expectedZkSync?: boolean,
145
+ ): CapturedChainSnapshotV1 => {
146
+ if (!value) throw new Error("current-state snapshot environment is missing");
147
+ let parsed: unknown;
148
+ try {
149
+ parsed = JSON.parse(value);
150
+ } catch {
151
+ throw new Error("current-state snapshot environment must contain valid JSON");
152
+ }
153
+ return parseCapturedChainSnapshot(parsed, expectedSourceNetwork, expectedZkSync);
154
+ };
155
+
156
+ export const parseZkSyncBlockDetails = (
157
+ value: unknown,
158
+ expectedBlockNumber: number,
159
+ ): Pick<CapturedZkSyncChainSnapshotV1, "protocolVersion" | "l1BatchNumber"> => {
160
+ if (!isRecord(value)) throw new Error("zkSync block details are missing");
161
+ const blockNumber = nonNegativeSafeInteger(value.number, "zkSync block details number");
162
+ if (blockNumber !== expectedBlockNumber) {
163
+ throw new Error("zkSync block details number does not match the captured block number");
164
+ }
165
+ return {
166
+ protocolVersion: parseProtocolVersion(value.protocolVersion),
167
+ l1BatchNumber: nonNegativeSafeInteger(
168
+ value.l1BatchNumber,
169
+ "zkSync block details l1BatchNumber",
170
+ ),
171
+ };
172
+ };
173
+
174
+ export const parseForkSnapshot = (
175
+ value: unknown,
176
+ expectedSourceNetwork?: string,
177
+ ): ForkSnapshotV1 => {
178
+ if (!isRecord(value)) throw new Error("fork snapshot must be an object");
179
+ if (!isRecord(value.runner)) throw new Error("fork snapshot runner must be an object");
180
+ exactKeys(value.runner, ["kind", "version"], "fork snapshot runner");
181
+ if (value.runner.kind !== "hardhat" && value.runner.kind !== "anvil-zksync") {
182
+ throw new Error("fork snapshot runner kind is invalid");
183
+ }
184
+ if (
185
+ typeof value.runner.version !== "string"
186
+ || !RUNNER_VERSION.test(value.runner.version)
187
+ ) {
188
+ throw new Error("fork snapshot runner version is invalid");
189
+ }
190
+ const { runner: _runner, ...capturedValue } = value;
191
+ const captured = parseCapturedChainSnapshot(
192
+ capturedValue,
193
+ expectedSourceNetwork,
194
+ value.runner.kind === "anvil-zksync",
195
+ );
196
+ if (value.runner.kind === "anvil-zksync") {
197
+ if (!isCapturedZkSyncChainSnapshot(captured)) {
198
+ throw new Error("zkSync fork snapshot protocol metadata is missing");
199
+ }
200
+ return {
201
+ ...captured,
202
+ runner: { kind: "anvil-zksync", version: value.runner.version },
203
+ };
204
+ }
205
+ if (isCapturedZkSyncChainSnapshot(captured)) {
206
+ throw new Error("EVM fork snapshot cannot contain zkSync protocol metadata");
207
+ }
208
+ return {
209
+ ...captured,
210
+ runner: { kind: "hardhat", version: value.runner.version },
211
+ };
212
+ };
213
+
214
+ export const parseForkSnapshotJson = (
215
+ value: string | undefined,
216
+ expectedSourceNetwork?: string,
217
+ ): ForkSnapshotV1 => {
218
+ if (!value) throw new Error("fork snapshot environment is missing");
219
+ let parsed: unknown;
220
+ try {
221
+ parsed = JSON.parse(value);
222
+ } catch {
223
+ throw new Error("fork snapshot environment must contain valid JSON");
224
+ }
225
+ return parseForkSnapshot(parsed, expectedSourceNetwork);
226
+ };
227
+
228
+ export const buildForkSnapshot = (
229
+ captured: CapturedChainSnapshotV1,
230
+ runner: ForkSnapshotV1["runner"],
231
+ ): ForkSnapshotV1 => parseForkSnapshot({ ...captured, runner }, captured.sourceNetwork);
@@ -0,0 +1,261 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import hardhat from "../../projectHardhat";
4
+ import {
5
+ canonicalPreparationJson,
6
+ hashPreparationRequest,
7
+ normalizePreparationPlan,
8
+ normalizePreparationRequest,
9
+ prepareWorkflow,
10
+ writePreparationPlanAtomic,
11
+ } from "gate-evm-tools/workflow";
12
+ import type {
13
+ GateToolPreparationHre,
14
+ GateToolPreparationPlanV1,
15
+ GateToolPreparationRequestV1,
16
+ GateToolTransactionPurpose,
17
+ } from "gate-evm-tools/workflow";
18
+
19
+ export interface PrepareGateToolWorkflowOptions {
20
+ root: string;
21
+ evidenceDir: string;
22
+ evidenceName: string;
23
+ request: GateToolPreparationRequestV1;
24
+ hre?: GateToolPreparationHre;
25
+ readBlockTag?: number;
26
+ }
27
+
28
+ export interface PreparedGateToolWorkflow {
29
+ request: GateToolPreparationRequestV1;
30
+ requestPath: string;
31
+ plan: GateToolPreparationPlanV1;
32
+ planPath: string;
33
+ }
34
+
35
+ const SAFE_FILE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;
36
+
37
+ const pinGateToolReadBlockTag = (
38
+ runtime: GateToolPreparationHre,
39
+ blockTag: number | undefined,
40
+ ): GateToolPreparationHre => {
41
+ if (blockTag === undefined) return runtime;
42
+ if (!Number.isSafeInteger(blockTag) || blockTag < 0) {
43
+ throw new Error("GateTool readBlockTag must be a non-negative safe integer");
44
+ }
45
+ const source = runtime as GateToolPreparationHre & {
46
+ ethers?: {
47
+ provider?: {
48
+ getCode(address: string, requestedBlockTag?: number): Promise<string>;
49
+ getStorage?(address: string, slot: string, requestedBlockTag?: number): Promise<string>;
50
+ [key: PropertyKey]: unknown;
51
+ };
52
+ [key: PropertyKey]: unknown;
53
+ };
54
+ [key: PropertyKey]: unknown;
55
+ };
56
+ const baseEthers = source.ethers;
57
+ const baseProvider = baseEthers?.provider;
58
+ if (!baseEthers || !baseProvider || typeof baseProvider.getCode !== "function") {
59
+ throw new Error("GateTool pinned reads require the active Hardhat ethers provider");
60
+ }
61
+ const provider = new Proxy(baseProvider, {
62
+ get(target, property) {
63
+ if (property === "getCode") {
64
+ return (address: string, requestedBlockTag?: number) => target.getCode(
65
+ address,
66
+ requestedBlockTag ?? blockTag,
67
+ );
68
+ }
69
+ if (property === "getStorage" && typeof target.getStorage === "function") {
70
+ return (address: string, slot: string, requestedBlockTag?: number) => (
71
+ target.getStorage!(address, slot, requestedBlockTag ?? blockTag)
72
+ );
73
+ }
74
+ const value = Reflect.get(target, property, target);
75
+ return typeof value === "function" ? value.bind(target) : value;
76
+ },
77
+ });
78
+ const ethers = new Proxy(baseEthers, {
79
+ get(target, property) {
80
+ if (property === "provider") return provider;
81
+ const value = Reflect.get(target, property, target);
82
+ return typeof value === "function" ? value.bind(target) : value;
83
+ },
84
+ });
85
+ return new Proxy(source, {
86
+ get(target, property) {
87
+ if (property === "ethers") return ethers;
88
+ const value = Reflect.get(target, property, target);
89
+ return typeof value === "function" ? value.bind(target) : value;
90
+ },
91
+ });
92
+ };
93
+
94
+ const confinedPath = (
95
+ root: string,
96
+ requestedPath: string,
97
+ label: string,
98
+ ): string => {
99
+ const resolvedRoot = path.resolve(root);
100
+ const resolvedPath = path.resolve(requestedPath);
101
+ const relative = path.relative(resolvedRoot, resolvedPath);
102
+ if (relative === "" || relative.startsWith("..") || path.isAbsolute(relative)) {
103
+ throw new Error(`${label} must be inside the project root`);
104
+ }
105
+ let current = resolvedRoot;
106
+ for (const segment of relative.split(path.sep).filter(Boolean)) {
107
+ current = path.join(current, segment);
108
+ if (fs.existsSync(current) && fs.lstatSync(current).isSymbolicLink()) {
109
+ throw new Error(`${label} path cannot contain a symlink`);
110
+ }
111
+ }
112
+ return resolvedPath;
113
+ };
114
+
115
+ const writeCanonicalJsonAtomic = (
116
+ filePath: string,
117
+ value: unknown,
118
+ root: string,
119
+ ): void => {
120
+ const confined = confinedPath(root, filePath, "GateTool request output");
121
+ fs.mkdirSync(path.dirname(confined), { recursive: true });
122
+ const temporary = `${confined}.${process.pid}.${Date.now()}.tmp`;
123
+ try {
124
+ fs.writeFileSync(temporary, `${canonicalPreparationJson(value)}\n`, {
125
+ flag: "wx",
126
+ mode: 0o600,
127
+ });
128
+ fs.renameSync(temporary, confined);
129
+ } catch (error) {
130
+ if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
131
+ throw error;
132
+ }
133
+ };
134
+
135
+ const readRegularJson = (
136
+ filePath: string,
137
+ root: string,
138
+ label: string,
139
+ ): unknown => {
140
+ const confined = confinedPath(root, filePath, label);
141
+ const stat = fs.statSync(confined);
142
+ if (!stat.isFile()) throw new Error(`${label} must be a regular file`);
143
+ try {
144
+ return JSON.parse(fs.readFileSync(confined, "utf8")) as unknown;
145
+ } catch (error) {
146
+ throw new Error(
147
+ `${label} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
148
+ );
149
+ }
150
+ };
151
+
152
+ const expectedTransactionPurposes = (
153
+ plan: GateToolPreparationPlanV1,
154
+ ): GateToolTransactionPurpose[] => {
155
+ const requiredRoles = new Set(
156
+ plan.deployments
157
+ .filter((deployment) => deployment.status === "required")
158
+ .map((deployment) => deployment.role),
159
+ );
160
+ if (plan.kind === "create2-deploy") {
161
+ return requiredRoles.has("contract") ? ["deploy-contract"] : [];
162
+ }
163
+ if (plan.kind === "uups-placeholder-deploy") {
164
+ if (!requiredRoles.has("proxy")) {
165
+ if (requiredRoles.has("implementation")) {
166
+ throw new Error(
167
+ "GateTool cannot reuse a UUPS proxy while requiring its predicted implementation",
168
+ );
169
+ }
170
+ return [];
171
+ }
172
+ return [
173
+ ...(requiredRoles.has("implementation") ? ["deploy-implementation" as const] : []),
174
+ "deploy-proxy",
175
+ "upgrade-proxy",
176
+ ];
177
+ }
178
+ return [
179
+ ...(requiredRoles.has("implementation") ? ["deploy-implementation" as const] : []),
180
+ "upgrade-proxy",
181
+ ];
182
+ };
183
+
184
+ const assertPlanMatchesRequest = async (
185
+ hre: GateToolPreparationHre,
186
+ request: GateToolPreparationRequestV1,
187
+ rawPlan: unknown,
188
+ ): Promise<GateToolPreparationPlanV1> => {
189
+ const plan = normalizePreparationPlan(rawPlan);
190
+ const provider = (hre as GateToolPreparationHre & {
191
+ ethers?: { provider?: { getNetwork(): Promise<{ chainId: bigint | number | string }> } };
192
+ }).ethers?.provider;
193
+ if (!provider) throw new Error("GateTool preparation requires the active Hardhat ethers provider");
194
+ const chainId = (await provider.getNetwork()).chainId.toString();
195
+ const expectedPurposes = expectedTransactionPurposes(plan);
196
+ const actualPurposes = plan.transactions.map((transaction) => transaction.purpose);
197
+
198
+ if (plan.requestHash !== hashPreparationRequest(request)) {
199
+ throw new Error("GateTool plan requestHash does not match its canonical request");
200
+ }
201
+ if (
202
+ plan.kind !== request.kind
203
+ || plan.scheme !== request.scheme
204
+ || plan.network !== request.network
205
+ || plan.target !== request.target
206
+ || plan.contract !== request.contract
207
+ || plan.chainId !== chainId
208
+ ) {
209
+ throw new Error("GateTool plan identity does not match the active workflow request");
210
+ }
211
+ if (
212
+ actualPurposes.length !== expectedPurposes.length
213
+ || actualPurposes.some((purpose, index) => purpose !== expectedPurposes[index])
214
+ ) {
215
+ throw new Error("GateTool plan transaction order does not match its deployment evidence");
216
+ }
217
+ return plan;
218
+ };
219
+
220
+ export const prepareGateToolWorkflow = async (
221
+ options: PrepareGateToolWorkflowOptions,
222
+ ): Promise<PreparedGateToolWorkflow> => {
223
+ if (!SAFE_FILE_ID.test(options.evidenceName)) {
224
+ throw new Error(`GateTool evidenceName must match ${SAFE_FILE_ID}`);
225
+ }
226
+ const request = normalizePreparationRequest(options.request);
227
+ const runtime = pinGateToolReadBlockTag(
228
+ options.hre ?? hardhat as unknown as GateToolPreparationHre,
229
+ options.readBlockTag,
230
+ );
231
+ const evidenceDir = confinedPath(options.root, options.evidenceDir, "GateTool evidence directory");
232
+ const requestPath = path.join(evidenceDir, `${options.evidenceName}-request.json`);
233
+ const planPath = path.join(evidenceDir, `${options.evidenceName}-plan.json`);
234
+
235
+ const requestExists = fs.existsSync(requestPath);
236
+ const planExists = fs.existsSync(planPath);
237
+ if (requestExists !== planExists) {
238
+ throw new Error("GateTool preparation evidence is incomplete for this execution");
239
+ }
240
+ if (requestExists) {
241
+ const existingRequest = normalizePreparationRequest(
242
+ readRegularJson(requestPath, options.root, "GateTool request evidence"),
243
+ );
244
+ if (canonicalPreparationJson(existingRequest) !== canonicalPreparationJson(request)) {
245
+ throw new Error("GateTool request evidence does not match the immutable execution request");
246
+ }
247
+ const plan = await assertPlanMatchesRequest(
248
+ runtime,
249
+ request,
250
+ readRegularJson(planPath, options.root, "GateTool plan evidence"),
251
+ );
252
+ return { request, requestPath, plan, planPath };
253
+ }
254
+
255
+ writeCanonicalJsonAtomic(requestPath, request, options.root);
256
+ const prepared = await prepareWorkflow(runtime, request);
257
+ const plan = await assertPlanMatchesRequest(runtime, request, prepared);
258
+ writePreparationPlanAtomic(planPath, plan, options.root);
259
+
260
+ return { request, requestPath, plan, planPath };
261
+ };