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,772 @@
1
+ import { CONTROLLED_MULTICALL_AUTHORITY_ABI } from "../lib/controlledMulticallAbi";
2
+ import path from "path";
3
+ import { ethers, network } from "../../projectHardhat";
4
+ import type {
5
+ GateToolDeploymentPlan,
6
+ GateToolPreparationPlanV1,
7
+ GateToolPreparationRequestV1,
8
+ GateToolTransactionPlan,
9
+ } from "gate-evm-tools/workflow";
10
+ import type { WorkflowContext } from "../run";
11
+ import {
12
+ requireExistingDeploymentPolicy,
13
+ resolveExistingDeploymentPolicyAction,
14
+ resolveValue,
15
+ WorkflowStep,
16
+ } from "../lib/parameters";
17
+ import {
18
+ actualContractName,
19
+ contractInfoKey,
20
+ findDeploymentAddress,
21
+ } from "../lib/deployments";
22
+ import type { DeploymentChange } from "../lib/deploymentRecords";
23
+ import {
24
+ assertCreate2AddressPolicy,
25
+ Create2Options,
26
+ prepareControlledMulticallTransaction,
27
+ resolveCreate2Options,
28
+ sendPreparedControlledMulticallTransaction,
29
+ } from "../lib/create2";
30
+ import { assertReusableDeployment } from "../lib/checkCodeReport";
31
+ import { getERC1967Implementation } from "../lib/erc1967";
32
+ import { recordParameterLockImplementationSalts } from "../lib/lock";
33
+ import {
34
+ deriveImplementationSalt,
35
+ FirstUpgradeOptions,
36
+ ProxyOptions,
37
+ } from "../lib/proxy";
38
+ import { decideControlledMulticallAuthority } from "../lib/authority";
39
+ import { impersonateWorkflowSimulationSigner } from "../lib/signer";
40
+ import { prepareGateToolWorkflow } from "../lib/gateTool";
41
+ import { syncGateToolUups } from "../lib/gateToolSync";
42
+ import { resolvePendingUupsReuse } from "../lib/pendingDeploymentReuse";
43
+
44
+ const resolveInContext = (
45
+ context: WorkflowContext,
46
+ value: unknown,
47
+ ): unknown => resolveValue(value, {
48
+ targetId: context.targetId,
49
+ target: context.target,
50
+ params: context.targetParams,
51
+ state: context.state,
52
+ });
53
+
54
+ const resolveArray = (
55
+ context: WorkflowContext,
56
+ value: unknown,
57
+ label: string,
58
+ ): unknown[] => {
59
+ const resolved = resolveInContext(context, value || []);
60
+ if (!Array.isArray(resolved)) throw new Error(`${label} must resolve to an array`);
61
+ return resolved;
62
+ };
63
+
64
+ const resolveObject = (
65
+ context: WorkflowContext,
66
+ value: unknown,
67
+ ): Record<string, unknown> => {
68
+ const resolved = resolveInContext(context, value || {});
69
+ if (!resolved || typeof resolved !== "object" || Array.isArray(resolved)) return {};
70
+ return resolved as Record<string, unknown>;
71
+ };
72
+
73
+ const resolveProxyOptions = (
74
+ context: WorkflowContext,
75
+ step: WorkflowStep,
76
+ ): { options: ProxyOptions } | undefined => {
77
+ if (step.proxy === undefined) return undefined;
78
+ const proxy = resolveObject(context, step.proxy);
79
+ const initializer = proxy.initializer === false
80
+ ? false
81
+ : typeof proxy.initializer === "string"
82
+ ? proxy.initializer
83
+ : undefined;
84
+ return {
85
+ options: {
86
+ kind: typeof proxy.kind === "string" ? proxy.kind : undefined,
87
+ initializer,
88
+ unsafeAllow: Array.isArray(proxy.unsafeAllow)
89
+ ? proxy.unsafeAllow.map((item) => String(item))
90
+ : undefined,
91
+ constructorArgs: proxy.constructorArgs === undefined
92
+ ? undefined
93
+ : resolveArray(context, proxy.constructorArgs, `Step ${step.id} proxy.constructorArgs`),
94
+ },
95
+ };
96
+ };
97
+
98
+ const assertCreate2Options = (
99
+ step: WorkflowStep,
100
+ options: Create2Options | undefined,
101
+ ): Create2Options => {
102
+ if (!options) throw new Error(`Deploy step ${step.id} requires strategy: create2`);
103
+ return options;
104
+ };
105
+
106
+ const setDeploymentState = (
107
+ context: WorkflowContext,
108
+ names: string[],
109
+ value: Record<string, unknown>,
110
+ ): void => {
111
+ for (const name of new Set(names)) context.state.set(name, value);
112
+ };
113
+
114
+ const stringObjectField = (
115
+ source: Record<string, unknown>,
116
+ key: string,
117
+ ): string | undefined => {
118
+ const value = source[key];
119
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
120
+ };
121
+
122
+ const resolveFirstUpgradeOptions = (
123
+ context: WorkflowContext,
124
+ step: WorkflowStep,
125
+ ): FirstUpgradeOptions | undefined => {
126
+ if (step.firstUpgrade === undefined) return undefined;
127
+ const firstUpgrade = resolveObject(context, step.firstUpgrade);
128
+ const contractName = stringObjectField(firstUpgrade, "contract");
129
+ if (!contractName) throw new Error(`Deploy step ${step.id} firstUpgrade requires contract`);
130
+ const callObject = resolveObject(context, firstUpgrade.call);
131
+ const fn = stringObjectField(callObject, "fn") || stringObjectField(callObject, "method");
132
+ return {
133
+ contractName,
134
+ call: fn
135
+ ? {
136
+ fn,
137
+ args: resolveArray(
138
+ context,
139
+ callObject.args || [],
140
+ `Step ${step.id} firstUpgrade.call.args`,
141
+ ),
142
+ }
143
+ : undefined,
144
+ constructorArgs: resolveArray(
145
+ context,
146
+ firstUpgrade.constructorArgs || [],
147
+ `Step ${step.id} firstUpgrade.constructorArgs`,
148
+ ),
149
+ unsafeAllow: Array.isArray(firstUpgrade.unsafeAllow)
150
+ ? firstUpgrade.unsafeAllow.map((item) => String(item))
151
+ : undefined,
152
+ };
153
+ };
154
+
155
+ const applyExistingDeploymentPolicy = async (
156
+ context: WorkflowContext,
157
+ step: WorkflowStep,
158
+ saveAs: string,
159
+ preparedChange: DeploymentChange,
160
+ create2Options: Create2Options,
161
+ declaredUpgradeable: boolean,
162
+ ): Promise<{
163
+ completed: boolean;
164
+ create2Options: Create2Options;
165
+ existingAddress?: string;
166
+ redeployReason?: string;
167
+ }> => {
168
+ const existing = findDeploymentAddress(context.root, context.config, context.targetId, saveAs);
169
+ if (!existing) return { completed: false, create2Options };
170
+ const policy = requireExistingDeploymentPolicy(context.existingDeploymentPolicies, saveAs);
171
+ const implementationAddress = await getERC1967Implementation(ethers.provider, existing);
172
+ const action = resolveExistingDeploymentPolicyAction(policy, {
173
+ instanceId: saveAs,
174
+ existingAddress: existing,
175
+ currentSalt: create2Options.salt,
176
+ upgradeable: declaredUpgradeable || implementationAddress !== undefined,
177
+ });
178
+ if (action.mode === "reuse") {
179
+ if (!context.releaseArtifactHash) {
180
+ throw new Error(
181
+ `Deploy step ${step.id} cannot reuse ${context.targetId}.${saveAs} without an execution artifactHash`,
182
+ );
183
+ }
184
+ const evidence = assertReusableDeployment(context.root, {
185
+ network: context.targetId,
186
+ scheme: create2Options.scheme,
187
+ instanceId: saveAs,
188
+ address: existing,
189
+ artifactHash: context.releaseArtifactHash,
190
+ });
191
+ context.deploymentRecorder?.prepare(preparedChange);
192
+ context.deploymentRecorder?.apply({
193
+ ...preparedChange,
194
+ address: existing,
195
+ proxyAddress: implementationAddress ? existing : undefined,
196
+ implementationAddress,
197
+ reused: true,
198
+ alreadyDeployed: true,
199
+ gateTool: {
200
+ outputPath: "scripts/checkcode/index.json",
201
+ data: { runId: evidence.runId, artifactHash: evidence.artifactHash },
202
+ },
203
+ });
204
+ setDeploymentState(context, [saveAs], {
205
+ address: existing,
206
+ implementationAddress,
207
+ reused: true,
208
+ alreadyDeployed: true,
209
+ });
210
+ context.reporter.result("execution", {
211
+ stepId: step.id,
212
+ kind: step.kind,
213
+ contract: preparedChange.actualContract,
214
+ saveAs,
215
+ strategy: "reuse",
216
+ address: existing,
217
+ implementationAddress,
218
+ checkCodeRunId: evidence.runId,
219
+ reused: true,
220
+ alreadyDeployed: true,
221
+ });
222
+ return { completed: true, create2Options, existingAddress: existing };
223
+ }
224
+ return {
225
+ completed: false,
226
+ existingAddress: existing,
227
+ redeployReason: action.reason,
228
+ create2Options: {
229
+ ...create2Options,
230
+ salt: action.salt,
231
+ expectedAddress: action.expectedAddress,
232
+ },
233
+ };
234
+ };
235
+
236
+ const deploymentForRole = (
237
+ plan: GateToolPreparationPlanV1,
238
+ role: GateToolDeploymentPlan["role"],
239
+ ): GateToolDeploymentPlan => {
240
+ const deployment = plan.deployments.find((entry) => entry.role === role);
241
+ if (!deployment) throw new Error(`GateTool plan is missing ${role} deployment evidence`);
242
+ return deployment;
243
+ };
244
+
245
+ const assertDeployedCode = async (
246
+ label: string,
247
+ address: string,
248
+ ): Promise<void> => {
249
+ const code = await ethers.provider.getCode(address);
250
+ if (!code || code === "0x") {
251
+ throw new Error(`${label} is missing deployed code at ${address}`);
252
+ }
253
+ };
254
+
255
+ const gateToolEvidenceDir = (context: WorkflowContext): string => path.join(
256
+ context.taskDir,
257
+ "results",
258
+ context.targetId,
259
+ context.executionId,
260
+ "gate-tool",
261
+ context.mode,
262
+ );
263
+
264
+ const runGateToolControlledMulticall = async (
265
+ context: WorkflowContext,
266
+ step: WorkflowStep,
267
+ create2: Create2Options,
268
+ transactions: GateToolTransactionPlan[],
269
+ ): Promise<{ external: boolean; transactionId?: string; txHash?: string }> => {
270
+ if (transactions.length === 0) return { external: false };
271
+ if (!create2.controlledMulticall) {
272
+ throw new Error(`Deploy step ${step.id} requires controlledMulticall`);
273
+ }
274
+ if (!context.signer || !context.signerAddress) {
275
+ throw new Error(`Deploy step ${step.id} requires a signer`);
276
+ }
277
+ const prepared = prepareControlledMulticallTransaction(
278
+ create2.controlledMulticall,
279
+ transactions.map((transaction) => ({
280
+ target: transaction.to,
281
+ value: transaction.value,
282
+ data: transaction.data,
283
+ ...(transaction.factoryDeps === undefined
284
+ ? {}
285
+ : { factoryDeps: transaction.factoryDeps }),
286
+ })),
287
+ create2.scheme,
288
+ );
289
+ const multicall = await ethers.getContractAt(
290
+ CONTROLLED_MULTICALL_AUTHORITY_ABI,
291
+ create2.controlledMulticall,
292
+ context.signer,
293
+ );
294
+ const authority = await decideControlledMulticallAuthority(
295
+ multicall as unknown as {
296
+ callers: (caller: string) => Promise<boolean>;
297
+ factoryCallers: (factoryAddress: string, caller: string) => Promise<boolean>;
298
+ owner?: () => Promise<unknown>;
299
+ },
300
+ create2.factory,
301
+ context.target,
302
+ context.signerAddress,
303
+ );
304
+ const executor = authority.mode === "execute" ? context.signerAddress : authority.executor;
305
+ if (!executor) throw new Error(`Deploy step ${step.id} cannot resolve its required executor`);
306
+ if (create2.scheme === "zksync-eravm" && authority.mode !== "execute") {
307
+ throw new Error(
308
+ `Deploy step ${step.id} requires unsupported zkSync external Admin execution`,
309
+ );
310
+ }
311
+
312
+ if (!context.executionPlanner) {
313
+ if (authority.mode !== "execute") {
314
+ throw new Error(`Deploy step ${step.id} requires a locked mixed-authority execution plan`);
315
+ }
316
+ const transaction = await sendPreparedControlledMulticallTransaction(prepared, context.signer);
317
+ return { external: false, txHash: transaction.hash };
318
+ }
319
+
320
+ const planned = context.executionPlanner.add({
321
+ stepId: step.id,
322
+ executor,
323
+ to: prepared.target,
324
+ value: prepared.value,
325
+ data: prepared.data,
326
+ operation: 0,
327
+ ...(prepared.scheme === undefined ? {} : { scheme: prepared.scheme }),
328
+ ...(prepared.factoryDeps === undefined ? {} : { factoryDeps: prepared.factoryDeps }),
329
+ });
330
+ if (planned.executionAction === "replay") {
331
+ return {
332
+ external: planned.route === "external",
333
+ transactionId: planned.transactionId,
334
+ txHash: planned.transactionHash,
335
+ };
336
+ }
337
+ if (planned.route === "external" && context.mode !== "simulate") {
338
+ context.externalCalls.push({
339
+ transactionId: planned.transactionId,
340
+ stepId: planned.stepId,
341
+ to: planned.to,
342
+ value: planned.value,
343
+ data: planned.data,
344
+ operation: planned.operation,
345
+ method: prepared.method,
346
+ args: prepared.calls,
347
+ executor: planned.executor,
348
+ reason: authority.reason,
349
+ });
350
+ return { external: true, transactionId: planned.transactionId };
351
+ }
352
+ const selectedSigner = planned.route === "external"
353
+ ? await impersonateWorkflowSimulationSigner(planned.executor)
354
+ : context.signer;
355
+ const transaction = await sendPreparedControlledMulticallTransaction(prepared, selectedSigner);
356
+ if (context.mode === "execute" && planned.route === "operator") {
357
+ context.operatorReceipts.push({
358
+ transactionId: planned.transactionId,
359
+ transactionHash: transaction.hash,
360
+ });
361
+ }
362
+ return {
363
+ external: false,
364
+ transactionId: planned.transactionId,
365
+ txHash: transaction.hash,
366
+ };
367
+ };
368
+
369
+ const addressPolicy = (options: Create2Options) => (
370
+ options.expectedAddress === undefined && options.leadingZeroBytes === undefined
371
+ ? undefined
372
+ : {
373
+ ...(options.expectedAddress === undefined
374
+ ? {}
375
+ : { expectedAddress: options.expectedAddress }),
376
+ ...(options.leadingZeroBytes === undefined
377
+ ? {}
378
+ : { leadingZeroBytes: options.leadingZeroBytes }),
379
+ }
380
+ );
381
+
382
+ const gateToolChange = (
383
+ context: WorkflowContext,
384
+ planPath: string,
385
+ plan: GateToolPreparationPlanV1,
386
+ ) => ({
387
+ outputPath: path.relative(context.root, planPath).split(path.sep).join("/"),
388
+ data: plan as unknown as Record<string, unknown>,
389
+ });
390
+
391
+ export const runDeployStep = async (
392
+ context: WorkflowContext,
393
+ step: WorkflowStep,
394
+ ): Promise<void> => {
395
+ const contractName = String(step.contract);
396
+ const saveAs = typeof step.saveAs === "string" ? step.saveAs.trim() : "";
397
+ if (!saveAs) throw new Error(`Deploy step ${step.id} requires saveAs`);
398
+ const create2Options = assertCreate2Options(step, resolveCreate2Options(context, step));
399
+ const proxy = resolveProxyOptions(context, step);
400
+ const recorder = context.mode === "execute" ? context.deploymentRecorder : undefined;
401
+ if (context.mode === "execute" && !recorder) {
402
+ throw new Error(`Deploy step ${step.id} requires an execution deployment recorder`);
403
+ }
404
+
405
+ if (proxy) {
406
+ const firstUpgrade = resolveFirstUpgradeOptions(context, step);
407
+ if (step.upgradeableStrategy !== "uups-placeholder-proxy" || !firstUpgrade) {
408
+ throw new Error(`Deploy step ${step.id} requires firstUpgrade for uups-placeholder-proxy`);
409
+ }
410
+ if ((proxy.options.kind || "uups") !== "uups") {
411
+ throw new Error(`Deploy step ${step.id} only supports UUPS placeholder proxies`);
412
+ }
413
+ if (proxy.options.initializer !== false) {
414
+ throw new Error(
415
+ `Deploy step ${step.id} must use proxy.initializer: false for uups-placeholder-proxy`,
416
+ );
417
+ }
418
+ if (!create2Options.controlledMulticall) {
419
+ throw new Error(`Deploy step ${step.id} requires controlledMulticall for atomic firstUpgrade`);
420
+ }
421
+ if (!create2Options.uupsPlaceholderImplementation) {
422
+ throw new Error(`Deploy step ${step.id} requires target.uups.placeholderImplementation`);
423
+ }
424
+
425
+ const actualContract = actualContractName(firstUpgrade.contractName);
426
+ const registryKey = contractInfoKey(saveAs, firstUpgrade.contractName);
427
+ const preparedChange: DeploymentChange = {
428
+ stepId: step.id,
429
+ kind: "deploy",
430
+ instanceId: saveAs,
431
+ actualContract,
432
+ contractInfoKey: registryKey,
433
+ strategy: "create2",
434
+ proxyKind: "uups",
435
+ factory: create2Options.factory,
436
+ multicall: create2Options.controlledMulticall,
437
+ salt: create2Options.salt,
438
+ expectedAddress: create2Options.expectedAddress,
439
+ leadingZeroBytes: create2Options.leadingZeroBytes,
440
+ placeholderImplementationAddress: create2Options.uupsPlaceholderImplementation,
441
+ };
442
+ const existingResolution = await applyExistingDeploymentPolicy(
443
+ context,
444
+ step,
445
+ saveAs,
446
+ preparedChange,
447
+ create2Options,
448
+ true,
449
+ );
450
+ if (existingResolution.completed) return;
451
+ const effectiveCreate2 = existingResolution.create2Options;
452
+ const pendingReuse = context.parameterLockExecutionId
453
+ ? await resolvePendingUupsReuse({
454
+ root: context.root,
455
+ taskDir: context.taskDir,
456
+ taskId: context.taskId,
457
+ currentExecutionId: context.parameterLockExecutionId,
458
+ network: context.targetId,
459
+ stepId: step.id,
460
+ instanceId: saveAs,
461
+ actualContract,
462
+ contractInfoKey: registryKey,
463
+ scheme: effectiveCreate2.scheme,
464
+ factory: effectiveCreate2.factory,
465
+ multicall: effectiveCreate2.controlledMulticall!,
466
+ proxySalt: effectiveCreate2.salt,
467
+ expectedAddress: effectiveCreate2.expectedAddress,
468
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation!,
469
+ provider: ethers.provider,
470
+ blockTag: context.mode === "simulate"
471
+ ? context.simulation.snapshot?.blockNumber
472
+ : undefined,
473
+ })
474
+ : undefined;
475
+ const implementationSalt = pendingReuse?.implementationSalt ?? deriveImplementationSalt(
476
+ context.executionId,
477
+ firstUpgrade.contractName,
478
+ effectiveCreate2.salt,
479
+ );
480
+ const request: GateToolPreparationRequestV1 = {
481
+ version: 1,
482
+ kind: "uups-placeholder-deploy",
483
+ scheme: effectiveCreate2.scheme,
484
+ network: network.name,
485
+ target: context.targetId,
486
+ contract: firstUpgrade.contractName,
487
+ constructorArgs: firstUpgrade.constructorArgs || [],
488
+ factory: effectiveCreate2.factory,
489
+ proxyKind: "uups",
490
+ implementationSalt,
491
+ proxySalt: effectiveCreate2.salt,
492
+ placeholderImplementation: effectiveCreate2.uupsPlaceholderImplementation!,
493
+ ...(firstUpgrade.unsafeAllow || proxy.options.unsafeAllow
494
+ ? { unsafeAllow: firstUpgrade.unsafeAllow || proxy.options.unsafeAllow }
495
+ : {}),
496
+ ...(addressPolicy(effectiveCreate2)
497
+ ? { proxyAddressPolicy: addressPolicy(effectiveCreate2) }
498
+ : {}),
499
+ ...(firstUpgrade.call
500
+ ? { call: { method: firstUpgrade.call.fn, args: firstUpgrade.call.args } }
501
+ : {}),
502
+ };
503
+ const prepared = await prepareGateToolWorkflow({
504
+ root: context.root,
505
+ evidenceDir: gateToolEvidenceDir(context),
506
+ evidenceName: step.id,
507
+ request,
508
+ readBlockTag: context.mode === "simulate"
509
+ ? context.simulation.snapshot?.blockNumber
510
+ : undefined,
511
+ });
512
+ const implementation = deploymentForRole(prepared.plan, "implementation");
513
+ const proxyDeployment = deploymentForRole(prepared.plan, "proxy");
514
+ if (pendingReuse && (
515
+ prepared.plan.transactions.length !== 0
516
+ || prepared.plan.artifact.digest !== pendingReuse.evidence.artifactDigest
517
+ || implementation.address.toLowerCase() !== pendingReuse.implementationAddress.toLowerCase()
518
+ || proxyDeployment.address.toLowerCase() !== pendingReuse.proxyAddress.toLowerCase()
519
+ )) {
520
+ throw new Error(
521
+ `Deploy step ${step.id} current GateTool plan does not match trusted pending reuse evidence`,
522
+ );
523
+ }
524
+ assertCreate2AddressPolicy(
525
+ `${firstUpgrade.contractName} proxy`,
526
+ proxyDeployment.address,
527
+ effectiveCreate2,
528
+ );
529
+ if (
530
+ existingResolution.existingAddress
531
+ && proxyDeployment.address.toLowerCase() === existingResolution.existingAddress.toLowerCase()
532
+ ) {
533
+ throw new Error(`Deploy step ${step.id} redeploy predicted the existing address`);
534
+ }
535
+ const gateTool = gateToolChange(context, prepared.planPath, prepared.plan);
536
+ const plannedChange: DeploymentChange = {
537
+ ...preparedChange,
538
+ salt: effectiveCreate2.salt,
539
+ previousAddress: existingResolution.existingAddress,
540
+ redeployReason: existingResolution.redeployReason,
541
+ implementationAddress: implementation.address,
542
+ implementationSalt,
543
+ constructorArgs: firstUpgrade.constructorArgs || [],
544
+ predictedAddress: proxyDeployment.address,
545
+ gateTool,
546
+ ...(pendingReuse ? { pendingReuse: pendingReuse.evidence } : {}),
547
+ };
548
+ if (context.parameterLockExecutionId) {
549
+ recordParameterLockImplementationSalts(
550
+ context.taskDir,
551
+ context.parameterLockExecutionId,
552
+ { [`${step.id}.implementation`]: implementationSalt },
553
+ );
554
+ }
555
+ recorder?.prepare(plannedChange);
556
+ if (context.mode === "execute") {
557
+ recorder?.stageAddressCandidate(plannedChange, proxyDeployment.address);
558
+ }
559
+ const execution = await runGateToolControlledMulticall(
560
+ context,
561
+ step,
562
+ effectiveCreate2,
563
+ prepared.plan.transactions,
564
+ );
565
+ if (context.mode === "execute" && execution.transactionId) {
566
+ recorder?.bindProxyTransaction(step.id, execution.transactionId);
567
+ }
568
+ if (!execution.external) {
569
+ await assertDeployedCode(
570
+ `${firstUpgrade.contractName} implementation`,
571
+ implementation.address,
572
+ );
573
+ await assertDeployedCode("ERC1967Proxy", proxyDeployment.address);
574
+ const currentImplementation = await getERC1967Implementation(
575
+ ethers.provider,
576
+ proxyDeployment.address,
577
+ );
578
+ if (
579
+ !currentImplementation
580
+ || currentImplementation.toLowerCase() !== implementation.address.toLowerCase()
581
+ ) {
582
+ throw new Error(
583
+ `ERC1967Proxy ${proxyDeployment.address} does not point to GateTool implementation ${implementation.address}`,
584
+ );
585
+ }
586
+ }
587
+ const gateToolSync = context.mode === "execute"
588
+ && !execution.external
589
+ && proxyDeployment.status !== "reused"
590
+ ? await syncGateToolUups({
591
+ root: context.root,
592
+ evidenceDir: gateToolEvidenceDir(context),
593
+ evidenceName: step.id,
594
+ scheme: prepared.plan.scheme,
595
+ network: network.name,
596
+ target: context.targetId,
597
+ manifestDir: context.target.openzeppelin.manifestDir,
598
+ proxy: proxyDeployment.address,
599
+ implementation: implementation.address,
600
+ contract: actualContract,
601
+ constructorArgs: firstUpgrade.constructorArgs || [],
602
+ transactionHash: execution.txHash || "",
603
+ })
604
+ : undefined;
605
+ if (context.mode === "execute" && !execution.external) {
606
+ recorder?.applyAddress({
607
+ ...plannedChange,
608
+ address: proxyDeployment.address,
609
+ proxyAddress: proxyDeployment.address,
610
+ txHash: execution.txHash,
611
+ gateToolSync,
612
+ reused: proxyDeployment.status === "reused",
613
+ alreadyDeployed: proxyDeployment.status === "reused",
614
+ }, proxyDeployment.address);
615
+ }
616
+ setDeploymentState(context, [saveAs], {
617
+ address: proxyDeployment.address,
618
+ proxyAddress: proxyDeployment.address,
619
+ implementationAddress: implementation.address,
620
+ implementationSalt,
621
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation,
622
+ txHash: execution.txHash,
623
+ external: execution.external,
624
+ });
625
+ context.reporter.result("execution", {
626
+ stepId: step.id,
627
+ kind: step.kind,
628
+ mode: execution.external ? "external" : context.mode,
629
+ transactionId: execution.transactionId,
630
+ contract: contractName,
631
+ actualContract,
632
+ saveAs,
633
+ contractInfoKey: registryKey,
634
+ strategy: "create2",
635
+ scheme: prepared.plan.scheme,
636
+ proxy: "uups",
637
+ address: proxyDeployment.address,
638
+ implementationAddress: implementation.address,
639
+ firstUpgradeImplementationAddress: implementation.address,
640
+ placeholderImplementationAddress: effectiveCreate2.uupsPlaceholderImplementation,
641
+ predictedAddress: proxyDeployment.address,
642
+ reused: proxyDeployment.status === "reused",
643
+ alreadyDeployed: proxyDeployment.status === "reused",
644
+ txHash: execution.txHash,
645
+ gateToolPlan: gateTool.outputPath,
646
+ gateToolSync: gateToolSync?.outputPath,
647
+ pendingReuse: pendingReuse?.evidence,
648
+ });
649
+ return;
650
+ }
651
+
652
+ const args = resolveArray(context, step.args || [], `Step ${step.id} args`);
653
+ const actualContract = actualContractName(contractName);
654
+ const registryKey = contractInfoKey(saveAs, contractName);
655
+ let preparedChange: DeploymentChange = {
656
+ stepId: step.id,
657
+ kind: "deploy",
658
+ instanceId: saveAs,
659
+ actualContract,
660
+ contractInfoKey: registryKey,
661
+ strategy: "create2",
662
+ factory: create2Options.factory,
663
+ multicall: create2Options.controlledMulticall,
664
+ salt: create2Options.salt,
665
+ expectedAddress: create2Options.expectedAddress,
666
+ leadingZeroBytes: create2Options.leadingZeroBytes,
667
+ };
668
+ const existingResolution = await applyExistingDeploymentPolicy(
669
+ context,
670
+ step,
671
+ saveAs,
672
+ preparedChange,
673
+ create2Options,
674
+ false,
675
+ );
676
+ if (existingResolution.completed) return;
677
+ const effectiveCreate2 = existingResolution.create2Options;
678
+ const request: GateToolPreparationRequestV1 = {
679
+ version: 1,
680
+ kind: "create2-deploy",
681
+ scheme: effectiveCreate2.scheme,
682
+ network: network.name,
683
+ target: context.targetId,
684
+ contract: contractName,
685
+ constructorArgs: args,
686
+ factory: effectiveCreate2.factory,
687
+ salt: effectiveCreate2.salt,
688
+ ...(effectiveCreate2.create2ForwardValue === undefined
689
+ ? {}
690
+ : { create2ForwardValue: effectiveCreate2.create2ForwardValue }),
691
+ ...(effectiveCreate2.callForwardValue === undefined
692
+ ? {}
693
+ : { callForwardValue: effectiveCreate2.callForwardValue }),
694
+ ...(addressPolicy(effectiveCreate2)
695
+ ? { addressPolicy: addressPolicy(effectiveCreate2) }
696
+ : {}),
697
+ };
698
+ const prepared = await prepareGateToolWorkflow({
699
+ root: context.root,
700
+ evidenceDir: gateToolEvidenceDir(context),
701
+ evidenceName: step.id,
702
+ request,
703
+ readBlockTag: context.mode === "simulate"
704
+ ? context.simulation.snapshot?.blockNumber
705
+ : undefined,
706
+ });
707
+ const deployment = deploymentForRole(prepared.plan, "contract");
708
+ assertCreate2AddressPolicy(contractName, deployment.address, effectiveCreate2);
709
+ if (
710
+ existingResolution.existingAddress
711
+ && deployment.address.toLowerCase() === existingResolution.existingAddress.toLowerCase()
712
+ ) {
713
+ throw new Error(`Deploy step ${step.id} redeploy predicted the existing address`);
714
+ }
715
+ const gateTool = gateToolChange(context, prepared.planPath, prepared.plan);
716
+ preparedChange = {
717
+ ...preparedChange,
718
+ salt: effectiveCreate2.salt,
719
+ expectedAddress: effectiveCreate2.expectedAddress,
720
+ previousAddress: existingResolution.existingAddress,
721
+ redeployReason: existingResolution.redeployReason,
722
+ predictedAddress: deployment.address,
723
+ gateTool,
724
+ };
725
+ recorder?.prepare(preparedChange);
726
+ if (context.mode === "execute") {
727
+ recorder?.stageAddressCandidate(preparedChange, deployment.address);
728
+ }
729
+ const execution = await runGateToolControlledMulticall(
730
+ context,
731
+ step,
732
+ effectiveCreate2,
733
+ prepared.plan.transactions,
734
+ );
735
+ if (!execution.external) {
736
+ await assertDeployedCode(contractName, deployment.address);
737
+ }
738
+ if (context.mode === "execute" && !execution.external) {
739
+ recorder?.applyAddress({
740
+ ...preparedChange,
741
+ address: deployment.address,
742
+ txHash: execution.txHash,
743
+ reused: deployment.status === "reused",
744
+ alreadyDeployed: deployment.status === "reused",
745
+ }, deployment.address);
746
+ }
747
+ context.state.set(saveAs, {
748
+ address: deployment.address,
749
+ predictedAddress: deployment.address,
750
+ txHash: execution.txHash,
751
+ external: execution.external,
752
+ alreadyDeployed: deployment.status === "reused",
753
+ });
754
+ context.reporter.result("execution", {
755
+ stepId: step.id,
756
+ kind: step.kind,
757
+ mode: execution.external ? "external" : context.mode,
758
+ transactionId: execution.transactionId,
759
+ contract: contractName,
760
+ actualContract,
761
+ saveAs,
762
+ contractInfoKey: registryKey,
763
+ strategy: "create2",
764
+ scheme: prepared.plan.scheme,
765
+ address: deployment.address,
766
+ predictedAddress: deployment.address,
767
+ reused: deployment.status === "reused",
768
+ alreadyDeployed: deployment.status === "reused",
769
+ txHash: execution.txHash,
770
+ gateToolPlan: gateTool.outputPath,
771
+ });
772
+ };