-
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/optimize-constant-div
* master: feat: implement euclidean division and signed division in terms of `AcirVar`s (#3230) feat: replace boolean range constraints with arithmetic opcodes (#3234) feat!: Switch to new pedersen implementation (#3151) feat: noir-wasm takes dependency graph (#3213) chore(docs): Rearrange NoirJS section (#3260) chore(docs): Document `nargo fmt` (#3262) feat(debugger): Print limited source code context (#3217) fix: recompile artefacts from a different noir version (#3248) chore: Update ACIR artifacts (#3263) fix: Show println output before an error occurs in `nargo execute` (#3211) chore(docs): document info codelens (#3252) fix: Impl methods are no longer placed in contracts (#3255) feat(stdlib): optimize constraint counts in sha256/sha512 (#3253) chore: enhance code formatting for If expressions (#3246) feat: Cache debug artifacts (#3133)
- Loading branch information
Showing
126 changed files
with
1,438 additions
and
595 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
Oops, something went wrong.