You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resolves INT-3882, and records changes in the book as per INT-4038. Most
importantly, reworks command outputs to primarily use the `target/`
directory that Cargo uses and assumes full control over.
- User can specify `target_dir`; if unspecified, `cargo openvm` will use
the Cargo default
- Keys are stored in `${target_dir}/openvm/`, while all other artifacts
are stored in `${target_dir}/openvm/${profile}`
- User can copy outputs to `${output_dir}`
- **NOTE** - generated proofs are stored at `.`, as this file should
generally be the final output
Other changes include:
- `build` no longer generates app commits
- `run` will call `build` before attempting to execute
- `prove` will call `build` before attempting to generate a proof
- Replaced all references to `evm-proving-setup` with references to
`setup`
- `openvm.toml`'s default location is in the working directory instead
of `.`
The basic workflow should now be `cargo openvm prove ...` into `cargo
openvm verify ...`.
Copy file name to clipboardExpand all lines: book/src/writing-apps/build.md
+86-79Lines changed: 86 additions & 79 deletions
Original file line number
Diff line number
Diff line change
@@ -9,135 +9,142 @@ The command `cargo openvm build` compiles the program on host to an executable f
9
9
It first compiles the program normally on your _host_ platform with RISC-V and then transpiles it to a different target. See here for some explanation of [cross-compilation](https://rust-lang.github.io/rustup/cross-compilation.html).
10
10
Right now we use `riscv32im-risc0-zkvm-elf` target which is available in the [Rust toolchain](https://doc.rust-lang.org/rustc/platform-support/riscv32im-risc0-zkvm-elf.html), but we will contribute an OpenVM target to Rust in the future.
11
11
12
-
## Build flags
12
+
## Build Flags
13
13
14
-
The following flags are available for the `cargo openvm build` command:
14
+
The following flags are available for the `cargo openvm build` command. You can run `cargo openvm build --help` for this list within the command line.
15
15
16
-
-`--manifest-dir <MANIFEST_DIR>`
16
+
Generally, outputs will always be built to the **target directory**, which will either be determined by the manifest path or explicitly set using the `--target-dir` option. By default Cargo sets this to be `<workspace_or_package_root>/target/`.
17
17
18
-
**Description**: Specifies the directory containing the `Cargo.toml` file for the guest code.
18
+
OpenVM-specific artifacts will be placed in `${target_dir}/openvm/`, but if `--output-dir` is specified they will be copied to `${output-dir}/` as well.
19
19
20
-
**Default**: The current directory (`.`).
20
+
### OpenVM Options
21
21
22
-
**Usage Example**: If your `Cargo.toml` is located in `my_project/`, you can run:
22
+
-`--no-transpile`
23
23
24
-
```bash
25
-
cargo openvm build --manifest-dir my_project
26
-
```
24
+
**Description**: Skips transpilation into an OpenVM-compatible `.vmexe` executable when set.
27
25
28
-
This ensures the build command is executed in that directory.
26
+
-`--config <CONFIG>`
29
27
30
-
-`--target-dir <TARGET_DIR>`
28
+
**Description**: Path to the OpenVM config `.toml` file that specifies the VM extensions. By default will search the manifest directory for `openvm.toml`. If no file is found, OpenVM will use a default configuration. Currently the CLI only supports known extensions listed in the [Using Existing Extensions](../custom-extensions/overview.md) section. To use other extensions, use the [SDK](../advanced-usage/sdk.md).
31
29
32
-
**Description**: Specifies the directory where the guest binary will be built. If not specified, the default target directory is used.
30
+
-`--output_dir <OUTPUT_DIR>`
33
31
34
-
**Default**: The `target` directory in the package root directory.
32
+
**Description**: Output directory for OpenVM artifacts to be copied to. Keys will be placed in `${output-dir}/`, while all other artifacts will be in `${output-dir}/${profile}`.
35
33
36
-
**Usage Example**: To build the guest binary in the `my_target` directory:
34
+
-`--init-file-name <INIT_FILE_NAME>`
37
35
38
-
```bash
39
-
cargo openvm build --target-dir my_target
40
-
```
36
+
**Description**: Name of the generated initialization file, which will be written into the manifest directory.
41
37
42
-
-`--features <FEATURES>`
38
+
**Default**: `openvm_init.rs`
43
39
44
-
**Description**: Passes a list of feature flags to the Cargo build process. These flags enable or disable conditional compilation features defined in your `Cargo.toml`.
40
+
### Package Selection
45
41
46
-
**Usage Example**: To enable the `my_feature` feature:
42
+
As with `cargo build`, default package selection depends on the working directory. If the working directory is a subdirectory of a specific package, then only that package will be built. Else, all packages in the workspace will be built by default.
47
43
48
-
```bash
49
-
cargo openvm build --features my_feature
50
-
```
44
+
-`--package <PACKAGES>`
51
45
52
-
-`--bin <NAME>`
46
+
**Description**: Builds only the specified packages. This flag may be specified multiple times or as a comma-separated list.
53
47
54
-
**Description**: Restricts the build to the binary target with the given name, similar to `cargo build --bin <NAME>`. If your project has multiple target types (binaries, libraries, examples, etc.), using `--bin <NAME>` narrows down the build to the binary target with the given name.
48
+
-`--workspace`
55
49
56
-
**Usage Example**:
50
+
**Description**: Builds all members of the workspace (alias `--all`).
57
51
58
-
```bash
59
-
cargo openvm build --bin my_bin
60
-
```
52
+
-`--exclude <PACKAGES>`
61
53
62
-
-`--example <NAME>`
54
+
**Description**: Excludes the specified packages. Must be used in conjunction with `--workspace`. This flag may be specified multiple times or as a comma-separated list.
63
55
64
-
**Description**: Restricts the build to the example target with the given name, similar to `cargo build --example <NAME>`. Projects often include code samples or demos under the examples directory, and this flag focuses on compiling a specific example.
56
+
### Target Selection
65
57
66
-
**Usage Example**:
58
+
By default all package libraries and binaries will be built. To build samples or demos under the `examples` directory, use either the `--example` or `--examples` option.
67
59
68
-
```bash
69
-
cargo openvm build --example my_example
70
-
```
60
+
-`--lib`
71
61
72
-
-`--no-transpile`
62
+
**Description**: Builds the package's library.
73
63
74
-
**Description**: After building the guest code, doesn't transpile the target ELF into an OpenVM-compatible executable (by default it does).
64
+
-`--bin <BIN>`
75
65
76
-
**Usage Example**:
66
+
**Description**: Builds the specified binary. This flag may be specified multiple times or as a comma-separated list.
77
67
78
-
```bash
79
-
cargo openvm build --no-transpile
80
-
```
68
+
-`--bins`
81
69
82
-
-`--config <CONFIG>`
70
+
**Description**: Builds all binary targets.
71
+
72
+
-`--example <EXAMPLE>`
73
+
74
+
**Description**: Builds the specified example. This flag may be specified multiple times or as a comma-separated list.
75
+
76
+
-`--examples`
77
+
78
+
**Description**: Builds all example targets.
79
+
80
+
-`--all-targets`
81
+
82
+
**Description**: Builds all package targets. Equivalent to specifying `--lib``--bins``--examples`.
83
+
84
+
### Feature Selection
85
+
86
+
The following options enable or disable conditional compilation features defined in your `Cargo.toml`.
87
+
88
+
-`-F`, `--features <FEATURES>`
89
+
90
+
**Description**: Space or comma separated list of features to activate. Features of workspace members may be enabled with `package-name/feature-name` syntax. This flag may also be specified multiple times.
91
+
92
+
-`--all-features`
93
+
94
+
**Description**: Activates all available features of all selected packages.
95
+
96
+
-`--no-default-features`
97
+
98
+
**Description**: Do not activate the `default` feature of the selected packages.
99
+
100
+
### Compilation Options
101
+
102
+
-`--profile <NAME>`
83
103
84
-
**Description**: Specifies the path to a .toml configuration file that defines which VM extensions to use.
104
+
**Description**: Builds with the given profile. Common profiles are `dev` (faster builds, less optimization) and `release` (slower builds, more optimization). For more information on profiles, see [Cargo's reference page](https://doc.rust-lang.org/cargo/reference/profiles.html).
85
105
86
-
**Default**: `./openvm.toml` if `--config` flag is not provided.
106
+
**Default**: `release`
87
107
88
-
**Usage Example**:
108
+
### Output Options
89
109
90
-
```bash
91
-
cargo openvm build --config path/to/openvm.toml
92
-
```
110
+
-`--target_dir <TARGET_DIR>`
93
111
94
-
This allows you to customize the extensions. Currently the CLI only supports known extensions listed in the [Using Existing Extensions](../custom-extensions/overview.md) section. To use other extensions, use the [SDK](../advanced-usage/sdk.md).
112
+
**Description**: Directory for all generated artifacts and intermediate files. Defaults to directory `target/` at the root of the workspace.
95
113
96
-
-`--exe-output <EXE_OUTPUT>`
114
+
### Display Options
97
115
98
-
**Description**: Sets the output path for the transpiled program.
116
+
-`-v`, `--verbose`
99
117
100
-
**Default**: `./openvm/app.vmexe` if `--exe-output` flag is not provided.
118
+
**Description**: Use verbose output.
101
119
102
-
**Usage Example**: To specify a custom output filename:
**Description**: Determines the build profile used by Cargo. Common profiles are dev (faster builds, less optimization) and release (slower builds, more optimization).
126
+
**Description**: Controls when colored output is used.
111
127
112
-
**Default**: release
128
+
**Default**: `always`
113
129
114
-
**Usage Example**:
130
+
### Manifest Options
115
131
116
-
```bash
117
-
cargo openvm build --profile dev
118
-
```
132
+
-`--manifest-path <PATH>`
119
133
120
-
-`--help`
134
+
**Description**: Path to the guest code Cargo.toml file. By default, `build` searches for the file in the current or any parent directory. The `build` command will be executed in that directory.
121
135
122
-
**Description**: Prints a help message describing the available options and their usage.
136
+
-`--ignore-rust-version`
123
137
124
-
**Usage Example**:
138
+
**Description**: Ignores rust-version specification in packages.
125
139
126
-
```bash
127
-
cargo openvm build --help
128
-
```
140
+
-`--locked`
129
141
130
-
## Running a Program
142
+
**Description**: Asserts the same dependencies and versions are used as when the existing Cargo.lock file was originally generated.
131
143
132
-
After building and transpiling a program, you can execute it using the `run` command. The `run` command has the following arguments:
144
+
-`--offline`
133
145
134
-
```bash
135
-
cargo openvm run
136
-
--exe <path_to_transpiled_program>
137
-
--config <path_to_app_config>
138
-
--input <path_to_input>
139
-
```
146
+
**Description**: Prevents Cargo from accessing the network for any reason.
140
147
141
-
If `--exe` and/or `--config` are not provided, the command will search for these files in `./openvm/app.vmexe` and `./openvm.toml` respectively. If `./openvm.toml` is not present, a default configuration will be used.
148
+
-`--frozen`
142
149
143
-
If your program doesn't require inputs, you can (and should) omit the `--input` flag.
150
+
**Description**: Equivalent to specifying both `--locked`and `--offline`.
Copy file name to clipboardExpand all lines: book/src/writing-apps/prove.md
+17-12Lines changed: 17 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,41 +4,46 @@ Generating a proof using the CLI is simple - first generate a key, then generate
4
4
5
5
```bash
6
6
cargo openvm keygen
7
-
cargo openvm prove [app | evm]
7
+
cargo openvm prove [app |stark |evm]
8
8
```
9
9
10
10
## Key Generation
11
11
12
-
The `keygen`CLI command has the following optional arguments:
12
+
The `keygen` command generates both an application proving and verification key.
13
13
14
14
```bash
15
15
cargo openvm keygen
16
16
--config <path_to_app_config>
17
-
--output <path_to_app_pk>
18
-
--vk_output <path_to_app_vk>
19
17
```
20
18
21
-
If `--config` is not provided, the command will search for `./openvm.toml` and use that as the application configuration if present. If it is not present, a default configuration will be used.
19
+
Similarly to `build`, `run`, and `prove`, options `--manifest-path`, `--target-dir`, and `--output-dir` are provided.
22
20
23
-
If `--output` and/or `--vk_output` are not provided, the keys will be written to default locations `./openvm/app.pk` and/or `./openvm/app.vk` respectively.
21
+
If `--config` is not specified, the command will search for `openvm.toml` in the manifest directory. If the file isn't found, a default configuration will be used.
22
+
23
+
The proving and verification key will be written to `${target_dir}/openvm/` (and `--output-dir` if specified).
24
24
25
25
## Proof Generation
26
26
27
-
The `prove` CLI command has the following optional arguments:
27
+
The `prove` CLI command, at its core, uses the options below. `prove` gets access to all of the options that `run` has (see [Running a Program](../writing-apps/run.md) for more information).
28
28
29
29
```bash
30
-
cargo openvm prove [app | evm]
31
-
--app_pk<path_to_app_pk>
30
+
cargo openvm prove [app |stark |evm]
31
+
--app-pk<path_to_app_pk>
32
32
--exe <path_to_transpiled_program>
33
33
--input <path_to_input>
34
-
--output <path_to_output>
34
+
--proof <path_to_proof_output>
35
35
```
36
36
37
+
If `--app-pk` is not provided, the command will search for a proving key at `${target_dir}/openvm/app.pk`.
38
+
39
+
If `--exe` is not provided, the command will call `build` before generating a proof.
40
+
37
41
If your program doesn't require inputs, you can (and should) omit the `--input` flag.
38
42
39
-
If `--app_pk` and/or `--exe` are not provided, the command will search for these files in `./openvm/app.pk` and `./openvm/app.vmexe` respectively. Similarly, if `--output` is not provided then the command will write the proof to `./openvm/[app | evm].proof` by default.
43
+
If `--proof` is not provided then the command will write the proof to `./[app | stark | evm].proof` by default.
44
+
40
45
41
-
The `app` subcommand is used to generate an application-level proof, while the `evm` command generates an end-to-end EVM proof.
46
+
The `app` subcommand generates an application-level proof, the `stark` command generates an aggregated root-level proof, while the `evm` command generates an end-to-end EVM proof. For more information on aggregation, see [this specification](https://github.com/openvm-org/openvm/blob/bf8df90b13f4e80bb76dbb71f255a12154c84838/docs/specs/continuations.md).
42
47
43
48
> ⚠️ **WARNING**
44
49
> In order to run the `evm` subcommand, you must have previously called the costly `cargo openvm setup`, which requires very large amounts of computation and memory (~200 GB).
0 commit comments