Skip to content

Commit

Permalink
Merge branch 'main' into sina/regex-example
Browse files Browse the repository at this point in the history
  • Loading branch information
puma314 committed Feb 13, 2024
2 parents 3e00649 + 47d23a5 commit f3d69fe
Show file tree
Hide file tree
Showing 82 changed files with 546 additions and 468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/perf-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:

jobs:
benchmark:
runs-on: buildjet-32vcpu-ubuntu-2204
runs-on: warp-ubuntu-latest-arm64-16x
if: contains(github.event.pull_request.title, 'perf') || contains(github.event.pull_request.body, 'perf')
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:

jobs:
benchmark:
runs-on: buildjet-32vcpu-ubuntu-2204
runs-on: warp-ubuntu-latest-arm64-16x
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
main:
name: Title
runs-on: buildjet-2vcpu-ubuntu-2204
runs-on: warp-ubuntu-latest-arm64-4x
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
svm_target_platform: linux-amd64
platform: linux
arch: amd64
- runner: buildjet-4vcpu-ubuntu-2204-arm
- runner: warp-ubuntu-latest-arm64-4x
target: aarch64-unknown-linux-gnu
svm_target_platform: linux-aarch64
platform: linux
Expand Down Expand Up @@ -147,7 +147,7 @@ jobs:
[[ "$target" == *windows* ]] && exe=".exe"
cargo build --release -p cli --target "$target" "${flags[@]}"
cargo build --release -p curta-cli --target "$target" "${flags[@]}"
bins=(cargo-prove)
for name in "${bins[@]}"; do
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
test:
name: CI Test Suite
runs-on: buildjet-32vcpu-ubuntu-2204
runs-on: warp-ubuntu-latest-arm64-16x
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand All @@ -26,7 +26,7 @@ jobs:
git config --global url."https://${{ secrets.PRIVATE_PULL_TOKEN }}@github.com".insteadOf https://github.com
- name: rust-cache
uses: buildjet/cache@v3
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:

lints:
name: Formatting & Clippy
runs-on: buildjet-32vcpu-ubuntu-2204
runs-on: warp-ubuntu-latest-arm64-16x
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
Expand All @@ -72,7 +72,7 @@ jobs:
git config --global url."https://${{ secrets.PRIVATE_PULL_TOKEN }}@github.com".insteadOf https://github.com
- name: rust-cache
uses: buildjet/cache@v3
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
Expand Down
2 changes: 1 addition & 1 deletion book/generating-proofs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Instead, you should have your script only execute the program with the RISC-V ru
use curta_core::{CurtaProver, CurtaStdin, CurtaVerifier};
// The ELF file with the RISC-V bytecode of the program from above.
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-curta-zkvm-elf");
fn main() {
let mut stdin = CurtaStdin::new();
Expand Down
6 changes: 3 additions & 3 deletions book/getting-started/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build the toolchain and CLI from source.

Make sure you have [Rust](https://www.rust-lang.org/tools/install) installed.

## Prebuilt Binaries (Recommended)
## Option 1: Prebuilt Binaries (Recommended)

Curtaup is the Curta zkVM toolchain installer. Open your terminal and run the following command and follow the instructions:

Expand All @@ -21,7 +21,7 @@ After following the instructions, you can run `curtaup` to install the toolchain
curtaup
```

This will install support for the `riscv32im-succinct-zkvm-elf` compilation target within your Rust compiler
This will install support for the `riscv32im-curta-zkvm-elf` compilation target within your Rust compiler
and a `cargo prove` CLI tool that will let you compile provable programs and then prove their correctness.

You can verify the installation by running `cargo prove --version`:
Expand All @@ -32,7 +32,7 @@ cargo prove --version

If this works, go to the [next section](./quickstart.md) to compile and prove a simple zkVM program.

## Building from Source
## Option 2: Building from Source

Make sure you have installed the [dependencies](https://github.com/rust-lang/rust/blob/master/INSTALL.md#dependencies) needed to build the rust toolchain from source.

Expand Down
11 changes: 4 additions & 7 deletions book/getting-started/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ The first step is to create a new project using the `cargo prove new <name>` com

```bash
cargo prove new fibonacci
cd fibonacci
```

This will create a new project with the following structure:

```bash
cd fibonacci
tree . -L 3
```
```
.
├── program
Expand Down Expand Up @@ -50,7 +47,7 @@ cargo prove build
The resulting compiled executable is called an [ELF (Executable and Linkable Format)](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format) and contains bytecode that can be executed by the Curta zkVM.


You can verify that the ELF was generated by looking in the `elf` directory and looking for a file called `riscv32im-succinct-zkvm-elf`:
You can verify that the ELF was generated by looking in the `elf` directory and looking for a file called `riscv32im-curta-zkvm-elf`:
```bash
ls elf
```
Expand All @@ -64,9 +61,9 @@ cd ../script
RUST_LOG=info cargo run --release
```
```
Compiling hello_curta-script v0.1.0 (/Users/umaroy/Documents/hello_curta/script)
Compiling fibonacci-script v0.1.0 (/Users/umaroy/Documents/fibonacci/script)
Finished release [optimized] target(s) in 26.14s
Running `target/release/hello_curta-script`
Running `target/release/fibonacci-script`
a: 3867074829
b: 2448710421
succesfully generated and verified proof for the program!
Expand Down
4 changes: 2 additions & 2 deletions book/writing-programs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To build the program, simply run:
cargo prove build
```

This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-succinct-zkvm-elf`.
This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-curta-zkvm-elf`.


## Manual
Expand Down Expand Up @@ -70,4 +70,4 @@ To build the program, simply run:
cargo prove build
```

This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-succinct-zkvm-elf`.
This will compile the ELF that can be executed in the zkVM and put the executable in `elf/riscv32im-curta-zkvm-elf`.
4 changes: 2 additions & 2 deletions cli/src/assets/script/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use curta_core::{CurtaProver, CurtaStdin, CurtaVerifier};

const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-succinct-zkvm-elf");
const ELF: &[u8] = include_bytes!("../../program/elf/riscv32im-curta-zkvm-elf");

fn main() {
// Generate proof.
Expand All @@ -21,7 +21,7 @@ fn main() {

// Save proof.
proof
.save("proof-with-pis.json")
.save("proof-with-io.json")
.expect("saving proof failed");

println!("succesfully generated and verified proof for the program!")
Expand Down
3 changes: 3 additions & 0 deletions cli/src/assets/script/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly-2024-01-25"
components = ["llvm-tools", "rustc-dev"]
8 changes: 4 additions & 4 deletions cli/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl BuildCmd {
let root_package = metadata.root_package();
let root_package_name = root_package.as_ref().map(|p| &p.name);

let build_target = "riscv32im-succinct-zkvm-elf";
let build_target = "riscv32im-curta-zkvm-elf";
let rust_flags = [
"-C",
"passes=loweratomic",
Expand All @@ -29,9 +29,9 @@ impl BuildCmd {
];

Command::new("cargo")
.env("RUSTUP_TOOLCHAIN", "succinct")
.env("RUSTUP_TOOLCHAIN", "curta")
.env("CARGO_ENCODED_RUSTFLAGS", rust_flags.join("\x1f"))
.env("SUCCINCT_BUILD_IGNORE", "1")
.env("CURTA_BUILD_IGNORE", "1")
.args(["build", "--release", "--target", build_target, "--locked"])
.run()
.unwrap();
Expand All @@ -43,7 +43,7 @@ impl BuildCmd {
.join(root_package_name.unwrap());
let elf_dir = metadata.target_directory.parent().unwrap().join("elf");
fs::create_dir_all(&elf_dir)?;
fs::copy(elf_path, elf_dir.join("riscv32im-succinct-zkvm-elf"))?;
fs::copy(elf_path, elf_dir.join("riscv32im-curta-zkvm-elf"))?;

Ok(())
}
Expand Down
23 changes: 10 additions & 13 deletions cli/src/commands/build_toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ impl BuildToolchainCmd {
pub fn run(&self) -> Result<()> {
// Get enviroment variables.
let github_access_token = std::env::var("GITHUB_ACCESS_TOKEN");
let build_dir = std::env::var("SUCCINCT_BUILD_DIR");
let build_dir = std::env::var("CURTA_BUILD_DIR");

// Clone our rust fork, if necessary.
let rust_dir = match build_dir {
Ok(build_dir) => {
println!("Detected SUCCINCT_BUILD_DIR, skipping cloning rust.");
println!("Detected CURTA_BUILD_DIR, skipping cloning rust.");
PathBuf::from(build_dir).join("rust")
}
Err(_) => {
println!("No SUCCINCT_BUILD_DIR detected, cloning rust.");
println!("No CURTA_BUILD_DIR detected, cloning rust.");
let repo_url = match github_access_token {
Ok(github_access_token) => {
println!("Detected GITHUB_ACCESS_TOKEN, using it to clone rust.");
Expand All @@ -37,7 +37,7 @@ impl BuildToolchainCmd {
};
Command::new("git").args(["clone", &repo_url]).run()?;
Command::new("git")
.args(["checkout", "rustc-17.0"])
.args(["checkout", "rustc-1.75"])
.current_dir("rust")
.run()?;
Command::new("git")
Expand All @@ -59,7 +59,7 @@ impl BuildToolchainCmd {
// Build the toolchain (stage 1).
Command::new("python3")
.env(
"CARGO_TARGET_RISCV32IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS",
"CARGO_TARGET_RISCV32IM_CURTA_ZKVM_ELF_RUSTFLAGS",
"-Cpasses=loweratomic",
)
.args(["x.py", "build"])
Expand All @@ -69,7 +69,7 @@ impl BuildToolchainCmd {
// Build the toolchain (stage 2).
Command::new("python3")
.env(
"CARGO_TARGET_RISCV32IM_SUCCINCT_ZKVM_ELF_RUSTFLAGS",
"CARGO_TARGET_RISCV32IM_CURTA_ZKVM_ELF_RUSTFLAGS",
"-Cpasses=loweratomic",
)
.args(["x.py", "build", "--stage", "2"])
Expand Down Expand Up @@ -122,18 +122,15 @@ impl BuildToolchainCmd {
let tar_gz_path = format!("rust-toolchain-{}.tar.gz", target);
Command::new("tar")
.args([
"--exclude",
"lib/rustlib/src",
"--exclude",
"lib/rustlib/rustc-src",
"-hczvf",
&tar_gz_path,
"-C",
toolchain_dir.to_str().unwrap(),
".",
"--exclude",
toolchain_dir.join("lib/rustlib/src").to_str().unwrap(),
"--exclude",
toolchain_dir
.join("lib/rustlib/rustc-src")
.to_str()
.unwrap(),
])
.run()?;
println!("Succesfully compressed the toolchain to {}.", tar_gz_path);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
changelog-seen = 2

[build]
target = ["riscv32im-succinct-zkvm-elf"]
target = ["riscv32im-curta-zkvm-elf"]
extended = true
tools = ["cargo", "cargo-clippy", "clippy", "rustfmt"]
configure-args = []
Expand Down
10 changes: 5 additions & 5 deletions cli/src/commands/install_toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl InstallToolchainCmd {
let client = Client::builder().user_agent("Mozilla/5.0").build()?;

// Setup variables.
let root_dir = home_dir().unwrap().join(".cargo-prove");
let root_dir = home_dir().unwrap().join(".curta");
match fs::read_dir(&root_dir) {
Ok(entries) =>
{
Expand All @@ -47,12 +47,12 @@ impl InstallToolchainCmd {
}
}
}
Err(_) => println!("No existing ~/.cargo-prove directory to remove."),
Err(_) => println!("No existing ~/.curta directory to remove."),
}
println!("Succesfully cleaned up ~/.cargo-prove directory.");
println!("Succesfully cleaned up ~/.curta directory.");
match fs::create_dir_all(&root_dir) {
Ok(_) => println!("Succesfully created ~/.cargo-prove directory."),
Err(err) => println!("Failed to create ~/.cargo-prove directory: {}", err),
Ok(_) => println!("Succesfully created ~/.curta directory."),
Err(err) => println!("Failed to create ~/.curta directory: {}", err),
};
let target = get_target();
let toolchain_asset_name = format!("rust-toolchain-{}.tar.gz", target);
Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const PROGRAM_CARGO_TOML: &str = include_str!("../assets/program/Cargo.toml");
const PROGRAM_MAIN_RS: &str = include_str!("../assets/program/main.rs");
const SCRIPT_CARGO_TOML: &str = include_str!("../assets/script/Cargo.toml");
const SCRIPT_MAIN_RS: &str = include_str!("../assets/script/main.rs");
const SCRIPT_RUST_TOOLCHAIN: &str = include_str!("../assets/script/rust-toolchain");

#[derive(Parser)]
#[command(
Expand Down Expand Up @@ -44,6 +45,7 @@ impl NewCmd {
SCRIPT_CARGO_TOML.replace("unnamed", &self.name),
)?;
fs::write(script_root.join("src").join("main.rs"), SCRIPT_MAIN_RS)?;
fs::write(script_root.join("rust-toolchain"), SCRIPT_RUST_TOOLCHAIN)?;

println!(
" \x1b[1m{}\x1b[0m {} ({})",
Expand Down
6 changes: 3 additions & 3 deletions cli/src/commands/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl ProveCmd {
let root_package = metadata.root_package();
let root_package_name = root_package.as_ref().map(|p| &p.name);

let build_target = "riscv32im-succinct-zkvm-elf";
let build_target = "riscv32im-curta-zkvm-elf";
let rust_flags = [
"-C",
"passes=loweratomic",
Expand All @@ -48,7 +48,7 @@ impl ProveCmd {
];

Command::new("cargo")
.env("RUSTUP_TOOLCHAIN", "succinct")
.env("RUSTUP_TOOLCHAIN", "curta")
.env("CARGO_ENCODED_RUSTFLAGS", rust_flags.join("\x1f"))
.env("SUCCINCT_BUILD_IGNORE", "1")
.args(["build", "--release", "--target", build_target, "--locked"])
Expand All @@ -62,7 +62,7 @@ impl ProveCmd {
.join(root_package_name.unwrap());
let elf_dir = metadata.target_directory.parent().unwrap().join("elf");
fs::create_dir_all(&elf_dir)?;
fs::copy(&elf_path, elf_dir.join("riscv32im-succinct-zkvm-elf"))?;
fs::copy(&elf_path, elf_dir.join("riscv32im-curta-zkvm-elf"))?;

if !self.profile {
match env::var("RUST_LOG") {
Expand Down
Loading

0 comments on commit f3d69fe

Please sign in to comment.