From 541d64d68febd19254dd9b1c69a2241c6752c259 Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 11 Jan 2022 12:40:52 +0100 Subject: [PATCH 1/8] update git2 dependency --- Cargo.lock | 8 ++++---- zokrates_core/Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b46577108..1afa62d6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1121,9 +1121,9 @@ checksum = "f0a01e0497841a3b2db4f8afa483cce65f7e96a3498bd6c541734792aeac8fe7" [[package]] name = "git2" -version = "0.13.23" +version = "0.13.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8057932925d3a9d9e4434ea016570d37420ddb1ceed45a174d577f24ed6700" +checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" dependencies = [ "bitflags", "libc", @@ -1246,9 +1246,9 @@ checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce" [[package]] name = "libgit2-sys" -version = "0.12.24+1.3.0" +version = "0.12.26+1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c" +checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" dependencies = [ "cc", "libc", diff --git a/zokrates_core/Cargo.toml b/zokrates_core/Cargo.toml index 194b9b21a..07184a7ea 100644 --- a/zokrates_core/Cargo.toml +++ b/zokrates_core/Cargo.toml @@ -66,4 +66,4 @@ zokrates_fs_resolver = { version = "0.5", path = "../zokrates_fs_resolver"} [build-dependencies] cc = { version = "1.0", features = ["parallel"], optional = true } cmake = { version = "=0.1.45", optional = true } -git2 = { version = "0.13.1", optional = true } +git2 = { version = "0.13.25", optional = true } From 0ad4bbef9f1e0e9162fb03735e0323d478f58e16 Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 11 Jan 2022 12:51:37 +0100 Subject: [PATCH 2/8] update libsnark --- zokrates_core/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index 4c8e53795..eac791b4f 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -14,8 +14,8 @@ fn main() { use std::path::PathBuf; // fetch libsnark source - const LIBSNARK_URL: &'static str = "https://github.com/scipr-lab/libsnark.git"; - const LIBSNARK_COMMIT: &'static str = "f7c87b88744ecfd008126d415494d9b34c4c1b20"; + const LIBSNARK_URL: &'static str = "https://github.com/dark64/libsnark.git"; + const LIBSNARK_COMMIT: &'static str = "a38294cf04e80de32c2fb8b312557188315605cb"; let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let libsnark_source_path = &out_path.join("libsnark"); From 97f2b96328e33f6902106b3808263a00f24e6444 Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 11 Jan 2022 15:38:34 +0100 Subject: [PATCH 3/8] update build.rs --- zokrates_core/build.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index eac791b4f..1dc61fb35 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -26,10 +26,13 @@ fn main() { }); let commit = Oid::from_str(LIBSNARK_COMMIT).unwrap(); - let commit = repo.find_commit(commit).unwrap(); + let head = repo.head().unwrap(); - repo.reset(&commit.as_object(), ResetType::Hard, None) - .unwrap(); + if commit.ne(&head.target().unwrap()) { + let commit = repo.find_commit(commit).unwrap(); + repo.reset(&commit.as_object(), ResetType::Hard, None) + .unwrap(); + } for mut s in repo.submodules().unwrap() { s.update(true, None).unwrap(); From da4b80db21f624907c7bed396c5bf2255f378bd1 Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 11 Jan 2022 16:03:07 +0100 Subject: [PATCH 4/8] checkout head --- zokrates_core/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index 1dc61fb35..0298201a7 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -25,6 +25,8 @@ fn main() { Repository::clone(LIBSNARK_URL, libsnark_source_path).unwrap() }); + repo.checkout_head(None).unwrap(); + let commit = Oid::from_str(LIBSNARK_COMMIT).unwrap(); let head = repo.head().unwrap(); From ac3786d0ccf4a6a17a18dafe58b9291b2dc01087 Mon Sep 17 00:00:00 2001 From: dark64 Date: Tue, 11 Jan 2022 16:16:42 +0100 Subject: [PATCH 5/8] update build.rs --- zokrates_core/build.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index 0298201a7..64bb40e49 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -25,16 +25,8 @@ fn main() { Repository::clone(LIBSNARK_URL, libsnark_source_path).unwrap() }); - repo.checkout_head(None).unwrap(); - - let commit = Oid::from_str(LIBSNARK_COMMIT).unwrap(); - let head = repo.head().unwrap(); - - if commit.ne(&head.target().unwrap()) { - let commit = repo.find_commit(commit).unwrap(); - repo.reset(&commit.as_object(), ResetType::Hard, None) - .unwrap(); - } + let (object, _) = repo.revparse_ext(LIBSNARK_COMMIT).unwrap(); + repo.checkout_tree(&object, None).unwrap(); for mut s in repo.submodules().unwrap() { s.update(true, None).unwrap(); From eaa22643c24edc630d73e16c97c68cf80f593541 Mon Sep 17 00:00:00 2001 From: dark64 Date: Wed, 12 Jan 2022 08:57:29 +0100 Subject: [PATCH 6/8] remove unused imports --- zokrates_core/build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index 64bb40e49..82d0c96d7 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -8,7 +8,7 @@ extern crate git2; fn main() { #[cfg(feature = "libsnark")] { - use git2::{Oid, Repository, ResetType}; + use git2::Repository; use std::env; use std::fs::remove_dir; use std::path::PathBuf; @@ -25,7 +25,7 @@ fn main() { Repository::clone(LIBSNARK_URL, libsnark_source_path).unwrap() }); - let (object, _) = repo.revparse_ext(LIBSNARK_COMMIT).unwrap(); + let object = repo.revparse_single(LIBSNARK_COMMIT).unwrap(); repo.checkout_tree(&object, None).unwrap(); for mut s in repo.submodules().unwrap() { From 297af89ca2387923d488e880ac806462b896628e Mon Sep 17 00:00:00 2001 From: dark64 Date: Wed, 12 Jan 2022 09:40:03 +0100 Subject: [PATCH 7/8] use cache version from env in ci --- .circleci/config.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8007b279b..2e682aa29 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,7 +23,7 @@ jobs: command: cargo generate-lockfile - restore_cache: keys: - - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }} - run: name: Build command: WITH_LIBSNARK=1 RUSTFLAGS="-D warnings" ./build.sh @@ -33,7 +33,7 @@ jobs: - target/debug/.fingerprint - target/debug/build - target/debug/deps - key: v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + key: cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }} test: docker: - image: zokrates/env:latest @@ -48,7 +48,7 @@ jobs: command: cargo generate-lockfile - restore_cache: keys: - - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }} - run: name: Check format command: cargo fmt --all -- --check @@ -82,7 +82,7 @@ jobs: command: cargo generate-lockfile - restore_cache: keys: - - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }} - run: name: Test on firefox command: | @@ -103,7 +103,7 @@ jobs: command: cargo generate-lockfile - restore_cache: keys: - - v4-cargo-cache-{{ arch }}-{{ checksum "Cargo.lock" }} + - cargo-cache-{{ .Environment.CACHE_VERSION }}-{{ arch }}-{{ checksum "Cargo.lock" }} - run: name: Run integration tests no_output_timeout: "30m" From be9d784a84a1ea1077a9fc5e9a3f530a5403e73a Mon Sep 17 00:00:00 2001 From: dark64 Date: Wed, 12 Jan 2022 10:55:48 +0100 Subject: [PATCH 8/8] patch submodule urls --- zokrates_core/build.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/zokrates_core/build.rs b/zokrates_core/build.rs index 82d0c96d7..8d281b522 100644 --- a/zokrates_core/build.rs +++ b/zokrates_core/build.rs @@ -14,8 +14,8 @@ fn main() { use std::path::PathBuf; // fetch libsnark source - const LIBSNARK_URL: &'static str = "https://github.com/dark64/libsnark.git"; - const LIBSNARK_COMMIT: &'static str = "a38294cf04e80de32c2fb8b312557188315605cb"; + const LIBSNARK_URL: &'static str = "https://github.com/scipr-lab/libsnark.git"; + const LIBSNARK_COMMIT: &'static str = "f7c87b88744ecfd008126d415494d9b34c4c1b20"; let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); let libsnark_source_path = &out_path.join("libsnark"); @@ -25,6 +25,15 @@ fn main() { Repository::clone(LIBSNARK_URL, libsnark_source_path).unwrap() }); + // Unencrypted `git://` protocol is no longer supported on GitHub + // so we replace all submodule urls to use `https://` + let gitmodules_path = libsnark_source_path.join(".gitmodules"); + let gitmodules = std::fs::read_to_string(&gitmodules_path) + .unwrap() + .replace("git://", "https://"); + + std::fs::write(&gitmodules_path, gitmodules).unwrap(); + let object = repo.revparse_single(LIBSNARK_COMMIT).unwrap(); repo.checkout_tree(&object, None).unwrap();