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.
- package/README.md +33 -11
- package/bin/workflow.cjs +19 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -57
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/checkBatch.d.ts +4 -0
- package/dist/commands/checkBatch.d.ts.map +1 -0
- package/dist/commands/checkBatch.js +57 -0
- package/dist/commands/checkBatch.js.map +1 -0
- package/dist/commands/checkOptions.d.ts +3 -0
- package/dist/commands/checkOptions.d.ts.map +1 -1
- package/dist/commands/checkOptions.js +10 -1
- package/dist/commands/checkOptions.js.map +1 -1
- package/dist/commands/prepare.d.ts +1 -2
- package/dist/commands/prepare.d.ts.map +1 -1
- package/dist/commands/prepare.js +2 -17
- package/dist/commands/prepare.js.map +1 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +2 -17
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +2 -17
- package/dist/commands/validate.js.map +1 -1
- 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/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/hardhat.d.ts +4 -0
- package/dist/utils/hardhat.d.ts.map +1 -0
- package/dist/utils/hardhat.js +9 -0
- package/dist/utils/hardhat.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 +26 -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,335 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { getAddress, ZeroAddress } from "ethers";
|
|
5
|
+
import YAML from "yaml";
|
|
6
|
+
import { hashValue } from "./release";
|
|
7
|
+
|
|
8
|
+
export interface SimulationCallerNetworkInput {
|
|
9
|
+
default: string;
|
|
10
|
+
steps?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SimulationCallersDocument {
|
|
14
|
+
version: 1;
|
|
15
|
+
networks: Record<string, SimulationCallerNetworkInput>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ResolvedSimulationCaller {
|
|
19
|
+
stepId: string;
|
|
20
|
+
callerAddress: string;
|
|
21
|
+
source: "step" | "network_default";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface SimulationCallerNetworkBinding {
|
|
25
|
+
network: string;
|
|
26
|
+
manifestHash: string;
|
|
27
|
+
defaultAddress: string;
|
|
28
|
+
resolved: ResolvedSimulationCaller[];
|
|
29
|
+
networkHash: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface ManifestStepInput {
|
|
33
|
+
id: string;
|
|
34
|
+
kind: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const UNSAFE_KEYS = new Set(["__proto__", "prototype", "constructor"]);
|
|
38
|
+
|
|
39
|
+
const record = <T>(): Record<string, T> => (
|
|
40
|
+
Object.create(null) as Record<string, T>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const stringKey = (value: unknown, label: string): string => {
|
|
44
|
+
if (typeof value !== "string" || !value || value !== value.trim()) {
|
|
45
|
+
throw new Error(`${label} must be a non-empty string without surrounding whitespace`);
|
|
46
|
+
}
|
|
47
|
+
if (value === "<<" || UNSAFE_KEYS.has(value)) {
|
|
48
|
+
throw new Error(`${label} contains an unsafe key`);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const normalizedAddress = (value: unknown, label: string): string => {
|
|
54
|
+
if (typeof value !== "string" || !value || value !== value.trim()) {
|
|
55
|
+
throw new Error(`${label} must be a valid non-zero EVM address`);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const address = getAddress(value);
|
|
59
|
+
if (address === ZeroAddress) throw new Error("zero address");
|
|
60
|
+
return address;
|
|
61
|
+
} catch {
|
|
62
|
+
throw new Error(`${label} must be a valid non-zero EVM address`);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const entriesOf = (value: unknown, label: string): Array<[string, unknown]> => {
|
|
67
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
68
|
+
throw new Error(`${label} must be a mapping`);
|
|
69
|
+
}
|
|
70
|
+
return Object.keys(value as Record<string, unknown>).map((key) => [
|
|
71
|
+
stringKey(key, `${label} key`),
|
|
72
|
+
(value as Record<string, unknown>)[key],
|
|
73
|
+
]);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const normalizeDocument = (value: unknown): SimulationCallersDocument => {
|
|
77
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
78
|
+
throw new Error("simulation callers document must be a mapping");
|
|
79
|
+
}
|
|
80
|
+
const document = value as Record<string, unknown>;
|
|
81
|
+
const keys = Object.keys(document);
|
|
82
|
+
if (keys.length !== 2 || !keys.includes("version") || !keys.includes("networks")) {
|
|
83
|
+
throw new Error("simulation callers document contains unsupported or missing fields");
|
|
84
|
+
}
|
|
85
|
+
if (document.version !== 1 && document.version !== "1") {
|
|
86
|
+
throw new Error("simulation callers version must equal 1");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const networks = record<SimulationCallerNetworkInput>();
|
|
90
|
+
for (const [network, networkValue] of entriesOf(
|
|
91
|
+
document.networks,
|
|
92
|
+
"simulation callers networks",
|
|
93
|
+
)) {
|
|
94
|
+
const networkEntries = entriesOf(networkValue, `simulation caller network ${network}`);
|
|
95
|
+
const networkKeys = new Set(networkEntries.map(([key]) => key));
|
|
96
|
+
if (!networkKeys.has("default")) {
|
|
97
|
+
throw new Error(`simulation caller network ${network} is missing required field default`);
|
|
98
|
+
}
|
|
99
|
+
if ([...networkKeys].some((key) => key !== "default" && key !== "steps")) {
|
|
100
|
+
throw new Error(`simulation caller network ${network} contains unsupported fields`);
|
|
101
|
+
}
|
|
102
|
+
const networkRecord = Object.fromEntries(networkEntries) as Record<string, unknown>;
|
|
103
|
+
const defaultAddress = normalizedAddress(
|
|
104
|
+
networkRecord.default,
|
|
105
|
+
`simulation caller network ${network} default`,
|
|
106
|
+
);
|
|
107
|
+
const stepsValue = networkRecord.steps;
|
|
108
|
+
let steps: Record<string, string> | undefined;
|
|
109
|
+
if (stepsValue !== undefined) {
|
|
110
|
+
steps = record<string>();
|
|
111
|
+
for (const [stepId, address] of entriesOf(
|
|
112
|
+
stepsValue,
|
|
113
|
+
`simulation caller network ${network} steps`,
|
|
114
|
+
)) {
|
|
115
|
+
steps[stepId] = normalizedAddress(
|
|
116
|
+
address,
|
|
117
|
+
`simulation caller network ${network} step ${stepId}`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
networks[network] = {
|
|
122
|
+
default: defaultAddress,
|
|
123
|
+
...(steps ? { steps } : {}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return { version: 1, networks };
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const parseYamlValue = (text: string): unknown => {
|
|
130
|
+
if (typeof text !== "string") throw new Error("simulation callers YAML must be text");
|
|
131
|
+
const document = YAML.parseDocument(text, {
|
|
132
|
+
merge: false,
|
|
133
|
+
prettyErrors: true,
|
|
134
|
+
schema: "failsafe",
|
|
135
|
+
uniqueKeys: true,
|
|
136
|
+
});
|
|
137
|
+
if (document.errors.length > 0) {
|
|
138
|
+
throw new Error(`invalid simulation callers YAML: ${document.errors[0].message}`);
|
|
139
|
+
}
|
|
140
|
+
const compatibleDocument = document as unknown as {
|
|
141
|
+
toJS?: (options: { mapAsMap: boolean; maxAliasCount: number }) => unknown;
|
|
142
|
+
toJSON: () => unknown;
|
|
143
|
+
};
|
|
144
|
+
return typeof compatibleDocument.toJS === "function"
|
|
145
|
+
? compatibleDocument.toJS({ mapAsMap: true, maxAliasCount: 0 })
|
|
146
|
+
: compatibleDocument.toJSON();
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const mapToNullRecords = (value: unknown, label: string): unknown => {
|
|
150
|
+
if (value instanceof Map) {
|
|
151
|
+
const output = record<unknown>();
|
|
152
|
+
for (const [keyValue, child] of value.entries()) {
|
|
153
|
+
const key = stringKey(keyValue, `${label} key`);
|
|
154
|
+
output[key] = mapToNullRecords(child, `${label}.${key}`);
|
|
155
|
+
}
|
|
156
|
+
return output;
|
|
157
|
+
}
|
|
158
|
+
if (Array.isArray(value)) {
|
|
159
|
+
return value.map((child, index) => mapToNullRecords(child, `${label}[${index}]`));
|
|
160
|
+
}
|
|
161
|
+
return value;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const validatedManifestSteps = (steps: ManifestStepInput[]): ManifestStepInput[] => {
|
|
165
|
+
if (!Array.isArray(steps) || steps.length === 0) {
|
|
166
|
+
throw new Error("Manifest must contain at least one simulation caller step");
|
|
167
|
+
}
|
|
168
|
+
const seen = new Set<string>();
|
|
169
|
+
return steps.map((step, index) => {
|
|
170
|
+
if (!step || typeof step !== "object") {
|
|
171
|
+
throw new Error(`Manifest step ${index} is invalid`);
|
|
172
|
+
}
|
|
173
|
+
const id = stringKey(step.id, `Manifest step ${index} id`);
|
|
174
|
+
if (seen.has(id)) throw new Error(`Duplicate Manifest step ${id}`);
|
|
175
|
+
seen.add(id);
|
|
176
|
+
if (typeof step.kind !== "string" || !step.kind || step.kind !== step.kind.trim()) {
|
|
177
|
+
throw new Error(`Manifest step ${id} kind must be a non-empty string`);
|
|
178
|
+
}
|
|
179
|
+
return { id, kind: step.kind };
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const manifestHash = (value: string): string => (
|
|
184
|
+
crypto.createHash("sha256").update(value).digest("hex")
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
export const parseSimulationCallersYaml = (text: string): SimulationCallersDocument => {
|
|
188
|
+
return normalizeDocument(
|
|
189
|
+
mapToNullRecords(parseYamlValue(text), "simulation callers document"),
|
|
190
|
+
);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
export const validateSimulationCallersDocument = (input: {
|
|
194
|
+
document: SimulationCallersDocument;
|
|
195
|
+
targetNetworks: string[];
|
|
196
|
+
manifestSteps: ManifestStepInput[];
|
|
197
|
+
}): SimulationCallersDocument => {
|
|
198
|
+
const document = normalizeDocument(input.document);
|
|
199
|
+
if (!Array.isArray(input.targetNetworks) || input.targetNetworks.length === 0) {
|
|
200
|
+
throw new Error("simulation caller target networks must be a non-empty array");
|
|
201
|
+
}
|
|
202
|
+
const targetNetworks = input.targetNetworks.map((network, index) => (
|
|
203
|
+
stringKey(network, `simulation caller target network ${index}`)
|
|
204
|
+
));
|
|
205
|
+
if (new Set(targetNetworks).size !== targetNetworks.length) {
|
|
206
|
+
throw new Error("Duplicate simulation caller target network");
|
|
207
|
+
}
|
|
208
|
+
const configuredNetworks = Object.keys(document.networks);
|
|
209
|
+
const expectedSet = [...targetNetworks].sort();
|
|
210
|
+
const configuredSet = [...configuredNetworks].sort();
|
|
211
|
+
if (
|
|
212
|
+
expectedSet.length !== configuredSet.length
|
|
213
|
+
|| expectedSet.some((network, index) => network !== configuredSet[index])
|
|
214
|
+
) {
|
|
215
|
+
throw new Error("simulation caller target networks do not match configured target networks");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const manifestSteps = validatedManifestSteps(input.manifestSteps);
|
|
219
|
+
const manifestStepIds = new Set(manifestSteps.map((step) => step.id));
|
|
220
|
+
const networks = record<SimulationCallerNetworkInput>();
|
|
221
|
+
for (const network of targetNetworks) {
|
|
222
|
+
const configured = document.networks[network];
|
|
223
|
+
const steps = record<string>();
|
|
224
|
+
for (const stepId of Object.keys(configured.steps ?? {})) {
|
|
225
|
+
if (!manifestStepIds.has(stepId)) {
|
|
226
|
+
throw new Error(
|
|
227
|
+
`simulation caller network ${network} references unknown Manifest step ${stepId}`,
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
for (const step of manifestSteps) {
|
|
232
|
+
const override = configured.steps?.[step.id];
|
|
233
|
+
if (override !== undefined) steps[step.id] = override;
|
|
234
|
+
}
|
|
235
|
+
networks[network] = {
|
|
236
|
+
default: configured.default,
|
|
237
|
+
...(Object.keys(steps).length > 0 ? { steps } : {}),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return { version: 1, networks };
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export const buildSimulationCallerNetworkBinding = (input: {
|
|
244
|
+
document: SimulationCallersDocument;
|
|
245
|
+
network: string;
|
|
246
|
+
manifestText: string;
|
|
247
|
+
manifestSteps: ManifestStepInput[];
|
|
248
|
+
}): SimulationCallerNetworkBinding => {
|
|
249
|
+
const document = normalizeDocument(input.document);
|
|
250
|
+
const network = stringKey(input.network, "simulation caller binding network");
|
|
251
|
+
const configured = document.networks[network];
|
|
252
|
+
if (!configured) throw new Error(`Unknown simulation caller network ${network}`);
|
|
253
|
+
const manifestSteps = validatedManifestSteps(input.manifestSteps);
|
|
254
|
+
const manifestStepIds = new Set(manifestSteps.map((step) => step.id));
|
|
255
|
+
for (const stepId of Object.keys(configured.steps ?? {})) {
|
|
256
|
+
if (!manifestStepIds.has(stepId)) {
|
|
257
|
+
throw new Error(
|
|
258
|
+
`simulation caller network ${network} references unknown Manifest step ${stepId}`,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const resolved: ResolvedSimulationCaller[] = manifestSteps.map((step) => {
|
|
263
|
+
const callerAddress = configured.steps?.[step.id];
|
|
264
|
+
return callerAddress === undefined
|
|
265
|
+
? {
|
|
266
|
+
stepId: step.id,
|
|
267
|
+
callerAddress: configured.default,
|
|
268
|
+
source: "network_default" as const,
|
|
269
|
+
}
|
|
270
|
+
: { stepId: step.id, callerAddress, source: "step" as const };
|
|
271
|
+
});
|
|
272
|
+
const exactManifestHash = manifestHash(input.manifestText);
|
|
273
|
+
const networkHash = hashValue({
|
|
274
|
+
version: 1,
|
|
275
|
+
manifestHash: exactManifestHash,
|
|
276
|
+
network,
|
|
277
|
+
default: configured.default.toLowerCase(),
|
|
278
|
+
resolved: resolved.map((entry) => ({
|
|
279
|
+
stepId: entry.stepId,
|
|
280
|
+
callerAddress: entry.callerAddress.toLowerCase(),
|
|
281
|
+
})),
|
|
282
|
+
});
|
|
283
|
+
return {
|
|
284
|
+
network,
|
|
285
|
+
manifestHash: exactManifestHash,
|
|
286
|
+
defaultAddress: configured.default,
|
|
287
|
+
resolved,
|
|
288
|
+
networkHash,
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
const simulationCallersPath = (taskDir: string): string => {
|
|
293
|
+
const realTaskDir = fs.realpathSync(taskDir);
|
|
294
|
+
const filePath = path.resolve(realTaskDir, "simulation-callers.yaml");
|
|
295
|
+
if (path.dirname(filePath) !== realTaskDir) {
|
|
296
|
+
throw new Error("simulation callers path escapes the task directory");
|
|
297
|
+
}
|
|
298
|
+
if (!fs.existsSync(filePath)) {
|
|
299
|
+
throw new Error(`Missing simulation callers file: ${filePath}`);
|
|
300
|
+
}
|
|
301
|
+
const stat = fs.lstatSync(filePath);
|
|
302
|
+
if (stat.isSymbolicLink()) {
|
|
303
|
+
throw new Error("simulation callers file cannot be a symlink");
|
|
304
|
+
}
|
|
305
|
+
if (!stat.isFile()) {
|
|
306
|
+
throw new Error("simulation callers path must be a regular file");
|
|
307
|
+
}
|
|
308
|
+
const realFilePath = fs.realpathSync(filePath);
|
|
309
|
+
if (path.dirname(realFilePath) !== realTaskDir) {
|
|
310
|
+
throw new Error("simulation callers file escapes the task directory");
|
|
311
|
+
}
|
|
312
|
+
return filePath;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export const loadSimulationCallerNetwork = (input: {
|
|
316
|
+
taskDir: string;
|
|
317
|
+
targetNetworks: string[];
|
|
318
|
+
network: string;
|
|
319
|
+
manifestText: string;
|
|
320
|
+
manifestSteps: ManifestStepInput[];
|
|
321
|
+
}): SimulationCallerNetworkBinding => {
|
|
322
|
+
const document = validateSimulationCallersDocument({
|
|
323
|
+
document: parseSimulationCallersYaml(
|
|
324
|
+
fs.readFileSync(simulationCallersPath(input.taskDir), "utf8"),
|
|
325
|
+
),
|
|
326
|
+
targetNetworks: input.targetNetworks,
|
|
327
|
+
manifestSteps: input.manifestSteps,
|
|
328
|
+
});
|
|
329
|
+
return buildSimulationCallerNetworkBinding({
|
|
330
|
+
document,
|
|
331
|
+
network: input.network,
|
|
332
|
+
manifestText: input.manifestText,
|
|
333
|
+
manifestSteps: input.manifestSteps,
|
|
334
|
+
});
|
|
335
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// The source-chain proxy exists only to hydrate a pinned local fork and verify
|
|
2
|
+
// its source snapshot. Keep this surface explicit: adding a method requires a
|
|
3
|
+
// review that it cannot sign, submit, mine, or otherwise mutate remote state.
|
|
4
|
+
const ALLOWED_SOURCE_RPC_METHODS = new Set([
|
|
5
|
+
"debug_traceTransaction",
|
|
6
|
+
"eth_blockNumber",
|
|
7
|
+
"eth_call",
|
|
8
|
+
"eth_chainId",
|
|
9
|
+
"eth_estimateGas",
|
|
10
|
+
"eth_feeHistory",
|
|
11
|
+
"eth_gasPrice",
|
|
12
|
+
"eth_getBalance",
|
|
13
|
+
"eth_getBlockByHash",
|
|
14
|
+
"eth_getBlockByNumber",
|
|
15
|
+
"eth_getBlockReceipts",
|
|
16
|
+
"eth_getBlockTransactionCountByHash",
|
|
17
|
+
"eth_getBlockTransactionCountByNumber",
|
|
18
|
+
"eth_getCode",
|
|
19
|
+
"eth_getLogs",
|
|
20
|
+
"eth_getProof",
|
|
21
|
+
"eth_getStorageAt",
|
|
22
|
+
"eth_getTransactionByBlockHashAndIndex",
|
|
23
|
+
"eth_getTransactionByBlockNumberAndIndex",
|
|
24
|
+
"eth_getTransactionByHash",
|
|
25
|
+
"eth_getTransactionCount",
|
|
26
|
+
"eth_getTransactionReceipt",
|
|
27
|
+
"eth_maxPriorityFeePerGas",
|
|
28
|
+
"net_version",
|
|
29
|
+
"web3_clientVersion",
|
|
30
|
+
"zks_getBlockDetails",
|
|
31
|
+
"zks_getBridgeContracts",
|
|
32
|
+
"zks_getBytecodeByHash",
|
|
33
|
+
"zks_getFeeParams",
|
|
34
|
+
"zks_getProof",
|
|
35
|
+
"zks_getRawBlockTransactions",
|
|
36
|
+
"zks_getTransactionDetails",
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
export const isAllowedSourceRpcMethod = (method: string): boolean => (
|
|
40
|
+
ALLOWED_SOURCE_RPC_METHODS.has(method)
|
|
41
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class WorkflowState {
|
|
2
|
+
private readonly values: Record<string, unknown> = {};
|
|
3
|
+
|
|
4
|
+
set(key: string, value: unknown): void {
|
|
5
|
+
this.values[key] = value;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
get(pathExpression: string): unknown {
|
|
9
|
+
const parts = pathExpression.split(".");
|
|
10
|
+
let current: unknown = this.values;
|
|
11
|
+
|
|
12
|
+
for (const part of parts) {
|
|
13
|
+
if (typeof current !== "object" || current === null || !(part in current)) {
|
|
14
|
+
throw new Error(`State reference not found: state.${pathExpression}`);
|
|
15
|
+
}
|
|
16
|
+
current = (current as Record<string, unknown>)[part];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return current;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
snapshot(): Record<string, unknown> {
|
|
23
|
+
return { ...this.values };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { spawnSync } from "child_process";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
|
|
6
|
+
export interface StaticValidationCommandResult {
|
|
7
|
+
status: number;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface StaticValidationOptions {
|
|
12
|
+
root: string;
|
|
13
|
+
deploymentId: string;
|
|
14
|
+
network?: string;
|
|
15
|
+
testCommand?: { command: string; args: string[] };
|
|
16
|
+
runCommand?: (
|
|
17
|
+
command: string,
|
|
18
|
+
args: string[],
|
|
19
|
+
options: { cwd: string },
|
|
20
|
+
) => Promise<StaticValidationCommandResult> | StaticValidationCommandResult;
|
|
21
|
+
now?: () => string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface StaticValidationResult {
|
|
25
|
+
status: "passed" | "failed";
|
|
26
|
+
reportPath: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SAFE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,199}$/;
|
|
30
|
+
|
|
31
|
+
const defaultRunCommand = (
|
|
32
|
+
command: string,
|
|
33
|
+
args: string[],
|
|
34
|
+
options: { cwd: string },
|
|
35
|
+
): StaticValidationCommandResult => {
|
|
36
|
+
const executable = process.platform === "win32" && (command === "npm" || command === "npx")
|
|
37
|
+
? `${command}.cmd`
|
|
38
|
+
: command;
|
|
39
|
+
const result = spawnSync(executable, args, { cwd: options.cwd, env: process.env, stdio: "inherit" });
|
|
40
|
+
return { status: result.status ?? 1, error: result.error?.message };
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const taskDocuments = (taskDir: string): string[] => {
|
|
44
|
+
const files: string[] = [];
|
|
45
|
+
const visit = (directory: string): void => {
|
|
46
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
47
|
+
const filePath = path.join(directory, entry.name);
|
|
48
|
+
if (entry.isSymbolicLink()) throw new Error(`Task validation does not follow symlinks: ${filePath}`);
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
visit(filePath);
|
|
51
|
+
} else if (/\.(?:json|ya?ml)$/i.test(entry.name)) {
|
|
52
|
+
files.push(filePath);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
visit(taskDir);
|
|
57
|
+
return files.sort();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const parseTaskDocuments = (taskDir: string): StaticValidationCommandResult => {
|
|
61
|
+
try {
|
|
62
|
+
for (const filePath of taskDocuments(taskDir)) {
|
|
63
|
+
const contents = fs.readFileSync(filePath, "utf8");
|
|
64
|
+
if (/\.json$/i.test(filePath)) JSON.parse(contents);
|
|
65
|
+
else YAML.parse(contents);
|
|
66
|
+
}
|
|
67
|
+
return { status: 0 };
|
|
68
|
+
} catch (error) {
|
|
69
|
+
return { status: 1, error: error instanceof Error ? error.message : String(error) };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const writeTextAtomic = (filePath: string, contents: string): void => {
|
|
74
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
75
|
+
const temporary = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
76
|
+
try {
|
|
77
|
+
fs.writeFileSync(temporary, contents);
|
|
78
|
+
fs.renameSync(temporary, filePath);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (fs.existsSync(temporary)) fs.unlinkSync(temporary);
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const runStaticValidation = async (
|
|
86
|
+
options: StaticValidationOptions,
|
|
87
|
+
): Promise<StaticValidationResult> => {
|
|
88
|
+
if (!SAFE_ID.test(options.deploymentId)) throw new Error("deploymentId is invalid");
|
|
89
|
+
if (options.network !== undefined && !SAFE_ID.test(options.network)) {
|
|
90
|
+
throw new Error("network is invalid");
|
|
91
|
+
}
|
|
92
|
+
const taskDir = path.join(options.root, "scripts", "tasks", options.deploymentId);
|
|
93
|
+
if (!fs.existsSync(taskDir) || !fs.statSync(taskDir).isDirectory()) {
|
|
94
|
+
throw new Error(`Deployment task does not exist: ${options.deploymentId}`);
|
|
95
|
+
}
|
|
96
|
+
const runCommand = options.runCommand || defaultRunCommand;
|
|
97
|
+
const compileArgs = options.network
|
|
98
|
+
? ["run", "compile", "--", "--network", options.network]
|
|
99
|
+
: ["run", "compile"];
|
|
100
|
+
const commands = [
|
|
101
|
+
{ label: ["npm", ...compileArgs].join(" "), command: "npm", args: compileArgs },
|
|
102
|
+
{ label: "npx tsc --noEmit", command: "npx", args: ["tsc", "--noEmit"] },
|
|
103
|
+
{
|
|
104
|
+
label: (options.testCommand
|
|
105
|
+
? [options.testCommand.command, ...options.testCommand.args]
|
|
106
|
+
: ["npm", "test"]).join(" "),
|
|
107
|
+
command: options.testCommand?.command || "npm",
|
|
108
|
+
args: options.testCommand?.args || ["test"],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
const evidence: Array<{ label: string; result: StaticValidationCommandResult }> = [];
|
|
112
|
+
for (const command of commands) {
|
|
113
|
+
let result: StaticValidationCommandResult;
|
|
114
|
+
try {
|
|
115
|
+
result = await runCommand(command.command, command.args, { cwd: options.root });
|
|
116
|
+
} catch (error) {
|
|
117
|
+
result = { status: 1, error: error instanceof Error ? error.message : String(error) };
|
|
118
|
+
}
|
|
119
|
+
evidence.push({ label: command.label, result });
|
|
120
|
+
}
|
|
121
|
+
evidence.push({ label: "YAML/JSON parse", result: parseTaskDocuments(taskDir) });
|
|
122
|
+
const status = evidence.every((entry) => entry.result.status === 0) ? "passed" : "failed";
|
|
123
|
+
const completedAt = (options.now || (() => new Date().toISOString()))();
|
|
124
|
+
const reportPath = `scripts/tasks/${options.deploymentId}/docs/static-validation.md`;
|
|
125
|
+
const lines = [
|
|
126
|
+
"# Static Validation",
|
|
127
|
+
"",
|
|
128
|
+
`status: ${status}`,
|
|
129
|
+
`completedAt: ${completedAt}`,
|
|
130
|
+
"",
|
|
131
|
+
...evidence.flatMap((entry) => [
|
|
132
|
+
`## ${entry.label}`,
|
|
133
|
+
`command: ${entry.label}`,
|
|
134
|
+
`result: ${entry.result.status === 0 ? "passed" : "failed"}`,
|
|
135
|
+
`exit: ${entry.result.status}`,
|
|
136
|
+
...(entry.result.error ? [`error: ${entry.result.error}`] : []),
|
|
137
|
+
"",
|
|
138
|
+
]),
|
|
139
|
+
];
|
|
140
|
+
writeTextAtomic(path.join(options.root, ...reportPath.split("/")), lines.join("\n"));
|
|
141
|
+
return { status, reportPath };
|
|
142
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export interface ZkSyncForkRunnerIdentity {
|
|
2
|
+
kind: "anvil-zksync";
|
|
3
|
+
version: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export interface ResolvedZkSyncForkCapability {
|
|
7
|
+
runner: ZkSyncForkRunnerIdentity;
|
|
8
|
+
sourceProtocolVersion: number;
|
|
9
|
+
runnerProtocolVersion: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ZkSyncForkRunnerArtifact {
|
|
13
|
+
assetName: string;
|
|
14
|
+
archiveSha256: string;
|
|
15
|
+
binarySha256: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ProtocolInputOverride {
|
|
19
|
+
sourceProtocolVersion: number;
|
|
20
|
+
runnerProtocolVersion: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ZKSYNC_FORK_RUNNER_ARTIFACTS = Object.freeze<Record<string, ZkSyncForkRunnerArtifact>>({
|
|
24
|
+
"darwin/arm64": Object.freeze({
|
|
25
|
+
assetName: "anvil-zksync-v0.6.11-aarch64-apple-darwin.tar.gz",
|
|
26
|
+
archiveSha256: "79c15e079a4e7ac490e4c44572f81b918a81af315eacdd6e3639e66a2be8635c",
|
|
27
|
+
binarySha256: "881fc4d1a0ae43eea01da9e750da782b60e3babacae5f8b327eb0406024fa417",
|
|
28
|
+
}),
|
|
29
|
+
"linux/arm64": Object.freeze({
|
|
30
|
+
assetName: "anvil-zksync-v0.6.11-aarch64-unknown-linux-gnu.tar.gz",
|
|
31
|
+
archiveSha256: "f7d85fd20a41004e4c8662f6748a89ee45e9dc940bbca3a29b2a1634648a7285",
|
|
32
|
+
binarySha256: "565ea5418561937d704c5ef0b2fcea1cb01cd2338e45fdd32ac0516395938216",
|
|
33
|
+
}),
|
|
34
|
+
"darwin/x64": Object.freeze({
|
|
35
|
+
assetName: "anvil-zksync-v0.6.11-x86_64-apple-darwin.tar.gz",
|
|
36
|
+
archiveSha256: "7cff268d2a0a216f8d690d1e37e3f03ca2e45f8cef7657066d8c238efc89a2b4",
|
|
37
|
+
binarySha256: "0c39d3237e9f895633bf7d14d7ead7e08daf9ba7c5845e1b83d8dbe724bb04aa",
|
|
38
|
+
}),
|
|
39
|
+
"linux/x64": Object.freeze({
|
|
40
|
+
assetName: "anvil-zksync-v0.6.11-x86_64-unknown-linux-gnu.tar.gz",
|
|
41
|
+
archiveSha256: "127f1a75b6c4ccc5eaef00ca62753f243a76ba927cbd64a7b1bd99a5b5fb8728",
|
|
42
|
+
binarySha256: "4a801b25f543099838fa88df50f0e59f5e5c93b7a22330948ca7ed029f48228b",
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const ZKSYNC_FORK_RUNNER = Object.freeze({
|
|
47
|
+
kind: "anvil-zksync" as const,
|
|
48
|
+
version: "0.6.11",
|
|
49
|
+
minimumSourceProtocolVersion: 26,
|
|
50
|
+
protocolInputOverrides: Object.freeze<readonly ProtocolInputOverride[]>([
|
|
51
|
+
Object.freeze({ sourceProtocolVersion: 30, runnerProtocolVersion: 29 }),
|
|
52
|
+
]),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const resolveZkSyncForkRunnerArtifact = (
|
|
56
|
+
platform: string = process.platform,
|
|
57
|
+
arch: string = process.arch,
|
|
58
|
+
): ZkSyncForkRunnerArtifact | undefined => ZKSYNC_FORK_RUNNER_ARTIFACTS[`${platform}/${arch}`];
|
|
59
|
+
|
|
60
|
+
export const resolveZkSyncForkCapability = (
|
|
61
|
+
sourceProtocolVersion: number,
|
|
62
|
+
): ResolvedZkSyncForkCapability | undefined => {
|
|
63
|
+
if (
|
|
64
|
+
!Number.isSafeInteger(sourceProtocolVersion)
|
|
65
|
+
|| sourceProtocolVersion < ZKSYNC_FORK_RUNNER.minimumSourceProtocolVersion
|
|
66
|
+
) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const protocolOverride = ZKSYNC_FORK_RUNNER.protocolInputOverrides.find(
|
|
70
|
+
(entry) => entry.sourceProtocolVersion === sourceProtocolVersion,
|
|
71
|
+
);
|
|
72
|
+
return {
|
|
73
|
+
runner: {
|
|
74
|
+
kind: ZKSYNC_FORK_RUNNER.kind,
|
|
75
|
+
version: ZKSYNC_FORK_RUNNER.version,
|
|
76
|
+
},
|
|
77
|
+
sourceProtocolVersion,
|
|
78
|
+
runnerProtocolVersion: protocolOverride?.runnerProtocolVersion ?? sourceProtocolVersion,
|
|
79
|
+
};
|
|
80
|
+
};
|