Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 0 additions & 6 deletions .github/workflows/publish-acvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.ACVM_CRATES_IO_TOKEN }}

- name: Publish acvm_stdlib
run: |
cargo publish --package acvm_stdlib
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.ACVM_CRATES_IO_TOKEN }}

- name: Publish brillig_vm
run: |
cargo publish --package brillig_vm
Expand Down
8 changes: 0 additions & 8 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ members = [
"acvm-repo/acir",
"acvm-repo/acvm",
"acvm-repo/acvm_js",
"acvm-repo/stdlib",
"acvm-repo/brillig",
"acvm-repo/brillig_vm",
"acvm-repo/blackbox_solver",
Expand All @@ -53,7 +52,6 @@ repository = "https://github.com/noir-lang/noir/"
acir_field = { version = "0.37.0", path = "acvm-repo/acir_field", default-features = false }
acir = { version = "0.37.0", path = "acvm-repo/acir", default-features = false }
acvm = { version = "0.37.0", path = "acvm-repo/acvm" }
stdlib = { version = "0.37.0", package = "acvm_stdlib", path = "acvm-repo/stdlib", default-features = false }
brillig = { version = "0.37.0", path = "acvm-repo/brillig", default-features = false }
brillig_vm = { version = "0.37.0", path = "acvm-repo/brillig_vm", default-features = false }
acvm_blackbox_solver = { version = "0.37.0", path = "acvm-repo/blackbox_solver", default-features = false }
Expand Down
3 changes: 0 additions & 3 deletions acvm-repo/acir/src/circuit/black_box_functions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
//! Black box functions are ACIR opcodes which rely on backends implementing support for specialized constraints.
//! This makes certain zk-snark unfriendly computations cheaper than if they were implemented in more basic constraints.
//!
//! It is possible to fallback to less efficient implementations written in ACIR in some cases.
//! These are implemented inside the ACVM stdlib.

use serde::{Deserialize, Serialize};
#[cfg(test)]
Expand Down
26 changes: 0 additions & 26 deletions acvm-repo/acir/src/circuit/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ pub enum Opcode {
},
}

#[derive(Clone, PartialEq, Eq, Debug)]
pub enum UnsupportedMemoryOpcode {
MemoryOp,
MemoryInit,
}

impl std::fmt::Display for UnsupportedMemoryOpcode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
UnsupportedMemoryOpcode::MemoryOp => write!(f, "MemoryOp"),
UnsupportedMemoryOpcode::MemoryInit => write!(f, "MemoryInit"),
}
}
}

impl Opcode {
// TODO We can add a domain separator by doing something like:
// TODO concat!("directive:", directive.name)
Expand All @@ -62,17 +47,6 @@ impl Opcode {
}
}

pub fn unsupported_opcode(&self) -> UnsupportedMemoryOpcode {
match self {
Opcode::MemoryOp { .. } => UnsupportedMemoryOpcode::MemoryOp,
Opcode::MemoryInit { .. } => UnsupportedMemoryOpcode::MemoryInit,
Opcode::BlackBoxFuncCall(_) => {
unreachable!("Unsupported Blackbox function should not be reported here")
}
_ => unreachable!("Opcode is supported"),
}
}

pub fn is_arithmetic(&self) -> bool {
matches!(self, Opcode::Arithmetic(_))
}
Expand Down
7 changes: 1 addition & 6 deletions acvm-repo/acvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,23 @@ num-traits.workspace = true
thiserror.workspace = true

acir.workspace = true
stdlib.workspace = true
brillig_vm.workspace = true
acvm_blackbox_solver.workspace = true

indexmap = "1.7.0"

[features]
default = ["bn254", "testing"]
default = ["bn254"]
bn254 = [
"acir/bn254",
"stdlib/bn254",
"brillig_vm/bn254",
"acvm_blackbox_solver/bn254",
]
bls12_381 = [
"acir/bls12_381",
"stdlib/bls12_381",
"brillig_vm/bls12_381",
"acvm_blackbox_solver/bls12_381",
]
testing = ["stdlib/testing", "unstable-fallbacks"]
unstable-fallbacks = []

[dev-dependencies]
rand = "0.8.5"
Expand Down
24 changes: 4 additions & 20 deletions acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use acir::{
circuit::{opcodes::UnsupportedMemoryOpcode, Circuit, Opcode, OpcodeLocation},
BlackBoxFunc,
};
use thiserror::Error;
use acir::circuit::{Circuit, OpcodeLocation};

use crate::Language;

Expand All @@ -15,14 +11,6 @@ use optimizers::optimize_internal;
pub use transformers::transform;
use transformers::transform_internal;

#[derive(PartialEq, Eq, Debug, Error)]
pub enum CompileError {
#[error("The blackbox function {0} is not supported by the backend and acvm does not have a fallback implementation")]
UnsupportedBlackBox(BlackBoxFunc),
#[error("The opcode {0} is not supported by the backend and acvm does not have a fallback implementation")]
UnsupportedMemoryOpcode(UnsupportedMemoryOpcode),
}

/// This module moves and decomposes acir opcodes. The transformation map allows consumers of this module to map
/// metadata they had about the opcodes to the new opcode structure generated after the transformation.
#[derive(Debug)]
Expand Down Expand Up @@ -69,17 +57,13 @@ fn transform_assert_messages(
}

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`].
pub fn compile(
acir: Circuit,
np_language: Language,
is_opcode_supported: impl Fn(&Opcode) -> bool,
) -> Result<(Circuit, AcirTransformationMap), CompileError> {
pub fn compile(acir: Circuit, np_language: Language) -> (Circuit, AcirTransformationMap) {
let (acir, AcirTransformationMap { acir_opcode_positions }) = optimize_internal(acir);

let (mut acir, transformation_map) =
transform_internal(acir, np_language, is_opcode_supported, acir_opcode_positions)?;
transform_internal(acir, np_language, acir_opcode_positions);

acir.assert_messages = transform_assert_messages(acir.assert_messages, &transformation_map);

Ok((acir, transformation_map))
(acir, transformation_map)
}
158 changes: 0 additions & 158 deletions acvm-repo/acvm/src/compiler/transformers/fallback.rs

This file was deleted.

25 changes: 7 additions & 18 deletions acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,25 @@ use indexmap::IndexMap;
use crate::Language;

mod csat;
mod fallback;
mod r1cs;

pub(crate) use csat::CSatTransformer;
pub(crate) use fallback::FallbackTransformer;
pub(crate) use r1cs::R1CSTransformer;

use super::{transform_assert_messages, AcirTransformationMap, CompileError};
use super::{transform_assert_messages, AcirTransformationMap};

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`].
pub fn transform(
acir: Circuit,
np_language: Language,
is_opcode_supported: impl Fn(&Opcode) -> bool,
) -> Result<(Circuit, AcirTransformationMap), CompileError> {
pub fn transform(acir: Circuit, np_language: Language) -> (Circuit, AcirTransformationMap) {
// Track original acir opcode positions throughout the transformation passes of the compilation
// by applying the modifications done to the circuit opcodes and also to the opcode_positions (delete and insert)
let acir_opcode_positions = acir.opcodes.iter().enumerate().map(|(i, _)| i).collect();

let (mut acir, transformation_map) =
transform_internal(acir, np_language, is_opcode_supported, acir_opcode_positions)?;
transform_internal(acir, np_language, acir_opcode_positions);

acir.assert_messages = transform_assert_messages(acir.assert_messages, &transformation_map);

Ok((acir, transformation_map))
(acir, transformation_map)
}

/// Applies [`ProofSystemCompiler`][crate::ProofSystemCompiler] specific optimizations to a [`Circuit`].
Expand All @@ -41,18 +35,13 @@ pub fn transform(
pub(super) fn transform_internal(
acir: Circuit,
np_language: Language,
is_opcode_supported: impl Fn(&Opcode) -> bool,
acir_opcode_positions: Vec<usize>,
) -> Result<(Circuit, AcirTransformationMap), CompileError> {
// Fallback transformer pass
let (acir, acir_opcode_positions) =
FallbackTransformer::transform(acir, is_opcode_supported, acir_opcode_positions)?;

) -> (Circuit, AcirTransformationMap) {
let mut transformer = match &np_language {
crate::Language::R1CS => {
let transformation_map = AcirTransformationMap { acir_opcode_positions };
let transformer = R1CSTransformer::new(acir);
return Ok((transformer.transform(), transformation_map));
return (transformer.transform(), transformation_map);
}
crate::Language::PLONKCSat { width } => {
let mut csat = CSatTransformer::new(*width);
Expand Down Expand Up @@ -217,5 +206,5 @@ pub(super) fn transform_internal(
let transformation_map =
AcirTransformationMap { acir_opcode_positions: new_acir_opcode_positions };

Ok((acir, transformation_map))
(acir, transformation_map)
}
Loading