Skip to content

Commit

Permalink
Fix NixOS vendoring issue (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
akorchyn authored Mar 15, 2024
1 parent 43a13f3 commit f345b66
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ build/

# ccls cache dir
.ccls-cache/

target
File renamed without changes.
8 changes: 7 additions & 1 deletion bindings/rust/Cargo.toml → Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ license = "Apache-2.0"
links = "ckzg"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
include = ["src", "inc", "bindings/rust/src", "bindings/rust/build.rs", "blst/bindings/*.h"]
build = "bindings/rust/build.rs"

[lib]
path = "bindings/rust/src/lib.rs"

[features]
default = ["std", "portable"]
Expand Down Expand Up @@ -36,8 +41,8 @@ criterion = "0.5.1"
glob = "0.3.1"
rand = "0.8.5"
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.9.17"
serde_json = "1.0.105"
serde_yaml = "0.9.17"

[build-dependencies]
bindgen = { version = "0.69", optional = true }
Expand All @@ -47,5 +52,6 @@ cc = "1.0"
glob = "0.3"

[[bench]]
path = "bindings/rust/benches/kzg_benches.rs"
name = "kzg_benches"
harness = false
1 change: 0 additions & 1 deletion bindings/rust/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion bindings/rust/benches/kzg_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn generate_random_blob(rng: &mut ThreadRng) -> Blob {
pub fn criterion_benchmark(c: &mut Criterion) {
let max_count: usize = 64;
let mut rng = rand::thread_rng();
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = Arc::new(KzgSettings::load_trusted_setup_file(trusted_setup_file).unwrap());

Expand Down
15 changes: 6 additions & 9 deletions bindings/rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use std::env;
use std::path::PathBuf;
use std::{env, path::PathBuf};

fn main() {
let cargo_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let root_dir = cargo_dir
.parent()
.expect("rust dir is nested")
.parent()
.expect("bindings dir is nested");
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());

// Obtain the header files of blst
let blst_base_dir = root_dir.join("blst");
Expand Down Expand Up @@ -37,7 +31,10 @@ fn main() {
#[cfg(feature = "generate-bindings")]
{
let header_path = c_src_dir.join("c_kzg_4844.h");
let bindings_out_path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/bindings/generated.rs");
let bindings_out_path = concat!(
env!("CARGO_MANIFEST_DIR"),
"/bindings/rust/src/bindings/generated.rs"
);
make_bindings(
header_path.to_str().expect("valid header path"),
blst_headers_dir.to_str().expect("valid blst header path"),
Expand Down
26 changes: 13 additions & 13 deletions bindings/rust/src/bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,20 +648,20 @@ mod tests {

#[test]
fn test_end_to_end() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
test_simple(trusted_setup_file);
}

const BLOB_TO_KZG_COMMITMENT_TESTS: &str = "../../tests/blob_to_kzg_commitment/*/*/*";
const COMPUTE_KZG_PROOF_TESTS: &str = "../../tests/compute_kzg_proof/*/*/*";
const COMPUTE_BLOB_KZG_PROOF_TESTS: &str = "../../tests/compute_blob_kzg_proof/*/*/*";
const VERIFY_KZG_PROOF_TESTS: &str = "../../tests/verify_kzg_proof/*/*/*";
const VERIFY_BLOB_KZG_PROOF_TESTS: &str = "../../tests/verify_blob_kzg_proof/*/*/*";
const VERIFY_BLOB_KZG_PROOF_BATCH_TESTS: &str = "../../tests/verify_blob_kzg_proof_batch/*/*/*";
const BLOB_TO_KZG_COMMITMENT_TESTS: &str = "tests/blob_to_kzg_commitment/*/*/*";
const COMPUTE_KZG_PROOF_TESTS: &str = "tests/compute_kzg_proof/*/*/*";
const COMPUTE_BLOB_KZG_PROOF_TESTS: &str = "tests/compute_blob_kzg_proof/*/*/*";
const VERIFY_KZG_PROOF_TESTS: &str = "tests/verify_kzg_proof/*/*/*";
const VERIFY_BLOB_KZG_PROOF_TESTS: &str = "tests/verify_blob_kzg_proof/*/*/*";
const VERIFY_BLOB_KZG_PROOF_BATCH_TESTS: &str = "tests/verify_blob_kzg_proof_batch/*/*/*";

#[test]
fn test_blob_to_kzg_commitment() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(BLOB_TO_KZG_COMMITMENT_TESTS)
Expand All @@ -687,7 +687,7 @@ mod tests {

#[test]
fn test_compute_kzg_proof() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(COMPUTE_KZG_PROOF_TESTS)
Expand Down Expand Up @@ -716,7 +716,7 @@ mod tests {

#[test]
fn test_compute_blob_kzg_proof() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(COMPUTE_BLOB_KZG_PROOF_TESTS)
Expand All @@ -743,7 +743,7 @@ mod tests {

#[test]
fn test_verify_kzg_proof() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(VERIFY_KZG_PROOF_TESTS)
Expand Down Expand Up @@ -774,7 +774,7 @@ mod tests {

#[test]
fn test_verify_blob_kzg_proof() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(VERIFY_BLOB_KZG_PROOF_TESTS)
Expand Down Expand Up @@ -804,7 +804,7 @@ mod tests {

#[test]
fn test_verify_blob_kzg_proof_batch() {
let trusted_setup_file = Path::new("../../src/trusted_setup.txt");
let trusted_setup_file = Path::new("src/trusted_setup.txt");
assert!(trusted_setup_file.exists());
let kzg_settings = KZGSettings::load_trusted_setup_file(trusted_setup_file).unwrap();
let test_files: Vec<PathBuf> = glob::glob(VERIFY_BLOB_KZG_PROOF_BATCH_TESTS)
Expand Down

0 comments on commit f345b66

Please sign in to comment.