-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tf/acir-var-euclid
* master: feat: replace boolean range constraints with arithmetic opcodes (#3234) feat!: Switch to new pedersen implementation (#3151) feat: noir-wasm takes dependency graph (#3213)
- Loading branch information
Showing
52 changed files
with
691 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,14 @@ | ||
use std::{ | ||
fs::File, | ||
io::{Cursor, Read}, | ||
path::{Path, PathBuf}, | ||
}; | ||
use std::path::PathBuf; | ||
|
||
const BARRETENBERG_ARCHIVE: &str = "BARRETENBERG_ARCHIVE"; | ||
const BARRETENBERG_BIN_DIR: &str = "BARRETENBERG_BIN_DIR"; | ||
|
||
const BARRETENBERG_ARCHIVE_FALLBACK: &str = "https://github.com/AztecProtocol/barretenberg/releases/download/barretenberg-v0.5.0/acvm_backend.wasm.tar.gz"; | ||
// const ARCHIVE_SHA256: &str = "1xpycikqlvsjcryi3hkbc4mwmmdz7zshw6f76vyf1qssq53asyfx"; | ||
|
||
fn unpack_wasm(archive_path: &Path, target_dir: &Path) -> Result<(), String> { | ||
if archive_path.exists() && archive_path.is_file() { | ||
let archive = File::open(archive_path).map_err(|_| "Could not read archive")?; | ||
unpack_archive(archive, target_dir); | ||
|
||
Ok(()) | ||
} else { | ||
Err(format!("Unable to locate {BARRETENBERG_ARCHIVE} - Please set the BARRETENBERG_BIN_DIR env var to the directory where it exists, or ensure it's located at {}", archive_path.display())) | ||
} | ||
} | ||
|
||
fn unpack_archive<T: Read>(archive: T, target_dir: &Path) { | ||
use flate2::read::GzDecoder; | ||
use tar::Archive; | ||
|
||
let gz_decoder = GzDecoder::new(archive); | ||
let mut archive = Archive::new(gz_decoder); | ||
|
||
archive.unpack(target_dir).unwrap(); | ||
} | ||
|
||
/// Try to download the specified URL into a buffer which is returned. | ||
fn download_binary_from_url(url: &str) -> Result<Cursor<Vec<u8>>, String> { | ||
let response = reqwest::blocking::get(url).map_err(|error| error.to_string())?; | ||
|
||
let bytes = response.bytes().unwrap(); | ||
Ok(Cursor::new(bytes.to_vec())) | ||
} | ||
|
||
fn main() -> Result<(), String> { | ||
let out_dir = std::env::var("OUT_DIR").unwrap(); | ||
|
||
match std::env::var(BARRETENBERG_ARCHIVE) { | ||
Ok(archive_path) => { | ||
unpack_wasm(&PathBuf::from(archive_path), &PathBuf::from(&out_dir))?; | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
Ok(()) | ||
} | ||
Err(_) => { | ||
let wasm_bytes = download_binary_from_url(BARRETENBERG_ARCHIVE_FALLBACK) | ||
.expect("download should succeed"); | ||
let dest_path = PathBuf::from(out_dir.clone()).join("acvm_backend.wasm"); | ||
|
||
unpack_archive(wasm_bytes, &PathBuf::from(&out_dir)); | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
println!("cargo:rustc-env={BARRETENBERG_BIN_DIR}={out_dir}"); | ||
std::fs::copy("./src/acvm_backend.wasm", dest_path).unwrap(); | ||
|
||
Ok(()) | ||
} | ||
} | ||
Ok(()) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name="lib_a" | ||
type="lib" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] | ||
lib_b = { path = "../lib-b" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
use dep::lib_b::assert_non_zero; | ||
|
||
pub fn divide(a: u64, b: u64) -> u64 { | ||
assert_non_zero(b); | ||
a / b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name="lib_b" | ||
type="lib" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
pub fn assert_non_zero(x: u64) { | ||
assert(x != 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name="noir_wasm_testing" | ||
type="bin" | ||
authors = [""] | ||
compiler_version = "0.1" | ||
|
||
[dependencies] | ||
lib_a = { path="../lib-a" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use dep::lib_a::divide; | ||
fn main(x : u64, y : pub u64) { | ||
divide(x, y); | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.