@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
package/dist/commands/shell.js
CHANGED
|
@@ -1,65 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import {
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { getApplicationConfig, getContextPath } from "../base.js";
|
|
5
5
|
import { bootMachine } from "../machine.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const createShellCommand = () => {
|
|
7
|
+
return new Command("shell")
|
|
8
|
+
.argument("[image]", "image ID|name")
|
|
9
|
+
.option("--command <command>", "shell command to run", "/bin/sh")
|
|
10
|
+
.option("-c, --config <config>", "path to the configuration file", "cartesi.toml")
|
|
11
|
+
.option("--run-as-root", "run as root user", false)
|
|
12
|
+
.action(async (image, { command, config, runAsRoot }) => {
|
|
9
13
|
// get application configuration from 'cartesi.toml'
|
|
10
|
-
const
|
|
14
|
+
const c = getApplicationConfig(config);
|
|
11
15
|
// destination directory for image and intermediate files
|
|
12
|
-
const destination = path.resolve(
|
|
16
|
+
const destination = path.resolve(getContextPath());
|
|
13
17
|
// check if all drives are built
|
|
14
|
-
for (const [name, drive] of Object.entries(
|
|
18
|
+
for (const [name, drive] of Object.entries(c.drives)) {
|
|
15
19
|
const filename = `${name}.${drive.format}`;
|
|
16
|
-
const pathname =
|
|
20
|
+
const pathname = getContextPath(filename);
|
|
17
21
|
if (!fs.existsSync(pathname)) {
|
|
18
|
-
throw new Error(`drive '${name}' not built, run '
|
|
22
|
+
throw new Error(`drive '${name}' not built, run 'build'`);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
// create shell entrypoint
|
|
22
26
|
const info = {
|
|
23
27
|
cmd: [],
|
|
24
|
-
entrypoint: [
|
|
28
|
+
entrypoint: [command],
|
|
25
29
|
env: [],
|
|
26
30
|
workdir: "/",
|
|
27
31
|
};
|
|
28
32
|
// start with interactive mode on
|
|
29
|
-
|
|
33
|
+
c.machine.interactive = true;
|
|
30
34
|
// interactive mode can't have final hash
|
|
31
|
-
|
|
35
|
+
c.machine.finalHash = false;
|
|
32
36
|
// do not store machine in interactive mode
|
|
33
|
-
|
|
37
|
+
c.machine.store = undefined;
|
|
34
38
|
// run as root if flag is set
|
|
35
|
-
|
|
39
|
+
c.machine.user = runAsRoot ? "root" : undefined;
|
|
36
40
|
// boot machine
|
|
37
|
-
await bootMachine(
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
Shell.description = "Start a shell in cartesi machine of application";
|
|
41
|
-
Shell.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
42
|
-
Shell.args = {
|
|
43
|
-
image: Args.string({
|
|
44
|
-
description: "image ID|name",
|
|
45
|
-
required: false,
|
|
46
|
-
}),
|
|
41
|
+
await bootMachine(c, info, destination);
|
|
42
|
+
});
|
|
47
43
|
};
|
|
48
|
-
Shell.flags = {
|
|
49
|
-
command: Flags.string({
|
|
50
|
-
default: "/bin/sh",
|
|
51
|
-
description: "shell command to run",
|
|
52
|
-
summary: "shell to run",
|
|
53
|
-
}),
|
|
54
|
-
config: Flags.file({
|
|
55
|
-
char: "c",
|
|
56
|
-
default: "cartesi.toml",
|
|
57
|
-
summary: "path to the configuration file",
|
|
58
|
-
}),
|
|
59
|
-
"run-as-root": Flags.boolean({
|
|
60
|
-
default: false,
|
|
61
|
-
description: "run as root user",
|
|
62
|
-
summary: "run the cartesi machine as the root user",
|
|
63
|
-
}),
|
|
64
|
-
};
|
|
65
|
-
export default Shell;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createStartCommand: () => Command<[], {
|
|
3
|
+
runtimeVersion: string;
|
|
4
|
+
environmentName: string;
|
|
5
|
+
blockTime: number;
|
|
6
|
+
defaultBlock: "latest" | "pending" | "safe" | "finalized";
|
|
7
|
+
cpus?: number | undefined;
|
|
8
|
+
memory?: number | undefined;
|
|
9
|
+
services: string[];
|
|
10
|
+
port: number;
|
|
11
|
+
dryRun: boolean;
|
|
12
|
+
verbose: boolean;
|
|
13
|
+
}, {}>;
|
|
14
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAwJ9D,eAAO,MAAM,kBAAkB;;;;;;;;;;;MA8K9B,CAAC"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import pRetry from "p-retry";
|
|
7
|
+
import { getServiceHealth } from "../base.js";
|
|
8
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME, DEFAULT_SDK_IMAGE, DEFAULT_SDK_VERSION, } from "../config.js";
|
|
9
|
+
const commaSeparatedList = (value) => value.split(",");
|
|
10
|
+
const host = "http://127.0.0.1";
|
|
11
|
+
// services configuration
|
|
12
|
+
const baseServices = [
|
|
13
|
+
{
|
|
14
|
+
name: "anvil",
|
|
15
|
+
file: "docker-compose-anvil.yaml",
|
|
16
|
+
healthySemaphore: "anvil",
|
|
17
|
+
healthyTitle: (port) => `${chalk.cyan("anvil")} service ready at ${chalk.cyan(`${host}:${port}/anvil`)}`,
|
|
18
|
+
waitTitle: `${chalk.cyan("anvil")} service starting...`,
|
|
19
|
+
errorTitle: `${chalk.red("anvil")} service failed`,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "proxy",
|
|
23
|
+
file: "docker-compose-proxy.yaml",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "database",
|
|
27
|
+
file: "docker-compose-database.yaml",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "rpc",
|
|
31
|
+
file: "docker-compose-node.yaml",
|
|
32
|
+
healthySemaphore: "rollups-node",
|
|
33
|
+
healthyTitle: (port) => `${chalk.cyan("rpc")} service ready at ${chalk.cyan(`${host}:${port}/rpc`)}`,
|
|
34
|
+
waitTitle: `${chalk.cyan("rpc")} service starting...`,
|
|
35
|
+
errorTitle: `${chalk.red("rpc")} service failed`,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "inspect",
|
|
39
|
+
file: "docker-compose-node.yaml",
|
|
40
|
+
healthySemaphore: "rollups-node",
|
|
41
|
+
healthyTitle: (port) => `${chalk.cyan("inspect")} service ready at ${chalk.cyan(`${host}:${port}/inspect/<application_address>`)}`,
|
|
42
|
+
waitTitle: `${chalk.cyan("inspect")} service starting...`,
|
|
43
|
+
errorTitle: `${chalk.red("inspect")} service failed`,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
const availableServices = [
|
|
47
|
+
{
|
|
48
|
+
name: "bundler",
|
|
49
|
+
file: "docker-compose-bundler.yaml",
|
|
50
|
+
healthySemaphore: "bundler",
|
|
51
|
+
healthyTitle: (port) => `${chalk.cyan("bundler")} service ready at ${chalk.cyan(`${host}:${port}/bundler/rpc`)}`,
|
|
52
|
+
waitTitle: `${chalk.cyan("bundler")} service starting...`,
|
|
53
|
+
errorTitle: `${chalk.red("bundler")} service failed`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "espresso",
|
|
57
|
+
file: "docker-compose-espresso.yaml",
|
|
58
|
+
healthySemaphore: "espresso",
|
|
59
|
+
healthyTitle: (port) => `${chalk.cyan("espresso")} service ready at ${chalk.cyan(`${host}:${port}/transaction`)}`,
|
|
60
|
+
waitTitle: `${chalk.cyan("espresso")} service starting...`,
|
|
61
|
+
errorTitle: `${chalk.red("espresso")} service failed`,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "explorer",
|
|
65
|
+
file: "docker-compose-explorer.yaml",
|
|
66
|
+
healthySemaphore: "explorer_api",
|
|
67
|
+
healthyTitle: (port) => `${chalk.cyan("explorer")} service ready at ${chalk.cyan(`${host}:${port}/explorer`)}`,
|
|
68
|
+
waitTitle: `${chalk.cyan("explorer")} service starting...`,
|
|
69
|
+
errorTitle: `${chalk.red("explorer")} service failed`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "graphql",
|
|
73
|
+
file: "docker-compose-graphql.yaml",
|
|
74
|
+
healthySemaphore: "graphql",
|
|
75
|
+
healthyTitle: (port) => `${chalk.cyan("graphql")} service ready at ${chalk.cyan(`${host}:${port}/graphql`)}`,
|
|
76
|
+
waitTitle: `${chalk.cyan("graphql")} service starting...`,
|
|
77
|
+
errorTitle: `${chalk.red("graphql")} service failed`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "paymaster",
|
|
81
|
+
file: "docker-compose-paymaster.yaml",
|
|
82
|
+
healthySemaphore: "paymaster",
|
|
83
|
+
healthyTitle: (port) => `${chalk.cyan("paymaster")} service ready at ${chalk.cyan(`${host}:${port}/paymaster`)}`,
|
|
84
|
+
waitTitle: `${chalk.cyan("paymaster")} service starting...`,
|
|
85
|
+
errorTitle: `${chalk.red("paymaster")} service failed`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "passkey",
|
|
89
|
+
file: "docker-compose-passkey-server.yaml",
|
|
90
|
+
healthySemaphore: "passkey-server",
|
|
91
|
+
healthyTitle: (port) => `${chalk.cyan("passkey")} service ready at ${chalk.cyan(`${host}:${port}/passkey`)}`,
|
|
92
|
+
waitTitle: `${chalk.cyan("passkey")} service starting...`,
|
|
93
|
+
errorTitle: `${chalk.red("passkey")} service failed`,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const serviceMonitorTask = (options) => {
|
|
97
|
+
const { errorTitle, healthyTitle, service, waitTitle } = options;
|
|
98
|
+
return {
|
|
99
|
+
task: async (_ctx, task) => {
|
|
100
|
+
await pRetry(async () => {
|
|
101
|
+
const health = await getServiceHealth(options);
|
|
102
|
+
if (health !== "healthy") {
|
|
103
|
+
throw new Error(errorTitle ??
|
|
104
|
+
`Service ${chalk.cyan(service)} is not healthy`);
|
|
105
|
+
}
|
|
106
|
+
}, { retries: 100, minTimeout: 500, factor: 1.1 });
|
|
107
|
+
task.title =
|
|
108
|
+
healthyTitle ?? `Service ${chalk.cyan(service)} is ready`;
|
|
109
|
+
},
|
|
110
|
+
title: waitTitle ?? `Starting ${chalk.cyan(service)}...`,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export const createStartCommand = () => {
|
|
114
|
+
return new Command("start")
|
|
115
|
+
.description("Start a local environment.")
|
|
116
|
+
.configureHelp({ showGlobalOptions: true })
|
|
117
|
+
.addOption(new Option("--runtime-version <version>", "version for Cartesi Rollups Runtime to use")
|
|
118
|
+
.default(DEFAULT_SDK_VERSION)
|
|
119
|
+
.hideHelp())
|
|
120
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
121
|
+
.addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
|
|
122
|
+
.argParser(Number)
|
|
123
|
+
.default(5))
|
|
124
|
+
.addOption(new Option("--default-block <string>", "default block to be used when fetching new blocks.")
|
|
125
|
+
.choices(["latest", "safe", "pending", "finalized"])
|
|
126
|
+
.default("latest"))
|
|
127
|
+
.addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
|
|
128
|
+
.addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
|
|
129
|
+
.option("--services <string>", `optional services to start, comma separated list from [${availableServices.map(({ name }) => name).join(", ")}]`, commaSeparatedList, [])
|
|
130
|
+
.option("-p, --port <number>", "port to listen on", Number, 8080)
|
|
131
|
+
.option("--dry-run", "show the docker compose configuration", false)
|
|
132
|
+
.option("-v, --verbose", "verbose output", false)
|
|
133
|
+
.action(async (options, command) => {
|
|
134
|
+
const { blockTime, cpus, defaultBlock, dryRun, environmentName, memory, port, services, verbose, runtimeVersion, } = options;
|
|
135
|
+
// path of the tool instalation
|
|
136
|
+
const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
|
|
137
|
+
// setup the environment variable used in docker compose
|
|
138
|
+
const env = {
|
|
139
|
+
BLOCK_TIME: blockTime.toString(),
|
|
140
|
+
CARTESI_BLOCKCHAIN_DEFAULT_BLOCK: defaultBlock,
|
|
141
|
+
CARTESI_LOG_LEVEL: verbose ? "debug" : "info",
|
|
142
|
+
CARTESI_BIN_PATH: binPath,
|
|
143
|
+
CARTESI_LISTEN_PORT: port.toString(),
|
|
144
|
+
CARTESI_ROLLUPS_NODE_CPUS: cpus?.toString(),
|
|
145
|
+
CARTESI_ROLLUPS_NODE_MEMORY: memory?.toString(),
|
|
146
|
+
CARTESI_SDK_IMAGE: `${DEFAULT_SDK_IMAGE}:${runtimeVersion}`,
|
|
147
|
+
CARTESI_SDK_VERSION: runtimeVersion,
|
|
148
|
+
};
|
|
149
|
+
// build a list of unique compose files
|
|
150
|
+
const composeFiles = [
|
|
151
|
+
...new Set(baseServices.map(({ file }) => file)),
|
|
152
|
+
];
|
|
153
|
+
// cpu and memory limits, mostly for testing and debuggingpurposes
|
|
154
|
+
if (cpus) {
|
|
155
|
+
composeFiles.push("docker-compose-node-cpus.yaml");
|
|
156
|
+
}
|
|
157
|
+
if (memory) {
|
|
158
|
+
composeFiles.push("docker-compose-node-memory.yaml");
|
|
159
|
+
}
|
|
160
|
+
// select subset of optional services
|
|
161
|
+
const optionalServices = services.length === 1 && services[0] === "all"
|
|
162
|
+
? availableServices
|
|
163
|
+
: availableServices.filter(({ name }) => services.includes(name));
|
|
164
|
+
// add to compose files list
|
|
165
|
+
composeFiles.push(...optionalServices.map(({ file }) => file));
|
|
166
|
+
// create the "--file <file>" list
|
|
167
|
+
const files = composeFiles.flatMap((f) => [
|
|
168
|
+
"--file",
|
|
169
|
+
path.join(binPath, "compose", f),
|
|
170
|
+
]);
|
|
171
|
+
const composeArgs = [
|
|
172
|
+
"compose",
|
|
173
|
+
...files,
|
|
174
|
+
"--project-name",
|
|
175
|
+
environmentName,
|
|
176
|
+
];
|
|
177
|
+
// run in detached mode (background)
|
|
178
|
+
const upArgs = ["--detach"];
|
|
179
|
+
if (dryRun) {
|
|
180
|
+
// show the docker compose configuration
|
|
181
|
+
await execa("docker", [...composeArgs, "config"], {
|
|
182
|
+
env,
|
|
183
|
+
stdio: "inherit",
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (defaultBlock !== "finalized") {
|
|
188
|
+
console.warn(chalk.yellow(`WARNING: default block is set to '${defaultBlock}', production configuration will likely use 'finalized'`));
|
|
189
|
+
}
|
|
190
|
+
// pull images first
|
|
191
|
+
const pullArgs = ["--policy", "missing"];
|
|
192
|
+
await execa("docker", [...composeArgs, "pull", ...pullArgs], {
|
|
193
|
+
env,
|
|
194
|
+
stdio: "inherit",
|
|
195
|
+
});
|
|
196
|
+
// run compose environment
|
|
197
|
+
const up = execa("docker", [...composeArgs, "up", ...upArgs], {
|
|
198
|
+
env,
|
|
199
|
+
});
|
|
200
|
+
// create tasks to monitor services startup
|
|
201
|
+
const monitorTasks = [...baseServices, ...optionalServices]
|
|
202
|
+
.filter(({ healthySemaphore }) => !!healthySemaphore) // only services with a healthy semaphore
|
|
203
|
+
.map((service) => {
|
|
204
|
+
const healthyTitle = typeof service.healthyTitle === "function"
|
|
205
|
+
? service.healthyTitle(port)
|
|
206
|
+
: service.healthyTitle;
|
|
207
|
+
return serviceMonitorTask({
|
|
208
|
+
environmentName,
|
|
209
|
+
service: service.healthySemaphore,
|
|
210
|
+
errorTitle: service.errorTitle,
|
|
211
|
+
waitTitle: service.waitTitle,
|
|
212
|
+
healthyTitle,
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
const tasks = new Listr(monitorTasks, { concurrent: true });
|
|
216
|
+
await tasks.run();
|
|
217
|
+
await up;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,mBAAmB;;;MAkD/B,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import Table from "cli-table3";
|
|
4
|
+
import { getServiceState } from "../base.js";
|
|
5
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
|
|
6
|
+
import { getDeployments } from "../exec/rollups.js";
|
|
7
|
+
export const createStatusCommand = () => {
|
|
8
|
+
return new Command("status")
|
|
9
|
+
.description("Shows the status of a local environment.")
|
|
10
|
+
.configureHelp({ showGlobalOptions: true })
|
|
11
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
12
|
+
.option("--json", "output in JSON format")
|
|
13
|
+
.action(async ({ environmentName, json }, command) => {
|
|
14
|
+
const status = await getServiceState({
|
|
15
|
+
environmentName,
|
|
16
|
+
service: "rollups-node",
|
|
17
|
+
});
|
|
18
|
+
const deployments = await getDeployments({ environmentName });
|
|
19
|
+
if (json) {
|
|
20
|
+
process.stdout.write(JSON.stringify({
|
|
21
|
+
status,
|
|
22
|
+
deployments,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.log(`${chalk.cyan(environmentName)} is ${status === "running" ? chalk.green("running") : chalk.red("not running")}`);
|
|
27
|
+
if (status === "running") {
|
|
28
|
+
if (deployments.length === 0) {
|
|
29
|
+
console.log(chalk.red("no applications deployed"));
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// print as a table
|
|
33
|
+
const table = new Table({
|
|
34
|
+
head: ["Machine", "Address", "State"],
|
|
35
|
+
style: { border: [], head: [] },
|
|
36
|
+
});
|
|
37
|
+
table.push(...deployments.map((deployment) => [
|
|
38
|
+
deployment.templateHash,
|
|
39
|
+
deployment.address,
|
|
40
|
+
deployment.state,
|
|
41
|
+
]));
|
|
42
|
+
console.log(table.toString());
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,eAAO,MAAM,iBAAiB;;MA4B7B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
|
|
6
|
+
export const createStopCommand = () => {
|
|
7
|
+
return new Command("stop")
|
|
8
|
+
.description("Stop a local environment.")
|
|
9
|
+
.configureHelp({ showGlobalOptions: true })
|
|
10
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
11
|
+
.action(async ({ environmentName }, command) => {
|
|
12
|
+
const progress = ora(`Stopping ${chalk.cyan(environmentName)} environment...`).start();
|
|
13
|
+
try {
|
|
14
|
+
await execa("docker", [
|
|
15
|
+
"compose",
|
|
16
|
+
"-p",
|
|
17
|
+
environmentName,
|
|
18
|
+
"down",
|
|
19
|
+
"--volumes",
|
|
20
|
+
]);
|
|
21
|
+
progress.succeed(`${chalk.cyan(environmentName)} environment stopped.`);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
progress.fail(e.message);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# cartesi/rollups-node
|
|
2
|
+
|
|
3
|
+
#logs
|
|
4
|
+
CARTESI_LOG_LEVEL="${CARTESI_LOG_LEVEL:-info}"
|
|
5
|
+
|
|
6
|
+
# features
|
|
7
|
+
CARTESI_FEATURE_INPUT_READER_ENABLED="${CARTESI_FEATURE_INPUT_READER_ENABLED:-true}"
|
|
8
|
+
CARTESI_FEATURE_CLAIM_SUBMISSION_ENABLED="${CARTESI_FEATURE_CLAIM_SUBMISSION_ENABLED:-true}"
|
|
9
|
+
CARTESI_FEATURE_MACHINE_HASH_CHECK_ENABLED="${CARTESI_FEATURE_MACHINE_HASH_CHECK_ENABLED:-true}"
|
|
10
|
+
CARTESI_SNAPSHOTS_DIR="/var/lib/cartesi-rollups-node/snapshots"
|
|
11
|
+
|
|
12
|
+
# rollups
|
|
13
|
+
CARTESI_EVM_READER_RETRY_POLICY_MAX_RETRIES="${CARTESI_EVM_READER_RETRY_POLICY_MAX_RETRIES:-3}"
|
|
14
|
+
CARTESI_EVM_READER_RETRY_POLICY_MAX_DELAY="${CARTESI_EVM_READER_RETRY_POLICY_MAX_DELAY:-3}"
|
|
15
|
+
CARTESI_ADVANCER_POLLING_INTERVAL="${CARTESI_ADVANCER_POLLING_INTERVAL:-3}"
|
|
16
|
+
CARTESI_VALIDATOR_POLLING_INTERVAL="${CARTESI_VALIDATOR_POLLING_INTERVAL:-3}"
|
|
17
|
+
CARTESI_CLAIMER_POLLING_INTERVAL="${CARTESI_CLAIMER_POLLING_INTERVAL:-3}"
|
|
18
|
+
CARTESI_MAX_STARTUP_TIME="${CARTESI_MAX_STARTUP_TIME:-15}"
|
|
19
|
+
|
|
20
|
+
# blockchain
|
|
21
|
+
CARTESI_BLOCKCHAIN_ID="${CARTESI_BLOCKCHAIN_ID:-13370}"
|
|
22
|
+
CARTESI_BLOCKCHAIN_HTTP_ENDPOINT="${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}"
|
|
23
|
+
CARTESI_BLOCKCHAIN_WS_ENDPOINT="${CARTESI_BLOCKCHAIN_WS_ENDPOINT:-ws://anvil:8545}"
|
|
24
|
+
CARTESI_BLOCKCHAIN_DEFAULT_BLOCK="${CARTESI_BLOCKCHAIN_DEFAULT_BLOCK:-latest}"
|
|
25
|
+
|
|
26
|
+
# contracts
|
|
27
|
+
CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS:-0x2210ad1d9B0bD2D470c2bfA4814ab6253BC421A0}"
|
|
28
|
+
CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="${CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS:-0x451f57Ca716046D114Ab9ff23269a2F9F4a1bdaF}"
|
|
29
|
+
CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS:-0x4a409e1CaB9229711C4e1f68625DdbC75809e721}"
|
|
30
|
+
|
|
31
|
+
# auth
|
|
32
|
+
CARTESI_AUTH_MNEMONIC="${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}"
|
|
33
|
+
|
|
34
|
+
# postgres
|
|
35
|
+
CARTESI_DATABASE_CONNECTION="postgres://postgres:password@database:5432/rollupsdb?sslmode=disable"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
services:
|
|
2
|
+
anvil:
|
|
3
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
4
|
+
command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"]
|
|
5
|
+
healthcheck:
|
|
6
|
+
test: ["CMD", "eth_isready"]
|
|
7
|
+
start_period: 10s
|
|
8
|
+
start_interval: 200ms
|
|
9
|
+
interval: 10s
|
|
10
|
+
timeout: 1s
|
|
11
|
+
retries: 5
|
|
12
|
+
environment:
|
|
13
|
+
ANVIL_IP_ADDR: 0.0.0.0
|
|
14
|
+
|
|
15
|
+
proxy:
|
|
16
|
+
volumes:
|
|
17
|
+
- ./proxy/anvil.yaml:/etc/traefik/conf.d/anvil.yaml
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
services:
|
|
2
|
+
bundler:
|
|
3
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
4
|
+
command:
|
|
5
|
+
- "alto"
|
|
6
|
+
- "--entrypoints"
|
|
7
|
+
- "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789,0x0000000071727De22E5E9d8BAf0edAc6f37da032"
|
|
8
|
+
- "--log-level"
|
|
9
|
+
- "info"
|
|
10
|
+
- "--rpc-url"
|
|
11
|
+
- "http://anvil:8545"
|
|
12
|
+
- "--min-executor-balance"
|
|
13
|
+
- "0"
|
|
14
|
+
- "--utility-private-key"
|
|
15
|
+
- "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
|
|
16
|
+
- "--executor-private-keys"
|
|
17
|
+
- "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6,0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356,0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e,0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba,0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
|
|
18
|
+
- "--safe-mode"
|
|
19
|
+
- "false"
|
|
20
|
+
- "--port"
|
|
21
|
+
- "4337"
|
|
22
|
+
- "--public-client-log-level"
|
|
23
|
+
- "error"
|
|
24
|
+
- "--wallet-client-log-level"
|
|
25
|
+
- "error"
|
|
26
|
+
- "--enable-debug-endpoints"
|
|
27
|
+
healthcheck:
|
|
28
|
+
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:4337/health"]
|
|
29
|
+
start_period: 10s
|
|
30
|
+
start_interval: 200ms
|
|
31
|
+
interval: 10s
|
|
32
|
+
timeout: 1s
|
|
33
|
+
retries: 5
|
|
34
|
+
|
|
35
|
+
proxy:
|
|
36
|
+
volumes:
|
|
37
|
+
- ./proxy/bundler.yaml:/etc/traefik/conf.d/bundler.yaml
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
services:
|
|
2
2
|
database:
|
|
3
|
-
image:
|
|
3
|
+
image: cartesi/rollups-database:${CARTESI_SDK_VERSION}
|
|
4
4
|
healthcheck:
|
|
5
5
|
test: ["CMD-SHELL", "pg_isready -U postgres || exit 1"]
|
|
6
|
+
start_period: 10s
|
|
7
|
+
start_interval: 200ms
|
|
6
8
|
interval: 10s
|
|
7
|
-
timeout:
|
|
9
|
+
timeout: 1s
|
|
8
10
|
retries: 5
|
|
9
11
|
environment:
|
|
10
12
|
- POSTGRES_PASSWORD=password
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
services:
|
|
2
|
+
espresso:
|
|
3
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
4
|
+
command: ["espresso-dev-node"]
|
|
5
|
+
init: true
|
|
6
|
+
deploy:
|
|
7
|
+
resources:
|
|
8
|
+
limits:
|
|
9
|
+
cpus: "4"
|
|
10
|
+
memory: "1G"
|
|
11
|
+
depends_on:
|
|
12
|
+
database:
|
|
13
|
+
condition: service_healthy
|
|
14
|
+
anvil:
|
|
15
|
+
condition: service_healthy
|
|
16
|
+
environment:
|
|
17
|
+
ESPRESSO_SEQUENCER_L1_PROVIDER: ${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}
|
|
18
|
+
ESPRESSO_SEQUENCER_API_PORT: 24000
|
|
19
|
+
ESPRESSO_BUILDER_PORT: 23000
|
|
20
|
+
ESPRESSO_DEV_NODE_PORT: 20000
|
|
21
|
+
ESPRESSO_SEQUENCER_ETH_MNEMONIC: ${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}
|
|
22
|
+
ESPRESSO_SEQUENCER_L1_POLLING_INTERVAL: "${BLOCK_TIME}s"
|
|
23
|
+
ESPRESSO_STATE_PROVER_UPDATE_INTERVAL: "10s"
|
|
24
|
+
ESPRESSO_SEQUENCER_DATABASE_MAX_CONNECTIONS: 25
|
|
25
|
+
ESPRESSO_SEQUENCER_STORAGE_PATH: /data/espresso
|
|
26
|
+
healthcheck:
|
|
27
|
+
test:
|
|
28
|
+
[
|
|
29
|
+
"CMD",
|
|
30
|
+
"curl",
|
|
31
|
+
"-fsS",
|
|
32
|
+
"http://127.0.0.1:24000/status/block-height",
|
|
33
|
+
]
|
|
34
|
+
start_period: 10s
|
|
35
|
+
start_interval: 200ms
|
|
36
|
+
interval: 10s
|
|
37
|
+
timeout: 1s
|
|
38
|
+
retries: 5
|
|
39
|
+
|
|
40
|
+
espresso_reader:
|
|
41
|
+
image: ${CARTESI_SDK_IMAGE}
|
|
42
|
+
command: ["cartesi-rollups-espresso-reader"]
|
|
43
|
+
env_file:
|
|
44
|
+
- ${CARTESI_BIN_PATH}/compose/default.env
|
|
45
|
+
ports:
|
|
46
|
+
- 8081
|
|
47
|
+
depends_on:
|
|
48
|
+
database:
|
|
49
|
+
condition: service_healthy
|
|
50
|
+
espresso:
|
|
51
|
+
condition: service_healthy
|
|
52
|
+
environment:
|
|
53
|
+
CARTESI_DATABASE_CONNECTION: postgres://postgres:password@database:5432/rollupsdb?sslmode=disable
|
|
54
|
+
ESPRESSO_SERVICE_ENDPOINT: ":8081"
|
|
55
|
+
ESPRESSO_BASE_URL: http://espresso:24000
|
|
56
|
+
|
|
57
|
+
proxy:
|
|
58
|
+
volumes:
|
|
59
|
+
- ./proxy/espresso.yaml:/etc/traefik/conf.d/espresso.yaml
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
x-explorer_db_env: &explorer_db_env
|
|
2
|
+
DB_NAME: explorer
|
|
3
|
+
DB_PORT: 5432
|
|
4
|
+
DB_HOST: database
|
|
5
|
+
DB_PASS: password
|
|
6
|
+
|
|
7
|
+
services:
|
|
8
|
+
explorer_api:
|
|
9
|
+
image: cartesi/rollups-explorer-api:1.0.0-alpha.3
|
|
10
|
+
environment:
|
|
11
|
+
<<: *explorer_db_env
|
|
12
|
+
GQL_PORT: 4350
|
|
13
|
+
expose:
|
|
14
|
+
- 4350
|
|
15
|
+
command: ["sqd", "serve:prod"]
|
|
16
|
+
healthcheck:
|
|
17
|
+
test:
|
|
18
|
+
[
|
|
19
|
+
"CMD",
|
|
20
|
+
"curl",
|
|
21
|
+
"-fsS",
|
|
22
|
+
"http://127.0.0.1:4350/graphql?query=%7B__typename%7D",
|
|
23
|
+
]
|
|
24
|
+
start_period: 10s
|
|
25
|
+
start_interval: 200ms
|
|
26
|
+
interval: 10s
|
|
27
|
+
timeout: 1s
|
|
28
|
+
retries: 5
|
|
29
|
+
depends_on:
|
|
30
|
+
database:
|
|
31
|
+
condition: service_healthy
|
|
32
|
+
|
|
33
|
+
squid_processor:
|
|
34
|
+
image: cartesi/rollups-explorer-api:1.0.0-alpha.3
|
|
35
|
+
environment:
|
|
36
|
+
<<: *explorer_db_env
|
|
37
|
+
CHAIN_IDS: ${CARTESI_BLOCKCHAIN_ID:-13370}
|
|
38
|
+
RPC_URL_13370: ${RPC_URL:-http://anvil:8545}
|
|
39
|
+
BLOCK_CONFIRMATIONS_13370: 0
|
|
40
|
+
GENESIS_BLOCK_13370: 1
|
|
41
|
+
command: ["sqd", "process:prod"]
|
|
42
|
+
depends_on:
|
|
43
|
+
database:
|
|
44
|
+
condition: service_healthy
|
|
45
|
+
|
|
46
|
+
explorer:
|
|
47
|
+
image: cartesi/rollups-explorer:1.0.0-alpha.2
|
|
48
|
+
expose:
|
|
49
|
+
- 3000
|
|
50
|
+
depends_on:
|
|
51
|
+
database:
|
|
52
|
+
condition: service_healthy
|
|
53
|
+
|
|
54
|
+
proxy:
|
|
55
|
+
volumes:
|
|
56
|
+
- ./proxy/explorer.yaml:/etc/traefik/conf.d/explorer.yaml
|
|
57
|
+
- ./proxy/explorer-api.yaml:/etc/traefik/conf.d/explorer-api.yaml
|