Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions acvm-repo/acir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ serde.workspace = true
thiserror.workspace = true
flate2 = "1.0.24"
bincode.workspace = true
strum = "0.24"
strum_macros = "0.24"
base64.workspace = true

[dev-dependencies]
serde_json = "1.0"
strum = "0.24"
strum_macros = "0.24"
serde-reflection = "0.3.6"
serde-generate = "0.25.1"
fxhash.workspace = true
Expand Down
9 changes: 6 additions & 3 deletions acvm-repo/acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
//! These are implemented inside the ACVM stdlib.

use serde::{Deserialize, Serialize};
#[cfg(test)]
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[allow(clippy::upper_case_acronyms)]
#[derive(Clone, Debug, Hash, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(test, derive(EnumIter))]
#[derive(Clone, Debug, Hash, Copy, PartialEq, Eq, Serialize, Deserialize, EnumIter)]
pub enum BlackBoxFunc {
/// Bitwise AND.
AND,
Expand Down Expand Up @@ -99,6 +98,10 @@ impl BlackBoxFunc {
pub fn is_valid_black_box_func_name(op_name: &str) -> bool {
BlackBoxFunc::lookup(op_name).is_some()
}

pub fn all_blackbox_functions() -> Vec<String> {
Self::iter().map(|x| x.name().to_string()).collect()
}
}

#[cfg(test)]
Expand Down
11 changes: 11 additions & 0 deletions tooling/backend_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod proof_system;
mod smart_contract;

use acvm::acir::circuit::Opcode;
use acvm::acir::BlackBoxFunc;
use bb_abstraction_leaks::ACVM_BACKEND_BARRETENBERG;
use bb_abstraction_leaks::BB_VERSION;
use cli::VersionCommand;
Expand Down Expand Up @@ -141,6 +142,16 @@ pub struct BackendOpcodeSupport {
}

impl BackendOpcodeSupport {
pub fn all_opcodes_supported() -> Self {
BackendOpcodeSupport {
opcodes: vec!["arithmetic", "directive", "brillig", "memory_init", "memory_op"]
.into_iter()
.map(|s| s.to_string())
.collect(),
black_box_functions: BlackBoxFunc::all_blackbox_functions().into_iter().collect(),
}
}

pub fn is_opcode_supported(&self, opcode: &Opcode) -> bool {
match opcode {
Opcode::Arithmetic(_) => self.opcodes.contains("arithmetic"),
Expand Down
11 changes: 10 additions & 1 deletion tooling/nargo_cli/src/cli/compile_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub(crate) struct CompileCommand {
#[arg(long)]
include_keys: bool,

/// Compile without a backend
#[clap(long, default_value = "false", hide = true)]
no_backend: bool,

/// The name of the package to compile
#[clap(long, conflicts_with = "workspace")]
package: Option<CrateName>,
Expand Down Expand Up @@ -76,7 +80,12 @@ pub(crate) fn run(
.cloned()
.partition(|package| package.is_binary());

let (np_language, opcode_support) = backend.get_backend_info()?;
let (np_language, opcode_support) = if args.no_backend {
(Language::PLONKCSat { width: 3 }, BackendOpcodeSupport::all_opcodes_supported())
} else {
backend.get_backend_info()?
};

let (_, compiled_contracts) = compile_workspace(
&workspace,
&binary_packages,
Expand Down
13 changes: 12 additions & 1 deletion tooling/nargo_cli/src/cli/execute_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use acvm::acir::native_types::WitnessMap;
use acvm::Language;
use backend_interface::BackendOpcodeSupport;
use clap::Args;

use nargo::artifacts::debug::DebugArtifact;
Expand All @@ -24,6 +26,10 @@ pub(crate) struct ExecuteCommand {
/// Write the execution witness to named file
witness_name: Option<String>,

/// Compile without a backend
#[clap(long, default_value = "false", hide = true)]
no_backend: bool,

/// The name of the toml file which contains the inputs for the prover
#[clap(long, short, default_value = PROVER_INPUT_FILE)]
prover_name: String,
Expand Down Expand Up @@ -56,7 +62,12 @@ pub(crate) fn run(
)?;
let target_dir = &workspace.target_directory_path();

let (np_language, opcode_support) = backend.get_backend_info()?;
let (np_language, opcode_support) = if args.no_backend {
(Language::PLONKCSat { width: 3 }, BackendOpcodeSupport::all_opcodes_supported())
} else {
backend.get_backend_info()?
};

for package in &workspace {
let compiled_program = compile_bin_package(
&workspace,
Expand Down
2 changes: 1 addition & 1 deletion tooling/nargo_cli/tests/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ for dir in $base_path/*; do
if [ -d ./target/ ]; then
rm -r ./target/
fi
nargo compile && nargo execute witness
nargo compile --no-backend && nargo execute --no-backend witness

# Rename witness.tr to witness.gz
if [ -f ./target/witness.tr ]; then
Expand Down