From 4179984f77043cd435344aef4c2ff3d081f873d5 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 7 Oct 2024 16:17:08 -0700 Subject: [PATCH 1/5] feat(cli): show clone output, --evm/--bare, faster clone --- crates/cli/src/commands/new.rs | 46 ++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/crates/cli/src/commands/new.rs b/crates/cli/src/commands/new.rs index 3272600aab..104cac79da 100644 --- a/crates/cli/src/commands/new.rs +++ b/crates/cli/src/commands/new.rs @@ -1,17 +1,33 @@ use anyhow::Result; -use clap::Parser; -use std::{fs, path::Path, process::Command}; +use clap::{Args, Parser}; +use std::{ + fs, + path::Path, + process::{Command, Stdio}, +}; use yansi::Paint; +#[derive(Args)] +#[group(required = true, multiple = false)] +struct TemplateType { + /// Use the `bare` template which includes just a program and script. + #[arg(long)] + bare: bool, + + /// Use the `evm` template which includes Solidity smart contracts for onchain integration. + #[arg(long)] + evm: bool, +} + #[derive(Parser)] #[command(name = "new", about = "Setup a new project that runs inside the SP1.")] pub struct NewCmd { /// The name of the project. name: String, - /// Whether to create the project with template EVM contracts. - #[arg(long, action)] - evm: bool, + /// The template to use for the project. + #[command(flatten)] + template: TemplateType, /// Version of sp1-project-template to use (branch or tag). #[arg(long, default_value = "main")] @@ -32,16 +48,24 @@ impl NewCmd { println!(" \x1b[1m{}\x1b[0m {}", Paint::green("Cloning"), TEMPLATE_REPOSITORY_URL); // Clone the repository with the specified version. - let output = Command::new("git") + let mut command = Command::new("git"); + + command .arg("clone") .arg("--branch") .arg(&self.version) .arg(TEMPLATE_REPOSITORY_URL) .arg(root.as_os_str()) - .arg("--recurse-submodules") - .arg("--depth=1") - .output() - .expect("failed to execute command"); + .arg("--depth=1"); + + if self.template.evm { + command.arg("--recurse-submodules").arg("--shallow-submodules"); + } + + // Stream output to stdout. + command.stdout(Stdio::inherit()).stderr(Stdio::inherit()); + + let output = command.output().expect("failed to execute command"); if !output.status.success() { let stderr = String::from_utf8_lossy(&output.stderr); return Err(anyhow::anyhow!("failed to clone repository: {}", stderr)); @@ -50,7 +74,7 @@ impl NewCmd { // Remove the .git directory. fs::remove_dir_all(root.join(".git"))?; - if self.evm { + if self.template.evm { // Check if the user has `foundry` installed. if Command::new("foundry").arg("--version").output().is_err() { println!( From 8866fb5ed699beeca851314cba19b98e46848be5 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 7 Oct 2024 16:56:48 -0700 Subject: [PATCH 2/5] update docs --- book/generating-proofs/proof-types.md | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/book/generating-proofs/proof-types.md b/book/generating-proofs/proof-types.md index d6542d73bc..28e7a7a4e7 100644 --- a/book/generating-proofs/proof-types.md +++ b/book/generating-proofs/proof-types.md @@ -19,25 +19,20 @@ client.prove(&pk, stdin).run().unwrap(); ## Compressed The compressed prover mode generates STARK proofs that have constant size. Use this in settings where you -care about **verification cost / proof size**. This is useful for applications where you want to recursively verify SP1 proofs within SP1 (see the [proof aggregation](../writing-programs/proof-aggregation.md) section). +care about **verification cost / proof size**, but not onchain verification. Compressed proofs are also useful because they can be cheaply recursively verified within SP1 itself (see the [proof aggregation](../writing-programs/proof-aggregation.md) section). ```rust,noplayground let client = ProverClient::new(); client.prove(&pk, stdin).compressed().run().unwrap(); ``` -## Groth16 (testnet only) +## Groth16 -
-WARNING: Groth16 proofs are currently only verifiable on testnets & are not production-ready -
+> WARNING: The Groth16 prover requires around 64GB of RAM and only has prebuilt circuit artifacts on official releases of SP1. We recommend using the prover network to generate these proofs. -
-WARNING: The Groth16 prover requires around 64GB of RAM and are only guaranteed to work on official releases of SP1. We recommend using the prover network to generate these proofs. -
+The Groth16 prover mode generate a SNARK proof that is ~260 bytes large and can be verified onchain for around ~270k gas. Groth16 proofs take about ~30s longer to generate over a compressed proof. -The Groth16 prover mode generate a SNARK proof with extremely small proof size and low verification cost. -This mode generates proofs that can be verified onchain for around ~270k gas. +The trusted setup for the Groth16 circuit keys uses the [Aztec Ignition ceremony](https://github.com/AztecProtocol/ignition-verification) + entropy contributions from members of the Succinct team. ```rust,noplayground let client = ProverClient::new(); @@ -46,12 +41,11 @@ client.prove(&pk, stdin).groth16().run().unwrap(); ## PLONK -
-WARNING: The PLONK prover requires around 64GB of RAM and are only guaranteed to work on official releases of SP1. We recommend using the prover network to generate these proofs. -
+> WARNING: The PLONK prover requires around 64GB of RAM and only has prebuilt circuit artifacts on official releases of SP1. We recommend using the prover network to generate these proofs. -The Groth16 and PLONK prover modes generate a SNARK proof with extremely small proof size and low verification cost. -This mode generates proofs that can be verified onchain for around ~300k gas. +The PLONK prover mode generate a SNARK proof that is ~868 bytes large and can also be verified onchain for around ~300k gas. Plonk proofs take about ~1m30s longer to generate over a compressed proof. + +PLONK does not require a trusted setup. ```rust,noplayground let client = ProverClient::new(); From e15cc3286f13ed95124b94e14b8c0a65c5eb6a77 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 7 Oct 2024 17:24:49 -0700 Subject: [PATCH 3/5] fix ci --- .github/workflows/pr.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 1612f957df..0abd3f6203 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -297,7 +297,7 @@ jobs: low-memory: name: Low Memory - strategy: + strategy: matrix: mem_limit: [16, 32, 64] runs-on: @@ -353,16 +353,22 @@ jobs: include: - name: "Ubuntu 24.04 (x86_64)" runner: "ubuntu-24.04" + template: evm - name: "Ubuntu 22.04 (x86_64)" runner: "ubuntu-22.04" + template: bare - name: "Ubuntu 20.04 (x86_64)" runner: "ubuntu-20.04" + template: evm - name: "macOS Monterey (x86_64)" runner: "macos-12" + template: evm - name: "macOS Ventura (x86_64)" runner: "macos-13" + template: bare - name: "macOS Sonoma (ARM64)" runner: "macos-14" + template: evm runs-on: "${{ matrix.runner }}" steps: @@ -379,7 +385,7 @@ jobs: - name: "Create SP1 project from template" run: | - cargo prove new hello + cargo prove new --{{ matrix.template }} hello - name: "Build SP1 project" run: | From cba1d519aec6685b34605aad50b37294db62966f Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 7 Oct 2024 17:25:24 -0700 Subject: [PATCH 4/5] fix ci --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0abd3f6203..4c963c6e87 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -247,7 +247,7 @@ jobs: - name: Run cargo prove new run: | - cargo prove new fibonacci --version dev + cargo prove new fibonacci --version dev --evm - name: Build program and run script run: | From 359ca92e2b3e83f72824213a86499b73de7f37e2 Mon Sep 17 00:00:00 2001 From: Chris Tian Date: Mon, 7 Oct 2024 18:51:01 -0700 Subject: [PATCH 5/5] fix --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4c963c6e87..5095967882 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -385,7 +385,7 @@ jobs: - name: "Create SP1 project from template" run: | - cargo prove new --{{ matrix.template }} hello + cargo prove new --${{ matrix.template }} hello - name: "Build SP1 project" run: |