@cartesi/cli 2.0.0-alpha.1 → 2.0.0-alpha.12
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/dist/base.d.ts +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +99 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +1 -1
- package/dist/builder/docker.d.ts +1 -1
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +8 -8
- package/dist/builder/empty.d.ts +2 -2
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +2 -2
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +2 -2
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +1 -1
- package/dist/commands/address-book.d.ts +4 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +15 -14
- package/dist/commands/build.d.ts +5 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +18 -30
- package/dist/commands/clean.d.ts +2 -7
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -10
- package/dist/commands/create.d.ts +6 -15
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +24 -54
- package/dist/commands/deploy/build.d.ts +2 -14
- package/dist/commands/deploy/build.d.ts.map +1 -1
- package/dist/commands/deploy/build.js +8 -61
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +271 -0
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +90 -91
- package/dist/commands/hash.d.ts +4 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/logs.d.ts +10 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +33 -0
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +9 -190
- package/dist/commands/send/eip712.d.ts +34 -0
- package/dist/commands/send/eip712.d.ts.map +1 -0
- package/dist/commands/send/eip712.js +81 -0
- package/dist/commands/send/erc20.d.ts +11 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +57 -52
- package/dist/commands/send/erc721.d.ts +11 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +51 -46
- package/dist/commands/send/ether.d.ts +11 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +25 -21
- package/dist/commands/send/generic.d.ts +14 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +102 -99
- package/dist/commands/send.d.ts +21 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +67 -0
- package/dist/commands/shell.d.ts +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +22 -44
- package/dist/commands/start.d.ts +14 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +220 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +47 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +27 -0
- package/dist/compose/default.env +35 -0
- package/dist/compose/docker-compose-anvil.yaml +17 -0
- package/dist/compose/docker-compose-bundler.yaml +37 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-espresso.yaml +59 -0
- package/dist/compose/docker-compose-explorer.yaml +57 -0
- package/dist/compose/docker-compose-graphql.yaml +23 -0
- package/dist/compose/docker-compose-node-cpus.yaml +6 -0
- package/dist/compose/docker-compose-node-memory.yaml +6 -0
- package/dist/compose/docker-compose-node.yaml +31 -0
- package/dist/compose/docker-compose-passkey-server.yaml +15 -0
- package/dist/compose/docker-compose-paymaster.yaml +18 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/compose/proxy/anvil.yaml +17 -0
- package/dist/compose/proxy/bundler.yaml +29 -0
- package/dist/compose/proxy/espresso.yaml +17 -0
- package/dist/compose/proxy/explorer-api.yaml +17 -0
- package/dist/compose/proxy/explorer.yaml +10 -0
- package/dist/compose/proxy/graphql.yaml +10 -0
- package/dist/compose/proxy/passkey-server.yaml +17 -0
- package/dist/compose/proxy/paymaster.yaml +17 -0
- package/dist/compose/proxy/rollups-node.yaml +17 -0
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -35
- package/dist/contracts.d.ts +1695 -1636
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +632 -592
- package/dist/exec/cartesi-machine.d.ts +2 -2
- package/dist/exec/cartesi-machine.d.ts.map +1 -1
- package/dist/exec/cartesi-machine.js +1 -1
- package/dist/exec/crane.d.ts +4 -4
- package/dist/exec/crane.d.ts.map +1 -1
- package/dist/exec/crane.js +1 -1
- package/dist/exec/genext2fs.d.ts +2 -2
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +2 -2
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +2 -2
- package/dist/exec/rollups.d.ts +16 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +39 -0
- package/dist/exec/util.d.ts +3 -3
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +8 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -1
- package/dist/machine.d.ts +1 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/prompts.d.ts +3 -3
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/template.d.ts +3 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +16 -0
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +109 -84
- package/package.json +32 -50
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -25
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -8
- package/dist/baseCommand.d.ts +0 -22
- package/dist/baseCommand.d.ts.map +0 -1
- package/dist/baseCommand.js +0 -92
- package/dist/commands/deploy/index.d.ts +0 -12
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/index.js +0 -78
- package/dist/commands/send/index.d.ts +0 -28
- package/dist/commands/send/index.d.ts.map +0 -1
- package/dist/commands/send/index.js +0 -102
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/node/DockerfileDeploy.txt +0 -4
- package/dist/node/default.env +0 -27
- package/dist/node/docker-compose-anvil.yaml +0 -50
- package/dist/node/docker-compose-bundler.yaml +0 -57
- package/dist/node/docker-compose-envfile.yaml +0 -4
- package/dist/node/docker-compose-explorer.yaml +0 -88
- package/dist/node/docker-compose-host.yaml +0 -30
- package/dist/node/docker-compose-paymaster.yaml +0 -33
- package/dist/node/docker-compose-prompt.yaml +0 -17
- package/dist/node/docker-compose-proxy.yaml +0 -48
- package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
- package/dist/node/docker-compose-validator-cpus.yaml +0 -6
- package/dist/node/docker-compose-validator-memory.yaml +0 -6
- package/dist/node/docker-compose-validator.yaml +0 -59
- package/oclif.manifest.json +0 -876
|
@@ -1,62 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
async buildRollupsImage(platform) {
|
|
10
|
-
const buildResult = tmpNameSync();
|
|
11
|
-
const imagePath = this.getContextPath("image");
|
|
12
|
-
const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "..");
|
|
13
|
-
const dockerfile = path.join(binPath, "node", "DockerfileDeploy.txt");
|
|
14
|
-
const args = [
|
|
15
|
-
"buildx",
|
|
16
|
-
"build",
|
|
17
|
-
"-f",
|
|
18
|
-
dockerfile,
|
|
19
|
-
"--load",
|
|
20
|
-
"--iidfile",
|
|
21
|
-
buildResult,
|
|
22
|
-
imagePath,
|
|
23
|
-
];
|
|
24
|
-
// optional platform, default to not defining, which will build for the host platform
|
|
25
|
-
if (platform) {
|
|
26
|
-
args.push("--platform", platform);
|
|
27
|
-
}
|
|
28
|
-
await execa("docker", args, { stdio: "inherit" });
|
|
29
|
-
return fs.readFileSync(buildResult, "utf8");
|
|
30
|
-
}
|
|
31
|
-
async run() {
|
|
32
|
-
const { flags } = await this.parse(DeployBuild);
|
|
33
|
-
// print machine hash
|
|
34
|
-
const templateHash = this.getMachineHash();
|
|
35
|
-
if (!templateHash) {
|
|
36
|
-
this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
|
|
37
|
-
}
|
|
38
|
-
this.logPrompt({
|
|
39
|
-
title: "Cartesi machine templateHash",
|
|
40
|
-
value: templateHash,
|
|
41
|
-
});
|
|
42
|
-
this.log("Building application node Docker image...");
|
|
43
|
-
const image = await this.buildRollupsImage(flags.platform);
|
|
44
|
-
this.logPrompt({
|
|
45
|
-
title: "Application node Docker image",
|
|
46
|
-
value: image,
|
|
47
|
-
});
|
|
48
|
-
return { image };
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
DeployBuild.summary = "Build deployment Docker image of application.";
|
|
52
|
-
DeployBuild.description = "Package the application in a Docker image ready to be deployed.";
|
|
53
|
-
DeployBuild.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
54
|
-
DeployBuild.flags = {
|
|
55
|
-
platform: Flags.string({
|
|
56
|
-
options: ["linux/amd64", "linux/arm64"],
|
|
57
|
-
summary: "Docker image target platform",
|
|
58
|
-
description: "Select the target platform for the produced Docker image. It depends on the platform where the application node will be deployed.",
|
|
59
|
-
}),
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export const createBuildCommand = () => {
|
|
4
|
+
return new Command("build")
|
|
5
|
+
.description("DEPRECATED: Package the application in a Docker image ready to be deployed.")
|
|
6
|
+
.action(async () => {
|
|
7
|
+
console.warn(chalk.yellow("deploy build command is deprecated"));
|
|
8
|
+
});
|
|
60
9
|
};
|
|
61
|
-
DeployBuild.enableJsonFlag = true;
|
|
62
|
-
export default DeployBuild;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createDeployCommand: () => Command<[], {
|
|
3
|
+
environmentName: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
rpcUrl?: string | undefined;
|
|
6
|
+
mnemonic?: string | undefined;
|
|
7
|
+
mnemonicIndex: number;
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
authorityOwner?: `0x${string}` | undefined;
|
|
10
|
+
applicationOwner?: `0x${string}` | undefined;
|
|
11
|
+
epochLength: number;
|
|
12
|
+
salt: `0x${string}`;
|
|
13
|
+
json?: true | undefined;
|
|
14
|
+
dataAvailability: "input-box" | "espresso";
|
|
15
|
+
espressoBlock: number;
|
|
16
|
+
espressoNamespace: number;
|
|
17
|
+
}, {}>;
|
|
18
|
+
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAyQ9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;MAuJ/B,CAAC"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import input from "@inquirer/input";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { execa } from "execa";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import { encodeFunctionData, zeroHash } from "viem";
|
|
7
|
+
import { cannon } from "viem/chains";
|
|
8
|
+
import { getContextPath, getMachineHash, parseAddress, parseHash, } from "../base.js";
|
|
9
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
|
|
10
|
+
import { applicationFactoryAbi, applicationFactoryAddress, authorityFactoryAbi, authorityFactoryAddress, dataAvailabilityAbi, inputBoxAddress, } from "../contracts.js";
|
|
11
|
+
import { addressInput } from "../prompts.js";
|
|
12
|
+
import { connect } from "./send.js";
|
|
13
|
+
/**
|
|
14
|
+
* Deploy authority contract (if not already deployed)
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns address of the authority
|
|
17
|
+
*/
|
|
18
|
+
const deployAuthority = async (publicClient, walletClient, options) => {
|
|
19
|
+
const { epochLength, progress, salt } = options;
|
|
20
|
+
// deploy authority contract (if not already deployed)
|
|
21
|
+
const authorityOwner = options.authorityOwner ||
|
|
22
|
+
(await addressInput({
|
|
23
|
+
message: "Authority Owner",
|
|
24
|
+
default: walletClient.account?.address,
|
|
25
|
+
}));
|
|
26
|
+
const authorityAddress = await publicClient.readContract({
|
|
27
|
+
abi: authorityFactoryAbi,
|
|
28
|
+
address: authorityFactoryAddress,
|
|
29
|
+
functionName: "calculateAuthorityAddress",
|
|
30
|
+
args: [authorityOwner, BigInt(epochLength), salt],
|
|
31
|
+
});
|
|
32
|
+
// check if authority is already deployed
|
|
33
|
+
const authorityCode = await publicClient.getCode({
|
|
34
|
+
address: authorityAddress,
|
|
35
|
+
});
|
|
36
|
+
if (authorityCode === undefined) {
|
|
37
|
+
// deploy authority
|
|
38
|
+
const { request } = await publicClient.simulateContract({
|
|
39
|
+
abi: authorityFactoryAbi,
|
|
40
|
+
address: authorityFactoryAddress,
|
|
41
|
+
account: walletClient.account,
|
|
42
|
+
functionName: "newAuthority",
|
|
43
|
+
args: [authorityOwner, BigInt(epochLength), salt],
|
|
44
|
+
});
|
|
45
|
+
progress.start("Deploying authority...");
|
|
46
|
+
const hash = await walletClient.writeContract(request);
|
|
47
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
48
|
+
progress.succeed(`Authority ${chalk.cyan(authorityAddress)}`);
|
|
49
|
+
}
|
|
50
|
+
return authorityAddress;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Deploy application contract
|
|
54
|
+
* @param options
|
|
55
|
+
* @returns address of the application
|
|
56
|
+
*/
|
|
57
|
+
const deployApplication = async (publicClient, walletClient, options) => {
|
|
58
|
+
const { authorityAddress, progress, salt, templateHash, dataAvailability } = options;
|
|
59
|
+
const applicationOwner = options.applicationOwner ||
|
|
60
|
+
(await addressInput({
|
|
61
|
+
message: "Application Owner",
|
|
62
|
+
default: walletClient.account?.address,
|
|
63
|
+
}));
|
|
64
|
+
const applicationAddress = await publicClient.readContract({
|
|
65
|
+
abi: applicationFactoryAbi,
|
|
66
|
+
address: applicationFactoryAddress,
|
|
67
|
+
functionName: "calculateApplicationAddress",
|
|
68
|
+
args: [
|
|
69
|
+
authorityAddress,
|
|
70
|
+
applicationOwner,
|
|
71
|
+
templateHash,
|
|
72
|
+
dataAvailability,
|
|
73
|
+
salt,
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
// check if application is already deployed
|
|
77
|
+
const applicationCode = await publicClient.getCode({
|
|
78
|
+
address: applicationAddress,
|
|
79
|
+
});
|
|
80
|
+
if (applicationCode === undefined) {
|
|
81
|
+
// deploy application
|
|
82
|
+
const { request } = await publicClient.simulateContract({
|
|
83
|
+
abi: applicationFactoryAbi,
|
|
84
|
+
address: applicationFactoryAddress,
|
|
85
|
+
account: walletClient.account,
|
|
86
|
+
functionName: "newApplication",
|
|
87
|
+
args: [
|
|
88
|
+
authorityAddress,
|
|
89
|
+
applicationOwner,
|
|
90
|
+
templateHash,
|
|
91
|
+
dataAvailability,
|
|
92
|
+
salt,
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
progress.start("Deploying application...");
|
|
96
|
+
const hash = await walletClient.writeContract(request);
|
|
97
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
98
|
+
progress.succeed(`Application ${chalk.cyan(applicationAddress)}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// abort, because application is already deployed
|
|
102
|
+
throw new Error(`Application ${chalk.cyan(templateHash)} already deployed to ${chalk.cyan(applicationAddress)}`);
|
|
103
|
+
}
|
|
104
|
+
return applicationAddress;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Publish machine snapshot to rollups node by copying it to the rollups node container
|
|
108
|
+
* @param options
|
|
109
|
+
* @returns path to the snapshot in the rollups node
|
|
110
|
+
*/
|
|
111
|
+
const publishMachine = async (options) => {
|
|
112
|
+
const { progress, environmentName, templateHash } = options;
|
|
113
|
+
const snapshotPath = getContextPath("image");
|
|
114
|
+
const containerSnapshotPath = `/var/lib/cartesi-rollups-node/snapshots/${templateHash}/`;
|
|
115
|
+
progress.start("Publishing machine snapshot...");
|
|
116
|
+
await execa("docker", [
|
|
117
|
+
"compose",
|
|
118
|
+
"--project-name",
|
|
119
|
+
environmentName,
|
|
120
|
+
"cp",
|
|
121
|
+
snapshotPath,
|
|
122
|
+
`rollups-node:${containerSnapshotPath}`,
|
|
123
|
+
]);
|
|
124
|
+
progress.succeed(`Machine snapshot ${chalk.cyan(containerSnapshotPath)}`);
|
|
125
|
+
return containerSnapshotPath;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Register application in rollups node
|
|
129
|
+
* @param options
|
|
130
|
+
* @returns name of the application
|
|
131
|
+
*/
|
|
132
|
+
const registerApplication = async (options) => {
|
|
133
|
+
const { applicationAddress, progress, environmentName, snapshotPath, dataAvailability, } = options;
|
|
134
|
+
// use application address as the name of the deployment
|
|
135
|
+
const name = options.name ??
|
|
136
|
+
(await input({
|
|
137
|
+
message: "Application Name",
|
|
138
|
+
default: applicationAddress.toLowerCase(),
|
|
139
|
+
}));
|
|
140
|
+
// common app register args
|
|
141
|
+
const registerArgs = [
|
|
142
|
+
"--name",
|
|
143
|
+
name,
|
|
144
|
+
"--address",
|
|
145
|
+
applicationAddress,
|
|
146
|
+
"--template-path",
|
|
147
|
+
snapshotPath,
|
|
148
|
+
"--data-availability",
|
|
149
|
+
dataAvailability,
|
|
150
|
+
"--print-json",
|
|
151
|
+
];
|
|
152
|
+
// deploy application
|
|
153
|
+
progress.start("Registering application...");
|
|
154
|
+
const { stdout } = await execa("docker", [
|
|
155
|
+
"compose",
|
|
156
|
+
"--project-name",
|
|
157
|
+
environmentName,
|
|
158
|
+
"exec",
|
|
159
|
+
"rollups-node",
|
|
160
|
+
"cartesi-rollups-cli",
|
|
161
|
+
"app",
|
|
162
|
+
"register",
|
|
163
|
+
...registerArgs,
|
|
164
|
+
]);
|
|
165
|
+
const registration = stdout ? JSON.parse(stdout) : undefined;
|
|
166
|
+
if (registration) {
|
|
167
|
+
if (registration.state !== "ENABLED") {
|
|
168
|
+
throw new Error(registration.reason);
|
|
169
|
+
}
|
|
170
|
+
progress.succeed(`Registration ${chalk.cyan(name)}`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error("Failed to deploy application");
|
|
174
|
+
}
|
|
175
|
+
return name;
|
|
176
|
+
};
|
|
177
|
+
const parseDataAvailability = (type, espressoBlock, espressoNamespace) => {
|
|
178
|
+
if (type === "espresso") {
|
|
179
|
+
return encodeFunctionData({
|
|
180
|
+
abi: dataAvailabilityAbi,
|
|
181
|
+
functionName: "InputBoxAndEspresso",
|
|
182
|
+
args: [inputBoxAddress, BigInt(espressoBlock), espressoNamespace],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return encodeFunctionData({
|
|
186
|
+
abi: dataAvailabilityAbi,
|
|
187
|
+
functionName: "InputBox",
|
|
188
|
+
args: [inputBoxAddress],
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
export const createDeployCommand = () => {
|
|
192
|
+
return new Command("deploy")
|
|
193
|
+
.description("Deploy a rollups application to a rollups node.")
|
|
194
|
+
.configureHelp({ showGlobalOptions: true })
|
|
195
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
196
|
+
.option("--chain-id <id>", "Chain ID", Number.parseInt, 13370)
|
|
197
|
+
.option("--rpc-url <url>", "RPC URL")
|
|
198
|
+
.option("--mnemonic <phrase>", "Mnemonic passphrase")
|
|
199
|
+
.option("--mnemonic-index <index>", "Mnemonic account index", Number.parseInt, 0)
|
|
200
|
+
.option("--name <string>", "application name")
|
|
201
|
+
.option("--authority-owner <address>", "authority owner", parseAddress, undefined)
|
|
202
|
+
.option("--application-owner <address>", "application owner", parseAddress, undefined)
|
|
203
|
+
.addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
|
|
204
|
+
.argParser(Number)
|
|
205
|
+
.default(720))
|
|
206
|
+
.option("--salt <hash>", "salt for deployment", parseHash, zeroHash)
|
|
207
|
+
.option("--json", "output in JSON format")
|
|
208
|
+
.addOption(new Option("--data-availability <type>", "Data availability layer to use (input-box or espresso)")
|
|
209
|
+
.choices(["input-box", "espresso"])
|
|
210
|
+
.default("input-box"))
|
|
211
|
+
.addOption(new Option("--espresso-block <number>", "espresso starting block")
|
|
212
|
+
.argParser(Number)
|
|
213
|
+
.default(1))
|
|
214
|
+
.addOption(new Option("--espresso-namespace <number>", "espresso namespace Id")
|
|
215
|
+
.argParser(Number)
|
|
216
|
+
.default(1))
|
|
217
|
+
.action(async (options, command) => {
|
|
218
|
+
const { json, dataAvailability: daType, environmentName, espressoBlock, espressoNamespace, } = options;
|
|
219
|
+
// If inputbox is chosen, warn if espresso args are provided
|
|
220
|
+
if (daType === "input-box" &&
|
|
221
|
+
(espressoBlock !== undefined || espressoNamespace !== undefined)) {
|
|
222
|
+
console.warn(chalk.yellow("WARNING: --espresso-block and --espresso-namespace-id are ignored when --data-availability is input-box"));
|
|
223
|
+
}
|
|
224
|
+
const progress = ora();
|
|
225
|
+
// get cartesi machine snapshot hash, produced by 'build'
|
|
226
|
+
const templateHash = getMachineHash();
|
|
227
|
+
if (!templateHash) {
|
|
228
|
+
progress.fail(`Cartesi machine snapshot not found, run 'build'`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
progress.succeed(`Cartesi machine template hash ${chalk.cyan(templateHash)}`);
|
|
232
|
+
// connect to some chain
|
|
233
|
+
const { publicClient, walletClient } = await connect(options);
|
|
234
|
+
try {
|
|
235
|
+
// parse dataAvailability
|
|
236
|
+
const dataAvailability = parseDataAvailability(daType, espressoBlock, espressoNamespace);
|
|
237
|
+
// deploy authority contract (if not already deployed)
|
|
238
|
+
const authorityAddress = await deployAuthority(publicClient, walletClient, { progress, ...options });
|
|
239
|
+
// deploy application contract
|
|
240
|
+
const applicationAddress = await deployApplication(publicClient, walletClient, {
|
|
241
|
+
authorityAddress,
|
|
242
|
+
progress,
|
|
243
|
+
templateHash,
|
|
244
|
+
...options,
|
|
245
|
+
dataAvailability,
|
|
246
|
+
});
|
|
247
|
+
if (publicClient.chain?.id === cannon.id) {
|
|
248
|
+
// copy machine snapshot to rollups node container
|
|
249
|
+
const containerSnapshotPath = await publishMachine({
|
|
250
|
+
progress,
|
|
251
|
+
templateHash,
|
|
252
|
+
environmentName,
|
|
253
|
+
});
|
|
254
|
+
const name = await registerApplication({
|
|
255
|
+
applicationAddress,
|
|
256
|
+
progress,
|
|
257
|
+
snapshotPath: containerSnapshotPath,
|
|
258
|
+
...options,
|
|
259
|
+
dataAvailability,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const snapshotPath = getContextPath("image");
|
|
264
|
+
progress.succeed(`Done. Manually copy machine to rollups node ${chalk.cyan(snapshotPath)}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
progress.fail(e instanceof Error ? e.message : "Unknown error");
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
};
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
private static MINIMUM_DOCKER_VERSION;
|
|
6
|
-
private static MINIMUM_DOCKER_COMPOSE_VERSION;
|
|
7
|
-
private static MINIMUM_BUILDX_VERSION;
|
|
8
|
-
private checkDocker;
|
|
9
|
-
private checkCompose;
|
|
10
|
-
private checkBuildx;
|
|
11
|
-
run(): Promise<void>;
|
|
12
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createDoctorCommand: () => Command<[], {}, {}>;
|
|
13
3
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAyHtD,eAAO,MAAM,mBAAmB,2BAa/B,CAAC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,106 +1,105 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
1
3
|
import { execa } from "execa";
|
|
4
|
+
import ora from "ora";
|
|
2
5
|
import semver from "semver";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
6
|
+
const MINIMUM_DOCKER_VERSION = "23.0.0"; // Replace with our minimum required Docker version
|
|
7
|
+
const MINIMUM_DOCKER_COMPOSE_VERSION = "2.21.0"; // Replace with our minimum required Docker Compose version
|
|
8
|
+
const MINIMUM_BUILDX_VERSION = "0.13.0"; // Replace with our minimum required Buildx version
|
|
9
|
+
const checkDocker = async (progress) => {
|
|
10
|
+
try {
|
|
11
|
+
progress.start("Checking Docker Engine version...");
|
|
12
|
+
const { stdout: dockerVersion } = await execa("docker", [
|
|
13
|
+
"version",
|
|
14
|
+
"--format",
|
|
15
|
+
"{{json .Client.Version}}",
|
|
16
|
+
]);
|
|
17
|
+
const v = semver.coerce(dockerVersion);
|
|
18
|
+
if (v !== null && !semver.gte(v, MINIMUM_DOCKER_VERSION)) {
|
|
19
|
+
throw new Error(`Unsupported Docker version. Minimum required version is ${MINIMUM_DOCKER_VERSION}. Installed version is ${v}.`);
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw e;
|
|
25
|
-
}
|
|
21
|
+
progress.succeed(`Docker Engine ${chalk.cyan(v)}`);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (e instanceof Error &&
|
|
25
|
+
e.code === "ENOENT") {
|
|
26
|
+
throw new Error("Docker not found");
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
throw e;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
return true;
|
|
31
|
+
};
|
|
32
|
+
const checkCompose = async (progress) => {
|
|
33
|
+
try {
|
|
34
|
+
progress.start("Checking Docker Compose version...");
|
|
35
|
+
const { stdout: dockerComposeVersion } = await execa("docker", [
|
|
36
|
+
"compose",
|
|
37
|
+
"version",
|
|
38
|
+
"--short",
|
|
39
|
+
]);
|
|
40
|
+
const v = semver.coerce(dockerComposeVersion);
|
|
41
|
+
if (v !== null && !semver.gte(v, MINIMUM_DOCKER_COMPOSE_VERSION)) {
|
|
42
|
+
throw new Error(`Unsupported Docker Compose version. Minimum required version is ${MINIMUM_DOCKER_COMPOSE_VERSION}. Installed version is ${v}.`);
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
throw e;
|
|
49
|
-
}
|
|
44
|
+
progress.succeed(`Docker Compose ${chalk.cyan(dockerComposeVersion)}`);
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
if (e instanceof Error &&
|
|
48
|
+
e.exitCode === 125) {
|
|
49
|
+
throw new Error("Docker Compose is required but not installed or the command execution failed. Please refer to the Docker Compose documentation for installation instructions: https://docs.docker.com/compose/install/");
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
throw e;
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"buildx",
|
|
66
|
-
"ls",
|
|
67
|
-
"--format",
|
|
68
|
-
"{{.Platforms}}",
|
|
69
|
-
]);
|
|
70
|
-
const buildxPlatforms = platformsOutput
|
|
71
|
-
.split(",")
|
|
72
|
-
.map((platform) => platform.trim());
|
|
73
|
-
if (!buildxPlatforms.includes("linux/riscv64")) {
|
|
74
|
-
throw new Error("Your system does not support riscv64 architecture. Run `docker run --privileged --rm tonistiigi/binfmt:riscv` to enable riscv64 support.");
|
|
75
|
-
}
|
|
53
|
+
return true;
|
|
54
|
+
};
|
|
55
|
+
const checkBuildx = async (progress) => {
|
|
56
|
+
try {
|
|
57
|
+
progress.start("Checking Docker Buildx version...");
|
|
58
|
+
const { stdout: buildxOutput } = await execa("docker", [
|
|
59
|
+
"buildx",
|
|
60
|
+
"version",
|
|
61
|
+
]);
|
|
62
|
+
const v = semver.coerce(buildxOutput);
|
|
63
|
+
if (v !== null && !semver.gte(v, MINIMUM_BUILDX_VERSION)) {
|
|
64
|
+
throw new Error(`Unsupported Docker Buildx version. Minimum required version is ${MINIMUM_BUILDX_VERSION}. Installed version is ${v}.`);
|
|
76
65
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
progress.succeed(`Docker Buildx ${chalk.cyan(v)}`);
|
|
67
|
+
progress.start("Checking Docker RISC-V support...");
|
|
68
|
+
const { stdout: platformsOutput } = await execa("docker", [
|
|
69
|
+
"buildx",
|
|
70
|
+
"ls",
|
|
71
|
+
"--format",
|
|
72
|
+
"{{.Platforms}}",
|
|
73
|
+
]);
|
|
74
|
+
const buildxPlatforms = platformsOutput
|
|
75
|
+
.split(",")
|
|
76
|
+
.map((platform) => platform.trim());
|
|
77
|
+
if (!buildxPlatforms.includes("linux/riscv64")) {
|
|
78
|
+
throw new Error("Your system does not support riscv64 architecture. Run `docker run --privileged --rm tonistiigi/binfmt:riscv` to enable riscv64 support.");
|
|
85
79
|
}
|
|
86
|
-
|
|
80
|
+
progress.succeed(`Docker RISC-V support ${chalk.cyan("linux/riscv64")}`);
|
|
87
81
|
}
|
|
88
|
-
|
|
82
|
+
catch (e) {
|
|
83
|
+
if (e instanceof Error &&
|
|
84
|
+
e.exitCode === 125) {
|
|
85
|
+
throw new Error("Docker Buildx is required but not installed. Please refer to the Docker Desktop documentation for installation instructions: https://docs.docker.com/desktop/");
|
|
86
|
+
}
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
};
|
|
91
|
+
export const createDoctorCommand = () => {
|
|
92
|
+
return new Command("doctor").action(async () => {
|
|
93
|
+
const progress = ora();
|
|
89
94
|
try {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
95
|
+
await checkDocker(progress);
|
|
96
|
+
await checkCompose(progress);
|
|
97
|
+
await checkBuildx(progress);
|
|
98
|
+
progress.succeed("Your system is ready.");
|
|
94
99
|
}
|
|
95
100
|
catch (e) {
|
|
96
|
-
|
|
101
|
+
progress.fail(e.message);
|
|
102
|
+
process.exit(1);
|
|
97
103
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
DoctorCommand.description = "Verify the minimal sytem requirements";
|
|
102
|
-
DoctorCommand.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
103
|
-
DoctorCommand.MINIMUM_DOCKER_VERSION = "23.0.0"; // Replace with our minimum required Docker version
|
|
104
|
-
DoctorCommand.MINIMUM_DOCKER_COMPOSE_VERSION = "2.21.0"; // Replace with our minimum required Docker Compose version
|
|
105
|
-
DoctorCommand.MINIMUM_BUILDX_VERSION = "0.13.0"; // Replace with our minimum required Buildx version
|
|
106
|
-
export default DoctorCommand;
|
|
104
|
+
});
|
|
105
|
+
};
|
package/dist/commands/hash.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static enableJsonFlag: boolean;
|
|
6
|
-
run(): Promise<{
|
|
7
|
-
hash: `0x${string}`;
|
|
8
|
-
} | undefined>;
|
|
9
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createHashCommand: () => Command<[], {
|
|
3
|
+
json?: true | undefined;
|
|
4
|
+
}, {}>;
|
|
10
5
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/commands/hash.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/commands/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,iBAAiB;;MAsB7B,CAAC"}
|
package/dist/commands/hash.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import chalk from "chalk";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { getMachineHash } from "../base.js";
|
|
4
|
+
export const createHashCommand = () => {
|
|
5
|
+
return new Command("hash")
|
|
6
|
+
.description("Converts the binary generated by the build command to hexadecimal and prints out the result to console.")
|
|
7
|
+
.option("--json", "Format output as json.")
|
|
8
|
+
.action(async ({ json }, command) => {
|
|
9
|
+
const hash = getMachineHash();
|
|
6
10
|
if (hash) {
|
|
7
|
-
if (!
|
|
8
|
-
|
|
11
|
+
if (!json) {
|
|
12
|
+
console.log(`${chalk.green("?")} Cartesi machine templateHash ${chalk.cyan(hash)}\n`);
|
|
9
13
|
}
|
|
10
14
|
else {
|
|
11
|
-
|
|
15
|
+
process.stdout.write(JSON.stringify({ hash }));
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
|
-
|
|
19
|
+
command.error(`Cartesi machine snapshot not found, run 'build'`);
|
|
16
20
|
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
HashCommand.summary = "Prints out image hash generated by the build command";
|
|
20
|
-
HashCommand.description = "Converts the binary generated by the build command to hexadecimal and prints out the result to console";
|
|
21
|
-
HashCommand.enableJsonFlag = true;
|
|
22
|
-
export default HashCommand;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createLogsCommand: () => Command<[], {
|
|
3
|
+
environmentName: string;
|
|
4
|
+
follow?: true | undefined;
|
|
5
|
+
color: boolean;
|
|
6
|
+
since?: string | undefined;
|
|
7
|
+
tail: string;
|
|
8
|
+
until?: string | undefined;
|
|
9
|
+
}, {}>;
|
|
10
|
+
//# sourceMappingURL=logs.d.ts.map
|