gate-evm-tools 1.0.26 → 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.
- package/README.md +14 -0
- package/bin/workflow.cjs +19 -0
- package/dist/core/BytecodeChecker.d.ts.map +1 -1
- package/dist/core/BytecodeChecker.js +16 -1
- package/dist/core/BytecodeChecker.js.map +1 -1
- package/dist/core/legacyProxyArtifact.d.ts +6 -0
- package/dist/core/legacyProxyArtifact.d.ts.map +1 -0
- package/dist/core/legacyProxyArtifact.js +36 -0
- package/dist/core/legacyProxyArtifact.js.map +1 -0
- package/dist-runtime/config/hardhatAdapters.d.ts +5 -0
- package/dist-runtime/config/hardhatAdapters.js +53 -0
- package/dist-runtime/config/hardhatAdapters.js.map +1 -0
- package/dist-runtime/config/networks.d.ts +8 -0
- package/dist-runtime/config/networks.js +269 -0
- package/dist-runtime/config/networks.js.map +1 -0
- package/dist-runtime/config/openzeppelin.d.ts +28 -0
- package/dist-runtime/config/openzeppelin.js +144 -0
- package/dist-runtime/config/openzeppelin.js.map +1 -0
- package/dist-runtime/config/rpc.d.ts +7 -0
- package/dist-runtime/config/rpc.js +19 -0
- package/dist-runtime/config/rpc.js.map +1 -0
- package/dist-runtime/config/zksyncSolcPath.d.ts +1 -0
- package/dist-runtime/config/zksyncSolcPath.js +61 -0
- package/dist-runtime/config/zksyncSolcPath.js.map +1 -0
- package/dist-runtime/migrate.d.ts +13 -0
- package/dist-runtime/migrate.js +208 -0
- package/dist-runtime/migrate.js.map +1 -0
- package/dist-runtime/package.json +1 -0
- package/dist-runtime/projectHardhat.d.ts +4 -0
- package/dist-runtime/projectHardhat.js +16 -0
- package/dist-runtime/projectHardhat.js.map +1 -0
- package/dist-runtime/runtime-identity.json +4 -0
- package/dist-runtime/template-migration.json +293 -0
- package/dist-runtime/workflow/checkCode.d.ts +1 -0
- package/dist-runtime/workflow/checkCode.js +16 -0
- package/dist-runtime/workflow/checkCode.js.map +1 -0
- package/dist-runtime/workflow/checkCodeFinalize.d.ts +1 -0
- package/dist-runtime/workflow/checkCodeFinalize.js +11 -0
- package/dist-runtime/workflow/checkCodeFinalize.js.map +1 -0
- package/dist-runtime/workflow/checkCodePlan.d.ts +1 -0
- package/dist-runtime/workflow/checkCodePlan.js +11 -0
- package/dist-runtime/workflow/checkCodePlan.js.map +1 -0
- package/dist-runtime/workflow/cli.d.ts +1 -0
- package/dist-runtime/workflow/cli.js +302 -0
- package/dist-runtime/workflow/cli.js.map +1 -0
- package/dist-runtime/workflow/commitContractInfo.d.ts +1 -0
- package/dist-runtime/workflow/commitContractInfo.js +64 -0
- package/dist-runtime/workflow/commitContractInfo.js.map +1 -0
- package/dist-runtime/workflow/create2Hashes.d.ts +1 -0
- package/dist-runtime/workflow/create2Hashes.js +76 -0
- package/dist-runtime/workflow/create2Hashes.js.map +1 -0
- package/dist-runtime/workflow/forkSourceProxy.d.ts +1 -0
- package/dist-runtime/workflow/forkSourceProxy.js +151 -0
- package/dist-runtime/workflow/forkSourceProxy.js.map +1 -0
- package/dist-runtime/workflow/importState.d.ts +1 -0
- package/dist-runtime/workflow/importState.js +193 -0
- package/dist-runtime/workflow/importState.js.map +1 -0
- package/dist-runtime/workflow/lib/authority.d.ts +28 -0
- package/dist-runtime/workflow/lib/authority.js +122 -0
- package/dist-runtime/workflow/lib/authority.js.map +1 -0
- package/dist-runtime/workflow/lib/calldata.d.ts +2 -0
- package/dist-runtime/workflow/lib/calldata.js +8 -0
- package/dist-runtime/workflow/lib/calldata.js.map +1 -0
- package/dist-runtime/workflow/lib/calls.d.ts +23 -0
- package/dist-runtime/workflow/lib/calls.js +316 -0
- package/dist-runtime/workflow/lib/calls.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/args.d.ts +2 -0
- package/dist-runtime/workflow/lib/checkCode/args.js +68 -0
- package/dist-runtime/workflow/lib/checkCode/args.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/command.d.ts +5 -0
- package/dist-runtime/workflow/lib/checkCode/command.js +35 -0
- package/dist-runtime/workflow/lib/checkCode/command.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.d.ts +6 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.js +125 -0
- package/dist-runtime/workflow/lib/checkCode/dependencies.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.d.ts +17 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.js +174 -0
- package/dist-runtime/workflow/lib/checkCode/finalize.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/index.d.ts +3 -0
- package/dist-runtime/workflow/lib/checkCode/index.js +20 -0
- package/dist-runtime/workflow/lib/checkCode/index.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCode/plan.d.ts +22 -0
- package/dist-runtime/workflow/lib/checkCode/plan.js +145 -0
- package/dist-runtime/workflow/lib/checkCode/plan.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCodeReport.d.ts +25 -0
- package/dist-runtime/workflow/lib/checkCodeReport.js +102 -0
- package/dist-runtime/workflow/lib/checkCodeReport.js.map +1 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.d.ts +87 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.js +964 -0
- package/dist-runtime/workflow/lib/checkCodeRunner.js.map +1 -0
- package/dist-runtime/workflow/lib/cliTool.d.ts +10 -0
- package/dist-runtime/workflow/lib/cliTool.js +25 -0
- package/dist-runtime/workflow/lib/cliTool.js.map +1 -0
- package/dist-runtime/workflow/lib/config.d.ts +33 -0
- package/dist-runtime/workflow/lib/config.js +100 -0
- package/dist-runtime/workflow/lib/config.js.map +1 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.d.ts +82 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.js +441 -0
- package/dist-runtime/workflow/lib/contractInfoCandidates.js.map +1 -0
- package/dist-runtime/workflow/lib/create2.d.ts +49 -0
- package/dist-runtime/workflow/lib/create2.js +194 -0
- package/dist-runtime/workflow/lib/create2.js.map +1 -0
- package/dist-runtime/workflow/lib/create2Hashes.d.ts +22 -0
- package/dist-runtime/workflow/lib/create2Hashes.js +57 -0
- package/dist-runtime/workflow/lib/create2Hashes.js.map +1 -0
- package/dist-runtime/workflow/lib/deploymentInfo.d.ts +40 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js +240 -0
- package/dist-runtime/workflow/lib/deploymentInfo.js.map +1 -0
- package/dist-runtime/workflow/lib/deploymentRecords.d.ts +137 -0
- package/dist-runtime/workflow/lib/deploymentRecords.js +374 -0
- package/dist-runtime/workflow/lib/deploymentRecords.js.map +1 -0
- package/dist-runtime/workflow/lib/deployments.d.ts +21 -0
- package/dist-runtime/workflow/lib/deployments.js +240 -0
- package/dist-runtime/workflow/lib/deployments.js.map +1 -0
- package/dist-runtime/workflow/lib/erc1967.d.ts +5 -0
- package/dist-runtime/workflow/lib/erc1967.js +29 -0
- package/dist-runtime/workflow/lib/erc1967.js.map +1 -0
- package/dist-runtime/workflow/lib/errors.d.ts +6 -0
- package/dist-runtime/workflow/lib/errors.js +77 -0
- package/dist-runtime/workflow/lib/errors.js.map +1 -0
- package/dist-runtime/workflow/lib/executionId.d.ts +7 -0
- package/dist-runtime/workflow/lib/executionId.js +26 -0
- package/dist-runtime/workflow/lib/executionId.js.map +1 -0
- package/dist-runtime/workflow/lib/executionPlan.d.ts +85 -0
- package/dist-runtime/workflow/lib/executionPlan.js +450 -0
- package/dist-runtime/workflow/lib/executionPlan.js.map +1 -0
- package/dist-runtime/workflow/lib/executionProgress.d.ts +5 -0
- package/dist-runtime/workflow/lib/executionProgress.js +100 -0
- package/dist-runtime/workflow/lib/executionProgress.js.map +1 -0
- package/dist-runtime/workflow/lib/external.d.ts +62 -0
- package/dist-runtime/workflow/lib/external.js +282 -0
- package/dist-runtime/workflow/lib/external.js.map +1 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.d.ts +64 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.js +638 -0
- package/dist-runtime/workflow/lib/externalExecutionScanner.js.map +1 -0
- package/dist-runtime/workflow/lib/forkSnapshot.d.ts +34 -0
- package/dist-runtime/workflow/lib/forkSnapshot.js +167 -0
- package/dist-runtime/workflow/lib/forkSnapshot.js.map +1 -0
- package/dist-runtime/workflow/lib/gateTool.d.ts +16 -0
- package/dist-runtime/workflow/lib/gateTool.js +177 -0
- package/dist-runtime/workflow/lib/gateTool.js.map +1 -0
- package/dist-runtime/workflow/lib/gateToolSync.d.ts +22 -0
- package/dist-runtime/workflow/lib/gateToolSync.js +253 -0
- package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -0
- package/dist-runtime/workflow/lib/lock.d.ts +52 -0
- package/dist-runtime/workflow/lib/lock.js +269 -0
- package/dist-runtime/workflow/lib/lock.js.map +1 -0
- package/dist-runtime/workflow/lib/migrationState.d.ts +103 -0
- package/dist-runtime/workflow/lib/migrationState.js +920 -0
- package/dist-runtime/workflow/lib/migrationState.js.map +1 -0
- package/dist-runtime/workflow/lib/operatorExecution.d.ts +28 -0
- package/dist-runtime/workflow/lib/operatorExecution.js +134 -0
- package/dist-runtime/workflow/lib/operatorExecution.js.map +1 -0
- package/dist-runtime/workflow/lib/parameters.d.ts +58 -0
- package/dist-runtime/workflow/lib/parameters.js +322 -0
- package/dist-runtime/workflow/lib/parameters.js.map +1 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.d.ts +29 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +277 -0
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -0
- package/dist-runtime/workflow/lib/proxy.d.ts +18 -0
- package/dist-runtime/workflow/lib/proxy.js +19 -0
- package/dist-runtime/workflow/lib/proxy.js.map +1 -0
- package/dist-runtime/workflow/lib/registryCommit.d.ts +33 -0
- package/dist-runtime/workflow/lib/registryCommit.js +319 -0
- package/dist-runtime/workflow/lib/registryCommit.js.map +1 -0
- package/dist-runtime/workflow/lib/release.d.ts +57 -0
- package/dist-runtime/workflow/lib/release.js +256 -0
- package/dist-runtime/workflow/lib/release.js.map +1 -0
- package/dist-runtime/workflow/lib/releaseFinalize.d.ts +14 -0
- package/dist-runtime/workflow/lib/releaseFinalize.js +571 -0
- package/dist-runtime/workflow/lib/releaseFinalize.js.map +1 -0
- package/dist-runtime/workflow/lib/releaseParameters.d.ts +43 -0
- package/dist-runtime/workflow/lib/releaseParameters.js +184 -0
- package/dist-runtime/workflow/lib/releaseParameters.js.map +1 -0
- package/dist-runtime/workflow/lib/reporter.d.ts +39 -0
- package/dist-runtime/workflow/lib/reporter.js +452 -0
- package/dist-runtime/workflow/lib/reporter.js.map +1 -0
- package/dist-runtime/workflow/lib/resultPaths.d.ts +17 -0
- package/dist-runtime/workflow/lib/resultPaths.js +29 -0
- package/dist-runtime/workflow/lib/resultPaths.js.map +1 -0
- package/dist-runtime/workflow/lib/runtimeVersion.d.ts +10 -0
- package/dist-runtime/workflow/lib/runtimeVersion.js +46 -0
- package/dist-runtime/workflow/lib/runtimeVersion.js.map +1 -0
- package/dist-runtime/workflow/lib/signer.d.ts +10 -0
- package/dist-runtime/workflow/lib/signer.js +105 -0
- package/dist-runtime/workflow/lib/signer.js.map +1 -0
- package/dist-runtime/workflow/lib/signerIdentity.d.ts +1 -0
- package/dist-runtime/workflow/lib/signerIdentity.js +23 -0
- package/dist-runtime/workflow/lib/signerIdentity.js.map +1 -0
- package/dist-runtime/workflow/lib/simulation.d.ts +35 -0
- package/dist-runtime/workflow/lib/simulation.js +282 -0
- package/dist-runtime/workflow/lib/simulation.js.map +1 -0
- package/dist-runtime/workflow/lib/simulationCallers.d.ts +44 -0
- package/dist-runtime/workflow/lib/simulationCallers.js +260 -0
- package/dist-runtime/workflow/lib/simulationCallers.js.map +1 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.d.ts +1 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.js +43 -0
- package/dist-runtime/workflow/lib/sourceRpcPolicy.js.map +1 -0
- package/dist-runtime/workflow/lib/state.d.ts +6 -0
- package/dist-runtime/workflow/lib/state.js +25 -0
- package/dist-runtime/workflow/lib/state.js.map +1 -0
- package/dist-runtime/workflow/lib/staticValidation.d.ts +22 -0
- package/dist-runtime/workflow/lib/staticValidation.js +124 -0
- package/dist-runtime/workflow/lib/staticValidation.js.map +1 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.d.ts +27 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.js +52 -0
- package/dist-runtime/workflow/lib/zksyncForkCapability.js.map +1 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.d.ts +57 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.js +344 -0
- package/dist-runtime/workflow/lib/zksyncForkRunner.js.map +1 -0
- package/dist-runtime/workflow/reconcileExternal.d.ts +1 -0
- package/dist-runtime/workflow/reconcileExternal.js +87 -0
- package/dist-runtime/workflow/reconcileExternal.js.map +1 -0
- package/dist-runtime/workflow/reconcileExternalRun.d.ts +1 -0
- package/dist-runtime/workflow/reconcileExternalRun.js +77 -0
- package/dist-runtime/workflow/reconcileExternalRun.js.map +1 -0
- package/dist-runtime/workflow/releaseFinalize.d.ts +1 -0
- package/dist-runtime/workflow/releaseFinalize.js +11 -0
- package/dist-runtime/workflow/releaseFinalize.js.map +1 -0
- package/dist-runtime/workflow/run.d.ts +40 -0
- package/dist-runtime/workflow/run.js +858 -0
- package/dist-runtime/workflow/run.js.map +1 -0
- package/dist-runtime/workflow/staticValidate.d.ts +1 -0
- package/dist-runtime/workflow/staticValidate.js +26 -0
- package/dist-runtime/workflow/staticValidate.js.map +1 -0
- package/dist-runtime/workflow/steps/call.d.ts +3 -0
- package/dist-runtime/workflow/steps/call.js +9 -0
- package/dist-runtime/workflow/steps/call.js.map +1 -0
- package/dist-runtime/workflow/steps/check.d.ts +3 -0
- package/dist-runtime/workflow/steps/check.js +9 -0
- package/dist-runtime/workflow/steps/check.js.map +1 -0
- package/dist-runtime/workflow/steps/custom.d.ts +3 -0
- package/dist-runtime/workflow/steps/custom.js +33 -0
- package/dist-runtime/workflow/steps/custom.js.map +1 -0
- package/dist-runtime/workflow/steps/deploy.d.ts +3 -0
- package/dist-runtime/workflow/steps/deploy.js +595 -0
- package/dist-runtime/workflow/steps/deploy.js.map +1 -0
- package/dist-runtime/workflow/steps/upgrade.d.ts +3 -0
- package/dist-runtime/workflow/steps/upgrade.js +465 -0
- package/dist-runtime/workflow/steps/upgrade.js.map +1 -0
- package/dist-runtime/workflow/steps/view.d.ts +3 -0
- package/dist-runtime/workflow/steps/view.js +9 -0
- package/dist-runtime/workflow/steps/view.js.map +1 -0
- package/package.json +25 -5
- package/runtime/config/hardhatAdapters.ts +50 -0
- package/runtime/config/networks.ts +296 -0
- package/runtime/config/openzeppelin.ts +173 -0
- package/runtime/config/rpc.ts +27 -0
- package/runtime/config/zksyncSolcPath.ts +59 -0
- package/runtime/hardhat-types.d.ts +2 -0
- package/runtime/migrate.ts +154 -0
- package/runtime/projectHardhat.ts +10 -0
- package/runtime/template-migration.json +293 -0
- package/runtime/workflow/checkCode.ts +13 -0
- package/runtime/workflow/checkCodeFinalize.ts +8 -0
- package/runtime/workflow/checkCodePlan.ts +8 -0
- package/runtime/workflow/cli.ts +356 -0
- package/runtime/workflow/commitContractInfo.ts +63 -0
- package/runtime/workflow/create2Hashes.ts +79 -0
- package/runtime/workflow/forkSourceProxy.ts +193 -0
- package/runtime/workflow/importState.ts +190 -0
- package/runtime/workflow/lib/authority.ts +170 -0
- package/runtime/workflow/lib/calldata.ts +9 -0
- package/runtime/workflow/lib/calls.ts +407 -0
- package/runtime/workflow/lib/checkCode/args.ts +76 -0
- package/runtime/workflow/lib/checkCode/command.ts +36 -0
- package/runtime/workflow/lib/checkCode/dependencies.ts +112 -0
- package/runtime/workflow/lib/checkCode/finalize.ts +198 -0
- package/runtime/workflow/lib/checkCode/index.ts +18 -0
- package/runtime/workflow/lib/checkCode/plan.ts +163 -0
- package/runtime/workflow/lib/checkCodeReport.ts +133 -0
- package/runtime/workflow/lib/checkCodeRunner.ts +1225 -0
- package/runtime/workflow/lib/cliTool.ts +31 -0
- package/runtime/workflow/lib/config.ts +130 -0
- package/runtime/workflow/lib/contractInfoCandidates.ts +690 -0
- package/runtime/workflow/lib/create2.ts +278 -0
- package/runtime/workflow/lib/create2Hashes.ts +83 -0
- package/runtime/workflow/lib/deploymentInfo.ts +286 -0
- package/runtime/workflow/lib/deploymentRecords.ts +576 -0
- package/runtime/workflow/lib/deployments.ts +276 -0
- package/runtime/workflow/lib/erc1967.ts +57 -0
- package/runtime/workflow/lib/errors.ts +95 -0
- package/runtime/workflow/lib/executionId.ts +35 -0
- package/runtime/workflow/lib/executionPlan.ts +550 -0
- package/runtime/workflow/lib/executionProgress.ts +127 -0
- package/runtime/workflow/lib/external.ts +372 -0
- package/runtime/workflow/lib/externalExecutionScanner.ts +892 -0
- package/runtime/workflow/lib/forkSnapshot.ts +231 -0
- package/runtime/workflow/lib/gateTool.ts +261 -0
- package/runtime/workflow/lib/gateToolSync.ts +398 -0
- package/runtime/workflow/lib/lock.ts +388 -0
- package/runtime/workflow/lib/migrationState.ts +1246 -0
- package/runtime/workflow/lib/operatorExecution.ts +174 -0
- package/runtime/workflow/lib/parameters.ts +437 -0
- package/runtime/workflow/lib/pendingDeploymentReuse.ts +428 -0
- package/runtime/workflow/lib/proxy.ts +45 -0
- package/runtime/workflow/lib/registryCommit.ts +455 -0
- package/runtime/workflow/lib/release.ts +329 -0
- package/runtime/workflow/lib/releaseFinalize.ts +711 -0
- package/runtime/workflow/lib/releaseParameters.ts +248 -0
- package/runtime/workflow/lib/reporter.ts +502 -0
- package/runtime/workflow/lib/resultPaths.ts +49 -0
- package/runtime/workflow/lib/runtimeVersion.ts +28 -0
- package/runtime/workflow/lib/signer.ts +124 -0
- package/runtime/workflow/lib/signerIdentity.ts +22 -0
- package/runtime/workflow/lib/simulation.ts +415 -0
- package/runtime/workflow/lib/simulationCallers.ts +335 -0
- package/runtime/workflow/lib/sourceRpcPolicy.ts +41 -0
- package/runtime/workflow/lib/state.ts +25 -0
- package/runtime/workflow/lib/staticValidation.ts +142 -0
- package/runtime/workflow/lib/zksyncForkCapability.ts +80 -0
- package/runtime/workflow/lib/zksyncForkRunner.ts +505 -0
- package/runtime/workflow/reconcileExternal.ts +86 -0
- package/runtime/workflow/reconcileExternalRun.ts +88 -0
- package/runtime/workflow/releaseFinalize.ts +8 -0
- package/runtime/workflow/run.ts +1072 -0
- package/runtime/workflow/staticValidate.ts +23 -0
- package/runtime/workflow/steps/call.ts +10 -0
- package/runtime/workflow/steps/check.ts +10 -0
- package/runtime/workflow/steps/custom.ts +43 -0
- package/runtime/workflow/steps/deploy.ts +771 -0
- package/runtime/workflow/steps/upgrade.ts +598 -0
- package/runtime/workflow/steps/view.ts +10 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import type { ReleaseExecutionPlan } from "./executionPlan";
|
|
4
|
+
|
|
5
|
+
export interface ExternalCall {
|
|
6
|
+
transactionId: string;
|
|
7
|
+
stepId: string;
|
|
8
|
+
to: string;
|
|
9
|
+
value: string;
|
|
10
|
+
data: string;
|
|
11
|
+
operation: 0 | 1;
|
|
12
|
+
scheme?: "zksync-eravm";
|
|
13
|
+
factoryDeps?: string[];
|
|
14
|
+
method: string;
|
|
15
|
+
args: unknown[];
|
|
16
|
+
executor: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ExternalExecutionGroup {
|
|
21
|
+
groupId: string;
|
|
22
|
+
executor: string;
|
|
23
|
+
transactionIds: string[];
|
|
24
|
+
calls: ExternalCall[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ExternalExecutionSegment {
|
|
28
|
+
segmentId: string;
|
|
29
|
+
transactionStartIndex: number;
|
|
30
|
+
transactionIds: string[];
|
|
31
|
+
handoffBlock: number;
|
|
32
|
+
groups: ExternalExecutionGroup[];
|
|
33
|
+
createdAt: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ExternalExecutionPackage {
|
|
37
|
+
version: 1;
|
|
38
|
+
taskId: string;
|
|
39
|
+
target: string;
|
|
40
|
+
executionId: string;
|
|
41
|
+
operator: string;
|
|
42
|
+
executionPlanHash: string;
|
|
43
|
+
segments: ExternalExecutionSegment[];
|
|
44
|
+
createdAt: string;
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ExternalExecutionRequired extends Error {
|
|
49
|
+
constructor(
|
|
50
|
+
readonly stepId: string,
|
|
51
|
+
readonly calls: ExternalCall[],
|
|
52
|
+
) {
|
|
53
|
+
super(`External execution required for step ${stepId}`);
|
|
54
|
+
this.name = "ExternalExecutionRequired";
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const safeId = (value: string, label: string): string => {
|
|
59
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/.test(value)) {
|
|
60
|
+
throw new Error(`${label} is invalid`);
|
|
61
|
+
}
|
|
62
|
+
return value;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const normalizeAddress = (value: string, label: string): string => {
|
|
66
|
+
if (!/^0x[0-9a-fA-F]{40}$/.test(value)) throw new Error(`${label} is invalid`);
|
|
67
|
+
return value.toLowerCase();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const normalizeValue = (value: string, label: string): string => {
|
|
71
|
+
if (!/^(?:0[xX][0-9a-fA-F]+|[0-9]+)$/.test(value)) {
|
|
72
|
+
throw new Error(`${label} is invalid`);
|
|
73
|
+
}
|
|
74
|
+
return BigInt(value).toString(10);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const normalizeData = (value: string, label: string): string => {
|
|
78
|
+
if (!/^0x(?:[0-9a-fA-F]{2})*$/.test(value)) throw new Error(`${label} is invalid`);
|
|
79
|
+
return value.toLowerCase();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const normalizeFactoryDeps = (value: unknown, label: string): string[] => {
|
|
83
|
+
if (!Array.isArray(value)) throw new Error(`${label} must be an array`);
|
|
84
|
+
const output: string[] = [];
|
|
85
|
+
const seen = new Set<string>();
|
|
86
|
+
for (const [index, dependency] of value.entries()) {
|
|
87
|
+
if (typeof dependency !== "string" || !/^0x(?:[0-9a-fA-F]{2})+$/.test(dependency)) {
|
|
88
|
+
throw new Error(`${label}[${index}] is invalid`);
|
|
89
|
+
}
|
|
90
|
+
const normalized = dependency.toLowerCase();
|
|
91
|
+
if (seen.has(normalized)) continue;
|
|
92
|
+
seen.add(normalized);
|
|
93
|
+
output.push(normalized);
|
|
94
|
+
}
|
|
95
|
+
return output;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const canonicalCall = (call: ExternalCall, index: number): ExternalCall => {
|
|
99
|
+
if (call.operation !== 0 && call.operation !== 1) {
|
|
100
|
+
throw new Error(`external call ${index} operation is invalid`);
|
|
101
|
+
}
|
|
102
|
+
if (call.scheme !== undefined && call.scheme !== "zksync-eravm") {
|
|
103
|
+
throw new Error(`external call ${index} scheme is invalid`);
|
|
104
|
+
}
|
|
105
|
+
if (call.scheme === "zksync-eravm" && call.factoryDeps === undefined) {
|
|
106
|
+
throw new Error(`external call ${index} factoryDeps is required for zkSync`);
|
|
107
|
+
}
|
|
108
|
+
if (call.scheme === undefined && call.factoryDeps !== undefined) {
|
|
109
|
+
throw new Error(`external call ${index} factoryDeps is only supported for zkSync`);
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
transactionId: safeId(call.transactionId, `external call ${index} transactionId`),
|
|
113
|
+
stepId: safeId(call.stepId, `external call ${index} stepId`),
|
|
114
|
+
to: normalizeAddress(call.to, `external call ${index} to`),
|
|
115
|
+
value: normalizeValue(call.value, `external call ${index} value`),
|
|
116
|
+
data: normalizeData(call.data, `external call ${index} data`),
|
|
117
|
+
operation: call.operation,
|
|
118
|
+
...(call.scheme === "zksync-eravm"
|
|
119
|
+
? {
|
|
120
|
+
scheme: "zksync-eravm" as const,
|
|
121
|
+
factoryDeps: normalizeFactoryDeps(
|
|
122
|
+
call.factoryDeps,
|
|
123
|
+
`external call ${index} factoryDeps`,
|
|
124
|
+
),
|
|
125
|
+
}
|
|
126
|
+
: {}),
|
|
127
|
+
method: String(call.method),
|
|
128
|
+
args: call.args,
|
|
129
|
+
executor: normalizeAddress(call.executor, `external call ${index} executor`),
|
|
130
|
+
reason: String(call.reason),
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const groupAdjacentCalls = (calls: ExternalCall[]): ExternalExecutionGroup[] => {
|
|
135
|
+
const groups: ExternalExecutionGroup[] = [];
|
|
136
|
+
for (const call of calls) {
|
|
137
|
+
const previous = groups.at(-1);
|
|
138
|
+
if (previous && previous.executor === call.executor) {
|
|
139
|
+
previous.transactionIds.push(call.transactionId);
|
|
140
|
+
previous.calls.push(call);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
groups.push({
|
|
144
|
+
groupId: `group-${String(groups.length + 1).padStart(4, "0")}`,
|
|
145
|
+
executor: call.executor,
|
|
146
|
+
transactionIds: [call.transactionId],
|
|
147
|
+
calls: [call],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return groups;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
const packagePath = (taskDir: string, target: string, executionId: string): string => {
|
|
154
|
+
safeId(target, "external package target");
|
|
155
|
+
safeId(executionId, "external package executionId");
|
|
156
|
+
const resolvedTask = path.resolve(taskDir);
|
|
157
|
+
const filePath = path.join(
|
|
158
|
+
resolvedTask,
|
|
159
|
+
"calldata",
|
|
160
|
+
target,
|
|
161
|
+
executionId,
|
|
162
|
+
"external-execution.json",
|
|
163
|
+
);
|
|
164
|
+
const relative = path.relative(resolvedTask, filePath);
|
|
165
|
+
if (relative.startsWith("..") || path.isAbsolute(relative)) {
|
|
166
|
+
throw new Error("external package path escapes the task directory");
|
|
167
|
+
}
|
|
168
|
+
return filePath;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const writeAtomic = (filePath: string, value: unknown): void => {
|
|
172
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
173
|
+
const serialized = JSON.stringify(value, null, 2) + "\n";
|
|
174
|
+
const temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
175
|
+
try {
|
|
176
|
+
fs.writeFileSync(temporary, serialized, { flag: "wx", mode: 0o600 });
|
|
177
|
+
fs.renameSync(temporary, filePath);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const externalSegments = (
|
|
185
|
+
plan: ReleaseExecutionPlan,
|
|
186
|
+
): Array<{ index: number; transactions: ReleaseExecutionPlan["transactions"] }> => {
|
|
187
|
+
const segments: Array<{ index: number; transactions: ReleaseExecutionPlan["transactions"] }> = [];
|
|
188
|
+
for (const transaction of plan.transactions) {
|
|
189
|
+
if (transaction.route !== "external") continue;
|
|
190
|
+
const previous = segments.at(-1);
|
|
191
|
+
if (
|
|
192
|
+
previous
|
|
193
|
+
&& previous.transactions.at(-1)!.transactionIndex + 1 === transaction.transactionIndex
|
|
194
|
+
) {
|
|
195
|
+
previous.transactions.push(transaction);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
segments.push({ index: segments.length, transactions: [transaction] });
|
|
199
|
+
}
|
|
200
|
+
return segments;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
const canonicalSegmentCalls = (
|
|
204
|
+
plan: ReleaseExecutionPlan,
|
|
205
|
+
rawCalls: ExternalCall[],
|
|
206
|
+
): { segmentIndex: number; transactions: ReleaseExecutionPlan["transactions"]; calls: ExternalCall[] } => {
|
|
207
|
+
if (rawCalls.length === 0) {
|
|
208
|
+
throw new Error("external package calls must cover one consecutive external segment");
|
|
209
|
+
}
|
|
210
|
+
const calls = rawCalls.map(canonicalCall);
|
|
211
|
+
const segments = externalSegments(plan);
|
|
212
|
+
const segmentIndex = segments.findIndex((segment) => (
|
|
213
|
+
segment.transactions.length === calls.length
|
|
214
|
+
&& segment.transactions.every((transaction, index) => (
|
|
215
|
+
transaction.transactionId === calls[index].transactionId
|
|
216
|
+
))
|
|
217
|
+
));
|
|
218
|
+
if (segmentIndex < 0) {
|
|
219
|
+
throw new Error("external package calls must cover one consecutive external segment");
|
|
220
|
+
}
|
|
221
|
+
const transactions = segments[segmentIndex].transactions;
|
|
222
|
+
for (const [index, transaction] of transactions.entries()) {
|
|
223
|
+
const call = calls[index];
|
|
224
|
+
if (
|
|
225
|
+
call.stepId !== transaction.stepId
|
|
226
|
+
|| call.executor !== transaction.executor.toLowerCase()
|
|
227
|
+
|| call.to !== transaction.to.toLowerCase()
|
|
228
|
+
|| call.value !== BigInt(transaction.value).toString(10)
|
|
229
|
+
|| call.data !== transaction.data.toLowerCase()
|
|
230
|
+
|| call.operation !== transaction.operation
|
|
231
|
+
|| call.scheme !== transaction.scheme
|
|
232
|
+
|| JSON.stringify(call.factoryDeps) !== JSON.stringify(transaction.factoryDeps)
|
|
233
|
+
) {
|
|
234
|
+
throw new Error(
|
|
235
|
+
`external plan transaction ${transaction.transactionId} must match its segment call`,
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return { segmentIndex, transactions, calls };
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const assertExternalTransportSupported = (plan: ReleaseExecutionPlan): void => {
|
|
243
|
+
if (
|
|
244
|
+
plan.transactions.some(
|
|
245
|
+
(transaction) => transaction.route === "external" && transaction.scheme === "zksync-eravm",
|
|
246
|
+
)
|
|
247
|
+
) {
|
|
248
|
+
throw new Error(
|
|
249
|
+
"zkSync external Admin execution is not supported until an exact EIP-712 factoryDeps transport is implemented",
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const parseExistingPackage = (
|
|
255
|
+
filePath: string,
|
|
256
|
+
plan: ReleaseExecutionPlan,
|
|
257
|
+
): ExternalExecutionPackage | undefined => {
|
|
258
|
+
if (!fs.existsSync(filePath)) return undefined;
|
|
259
|
+
let parsed: unknown;
|
|
260
|
+
try {
|
|
261
|
+
parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
262
|
+
} catch (error) {
|
|
263
|
+
throw new Error(
|
|
264
|
+
`external execution package is invalid: ${error instanceof Error ? error.message : String(error)}`,
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
268
|
+
throw new Error("external execution package must be an object");
|
|
269
|
+
}
|
|
270
|
+
const value = parsed as Record<string, unknown>;
|
|
271
|
+
if (
|
|
272
|
+
value.version !== 1
|
|
273
|
+
|| value.taskId !== plan.taskId
|
|
274
|
+
|| value.target !== plan.target
|
|
275
|
+
|| value.executionId !== plan.executionId
|
|
276
|
+
|| value.operator !== plan.operator
|
|
277
|
+
|| value.executionPlanHash !== plan.planHash
|
|
278
|
+
|| !Array.isArray(value.segments)
|
|
279
|
+
|| typeof value.createdAt !== "string"
|
|
280
|
+
|| typeof value.updatedAt !== "string"
|
|
281
|
+
) {
|
|
282
|
+
throw new Error("external execution package does not match the execution plan");
|
|
283
|
+
}
|
|
284
|
+
const segments = externalSegments(plan);
|
|
285
|
+
for (const [index, rawSegment] of value.segments.entries()) {
|
|
286
|
+
if (!rawSegment || typeof rawSegment !== "object" || Array.isArray(rawSegment)) {
|
|
287
|
+
throw new Error(`external execution segment ${index} is invalid`);
|
|
288
|
+
}
|
|
289
|
+
const segment = rawSegment as ExternalExecutionSegment;
|
|
290
|
+
const expected = segments[index]?.transactions;
|
|
291
|
+
const calls = Array.isArray(segment.groups)
|
|
292
|
+
? segment.groups.flatMap((group) => group.calls)
|
|
293
|
+
: [];
|
|
294
|
+
if (
|
|
295
|
+
!expected
|
|
296
|
+
|| segment.segmentId !== `segment-${String(index + 1).padStart(4, "0")}`
|
|
297
|
+
|| segment.transactionStartIndex !== expected[0].transactionIndex
|
|
298
|
+
|| !Array.isArray(segment.transactionIds)
|
|
299
|
+
|| JSON.stringify(segment.transactionIds) !== JSON.stringify(
|
|
300
|
+
expected.map((transaction) => transaction.transactionId),
|
|
301
|
+
)
|
|
302
|
+
|| !Number.isSafeInteger(segment.handoffBlock)
|
|
303
|
+
|| segment.handoffBlock < 0
|
|
304
|
+
|| calls.length !== expected.length
|
|
305
|
+
) {
|
|
306
|
+
throw new Error(`external execution segment ${index} does not match the execution plan`);
|
|
307
|
+
}
|
|
308
|
+
canonicalSegmentCalls(plan, calls);
|
|
309
|
+
}
|
|
310
|
+
return value as unknown as ExternalExecutionPackage;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export const loadExternalExecutionPackage = (input: {
|
|
314
|
+
taskDir: string;
|
|
315
|
+
plan: ReleaseExecutionPlan;
|
|
316
|
+
}): { filePath: string; package: ExternalExecutionPackage } | undefined => {
|
|
317
|
+
assertExternalTransportSupported(input.plan);
|
|
318
|
+
const filePath = packagePath(input.taskDir, input.plan.target, input.plan.executionId);
|
|
319
|
+
const existing = parseExistingPackage(filePath, input.plan);
|
|
320
|
+
return existing ? { filePath, package: existing } : undefined;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
export const writeExternalExecutionPackage = (input: {
|
|
324
|
+
taskDir: string;
|
|
325
|
+
plan: ReleaseExecutionPlan;
|
|
326
|
+
handoffBlock: number;
|
|
327
|
+
calls: ExternalCall[];
|
|
328
|
+
now?: () => string;
|
|
329
|
+
}): { filePath: string; package: ExternalExecutionPackage } => {
|
|
330
|
+
assertExternalTransportSupported(input.plan);
|
|
331
|
+
if (!Number.isSafeInteger(input.handoffBlock) || input.handoffBlock < 0) {
|
|
332
|
+
throw new Error("external package handoffBlock must be a nonnegative safe integer");
|
|
333
|
+
}
|
|
334
|
+
if (!input.plan.transactions.some((transaction) => transaction.route === "external")) {
|
|
335
|
+
throw new Error("external execution package requires external plan transactions");
|
|
336
|
+
}
|
|
337
|
+
const { segmentIndex, transactions, calls } = canonicalSegmentCalls(input.plan, input.calls);
|
|
338
|
+
const target = safeId(input.plan.target, "external package target");
|
|
339
|
+
const executionId = safeId(input.plan.executionId, "external package executionId");
|
|
340
|
+
const filePath = packagePath(input.taskDir, target, executionId);
|
|
341
|
+
const existing = parseExistingPackage(filePath, input.plan);
|
|
342
|
+
if (existing?.segments[segmentIndex]) {
|
|
343
|
+
return { filePath, package: existing };
|
|
344
|
+
}
|
|
345
|
+
if ((existing?.segments.length ?? 0) !== segmentIndex) {
|
|
346
|
+
throw new Error("external execution segments must be appended in plan order");
|
|
347
|
+
}
|
|
348
|
+
const now = (input.now || (() => new Date().toISOString()))();
|
|
349
|
+
const segment: ExternalExecutionSegment = {
|
|
350
|
+
segmentId: `segment-${String(segmentIndex + 1).padStart(4, "0")}`,
|
|
351
|
+
transactionStartIndex: transactions[0].transactionIndex,
|
|
352
|
+
transactionIds: transactions.map((transaction) => transaction.transactionId),
|
|
353
|
+
handoffBlock: input.handoffBlock,
|
|
354
|
+
groups: groupAdjacentCalls(calls),
|
|
355
|
+
createdAt: now,
|
|
356
|
+
};
|
|
357
|
+
const output: ExternalExecutionPackage = existing
|
|
358
|
+
? { ...existing, segments: [...existing.segments, segment], updatedAt: now }
|
|
359
|
+
: {
|
|
360
|
+
version: 1,
|
|
361
|
+
taskId: safeId(input.plan.taskId, "external package taskId"),
|
|
362
|
+
target,
|
|
363
|
+
executionId,
|
|
364
|
+
operator: normalizeAddress(input.plan.operator, "external package operator"),
|
|
365
|
+
executionPlanHash: input.plan.planHash,
|
|
366
|
+
segments: [segment],
|
|
367
|
+
createdAt: now,
|
|
368
|
+
updatedAt: now,
|
|
369
|
+
};
|
|
370
|
+
writeAtomic(filePath, output);
|
|
371
|
+
return { filePath, package: output };
|
|
372
|
+
};
|