Fix NixOS vendoring issue (#409)

This commit is contained in:
Artur Yurii Korchynskyi 2024-03-15 23:49:33 +02:00 committed by GitHub
parent 43a13f37ee
commit f345b66f53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 29 additions and 25 deletions

2
.gitignore vendored
View File

@ -21,3 +21,5 @@ build/
# ccls cache dir
.ccls-cache/
target

View File

@ -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"]
@ -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 }
@ -47,5 +52,6 @@ cc = "1.0"
glob = "0.3"
[[bench]]
path = "bindings/rust/benches/kzg_benches.rs"
name = "kzg_benches"
harness = false

View File

@ -1 +0,0 @@
target/

View File

@ -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());

View File

@ -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");
@ -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"),

View File

@ -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)
@ -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)
@ -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)
@ -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)
@ -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)
@ -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)