Skip to content

feat: Incorporate dummy backend for bb.js [DO NOT MERGE]#1491

Closed
vezenovm wants to merge 48 commits intomasterfrom
mv/dummy-backend
Closed

feat: Incorporate dummy backend for bb.js [DO NOT MERGE]#1491
vezenovm wants to merge 48 commits intomasterfrom
mv/dummy-backend

Conversation

@vezenovm
Copy link
Copy Markdown
Contributor

@vezenovm vezenovm commented Jun 1, 2023

Description

Problem*

Resolves #1489

Summary*

The relevant ACVM rev that is updated to in this PR:
noir-lang/acvm#291
The updated acvm-backend-barretenberg:
noir-lang/acvm-backend-barretenberg#207

This PR sets out to enable compilation of ACIR circuits and witness generation in a format the bb.js expects. nargo built with the bb_js feature flag should only use the compile and execute commands as the rest are unimplemented. Until bb.js is fully integrated to nargo and/or fully dynamic backends are ready the other commands will not be usable with bb.js. This is an experimental feature and should only be used by advanced users comfortable with downloading from source and escaping from the normal nargo workflow.

Example

Before:

You could call cargo install --path=crates/nargo_cli to use nargo with the native acvm-backend-barretenberg. Addtional flags of --no-default-features --features=plonk_bn254_wasm would enable compilation with a wasm target.

Users can then use nargo commands to not only compile, but prove and verify their circuits such as with nargo prove p --verify.

After:

The previous commands work the same as before. However, adding the flags --no-default-features --features=bb_js will let a user compile a Noir circuit and generate a witness to file in the format that bb.js expects. However, proving and verifying will be done with bb.js. Binaries are being released for bb.js. Once someone has bb.js installed globally they can use it according to its CLI.

To prove and verify w/ bb.js the following command can be run over a compiled circuit and witness:
bb.js prove_and_verify -j ./target/c.json -w ./target/witness.tr

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@vezenovm vezenovm marked this pull request as ready for review June 6, 2023 19:24
@vezenovm vezenovm requested review from kevaundray and kobyhallx June 6, 2023 19:24
Comment thread crates/nargo/src/artifacts/mod.rs Outdated
where
S: Serializer,
{
println!("CUR WIT IDX: {:?}", circuit.current_witness_index);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove println

Comment thread crates/nargo/src/artifacts/mod.rs Outdated
let cs: ConstraintSystem =
ConstraintSystem::try_from(circuit).expect("should have no malformed bb funcs");
let circuit_bytes = cs.to_bytes();
println!("{:?}", circuit_bytes.capacity());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment thread crates/nargo/src/artifacts/mod.rs Outdated
where
D: Deserializer<'de>,
{
// panic!("Not supported");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

termcolor = "1.1.2"
color-eyre = "0.6.2"
tokio = "1.0"
tokio = { version = "1.0.0", features = ["rt"] }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the rt feature needed?

Comment thread crates/nargo_cli/src/cli/fs/witness.rs Outdated
@@ -1,19 +1,23 @@
use std::path::{Path, PathBuf};

// use noirc_abi::WitnessMap;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented out code

Comment thread Cargo.toml
noirc_evaluator = { path = "crates/noirc_evaluator" }
noirc_frontend = { path = "crates/noirc_frontend" }
noir_wasm = { path = "crates/wasm" }
base64 = "0.13"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you put a comment saying that this is only needed for the bb_js hack

@kevaundray
Copy link
Copy Markdown
Contributor

Can you merge master into this, so the diff is cleaner?

@TomAFrench TomAFrench closed this Sep 4, 2023
@TomAFrench TomAFrench deleted the mv/dummy-backend branch November 20, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(bb.js): Incorporate dummy backend to nargo that can interop with bb.js

4 participants