Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add noir-execute binary #7384

Merged
merged 30 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fd4ab05
Add artifact_cli
aakoshh Feb 12, 2025
1fb81c6
Turn artifact_cli into a library/binary combo
aakoshh Feb 13, 2025
9558618
Port fs from acvm_cli
aakoshh Feb 13, 2025
aac1b0f
Remove fs from acvm_cli
aakoshh Feb 13, 2025
10fbcb0
Parse inputs
aakoshh Feb 14, 2025
a568cce
Execute the circuit
aakoshh Feb 14, 2025
88ce449
Show diagnostic
aakoshh Feb 14, 2025
65ed320
Save the witness
aakoshh Feb 14, 2025
aea18c3
Add command docs
aakoshh Feb 14, 2025
7878c25
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 14, 2025
236e5f1
Reset indent size in Cargo.toml
aakoshh Feb 14, 2025
d36f2b9
Merge branch '7132-artifact-cli' of github.com:noir-lang/noir into 71…
aakoshh Feb 14, 2025
8bf7e61
Normalize paths
aakoshh Feb 14, 2025
4ec10a9
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 17, 2025
47c7ade
Move ACVM CLI witness functions back
aakoshh Feb 17, 2025
51b1bd7
Remove --oracle-file for now
aakoshh Feb 17, 2025
cff69fa
Add Format::from_ext
aakoshh Feb 17, 2025
98cfd77
Try to make read_inputs_from_file easier to read
aakoshh Feb 17, 2025
c18bb19
Rename to artifact_path
aakoshh Feb 17, 2025
5f89660
.
TomAFrench Feb 18, 2025
85bdd85
.
TomAFrench Feb 18, 2025
817df4a
.
TomAFrench Feb 18, 2025
51f2e2d
Switch to bin/execute.rs
aakoshh Feb 18, 2025
780cde3
Merge branch '7132-artifact-cli' of github.com:noir-lang/noir into 71…
aakoshh Feb 18, 2025
8a30ce5
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 18, 2025
48556ac
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 18, 2025
d4e5fa6
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 19, 2025
6c12079
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 19, 2025
7df9984
Merge branch 'master' into 7132-artifact-cli
TomAFrench Feb 19, 2025
2672478
Merge branch 'master' into 7132-artifact-cli
aakoshh Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"tooling/noirc_abi",
"tooling/noirc_abi_wasm",
"tooling/acvm_cli",
"tooling/artifact_cli",
"tooling/profiler",
"tooling/inspector",
# ACVM
Expand All @@ -40,6 +41,7 @@ members = [
default-members = [
"tooling/nargo_cli",
"tooling/acvm_cli",
"tooling/artifact_cli",
"tooling/profiler",
"tooling/inspector",
]
Expand Down Expand Up @@ -91,6 +93,7 @@ noir_debugger = { path = "tooling/debugger" }
noirc_abi = { path = "tooling/noirc_abi" }
noirc_artifacts = { path = "tooling/noirc_artifacts" }
noirc_artifacts_info = { path = "tooling/noirc_artifacts_info" }
noir_artifact_cli = { path = "tooling/artifact_cli" }

# Arkworks
ark-bn254 = { version = "^0.5.0", default-features = false, features = [
Expand Down
1 change: 1 addition & 0 deletions acvm-repo/acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ impl<F: for<'a> Deserialize<'a>> Program<F> {
.map_err(|err| std::io::Error::new(std::io::ErrorKind::InvalidInput, err))
}

/// Deserialize bytecode.
pub fn deserialize_program(serialized_circuit: &[u8]) -> std::io::Result<Self> {
Program::read(serialized_circuit)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_errors/src/reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ pub fn report_all<'files>(
}

impl FileDiagnostic {
/// Print the report; return true if it was an error.
pub fn report<'files>(
&self,
files: &'files impl Files<'files, FileId = fm::FileId>,
Expand Down
11 changes: 6 additions & 5 deletions tooling/acvm_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ name = "acvm"
path = "src/main.rs"

[dependencies]
thiserror.workspace = true
toml.workspace = true
color-eyre.workspace = true
clap.workspace = true
acvm.workspace = true
nargo.workspace = true
const_format.workspace = true
bn254_blackbox_solver.workspace = true
toml.workspace = true

acir.workspace = true
acvm.workspace = true
bn254_blackbox_solver.workspace = true
nargo.workspace = true
noir_artifact_cli.workspace = true

# Logs
tracing-subscriber.workspace = true
Expand Down
18 changes: 10 additions & 8 deletions tooling/acvm_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::io::{self, Write};
use std::path::PathBuf;

use acir::circuit::Program;
use acir::native_types::{WitnessMap, WitnessStack};
Expand All @@ -7,11 +8,12 @@ use bn254_blackbox_solver::Bn254BlackBoxSolver;
use clap::Args;
use nargo::PrintOutput;

use crate::cli::fs::inputs::{read_bytecode_from_file, read_inputs_from_file};
use crate::errors::CliError;
use nargo::{foreign_calls::DefaultForeignCallBuilder, ops::execute_program};
use noir_artifact_cli::errors::CliError;
use noir_artifact_cli::fs::artifact::read_bytecode_from_file;
use noir_artifact_cli::fs::witness::save_witness_to_dir;

use super::fs::witness::{create_output_witness_string, save_witness_to_dir};
use crate::fs::witness::{create_output_witness_string, read_witness_from_file};

/// Executes a circuit to calculate its return value
#[derive(Debug, Clone, Args)]
Expand All @@ -30,7 +32,7 @@ pub(crate) struct ExecuteCommand {

/// The working directory
#[clap(long, short)]
working_directory: String,
working_directory: PathBuf,

/// Set to print output witness to stdout
#[clap(long, short, action)]
Expand All @@ -45,9 +47,9 @@ pub(crate) struct ExecuteCommand {

fn run_command(args: ExecuteCommand) -> Result<String, CliError> {
let bytecode = read_bytecode_from_file(&args.working_directory, &args.bytecode)?;
let circuit_inputs = read_inputs_from_file(&args.working_directory, &args.input_witness)?;
let input_witness = read_witness_from_file(&args.working_directory.join(&args.input_witness))?;
let output_witness =
execute_program_from_witness(circuit_inputs, &bytecode, args.pedantic_solving)?;
execute_program_from_witness(input_witness, &bytecode, args.pedantic_solving)?;
assert_eq!(output_witness.length(), 1, "ACVM CLI only supports a witness stack of size 1");
let output_witness_string = create_output_witness_string(
&output_witness.peek().expect("Should have a witness stack item").witness,
Expand Down Expand Up @@ -76,8 +78,8 @@ pub(crate) fn execute_program_from_witness(
bytecode: &[u8],
pedantic_solving: bool,
) -> Result<WitnessStack<FieldElement>, CliError> {
let program: Program<FieldElement> = Program::deserialize_program(bytecode)
.map_err(|_| CliError::CircuitDeserializationError())?;
let program: Program<FieldElement> =
Program::deserialize_program(bytecode).map_err(CliError::CircuitDeserializationError)?;
execute_program(
&program,
inputs_map,
Expand Down
54 changes: 0 additions & 54 deletions tooling/acvm_cli/src/cli/fs/inputs.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tooling/acvm_cli/src/cli/fs/mod.rs

This file was deleted.

63 changes: 0 additions & 63 deletions tooling/acvm_cli/src/cli/fs/witness.rs

This file was deleted.

1 change: 0 additions & 1 deletion tooling/acvm_cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use color_eyre::eyre;
use const_format::formatcp;

mod execute_cmd;
mod fs;

const ACVM_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down
50 changes: 0 additions & 50 deletions tooling/acvm_cli/src/errors.rs

This file was deleted.

1 change: 1 addition & 0 deletions tooling/acvm_cli/src/fs/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub(crate) mod witness;
Loading
Loading