Skip to content

Commit

Permalink
Merge branch 'phated/acvm-0.12.0' into phated/witness-map
Browse files Browse the repository at this point in the history
* phated/acvm-0.12.0: (45 commits)
  chore!: Update to ACVM 0.12.0
  official release of backend
  feat: use dummy constructor for bb call
  chore: add missing `?`
  chore: use `try_vecmap` in old `vecmap` locations
  chore: update `acvm-backend-barretenberg` to 0.1.0 commit
  latest master
  fix: improve variable resolution
  test: re enabled sort test
  chore: update cargo tomls
  feat: adapted to heterogeneous bb calls
  remove unneeded import
  fix grep problems
  chore: replace long `Backend` type parameters with `B`
  update to latest commit
  chore: Make CliError generic over a Backend
  chore: Update nargo core to return backend errors
  chore!: Update to acvm 0.11.0
  chore(parser): Parser error optimisation (#1292)
  chore(ssa refactor): Implement function inlining (#1293)
  ...
  • Loading branch information
TomAFrench committed May 12, 2023
2 parents cfc8141 + 091fad1 commit aeeceda
Show file tree
Hide file tree
Showing 155 changed files with 2,711 additions and 1,038 deletions.
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Add/remove 'doc needed' label if issue/PR contains the line '- [x] This PR requires documentation updates when merged.'
"doc needed":
- '- \[x\] This PR requires documentation updates when merged.'
- '- \[(x|X)\] This PR requires documentation updates when merged.'
76 changes: 48 additions & 28 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "0.10.3"
acvm = "0.11.0"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand Down Expand Up @@ -52,4 +52,5 @@ wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] }
wasm-bindgen-test = "0.3.33"

[patch.crates-io]
acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "46c645233228c35bc22b6eb5fb5d1d3c0a33d507" }
acvm = { package = "acvm", git = "https://github.com/noir-lang/acvm", rev = "b248e606dd69c25d33ae77c5c5c0541adbf80cd6" }
acvm-backend-barretenberg = { git = "https://github.com/noir-lang/acvm-backend-barretenberg", rev = "030a7e7b9ba842f3d307dbab178962b63d0dedcf" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Noir is a Domain Specific Language for SNARK proving systems. It has been design

## Quick Start

Read the installation section [here](https://noir-lang.org/getting_started/nargo/nargo_installation).
Read the installation section [here](https://noir-lang.org/getting_started/nargo_installation).

Once you have read through the documentation, you can visit [Awesome Noir](https://github.com/noir-lang/awesome-noir) to run some of the examples that others have created.

Expand Down
10 changes: 4 additions & 6 deletions crates/nargo/src/ops/codegen_verifier.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use acvm::SmartContract;

use crate::NargoError;

pub fn codegen_verifier(
backend: &impl SmartContract,
pub fn codegen_verifier<B: SmartContract>(
backend: &B,
verification_key: &[u8],
) -> Result<String, NargoError> {
Ok(backend.eth_contract_from_vk(verification_key))
) -> Result<String, B::Error> {
backend.eth_contract_from_vk(verification_key)
}
6 changes: 4 additions & 2 deletions crates/nargo/src/ops/execute.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use acvm::pwg::PartialWitnessGeneratorStatus;
use acvm::PartialWitnessGenerator;
use acvm::{acir::circuit::Circuit, acir::native_types::WitnessMap, pwg::block::Blocks};
use acvm::{PartialWitnessGenerator, PartialWitnessGeneratorStatus};

use crate::NargoError;

Expand All @@ -9,7 +10,8 @@ pub fn execute_circuit(
mut initial_witness: WitnessMap,
) -> Result<WitnessMap, NargoError> {
let mut blocks = Blocks::default();
let solver_status = backend.solve(&mut initial_witness, &mut blocks, circuit.opcodes)?;
let solver_status =
acvm::pwg::solve(backend, &mut initial_witness, &mut blocks, circuit.opcodes)?;
if matches!(solver_status, PartialWitnessGeneratorStatus::RequiresOracleData { .. }) {
todo!("Add oracle support to nargo execute")
}
Expand Down
35 changes: 16 additions & 19 deletions crates/nargo/src/ops/preprocess.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use acvm::ProofSystemCompiler;
use iter_extended::vecmap;
use iter_extended::try_vecmap;
use noirc_driver::{CompiledContract, CompiledProgram};

use crate::{
artifacts::{
contract::{PreprocessedContract, PreprocessedContractFunction},
program::PreprocessedProgram,
},
NargoError,
use crate::artifacts::{
contract::{PreprocessedContract, PreprocessedContractFunction},
program::PreprocessedProgram,
};

// TODO: pull this from backend.
const BACKEND_IDENTIFIER: &str = "acvm-backend-barretenberg";

pub fn preprocess_program(
backend: &impl ProofSystemCompiler,
pub fn preprocess_program<B: ProofSystemCompiler>(
backend: &B,
compiled_program: CompiledProgram,
) -> Result<PreprocessedProgram, NargoError> {
) -> Result<PreprocessedProgram, B::Error> {
// TODO: currently `compiled_program`'s bytecode is already optimized for the backend.
// In future we'll need to apply those optimizations here.
let optimized_bytecode = compiled_program.circuit;
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode);
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?;

Ok(PreprocessedProgram {
backend: String::from(BACKEND_IDENTIFIER),
Expand All @@ -31,26 +28,26 @@ pub fn preprocess_program(
})
}

pub fn preprocess_contract(
backend: &impl ProofSystemCompiler,
pub fn preprocess_contract<B: ProofSystemCompiler>(
backend: &B,
compiled_contract: CompiledContract,
) -> Result<PreprocessedContract, NargoError> {
let preprocessed_contract_functions = vecmap(compiled_contract.functions, |func| {
) -> Result<PreprocessedContract, B::Error> {
let preprocessed_contract_functions = try_vecmap(compiled_contract.functions, |func| {
// TODO: currently `func`'s bytecode is already optimized for the backend.
// In future we'll need to apply those optimizations here.
let optimized_bytecode = func.bytecode;
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode);
let (proving_key, verification_key) = backend.preprocess(&optimized_bytecode)?;

PreprocessedContractFunction {
Ok(PreprocessedContractFunction {
name: func.name,
function_type: func.function_type,
abi: func.abi,

bytecode: optimized_bytecode,
proving_key,
verification_key,
}
});
})
})?;

Ok(PreprocessedContract {
name: compiled_contract.name,
Expand Down
12 changes: 4 additions & 8 deletions crates/nargo/src/ops/prove.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use acvm::acir::{circuit::Circuit, native_types::WitnessMap};
use acvm::ProofSystemCompiler;

use crate::NargoError;

pub fn prove_execution(
backend: &impl ProofSystemCompiler,
pub fn prove_execution<B: ProofSystemCompiler>(
backend: &B,
circuit: &Circuit,
solved_witness: WitnessMap,
proving_key: &[u8],
) -> Result<Vec<u8>, NargoError> {
let proof = backend.prove_with_pk(circuit, solved_witness, proving_key);

Ok(proof)
) -> Result<Vec<u8>, B::Error> {
backend.prove_with_pk(circuit, solved_witness, proving_key)
}
12 changes: 4 additions & 8 deletions crates/nargo/src/ops/verify.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use acvm::acir::{circuit::Circuit, native_types::WitnessMap};
use acvm::ProofSystemCompiler;

use crate::NargoError;

pub fn verify_proof(
backend: &impl ProofSystemCompiler,
pub fn verify_proof<B: ProofSystemCompiler>(
backend: &B,
circuit: &Circuit,
proof: &[u8],
public_inputs: WitnessMap,
verification_key: &[u8],
) -> Result<bool, NargoError> {
let valid_proof = backend.verify_with_vk(proof, public_inputs, circuit, verification_key);

Ok(valid_proof)
) -> Result<bool, B::Error> {
backend.verify_with_vk(proof, public_inputs, circuit, verification_key)
}
3 changes: 1 addition & 2 deletions crates/nargo_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ termcolor = "1.1.2"
color-eyre = "0.6.2"

# Backends
acvm-backend-barretenberg = { git = "https://github.com/noir-lang/aztec_backend", rev = "148521f851d22a1411b8491905585d3c77e22ee1", default-features = false }
acvm-backend-barretenberg = { version = "0.1.2", default-features = false }

[dev-dependencies]
tempdir = "0.3.7"
Expand All @@ -50,4 +50,3 @@ default = ["plonk_bn254"]
# The plonk backend can only use bn254, so we do not specify the field
plonk_bn254 = ["acvm-backend-barretenberg/native"]
plonk_bn254_wasm = ["acvm-backend-barretenberg/wasm"]

0 comments on commit aeeceda

Please sign in to comment.