gate-evm-tools 1.0.25 → 1.0.27

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 (352) hide show
  1. package/README.md +33 -11
  2. package/bin/workflow.cjs +19 -0
  3. package/dist/commands/check.d.ts.map +1 -1
  4. package/dist/commands/check.js +21 -57
  5. package/dist/commands/check.js.map +1 -1
  6. package/dist/commands/checkBatch.d.ts +4 -0
  7. package/dist/commands/checkBatch.d.ts.map +1 -0
  8. package/dist/commands/checkBatch.js +57 -0
  9. package/dist/commands/checkBatch.js.map +1 -0
  10. package/dist/commands/checkOptions.d.ts +3 -0
  11. package/dist/commands/checkOptions.d.ts.map +1 -1
  12. package/dist/commands/checkOptions.js +10 -1
  13. package/dist/commands/checkOptions.js.map +1 -1
  14. package/dist/commands/prepare.d.ts +1 -2
  15. package/dist/commands/prepare.d.ts.map +1 -1
  16. package/dist/commands/prepare.js +2 -17
  17. package/dist/commands/prepare.js.map +1 -1
  18. package/dist/commands/sync.d.ts.map +1 -1
  19. package/dist/commands/sync.js +2 -17
  20. package/dist/commands/sync.js.map +1 -1
  21. package/dist/commands/validate.d.ts.map +1 -1
  22. package/dist/commands/validate.js +2 -17
  23. package/dist/commands/validate.js.map +1 -1
  24. package/dist/core/BytecodeChecker.d.ts.map +1 -1
  25. package/dist/core/BytecodeChecker.js +16 -1
  26. package/dist/core/BytecodeChecker.js.map +1 -1
  27. package/dist/core/legacyProxyArtifact.d.ts +6 -0
  28. package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
  29. package/dist/core/legacyProxyArtifact.js +36 -0
  30. package/dist/core/legacyProxyArtifact.js.map +1 -0
  31. package/dist/index.js +3 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/types.d.ts +2 -2
  34. package/dist/types.d.ts.map +1 -1
  35. package/dist/utils/hardhat.d.ts +4 -0
  36. package/dist/utils/hardhat.d.ts.map +1 -0
  37. package/dist/utils/hardhat.js +9 -0
  38. package/dist/utils/hardhat.js.map +1 -0
  39. package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
  40. package/dist-runtime/config/hardhatAdapters.js +53 -0
  41. package/dist-runtime/config/hardhatAdapters.js.map +1 -0
  42. package/dist-runtime/config/networks.d.ts +8 -0
  43. package/dist-runtime/config/networks.js +269 -0
  44. package/dist-runtime/config/networks.js.map +1 -0
  45. package/dist-runtime/config/openzeppelin.d.ts +28 -0
  46. package/dist-runtime/config/openzeppelin.js +144 -0
  47. package/dist-runtime/config/openzeppelin.js.map +1 -0
  48. package/dist-runtime/config/rpc.d.ts +7 -0
  49. package/dist-runtime/config/rpc.js +19 -0
  50. package/dist-runtime/config/rpc.js.map +1 -0
  51. package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
  52. package/dist-runtime/config/zksyncSolcPath.js +61 -0
  53. package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
  54. package/dist-runtime/migrate.d.ts +13 -0
  55. package/dist-runtime/migrate.js +208 -0
  56. package/dist-runtime/migrate.js.map +1 -0
  57. package/dist-runtime/package.json +1 -0
  58. package/dist-runtime/projectHardhat.d.ts +4 -0
  59. package/dist-runtime/projectHardhat.js +16 -0
  60. package/dist-runtime/projectHardhat.js.map +1 -0
  61. package/dist-runtime/runtime-identity.json +4 -0
  62. package/dist-runtime/template-migration.json +293 -0
  63. package/dist-runtime/workflow/checkCode.d.ts +1 -0
  64. package/dist-runtime/workflow/checkCode.js +16 -0
  65. package/dist-runtime/workflow/checkCode.js.map +1 -0
  66. package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
  67. package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
  68. package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
  69. package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
  70. package/dist-runtime/workflow/checkCodePlan.js +11 -0
  71. package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
  72. package/dist-runtime/workflow/cli.d.ts +1 -0
  73. package/dist-runtime/workflow/cli.js +302 -0
  74. package/dist-runtime/workflow/cli.js.map +1 -0
  75. package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
  76. package/dist-runtime/workflow/commitContractInfo.js +64 -0
  77. package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
  78. package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
  79. package/dist-runtime/workflow/create2Hashes.js +76 -0
  80. package/dist-runtime/workflow/create2Hashes.js.map +1 -0
  81. package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
  82. package/dist-runtime/workflow/forkSourceProxy.js +151 -0
  83. package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
  84. package/dist-runtime/workflow/importState.d.ts +1 -0
  85. package/dist-runtime/workflow/importState.js +193 -0
  86. package/dist-runtime/workflow/importState.js.map +1 -0
  87. package/dist-runtime/workflow/lib/authority.d.ts +28 -0
  88. package/dist-runtime/workflow/lib/authority.js +122 -0
  89. package/dist-runtime/workflow/lib/authority.js.map +1 -0
  90. package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
  91. package/dist-runtime/workflow/lib/calldata.js +8 -0
  92. package/dist-runtime/workflow/lib/calldata.js.map +1 -0
  93. package/dist-runtime/workflow/lib/calls.d.ts +23 -0
  94. package/dist-runtime/workflow/lib/calls.js +316 -0
  95. package/dist-runtime/workflow/lib/calls.js.map +1 -0
  96. package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
  97. package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
  98. package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
  99. package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
  100. package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
  101. package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
  102. package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
  103. package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
  104. package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
  105. package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
  106. package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
  107. package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
  108. package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
  109. package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
  110. package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
  111. package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
  112. package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
  113. package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
  114. package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
  115. package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
  116. package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
  117. package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
  118. package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
  119. package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
  120. package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
  121. package/dist-runtime/workflow/lib/cliTool.js +25 -0
  122. package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
  123. package/dist-runtime/workflow/lib/config.d.ts +33 -0
  124. package/dist-runtime/workflow/lib/config.js +100 -0
  125. package/dist-runtime/workflow/lib/config.js.map +1 -0
  126. package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
  127. package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
  128. package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
  129. package/dist-runtime/workflow/lib/create2.d.ts +49 -0
  130. package/dist-runtime/workflow/lib/create2.js +194 -0
  131. package/dist-runtime/workflow/lib/create2.js.map +1 -0
  132. package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
  133. package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
  134. package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
  135. package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
  136. package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
  137. package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
  138. package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
  139. package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
  140. package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
  141. package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
  142. package/dist-runtime/workflow/lib/deployments.js +240 -0
  143. package/dist-runtime/workflow/lib/deployments.js.map +1 -0
  144. package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
  145. package/dist-runtime/workflow/lib/erc1967.js +29 -0
  146. package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
  147. package/dist-runtime/workflow/lib/errors.d.ts +6 -0
  148. package/dist-runtime/workflow/lib/errors.js +77 -0
  149. package/dist-runtime/workflow/lib/errors.js.map +1 -0
  150. package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
  151. package/dist-runtime/workflow/lib/executionId.js +26 -0
  152. package/dist-runtime/workflow/lib/executionId.js.map +1 -0
  153. package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
  154. package/dist-runtime/workflow/lib/executionPlan.js +450 -0
  155. package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
  156. package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
  157. package/dist-runtime/workflow/lib/executionProgress.js +100 -0
  158. package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
  159. package/dist-runtime/workflow/lib/external.d.ts +62 -0
  160. package/dist-runtime/workflow/lib/external.js +282 -0
  161. package/dist-runtime/workflow/lib/external.js.map +1 -0
  162. package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
  163. package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
  164. package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
  165. package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
  166. package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
  167. package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
  168. package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
  169. package/dist-runtime/workflow/lib/gateTool.js +177 -0
  170. package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
  171. package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
  172. package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
  173. package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
  174. package/dist-runtime/workflow/lib/lock.d.ts +52 -0
  175. package/dist-runtime/workflow/lib/lock.js +269 -0
  176. package/dist-runtime/workflow/lib/lock.js.map +1 -0
  177. package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
  178. package/dist-runtime/workflow/lib/migrationState.js +920 -0
  179. package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
  180. package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
  181. package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
  182. package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
  183. package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
  184. package/dist-runtime/workflow/lib/parameters.js +322 -0
  185. package/dist-runtime/workflow/lib/parameters.js.map +1 -0
  186. package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
  187. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
  188. package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
  189. package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
  190. package/dist-runtime/workflow/lib/proxy.js +19 -0
  191. package/dist-runtime/workflow/lib/proxy.js.map +1 -0
  192. package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
  193. package/dist-runtime/workflow/lib/registryCommit.js +319 -0
  194. package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
  195. package/dist-runtime/workflow/lib/release.d.ts +57 -0
  196. package/dist-runtime/workflow/lib/release.js +256 -0
  197. package/dist-runtime/workflow/lib/release.js.map +1 -0
  198. package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
  199. package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
  200. package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
  201. package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
  202. package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
  203. package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
  204. package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
  205. package/dist-runtime/workflow/lib/reporter.js +452 -0
  206. package/dist-runtime/workflow/lib/reporter.js.map +1 -0
  207. package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
  208. package/dist-runtime/workflow/lib/resultPaths.js +29 -0
  209. package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
  210. package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
  211. package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
  212. package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
  213. package/dist-runtime/workflow/lib/signer.d.ts +10 -0
  214. package/dist-runtime/workflow/lib/signer.js +105 -0
  215. package/dist-runtime/workflow/lib/signer.js.map +1 -0
  216. package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
  217. package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
  218. package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
  219. package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
  220. package/dist-runtime/workflow/lib/simulation.js +282 -0
  221. package/dist-runtime/workflow/lib/simulation.js.map +1 -0
  222. package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
  223. package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
  224. package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
  225. package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
  226. package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
  227. package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
  228. package/dist-runtime/workflow/lib/state.d.ts +6 -0
  229. package/dist-runtime/workflow/lib/state.js +25 -0
  230. package/dist-runtime/workflow/lib/state.js.map +1 -0
  231. package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
  232. package/dist-runtime/workflow/lib/staticValidation.js +124 -0
  233. package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
  234. package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
  235. package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
  236. package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
  237. package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
  238. package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
  239. package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
  240. package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
  241. package/dist-runtime/workflow/reconcileExternal.js +87 -0
  242. package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
  243. package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
  244. package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
  245. package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
  246. package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
  247. package/dist-runtime/workflow/releaseFinalize.js +11 -0
  248. package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
  249. package/dist-runtime/workflow/run.d.ts +40 -0
  250. package/dist-runtime/workflow/run.js +858 -0
  251. package/dist-runtime/workflow/run.js.map +1 -0
  252. package/dist-runtime/workflow/staticValidate.d.ts +1 -0
  253. package/dist-runtime/workflow/staticValidate.js +26 -0
  254. package/dist-runtime/workflow/staticValidate.js.map +1 -0
  255. package/dist-runtime/workflow/steps/call.d.ts +3 -0
  256. package/dist-runtime/workflow/steps/call.js +9 -0
  257. package/dist-runtime/workflow/steps/call.js.map +1 -0
  258. package/dist-runtime/workflow/steps/check.d.ts +3 -0
  259. package/dist-runtime/workflow/steps/check.js +9 -0
  260. package/dist-runtime/workflow/steps/check.js.map +1 -0
  261. package/dist-runtime/workflow/steps/custom.d.ts +3 -0
  262. package/dist-runtime/workflow/steps/custom.js +33 -0
  263. package/dist-runtime/workflow/steps/custom.js.map +1 -0
  264. package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
  265. package/dist-runtime/workflow/steps/deploy.js +595 -0
  266. package/dist-runtime/workflow/steps/deploy.js.map +1 -0
  267. package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
  268. package/dist-runtime/workflow/steps/upgrade.js +465 -0
  269. package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
  270. package/dist-runtime/workflow/steps/view.d.ts +3 -0
  271. package/dist-runtime/workflow/steps/view.js +9 -0
  272. package/dist-runtime/workflow/steps/view.js.map +1 -0
  273. package/package.json +26 -5
  274. package/runtime/config/hardhatAdapters.ts +50 -0
  275. package/runtime/config/networks.ts +296 -0
  276. package/runtime/config/openzeppelin.ts +173 -0
  277. package/runtime/config/rpc.ts +27 -0
  278. package/runtime/config/zksyncSolcPath.ts +59 -0
  279. package/runtime/hardhat-types.d.ts +2 -0
  280. package/runtime/migrate.ts +154 -0
  281. package/runtime/projectHardhat.ts +10 -0
  282. package/runtime/template-migration.json +293 -0
  283. package/runtime/workflow/checkCode.ts +13 -0
  284. package/runtime/workflow/checkCodeFinalize.ts +8 -0
  285. package/runtime/workflow/checkCodePlan.ts +8 -0
  286. package/runtime/workflow/cli.ts +356 -0
  287. package/runtime/workflow/commitContractInfo.ts +63 -0
  288. package/runtime/workflow/create2Hashes.ts +79 -0
  289. package/runtime/workflow/forkSourceProxy.ts +193 -0
  290. package/runtime/workflow/importState.ts +190 -0
  291. package/runtime/workflow/lib/authority.ts +170 -0
  292. package/runtime/workflow/lib/calldata.ts +9 -0
  293. package/runtime/workflow/lib/calls.ts +407 -0
  294. package/runtime/workflow/lib/checkCode/args.ts +76 -0
  295. package/runtime/workflow/lib/checkCode/command.ts +36 -0
  296. package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
  297. package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
  298. package/runtime/workflow/lib/checkCode/index.ts +18 -0
  299. package/runtime/workflow/lib/checkCode/plan.ts +163 -0
  300. package/runtime/workflow/lib/checkCodeReport.ts +133 -0
  301. package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
  302. package/runtime/workflow/lib/cliTool.ts +31 -0
  303. package/runtime/workflow/lib/config.ts +130 -0
  304. package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
  305. package/runtime/workflow/lib/create2.ts +278 -0
  306. package/runtime/workflow/lib/create2Hashes.ts +83 -0
  307. package/runtime/workflow/lib/deploymentInfo.ts +286 -0
  308. package/runtime/workflow/lib/deploymentRecords.ts +576 -0
  309. package/runtime/workflow/lib/deployments.ts +276 -0
  310. package/runtime/workflow/lib/erc1967.ts +57 -0
  311. package/runtime/workflow/lib/errors.ts +95 -0
  312. package/runtime/workflow/lib/executionId.ts +35 -0
  313. package/runtime/workflow/lib/executionPlan.ts +550 -0
  314. package/runtime/workflow/lib/executionProgress.ts +127 -0
  315. package/runtime/workflow/lib/external.ts +372 -0
  316. package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
  317. package/runtime/workflow/lib/forkSnapshot.ts +231 -0
  318. package/runtime/workflow/lib/gateTool.ts +261 -0
  319. package/runtime/workflow/lib/gateToolSync.ts +398 -0
  320. package/runtime/workflow/lib/lock.ts +388 -0
  321. package/runtime/workflow/lib/migrationState.ts +1246 -0
  322. package/runtime/workflow/lib/operatorExecution.ts +174 -0
  323. package/runtime/workflow/lib/parameters.ts +437 -0
  324. package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
  325. package/runtime/workflow/lib/proxy.ts +45 -0
  326. package/runtime/workflow/lib/registryCommit.ts +455 -0
  327. package/runtime/workflow/lib/release.ts +329 -0
  328. package/runtime/workflow/lib/releaseFinalize.ts +711 -0
  329. package/runtime/workflow/lib/releaseParameters.ts +248 -0
  330. package/runtime/workflow/lib/reporter.ts +502 -0
  331. package/runtime/workflow/lib/resultPaths.ts +49 -0
  332. package/runtime/workflow/lib/runtimeVersion.ts +28 -0
  333. package/runtime/workflow/lib/signer.ts +124 -0
  334. package/runtime/workflow/lib/signerIdentity.ts +22 -0
  335. package/runtime/workflow/lib/simulation.ts +415 -0
  336. package/runtime/workflow/lib/simulationCallers.ts +335 -0
  337. package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
  338. package/runtime/workflow/lib/state.ts +25 -0
  339. package/runtime/workflow/lib/staticValidation.ts +142 -0
  340. package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
  341. package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
  342. package/runtime/workflow/reconcileExternal.ts +86 -0
  343. package/runtime/workflow/reconcileExternalRun.ts +88 -0
  344. package/runtime/workflow/releaseFinalize.ts +8 -0
  345. package/runtime/workflow/run.ts +1072 -0
  346. package/runtime/workflow/staticValidate.ts +23 -0
  347. package/runtime/workflow/steps/call.ts +10 -0
  348. package/runtime/workflow/steps/check.ts +10 -0
  349. package/runtime/workflow/steps/custom.ts +43 -0
  350. package/runtime/workflow/steps/deploy.ts +771 -0
  351. package/runtime/workflow/steps/upgrade.ts +598 -0
  352. package/runtime/workflow/steps/view.ts +10 -0
@@ -0,0 +1,1072 @@
1
+ import { bindExecutionRuntime } from "./lib/runtimeVersion";
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import type { Signer } from "ethers";
5
+ import { artifacts, config as hardhatConfig, ethers, network } from "../projectHardhat";
6
+ import {
7
+ loadConfig,
8
+ resolveAdmin,
9
+ resolveTarget,
10
+ taskDir as resolveTaskDir,
11
+ TargetConfig,
12
+ } from "./lib/config";
13
+ import { buildExecutionId, validateExecutionId } from "./lib/executionId";
14
+ import {
15
+ assertParameterLockExecutable,
16
+ markParameterLockSimulationSucceeded,
17
+ ParameterLockExecution,
18
+ readParameterLockExecution,
19
+ writeParameterLock,
20
+ } from "./lib/lock";
21
+ import {
22
+ loadManifest,
23
+ loadParameterSchema,
24
+ loadParameters,
25
+ loadTaskMetadata,
26
+ targetParams,
27
+ assertExistingDeploymentPoliciesMatchTarget,
28
+ ExistingDeploymentPolicies,
29
+ validateExistingDeploymentPolicies,
30
+ WorkflowStep,
31
+ } from "./lib/parameters";
32
+ import { findDeploymentAddress } from "./lib/deployments";
33
+ import {
34
+ assertReleaseNetworkReady,
35
+ ArtifactFingerprintInput,
36
+ buildReleaseFingerprint,
37
+ loadRelease,
38
+ normalizeCreate2Scheme,
39
+ recordReleaseTargetSimulationSucceeded,
40
+ ReleaseFingerprint,
41
+ } from "./lib/release";
42
+ import {
43
+ resolveExecutionParameters,
44
+ } from "./lib/releaseParameters";
45
+ import { WorkflowReporter } from "./lib/reporter";
46
+ import {
47
+ ExternalCall,
48
+ ExternalExecutionRequired,
49
+ writeExternalExecutionPackage,
50
+ } from "./lib/external";
51
+ import { classifyWorkflowError } from "./lib/errors";
52
+ import {
53
+ resolveWorkflowMode,
54
+ setupSimulationFork,
55
+ assertSimulationSourceInfrastructure,
56
+ simulationForkEvidence,
57
+ SimulationFork,
58
+ verifySimulationForkSnapshot,
59
+ WorkflowMode,
60
+ } from "./lib/simulation";
61
+ import {
62
+ impersonateWorkflowSimulationSigner,
63
+ resolveSimulationSignerAddress,
64
+ resolveWorkflowSigner,
65
+ } from "./lib/signer";
66
+ import { loadSimulationCallerNetwork } from "./lib/simulationCallers";
67
+ import { WorkflowState } from "./lib/state";
68
+ import { DeploymentRecorder } from "./lib/deploymentRecords";
69
+ import { runDeployStep } from "./steps/deploy";
70
+ import { runCallStep } from "./steps/call";
71
+ import { runUpgradeStep } from "./steps/upgrade";
72
+ import { runViewStep } from "./steps/view";
73
+ import { runCheckStep } from "./steps/check";
74
+ import { runCustomStep } from "./steps/custom";
75
+ import {
76
+ ExecutionSegmentDeferred,
77
+ loadReleaseExecutionPlan,
78
+ ReleaseExecutionPlan,
79
+ ReleaseExecutionPlanner,
80
+ ReleaseKind,
81
+ releaseExecutionPlanRelativePath,
82
+ writeReleaseExecutionPlan,
83
+ } from "./lib/executionPlan";
84
+ import { writeOperatorExecutionResult } from "./lib/operatorExecution";
85
+ import { loadCompletedExecutionPrefix } from "./lib/executionProgress";
86
+
87
+ export interface WorkflowContext {
88
+ root: string;
89
+ taskId: string;
90
+ executionId: string;
91
+ taskDir: string;
92
+ targetId: string;
93
+ target: TargetConfig & Record<string, unknown> & { id: string };
94
+ targetParams: Record<string, unknown>;
95
+ existingDeploymentPolicies: ExistingDeploymentPolicies;
96
+ releaseArtifactHash?: string;
97
+ parameterLockExecutionId?: string;
98
+ parameterLockOperator?: string;
99
+ config: ReturnType<typeof loadConfig>;
100
+ mode: WorkflowMode;
101
+ simulation: SimulationFork;
102
+ signer?: Signer;
103
+ signerAddress?: string;
104
+ configuredSimulationCaller?: boolean;
105
+ state: WorkflowState;
106
+ reporter: WorkflowReporter;
107
+ deploymentRecorder?: DeploymentRecorder;
108
+ executionPlanner?: ReleaseExecutionPlanner;
109
+ lockedExecutionPlan?: ReleaseExecutionPlan;
110
+ externalCalls: ExternalCall[];
111
+ operatorReceipts: Array<{ transactionId: string; transactionHash: string }>;
112
+ }
113
+
114
+ const parseArgs = (argv: string[]): Record<string, string | boolean> => {
115
+ const args: Record<string, string | boolean> = {};
116
+ for (let index = 0; index < argv.length; index += 1) {
117
+ const item = argv[index];
118
+ if (!item.startsWith("--")) continue;
119
+ const equalIndex = item.indexOf("=");
120
+ if (equalIndex > 2) {
121
+ args[item.slice(2, equalIndex)] = item.slice(equalIndex + 1);
122
+ continue;
123
+ }
124
+ const key = item.slice(2);
125
+ const next = argv[index + 1];
126
+ if (!next || next.startsWith("--")) {
127
+ args[key] = true;
128
+ } else {
129
+ args[key] = next;
130
+ index += 1;
131
+ }
132
+ }
133
+ return args;
134
+ };
135
+
136
+ const parseEnvArgs = (): Record<string, string | boolean> => {
137
+ const raw = process.env.WORKFLOW_ARGS_JSON;
138
+ if (!raw) return {};
139
+
140
+ let parsed: unknown;
141
+ try {
142
+ parsed = JSON.parse(raw);
143
+ } catch (error) {
144
+ throw new Error(`WORKFLOW_ARGS_JSON must be valid JSON: ${error instanceof Error ? error.message : String(error)}`);
145
+ }
146
+
147
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
148
+ throw new Error("WORKFLOW_ARGS_JSON must be a JSON object");
149
+ }
150
+
151
+ const args: Record<string, string | boolean> = {};
152
+ for (const [key, value] of Object.entries(parsed)) {
153
+ if (typeof value !== "string" && typeof value !== "boolean") {
154
+ throw new Error(`WORKFLOW_ARGS_JSON.${key} must be a string or boolean`);
155
+ }
156
+ args[key] = value;
157
+ }
158
+ return args;
159
+ };
160
+
161
+ const assertWalletCredentialForExecution = (mode: WorkflowMode, targetId: string): void => {
162
+ if (mode !== "execute") return;
163
+ if (targetId === "hardhat" || targetId === "localhost") return;
164
+ if (process.env.WALLET_CREDENTIAL?.trim()) return;
165
+ if (process.env.PRIVATE_KEY?.trim()) return;
166
+
167
+ throw new Error(
168
+ `Missing wallet credential in project .env or process env. Execute mode on "${targetId}" requires a deployment signer.`,
169
+ );
170
+ };
171
+
172
+ const selectSteps = (
173
+ steps: WorkflowStep[],
174
+ args: Record<string, string | boolean>,
175
+ ): WorkflowStep[] => {
176
+ if (typeof args.step === "string") {
177
+ return steps.filter((step) => step.id === args.step);
178
+ }
179
+
180
+ if (typeof args.from === "string") {
181
+ const index = steps.findIndex((step) => step.id === args.from);
182
+ if (index < 0) throw new Error(`Unknown --from step: ${args.from}`);
183
+ return steps.slice(index);
184
+ }
185
+
186
+ return steps;
187
+ };
188
+
189
+ const runStep = async (context: WorkflowContext, step: WorkflowStep): Promise<void> => {
190
+ switch (step.kind) {
191
+ case "deploy":
192
+ await runDeployStep(context, step);
193
+ return;
194
+ case "call":
195
+ await runCallStep(context, step);
196
+ return;
197
+ case "upgrade":
198
+ await runUpgradeStep(context, step);
199
+ return;
200
+ case "view":
201
+ await runViewStep(context, step);
202
+ return;
203
+ case "check":
204
+ await runCheckStep(context, step);
205
+ return;
206
+ case "custom":
207
+ await runCustomStep(context, step);
208
+ return;
209
+ default:
210
+ throw new Error(`Unsupported step kind: ${step.kind}`);
211
+ }
212
+ };
213
+
214
+ interface PreparedReleaseExecution {
215
+ sourceSuperTaskId: string;
216
+ mergeCommit: string;
217
+ baselineParameters: Record<string, unknown>;
218
+ overrides: Record<string, unknown>;
219
+ resolvedParameters: Record<string, unknown>;
220
+ releaseFingerprint: ReleaseFingerprint;
221
+ existingDeploymentPolicies: ExistingDeploymentPolicies;
222
+ lockedExecution?: ParameterLockExecution;
223
+ }
224
+
225
+ const booleanArg = (
226
+ args: Record<string, string | boolean>,
227
+ key: string,
228
+ ): boolean => {
229
+ const value = args[key];
230
+ return value === true || value === "true";
231
+ };
232
+
233
+ const requiredStringArg = (
234
+ args: Record<string, string | boolean>,
235
+ key: string,
236
+ ): string => {
237
+ const value = args[key];
238
+ if (typeof value !== "string" || !value.trim()) {
239
+ throw new Error("Missing --" + key + " for release execution");
240
+ }
241
+ return value.trim();
242
+ };
243
+
244
+ const optionalStringArg = (
245
+ args: Record<string, string | boolean>,
246
+ key: string,
247
+ ): string | undefined => {
248
+ const value = args[key];
249
+ if (value === undefined) return undefined;
250
+ if (typeof value !== "string" || !value.trim()) {
251
+ throw new Error("--" + key + " requires a non-empty value");
252
+ }
253
+ return value.trim();
254
+ };
255
+
256
+ const releaseKindArg = (
257
+ args: Record<string, string | boolean>,
258
+ ): ReleaseKind => {
259
+ const value = requiredStringArg(args, "releaseKind");
260
+ if (value !== "development" && value !== "admin_release") {
261
+ throw new Error("--releaseKind must be development or admin_release");
262
+ }
263
+ return value;
264
+ };
265
+
266
+ const parseParameterOverrides = (
267
+ args: Record<string, string | boolean>,
268
+ ): Record<string, unknown> => {
269
+ const value = args.parameterOverrides;
270
+ if (value === undefined) return {};
271
+ if (typeof value !== "string") {
272
+ throw new Error("--parameterOverrides must be a JSON object");
273
+ }
274
+ let parsed: unknown;
275
+ try {
276
+ parsed = JSON.parse(value);
277
+ } catch (error) {
278
+ throw new Error(
279
+ "--parameterOverrides must be valid JSON: "
280
+ + (error instanceof Error ? error.message : String(error)),
281
+ );
282
+ }
283
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
284
+ throw new Error("--parameterOverrides must be a JSON object");
285
+ }
286
+ return parsed as Record<string, unknown>;
287
+ };
288
+
289
+ const parseExistingDeploymentPolicies = (
290
+ args: Record<string, string | boolean>,
291
+ ): ExistingDeploymentPolicies => {
292
+ const value = args.existingDeploymentPolicies;
293
+ if (value === undefined) return {};
294
+ if (typeof value !== "string") {
295
+ throw new Error("--existingDeploymentPolicies must be a JSON object");
296
+ }
297
+ let parsed: unknown;
298
+ try {
299
+ parsed = JSON.parse(value);
300
+ } catch (error) {
301
+ throw new Error(
302
+ "--existingDeploymentPolicies must be valid JSON: "
303
+ + (error instanceof Error ? error.message : String(error)),
304
+ );
305
+ }
306
+ return validateExistingDeploymentPolicies(parsed);
307
+ };
308
+
309
+ const manifestContractReferences = (steps: WorkflowStep[]): string[] => {
310
+ const references = new Set<string>();
311
+ for (const step of steps) {
312
+ if ((step.kind === "deploy" || step.kind === "upgrade") && typeof step.contract === "string") {
313
+ references.add(step.contract);
314
+ }
315
+ if (step.kind === "deploy" && step.firstUpgrade && typeof step.firstUpgrade === "object") {
316
+ const contract = (step.firstUpgrade as Record<string, unknown>).contract;
317
+ if (typeof contract === "string") references.add(contract);
318
+ }
319
+ if (step.kind === "deploy" && step.upgradeableStrategy === "uups-placeholder-proxy") {
320
+ references.add(
321
+ "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy",
322
+ );
323
+ }
324
+ }
325
+ return [...references].sort();
326
+ };
327
+
328
+ const loadArtifactFingerprintInputs = async (
329
+ manifest: { steps: WorkflowStep[] },
330
+ ): Promise<ArtifactFingerprintInput[]> => {
331
+ const inputs: ArtifactFingerprintInput[] = [];
332
+ for (const contractReference of manifestContractReferences(manifest.steps)) {
333
+ const artifact = await artifacts.readArtifact(contractReference);
334
+ const fullyQualifiedName = artifact.sourceName + ":" + artifact.contractName;
335
+ const buildInfo = await artifacts.getBuildInfo(fullyQualifiedName);
336
+ if (!buildInfo) {
337
+ throw new Error("Missing Hardhat build info for " + fullyQualifiedName);
338
+ }
339
+ const settings = buildInfo.input.settings as Record<string, unknown>;
340
+ inputs.push({
341
+ contract: fullyQualifiedName,
342
+ bytecode: artifact.bytecode,
343
+ deployedBytecode: artifact.deployedBytecode,
344
+ linkReferences: artifact.linkReferences,
345
+ deployedLinkReferences: artifact.deployedLinkReferences,
346
+ solcVersion: buildInfo.solcVersion,
347
+ optimizer: settings.optimizer || {},
348
+ evmVersion: typeof settings.evmVersion === "string" ? settings.evmVersion : undefined,
349
+ });
350
+ }
351
+ return inputs;
352
+ };
353
+
354
+ const targetChainId = (targetId: string): number | undefined => {
355
+ const networks = hardhatConfig.networks as Record<string, { chainId?: number }>;
356
+ return networks[targetId]?.chainId;
357
+ };
358
+
359
+ const equalStringArrays = (left: string[], right: string[]): boolean => {
360
+ return left.length === right.length && left.every((value, index) => value === right[index]);
361
+ };
362
+
363
+ const prepareReleaseExecution = async (
364
+ args: Record<string, string | boolean>,
365
+ mode: WorkflowMode,
366
+ taskDir: string,
367
+ targetId: string,
368
+ target: TargetConfig & Record<string, unknown>,
369
+ manifest: { steps: WorkflowStep[] },
370
+ existingDeploymentInstanceIds: string[],
371
+ parameters: ReturnType<typeof loadParameters>,
372
+ executionId: string,
373
+ selectedStepIds: string[],
374
+ ): Promise<PreparedReleaseExecution | undefined> => {
375
+ if (!booleanArg(args, "useLock")) return undefined;
376
+ if (
377
+ mode !== "simulate"
378
+ && mode !== "execute"
379
+ && mode !== "verify"
380
+ ) {
381
+ throw new Error("--useLock only supports simulate, execute, and verify modes");
382
+ }
383
+
384
+ const release = loadRelease(taskDir);
385
+ const baselineParameters = targetParams(parameters, targetId);
386
+ const releaseFingerprint = buildReleaseFingerprint({
387
+ manifest: fs.readFileSync(path.join(taskDir, "manifest.yaml"), "utf8"),
388
+ artifacts: await loadArtifactFingerprintInputs(manifest),
389
+ parameters: baselineParameters,
390
+ network: targetId,
391
+ chainId: targetChainId(targetId),
392
+ target,
393
+ });
394
+ assertReleaseNetworkReady(release, targetId, releaseFingerprint);
395
+
396
+ if (mode === "execute" || mode === "verify") {
397
+ const lockedExecution = readParameterLockExecution(taskDir, executionId);
398
+ if (lockedExecution.sourceSuperTaskId !== release.sourceSuperTaskId) {
399
+ throw new Error("Parameter lock sourceSuperTaskId does not match release.json");
400
+ }
401
+ const verifySelectionStart = mode === "verify"
402
+ ? lockedExecution.selectedStepIds.indexOf(selectedStepIds[0])
403
+ : -1;
404
+ const selectedStepsMatch = mode === "verify"
405
+ ? selectedStepIds.length > 0
406
+ && verifySelectionStart >= 0
407
+ && equalStringArrays(
408
+ lockedExecution.selectedStepIds.slice(verifySelectionStart),
409
+ selectedStepIds,
410
+ )
411
+ : equalStringArrays(lockedExecution.selectedStepIds, selectedStepIds);
412
+ if (!selectedStepsMatch) {
413
+ throw new Error("Parameter lock selectedStepIds do not match this execution");
414
+ }
415
+ assertParameterLockExecutable(lockedExecution, targetId, releaseFingerprint);
416
+ const existingDeploymentPolicies = validateExistingDeploymentPolicies(
417
+ lockedExecution.existingDeploymentPolicies,
418
+ );
419
+ assertExistingDeploymentPoliciesMatchTarget(
420
+ existingDeploymentPolicies,
421
+ targetId,
422
+ existingDeploymentInstanceIds,
423
+ );
424
+ return {
425
+ sourceSuperTaskId: lockedExecution.sourceSuperTaskId,
426
+ mergeCommit: lockedExecution.mergeCommit,
427
+ baselineParameters: lockedExecution.baselineParameters,
428
+ overrides: lockedExecution.overrides,
429
+ resolvedParameters: lockedExecution.resolvedParameters,
430
+ releaseFingerprint,
431
+ existingDeploymentPolicies,
432
+ lockedExecution,
433
+ };
434
+ }
435
+
436
+ const sourceSuperTaskId = requiredStringArg(args, "sourceSuperTaskId");
437
+ if (sourceSuperTaskId !== release.sourceSuperTaskId) {
438
+ throw new Error("--sourceSuperTaskId does not match release.json");
439
+ }
440
+ const mergeCommit = requiredStringArg(args, "mergeCommit");
441
+ if (!/^[0-9a-fA-F]{40}$/.test(mergeCommit)) {
442
+ throw new Error("--mergeCommit must be a 40 character git commit");
443
+ }
444
+ const overrides = parseParameterOverrides(args);
445
+ const existingDeploymentPolicies = parseExistingDeploymentPolicies(args);
446
+ assertExistingDeploymentPoliciesMatchTarget(
447
+ existingDeploymentPolicies,
448
+ targetId,
449
+ existingDeploymentInstanceIds,
450
+ );
451
+ const resolvedParameters = resolveExecutionParameters(
452
+ parameters,
453
+ targetId,
454
+ overrides,
455
+ loadParameterSchema(taskDir),
456
+ );
457
+
458
+ return {
459
+ sourceSuperTaskId,
460
+ mergeCommit,
461
+ baselineParameters,
462
+ overrides,
463
+ resolvedParameters,
464
+ releaseFingerprint,
465
+ existingDeploymentPolicies,
466
+ };
467
+ };
468
+
469
+ async function main(): Promise<void> {
470
+ const args = {
471
+ ...parseEnvArgs(),
472
+ ...parseArgs(process.argv.slice(2)),
473
+ };
474
+ const root = process.cwd();
475
+ const taskId = typeof args.task === "string" ? args.task : process.env.WORKFLOW_TASK;
476
+ if (!taskId) {
477
+ throw new Error("Missing task id. Pass --task <taskId> or set WORKFLOW_TASK=<taskId> before running workflow.");
478
+ }
479
+ const taskDir = resolveTaskDir(taskId, root);
480
+ const mode = resolveWorkflowMode(args);
481
+ const targetId = mode === "simulate"
482
+ ? typeof args.target === "string"
483
+ ? args.target
484
+ : ""
485
+ : network.name;
486
+ if (!targetId) {
487
+ throw new Error("Missing target network. Run execute/plan with --network <network>, or simulate with --network hardhat --target <network>.");
488
+ }
489
+ const requestedReleaseKind = args.releaseKind === undefined
490
+ ? undefined
491
+ : releaseKindArg(args);
492
+ const gateFlowNodeKey = process.env.GATEFLOW_NODE_KEY?.trim();
493
+ if (gateFlowNodeKey === "DevelopmentDeployExecute" && mode !== "execute") {
494
+ throw new Error("GateFlow node DevelopmentDeployExecute only allows workflow --mode execute");
495
+ }
496
+ const gateFlowDevelopmentNode = gateFlowNodeKey === "DevelopmentDeploySimulate"
497
+ || gateFlowNodeKey === "DevelopmentDeployExecute";
498
+ if (gateFlowDevelopmentNode && requestedReleaseKind !== "development") {
499
+ throw new Error("GateFlow development deployment nodes require --releaseKind development");
500
+ }
501
+ if (
502
+ gateFlowDevelopmentNode
503
+ && (typeof args.executionId !== "string" || !args.executionId.trim())
504
+ ) {
505
+ throw new Error(
506
+ "GateFlow development deployment nodes require an explicit --executionId reused across simulate and execute",
507
+ );
508
+ }
509
+ const executionId = validateExecutionId(
510
+ args.executionId === undefined ? buildExecutionId(targetId) : args.executionId,
511
+ );
512
+ if (mode === "simulate" || mode === "execute") bindExecutionRuntime({taskDir, target: targetId, executionId});
513
+ const reporter = new WorkflowReporter(taskDir, taskId, executionId, targetId, mode);
514
+ reporter.initializeResults();
515
+ let contextForFailure: WorkflowContext | undefined;
516
+
517
+ try {
518
+ const config = loadConfig(root);
519
+ const manifest = loadManifest(taskDir);
520
+ const parameters = loadParameters(taskDir);
521
+ const taskMetadata = loadTaskMetadata(taskDir);
522
+ const target = resolveTarget(config, targetId);
523
+ if (
524
+ mode === "execute"
525
+ && target.environment === "production"
526
+ && !booleanArg(args, "useLock")
527
+ ) {
528
+ throw new Error("Production execute requires --useLock and an immutable execution plan");
529
+ }
530
+ assertWalletCredentialForExecution(mode, targetId);
531
+ const steps = selectSteps(manifest.steps, args);
532
+ const existingDeploymentInstanceIds = manifest.steps
533
+ .filter((step) => step.kind === "deploy" && typeof step.saveAs === "string")
534
+ .map((step) => String(step.saveAs))
535
+ .filter((instanceId) => Boolean(
536
+ findDeploymentAddress(root, config, targetId, instanceId),
537
+ ));
538
+ const releaseTargetSimulation = mode === "simulate"
539
+ && (network.name === "hardhat" || network.name === "zkFork")
540
+ && typeof args.target === "string"
541
+ && (taskMetadata.releaseTargetNetworks ?? []).includes(targetId)
542
+ && !booleanArg(args, "useLock")
543
+ && requestedReleaseKind === undefined;
544
+ if (
545
+ releaseTargetSimulation
546
+ && (args.step !== undefined || args.from !== undefined)
547
+ ) {
548
+ throw new Error(
549
+ "Full release-target simulation does not support partial --step or --from selection",
550
+ );
551
+ }
552
+ const simulationCallerBinding = releaseTargetSimulation
553
+ ? loadSimulationCallerNetwork({
554
+ taskDir,
555
+ targetNetworks: taskMetadata.releaseTargetNetworks!,
556
+ network: targetId,
557
+ manifestText: fs.readFileSync(path.join(taskDir, "manifest.yaml"), "utf8"),
558
+ manifestSteps: manifest.steps,
559
+ })
560
+ : undefined;
561
+ const releaseTargetFingerprint = releaseTargetSimulation
562
+ ? buildReleaseFingerprint({
563
+ manifest: fs.readFileSync(path.join(taskDir, "manifest.yaml"), "utf8"),
564
+ artifacts: await loadArtifactFingerprintInputs(manifest),
565
+ parameters: targetParams(parameters, targetId),
566
+ network: targetId,
567
+ chainId: targetChainId(targetId),
568
+ target,
569
+ })
570
+ : undefined;
571
+ if (mode === "simulate" && steps.length === 0) {
572
+ throw new Error("Simulation must select at least one workflow step");
573
+ }
574
+ if (mode === "verify") {
575
+ const unsupported = steps.find((step) => step.kind !== "view" && step.kind !== "check");
576
+ if (unsupported) {
577
+ throw new Error(`verify mode only supports view and check steps; ${unsupported.id} is ${unsupported.kind}`);
578
+ }
579
+ }
580
+ const releaseExecution = await prepareReleaseExecution(
581
+ args,
582
+ mode,
583
+ taskDir,
584
+ targetId,
585
+ target,
586
+ manifest,
587
+ existingDeploymentInstanceIds,
588
+ parameters,
589
+ executionId,
590
+ steps.map((step) => step.id),
591
+ );
592
+ if (!releaseExecution && requestedReleaseKind === "admin_release") {
593
+ throw new Error("admin_release execution requires --useLock");
594
+ }
595
+ const developmentPlanExecution = !releaseExecution
596
+ && requestedReleaseKind === "development";
597
+ if (
598
+ developmentPlanExecution
599
+ && mode !== "simulate"
600
+ && mode !== "execute"
601
+ ) {
602
+ throw new Error("development releaseKind only supports simulate and execute modes");
603
+ }
604
+ const lockedExecutionPlan = releaseExecution?.lockedExecution
605
+ ? loadReleaseExecutionPlan({
606
+ root,
607
+ taskDir,
608
+ target: targetId,
609
+ executionId,
610
+ expectedHash: releaseExecution.lockedExecution.finalSimulation.status === "succeeded"
611
+ ? releaseExecution.lockedExecution.finalSimulation.executionPlanHash
612
+ : undefined,
613
+ })
614
+ : developmentPlanExecution && mode === "execute"
615
+ ? loadReleaseExecutionPlan({
616
+ root,
617
+ taskDir,
618
+ target: targetId,
619
+ executionId,
620
+ })
621
+ : undefined;
622
+ const releaseKind = releaseExecution
623
+ ? mode === "simulate"
624
+ ? requestedReleaseKind
625
+ : lockedExecutionPlan?.releaseKind
626
+ : developmentPlanExecution
627
+ ? "development"
628
+ : undefined;
629
+ const completedExecutionPrefix = mode === "execute" && lockedExecutionPlan
630
+ ? loadCompletedExecutionPrefix({ taskDir, plan: lockedExecutionPlan })
631
+ : [];
632
+ const simulationSignerAddress = mode === "simulate"
633
+ ? simulationCallerBinding?.defaultAddress
634
+ ?? resolveSimulationSignerAddress({
635
+ explicitAddress: optionalStringArg(args, "simulationSigner"),
636
+ taskAddress: taskMetadata.deploymentSignerAddress,
637
+ useLock: booleanArg(args, "useLock"),
638
+ })
639
+ : undefined;
640
+ const simulation = mode === "simulate" ? await setupSimulationFork(targetId) : {};
641
+ if (mode === "simulate") {
642
+ await assertSimulationSourceInfrastructure(targetId, target, simulation);
643
+ }
644
+ const signer = mode === "verify"
645
+ ? undefined
646
+ : mode === "simulate"
647
+ ? simulationCallerBinding
648
+ ? undefined
649
+ : await impersonateWorkflowSimulationSigner(simulationSignerAddress!)
650
+ : await resolveWorkflowSigner(mode, {
651
+ taskAddress: taskMetadata.deploymentSignerAddress,
652
+ });
653
+ const signerAddress = simulationCallerBinding?.defaultAddress
654
+ ?? (signer ? await signer.getAddress() : undefined);
655
+ const resolvedTarget = {
656
+ id: targetId,
657
+ ...target,
658
+ ...(signerAddress
659
+ ? {
660
+ signer: signerAddress,
661
+ admin: resolveAdmin(target, signerAddress),
662
+ }
663
+ : {}),
664
+ };
665
+
666
+ if (
667
+ lockedExecutionPlan
668
+ && mode === "execute"
669
+ && signerAddress
670
+ && lockedExecutionPlan.operator.toLowerCase() !== signerAddress.toLowerCase()
671
+ ) {
672
+ throw new Error("Execution plan operator does not match the execution signer");
673
+ }
674
+
675
+ if (releaseExecution && mode === "simulate") {
676
+ if (!signerAddress || !resolvedTarget.admin) {
677
+ throw new Error("Final simulation requires a resolved signer and admin");
678
+ }
679
+ const create2Config = resolvedTarget.create2 && typeof resolvedTarget.create2 === "object" && !Array.isArray(resolvedTarget.create2)
680
+ ? resolvedTarget.create2 as Record<string, unknown>
681
+ : {};
682
+ const uupsConfig = resolvedTarget.uups && typeof resolvedTarget.uups === "object" && !Array.isArray(resolvedTarget.uups)
683
+ ? resolvedTarget.uups as Record<string, unknown>
684
+ : {};
685
+ const multicallConfig = resolvedTarget.multicall && typeof resolvedTarget.multicall === "object" && !Array.isArray(resolvedTarget.multicall)
686
+ ? resolvedTarget.multicall as Record<string, unknown>
687
+ : {};
688
+ writeParameterLock({
689
+ taskDir,
690
+ deploymentId: taskId,
691
+ executionId,
692
+ sourceSuperTaskId: releaseExecution.sourceSuperTaskId,
693
+ mergeCommit: releaseExecution.mergeCommit,
694
+ selectedExecuteNetworks: [targetId],
695
+ selectedStepIds: steps.map((step) => step.id),
696
+ operator: signerAddress,
697
+ baselineParameters: releaseExecution.baselineParameters,
698
+ overrides: releaseExecution.overrides,
699
+ resolvedParameters: releaseExecution.resolvedParameters,
700
+ releaseFingerprint: releaseExecution.releaseFingerprint,
701
+ finalSimulation: { status: "pending" },
702
+ existingDeploymentPolicies: releaseExecution.existingDeploymentPolicies,
703
+ targetSnapshot: {
704
+ network: targetId,
705
+ signer: signerAddress,
706
+ admin: resolvedTarget.admin,
707
+ chainId: targetChainId(targetId),
708
+ create2Scheme: normalizeCreate2Scheme(create2Config.scheme),
709
+ create2Factory: typeof create2Config.factory === "string" ? create2Config.factory : undefined,
710
+ create2Caller: typeof create2Config.caller === "string" ? create2Config.caller : undefined,
711
+ controlledMulticall: typeof multicallConfig.controlledMulticall === "string"
712
+ ? multicallConfig.controlledMulticall
713
+ : undefined,
714
+ uupsPlaceholderImplementation: typeof uupsConfig.placeholderImplementation === "string"
715
+ ? uupsConfig.placeholderImplementation
716
+ : undefined,
717
+ leadingZeroBytes: typeof create2Config.leadingZeroBytes === "number"
718
+ ? create2Config.leadingZeroBytes
719
+ : undefined,
720
+ },
721
+ });
722
+ }
723
+
724
+ const context: WorkflowContext = {
725
+ root,
726
+ taskId,
727
+ executionId,
728
+ taskDir,
729
+ targetId,
730
+ target: resolvedTarget,
731
+ targetParams: releaseExecution?.resolvedParameters || targetParams(parameters, targetId),
732
+ existingDeploymentPolicies: releaseExecution
733
+ ? releaseExecution.existingDeploymentPolicies
734
+ : parseExistingDeploymentPolicies(args),
735
+ releaseArtifactHash: releaseExecution?.releaseFingerprint.artifactHash,
736
+ parameterLockExecutionId: releaseExecution ? executionId : undefined,
737
+ parameterLockOperator: releaseExecution?.lockedExecution?.operator,
738
+ config,
739
+ mode,
740
+ simulation,
741
+ signer,
742
+ signerAddress,
743
+ state: new WorkflowState(),
744
+ reporter,
745
+ executionPlanner: (releaseExecution || developmentPlanExecution)
746
+ && releaseKind
747
+ && (mode === "simulate" || mode === "execute")
748
+ ? new ReleaseExecutionPlanner({
749
+ taskId,
750
+ target: targetId,
751
+ executionId,
752
+ releaseKind,
753
+ operator: lockedExecutionPlan?.operator
754
+ || releaseExecution?.lockedExecution?.operator
755
+ || signerAddress!,
756
+ expectedPlan: lockedExecutionPlan,
757
+ segmentedExecution: mode === "execute"
758
+ && lockedExecutionPlan?.releaseKind === "admin_release",
759
+ completedTransactions: completedExecutionPrefix,
760
+ })
761
+ : undefined,
762
+ lockedExecutionPlan,
763
+ externalCalls: [],
764
+ operatorReceipts: [],
765
+ };
766
+ contextForFailure = context;
767
+
768
+ reporter.status("running", { mode, stepCount: steps.length });
769
+ reporter.event("workflow.started", { mode, network: network.name, target: targetId, steps: steps.map((step) => step.id) });
770
+
771
+ if (
772
+ mode === "execute" &&
773
+ (
774
+ Boolean(releaseExecution)
775
+ || steps.some((step) => step.kind === "deploy" || step.kind === "upgrade")
776
+ )
777
+ ) {
778
+ context.deploymentRecorder = new DeploymentRecorder({
779
+ root,
780
+ taskDir,
781
+ config,
782
+ taskId,
783
+ executionId,
784
+ network: targetId,
785
+ awaitRegistryCommit: Boolean(releaseExecution || developmentPlanExecution),
786
+ resume: completedExecutionPrefix.length > 0,
787
+ });
788
+ }
789
+
790
+ let executionSegmentDeferred = false;
791
+ stepLoop: for (const step of steps) {
792
+ if (
793
+ context.mode === "execute"
794
+ && context.externalCalls.length > 0
795
+ && (step.kind === "view" || step.kind === "check" || step.kind === "custom")
796
+ ) {
797
+ reporter.event("step.deferred_until_external_execution", {
798
+ stepId: step.id,
799
+ kind: step.kind,
800
+ });
801
+ break;
802
+ }
803
+ const configuredCaller = simulationCallerBinding?.resolved.find(
804
+ (entry) => entry.stepId === step.id,
805
+ );
806
+ const stepContext: WorkflowContext = configuredCaller
807
+ ? {
808
+ ...context,
809
+ signer: await impersonateWorkflowSimulationSigner(configuredCaller.callerAddress),
810
+ signerAddress: configuredCaller.callerAddress,
811
+ configuredSimulationCaller: true,
812
+ }
813
+ : context;
814
+ if (configuredCaller) {
815
+ reporter.setSimulationCallerAddress(configuredCaller.callerAddress);
816
+ }
817
+ try {
818
+ reporter.event("step.started", { stepId: step.id, kind: step.kind });
819
+ try {
820
+ await runStep(stepContext, step);
821
+ } catch (error) {
822
+ if (context.mode === "execute" && error instanceof ExecutionSegmentDeferred) {
823
+ executionSegmentDeferred = true;
824
+ reporter.event("execution.segment.deferred", {
825
+ transactionId: error.transactionId,
826
+ });
827
+ break stepLoop;
828
+ }
829
+ if (
830
+ context.mode === "execute"
831
+ && error instanceof ExternalExecutionRequired
832
+ ) {
833
+ if (!context.executionPlanner) {
834
+ throw new Error(
835
+ "External execution requires a locked mixed-authority plan; run final simulation and execute mode",
836
+ );
837
+ }
838
+ for (const call of error.calls) {
839
+ let planned;
840
+ try {
841
+ planned = context.executionPlanner.add({
842
+ stepId: call.stepId,
843
+ executor: call.executor,
844
+ to: call.to,
845
+ value: call.value,
846
+ data: call.data,
847
+ operation: call.operation,
848
+ });
849
+ } catch (planError) {
850
+ if (planError instanceof ExecutionSegmentDeferred) {
851
+ executionSegmentDeferred = true;
852
+ reporter.event("execution.segment.deferred", {
853
+ transactionId: planError.transactionId,
854
+ });
855
+ break;
856
+ }
857
+ throw planError;
858
+ }
859
+ if (planned.route !== "external") {
860
+ throw new Error(
861
+ `Step ${call.stepId} requested external execution for an operator route`,
862
+ );
863
+ }
864
+ if (planned.executionAction !== "replay") {
865
+ context.externalCalls.push({
866
+ ...call,
867
+ transactionId: planned.transactionId,
868
+ stepId: planned.stepId,
869
+ executor: planned.executor,
870
+ to: planned.to,
871
+ value: planned.value,
872
+ data: planned.data,
873
+ operation: planned.operation,
874
+ });
875
+ }
876
+ }
877
+ if (executionSegmentDeferred) break stepLoop;
878
+ continue;
879
+ }
880
+ throw error;
881
+ }
882
+ reporter.event("step.completed", { stepId: step.id, kind: step.kind });
883
+ } finally {
884
+ if (configuredCaller) reporter.clearSimulationCallerAddress();
885
+ }
886
+ }
887
+
888
+ const plannedBody = context.executionPlanner?.complete({
889
+ allowPartial: executionSegmentDeferred,
890
+ });
891
+ const completedPlan = mode === "simulate" && plannedBody
892
+ ? writeReleaseExecutionPlan({ root, taskDir, plan: plannedBody })
893
+ : lockedExecutionPlan;
894
+
895
+ if (mode === "simulate") {
896
+ await verifySimulationForkSnapshot(context.simulation);
897
+ }
898
+ if (completedPlan && mode === "execute") {
899
+ writeOperatorExecutionResult({
900
+ taskDir,
901
+ plan: completedPlan,
902
+ receipts: context.operatorReceipts,
903
+ });
904
+ }
905
+
906
+ if (releaseExecution && mode === "simulate") {
907
+ if (!completedPlan) throw new Error("Final simulation did not produce an execution plan");
908
+ reporter.result("execution", {
909
+ kind: "release-final-simulation",
910
+ status: "succeeded",
911
+ selectedStepIds: steps.map((step) => step.id),
912
+ releaseFingerprint: releaseExecution.releaseFingerprint,
913
+ releaseKind: completedPlan.releaseKind,
914
+ executionPlanHash: completedPlan.planHash,
915
+ executionPlanPath: releaseExecutionPlanRelativePath(taskDir, completedPlan),
916
+ });
917
+ }
918
+ let deploymentStatus;
919
+ if (
920
+ mode === "execute"
921
+ && completedPlan
922
+ && context.externalCalls.length > 0
923
+ ) {
924
+ const externalPackage = writeExternalExecutionPackage({
925
+ taskDir,
926
+ plan: completedPlan,
927
+ handoffBlock: await ethers.provider.getBlockNumber(),
928
+ calls: context.externalCalls,
929
+ });
930
+ const externalSegment = externalPackage.package.segments.at(-1)!;
931
+ context.deploymentRecorder?.markWaitingExternal({
932
+ packagePath: path.relative(root, externalPackage.filePath).split(path.sep).join("/"),
933
+ executionPlanHash: completedPlan.planHash,
934
+ handoffBlock: externalSegment.handoffBlock,
935
+ transactionIds: externalSegment.transactionIds,
936
+ });
937
+ deploymentStatus = "waiting_external";
938
+ } else {
939
+ deploymentStatus = context.deploymentRecorder?.complete();
940
+ }
941
+ const finalStatus = deploymentStatus === "waiting_code_check"
942
+ ? "waiting_code_check"
943
+ : deploymentStatus === "waiting_external"
944
+ ? "waiting_external"
945
+ : deploymentStatus === "partial"
946
+ ? "partial"
947
+ : "completed";
948
+ if (mode !== "simulate") {
949
+ reporter.status(finalStatus, { mode, stepCount: steps.length });
950
+ }
951
+ reporter.report(
952
+ mode === "simulate" ? "simulation-report.md" : "execution-report.md",
953
+ [
954
+ `# Execution Report`,
955
+ ``,
956
+ `Task: ${taskId}`,
957
+ `Target: ${targetId}`,
958
+ `Network: ${network.name}`,
959
+ `Mode: ${mode}`,
960
+ `Status: ${finalStatus}`,
961
+ ``,
962
+ `Steps:`,
963
+ ...steps.map((step) => `- ${step.id} (${step.kind})`),
964
+ ],
965
+ );
966
+ if (mode === "simulate") {
967
+ if (!signerAddress) {
968
+ throw new Error("Simulation completed without a selected signer address");
969
+ }
970
+ const simulationCallers = simulationCallerBinding?.resolved.map((entry) => ({
971
+ stepId: entry.stepId,
972
+ callerAddress: entry.callerAddress,
973
+ }));
974
+ const fork = simulationForkEvidence(context.simulation);
975
+ const completionPlan = completedPlan
976
+ ? { executionPlanHash: completedPlan.planHash }
977
+ : {};
978
+ const completionFork = fork ? { fork } : {};
979
+ reporter.result("execution", simulationCallerBinding
980
+ ? {
981
+ kind: "workflow-simulation-completed",
982
+ status: "succeeded",
983
+ selectedStepIds: steps.map((step) => step.id),
984
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
985
+ simulationCallers,
986
+ ...completionFork,
987
+ ...completionPlan,
988
+ }
989
+ : {
990
+ kind: "workflow-simulation-completed",
991
+ status: "succeeded",
992
+ selectedStepIds: steps.map((step) => step.id),
993
+ signerAddress,
994
+ ...completionFork,
995
+ ...completionPlan,
996
+ });
997
+ const simulationResult = simulationCallerBinding
998
+ ? reporter.simulationExecutionResultPath({
999
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
1000
+ simulationCallers: simulationCallers!,
1001
+ })
1002
+ : reporter.simulationExecutionResultPath(signerAddress);
1003
+ if (releaseTargetSimulation) {
1004
+ if (!simulationCallerBinding || !releaseTargetFingerprint) {
1005
+ throw new Error("Release target simulation evidence binding is missing");
1006
+ }
1007
+ recordReleaseTargetSimulationSucceeded({
1008
+ taskDir,
1009
+ network: targetId,
1010
+ executionId,
1011
+ simulationResult,
1012
+ simulatedAt: new Date().toISOString(),
1013
+ simulationCallerNetworkHash: simulationCallerBinding.networkHash,
1014
+ fingerprint: releaseTargetFingerprint,
1015
+ });
1016
+ }
1017
+ reporter.status(finalStatus, {
1018
+ mode,
1019
+ stepCount: steps.length,
1020
+ simulationResult,
1021
+ });
1022
+ if (releaseExecution) {
1023
+ if (!completedPlan) throw new Error("Final simulation execution plan is missing");
1024
+ markParameterLockSimulationSucceeded(
1025
+ taskDir,
1026
+ executionId,
1027
+ simulationResult,
1028
+ new Date().toISOString(),
1029
+ signerAddress,
1030
+ completedPlan.planHash,
1031
+ releaseExecutionPlanRelativePath(taskDir, completedPlan),
1032
+ );
1033
+ }
1034
+ }
1035
+ } catch (error) {
1036
+ if (contextForFailure?.deploymentRecorder) {
1037
+ try {
1038
+ contextForFailure.deploymentRecorder.markPartial(error);
1039
+ } catch (recordError) {
1040
+ reporter.event("deployment.record.failed", {
1041
+ message: recordError instanceof Error ? recordError.message : String(recordError),
1042
+ });
1043
+ }
1044
+ }
1045
+ if (mode === "simulate") {
1046
+ try {
1047
+ reporter.clearSimulationCompletionEvidence();
1048
+ } catch {
1049
+ // Preserve the original workflow failure if evidence cleanup also fails.
1050
+ }
1051
+ }
1052
+ const classification = classifyWorkflowError(error);
1053
+ reporter.status("failed", {
1054
+ mode,
1055
+ errorType: classification.errorType,
1056
+ retryable: classification.retryable,
1057
+ message: error instanceof Error ? error.message : String(error),
1058
+ });
1059
+ reporter.event("workflow.failed", {
1060
+ mode,
1061
+ errorType: classification.errorType,
1062
+ retryable: classification.retryable,
1063
+ message: error instanceof Error ? error.message : String(error),
1064
+ });
1065
+ throw error;
1066
+ }
1067
+ }
1068
+
1069
+ main().catch((error) => {
1070
+ console.error(error);
1071
+ process.exitCode = 1;
1072
+ });