Skip to content

Commit

Permalink
Merge pull request #257 from ArtiomTr/Bump-c-kzg-4844-commit
Browse files Browse the repository at this point in the history
Bump C_KZG_4844_GIT_HASH
  • Loading branch information
sauliusgrigaitis authored Jan 26, 2024
2 parents 86c23f4 + d8e03ae commit 33989b7
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: benchmarks
on: [push, pull_request, workflow_dispatch]
env:
C_KZG_4844_GIT_HASH: '624aa60d01da524827123506975431aa5454c80d'
C_KZG_4844_GIT_HASH: '5115420ba3f919f5501155ba18633667001b6a07'

jobs:
benchmarks:
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: tests
on: [push, pull_request, workflow_dispatch]
env:
C_KZG_4844_GIT_HASH: '624aa60d01da524827123506975431aa5454c80d'
C_KZG_4844_GIT_HASH: '5115420ba3f919f5501155ba18633667001b6a07'

jobs:
tests:
Expand Down Expand Up @@ -48,10 +48,9 @@ jobs:
distribution: "temurin"
java-version: "11"

- if: matrix.backend == 'constantine'
uses: jiro4989/setup-nim-action@v1
- uses: jiro4989/setup-nim-action@v1
with:
nim-version: '1.6.14'
nim-version: '2.0.2'

- uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
workflow_dispatch:

env:
C_KZG_4844_GIT_HASH: '624aa60d01da524827123506975431aa5454c80d'
C_KZG_4844_GIT_HASH: '5115420ba3f919f5501155ba18633667001b6a07'

jobs:
release-build:
Expand Down
35 changes: 35 additions & 0 deletions arkworks/nim.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From f34d21606bb5bc3dee4e7a643d7ab89a2c994fef Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 25 Jan 2024 11:26:35 +0200
Subject: [PATCH] Patch nim bindings

---
bindings/nim/kzg_abi.nim | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bindings/nim/kzg_abi.nim b/bindings/nim/kzg_abi.nim
index 36e4ba1..74d0ebc 100644
--- a/bindings/nim/kzg_abi.nim
+++ b/bindings/nim/kzg_abi.nim
@@ -10,6 +10,7 @@ from os import DirSep, AltSep
const
# kzgPath: c-kzg-4844 project path, removing 3 last elem
kzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/"
+ rustKzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 5)[0] & "/"
blstPath = kzgPath & "blst/"
srcPath = kzgPath & "src/"
bindingsPath = blstPath & "bindings"
@@ -20,7 +21,9 @@ when not defined(kzgExternalBlst):
{.compile: blstPath & "src/server.c"}
{.passc: "-D__BLST_PORTABLE__"}

-{.compile: srcPath & "c_kzg_4844.c"}
+{.passl: "-L" & rustKzgPath & "target/release" .}
+{.passl: "-l:rust_kzg_arkworks.a" .}
+{.passl: "-lm" .}

{.passc: "-I" & bindingsPath .}
{.passc: "-I" & srcPath .}
--
2.34.1

29 changes: 10 additions & 19 deletions arkworks/rust.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From c3d4cb77f5a797bd8f454a0d88e034391514ebd7 Mon Sep 17 00:00:00 2001
From e7d529a9ba017de920555ae9b4ab05a18174cdcf Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 26 Oct 2023 13:46:19 +0300
Subject: [PATCH] Patch rust binding
Date: Thu, 25 Jan 2024 11:42:12 +0200
Subject: [PATCH] Patch rust bindings

---
bindings/rust/Cargo.toml | 1 +
bindings/rust/build.rs | 29 +++++------------------------
2 files changed, 6 insertions(+), 24 deletions(-)
bindings/rust/build.rs | 22 +++-------------------
2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
index ab1f5b8..44e410e 100644
index 98bd814..9391f27 100644
--- a/bindings/rust/Cargo.toml
+++ b/bindings/rust/Cargo.toml
@@ -1,3 +1,4 @@
Expand All @@ -18,7 +18,7 @@ index ab1f5b8..44e410e 100644
name = "c-kzg"
version = "0.1.0"
diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs
index 692305a..e874ccd 100644
index 5148333..ec42e21 100644
--- a/bindings/rust/build.rs
+++ b/bindings/rust/build.rs
@@ -15,24 +15,7 @@ fn main() {
Expand All @@ -27,7 +27,7 @@ index 692305a..e874ccd 100644

- let mut cc = cc::Build::new();
-
- #[cfg(windows)]
- #[cfg(all(windows, target_env = "msvc"))]
- {
- cc.flag("-D_CRT_SECURE_NO_WARNINGS");
-
Expand All @@ -47,7 +47,7 @@ index 692305a..e874ccd 100644

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let bindings_out_path = out_dir.join("generated.rs");
@@ -46,14 +29,12 @@ fn main() {
@@ -46,7 +29,8 @@ fn main() {
);

// Finally, tell cargo this provides ckzg/ckzg_min
Expand All @@ -56,16 +56,7 @@ index 692305a..e874ccd 100644
+ println!("cargo:rustc-link-arg=-l:rust_kzg_arkworks.a");
}

-fn make_bindings<P>(
- header_path: &str,
- blst_headers_dir: &str,
- bindings_out_path: P,
-) where
+fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
+where
P: AsRef<std::path::Path>,
{
use bindgen::Builder;
fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
--
2.34.1

35 changes: 35 additions & 0 deletions blst/nim.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From f34d21606bb5bc3dee4e7a643d7ab89a2c994fef Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 25 Jan 2024 11:26:35 +0200
Subject: [PATCH] Patch nim bindings

---
bindings/nim/kzg_abi.nim | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bindings/nim/kzg_abi.nim b/bindings/nim/kzg_abi.nim
index 36e4ba1..74d0ebc 100644
--- a/bindings/nim/kzg_abi.nim
+++ b/bindings/nim/kzg_abi.nim
@@ -10,6 +10,7 @@ from os import DirSep, AltSep
const
# kzgPath: c-kzg-4844 project path, removing 3 last elem
kzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/"
+ rustKzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 5)[0] & "/"
blstPath = kzgPath & "blst/"
srcPath = kzgPath & "src/"
bindingsPath = blstPath & "bindings"
@@ -20,7 +21,9 @@ when not defined(kzgExternalBlst):
{.compile: blstPath & "src/server.c"}
{.passc: "-D__BLST_PORTABLE__"}

-{.compile: srcPath & "c_kzg_4844.c"}
+{.passl: "-L" & rustKzgPath & "target/release" .}
+{.passl: "-l:rust_kzg_blst.a" .}
+{.passl: "-lm" .}

{.passc: "-I" & bindingsPath .}
{.passc: "-I" & srcPath .}
--
2.34.1

29 changes: 10 additions & 19 deletions blst/rust.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From c3d4cb77f5a797bd8f454a0d88e034391514ebd7 Mon Sep 17 00:00:00 2001
From e7d529a9ba017de920555ae9b4ab05a18174cdcf Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 26 Oct 2023 13:46:19 +0300
Subject: [PATCH] Patch rust binding
Date: Thu, 25 Jan 2024 11:42:12 +0200
Subject: [PATCH] Patch rust bindings

---
bindings/rust/Cargo.toml | 1 +
bindings/rust/build.rs | 29 +++++------------------------
2 files changed, 6 insertions(+), 24 deletions(-)
bindings/rust/build.rs | 22 +++-------------------
2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
index ab1f5b8..44e410e 100644
index 98bd814..9391f27 100644
--- a/bindings/rust/Cargo.toml
+++ b/bindings/rust/Cargo.toml
@@ -1,3 +1,4 @@
Expand All @@ -18,7 +18,7 @@ index ab1f5b8..44e410e 100644
name = "c-kzg"
version = "0.1.0"
diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs
index 692305a..e874ccd 100644
index 5148333..ec42e21 100644
--- a/bindings/rust/build.rs
+++ b/bindings/rust/build.rs
@@ -15,24 +15,7 @@ fn main() {
Expand All @@ -27,7 +27,7 @@ index 692305a..e874ccd 100644

- let mut cc = cc::Build::new();
-
- #[cfg(windows)]
- #[cfg(all(windows, target_env = "msvc"))]
- {
- cc.flag("-D_CRT_SECURE_NO_WARNINGS");
-
Expand All @@ -47,7 +47,7 @@ index 692305a..e874ccd 100644

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let bindings_out_path = out_dir.join("generated.rs");
@@ -46,14 +29,12 @@ fn main() {
@@ -46,7 +29,8 @@ fn main() {
);

// Finally, tell cargo this provides ckzg/ckzg_min
Expand All @@ -56,16 +56,7 @@ index 692305a..e874ccd 100644
+ println!("cargo:rustc-link-arg=-l:rust_kzg_blst.a");
}

-fn make_bindings<P>(
- header_path: &str,
- blst_headers_dir: &str,
- bindings_out_path: P,
-) where
+fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
+where
P: AsRef<std::path::Path>,
{
use bindgen::Builder;
fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
--
2.34.1

35 changes: 35 additions & 0 deletions constantine/nim.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From f34d21606bb5bc3dee4e7a643d7ab89a2c994fef Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 25 Jan 2024 11:26:35 +0200
Subject: [PATCH] Patch nim bindings

---
bindings/nim/kzg_abi.nim | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bindings/nim/kzg_abi.nim b/bindings/nim/kzg_abi.nim
index 36e4ba1..74d0ebc 100644
--- a/bindings/nim/kzg_abi.nim
+++ b/bindings/nim/kzg_abi.nim
@@ -10,6 +10,7 @@ from os import DirSep, AltSep
const
# kzgPath: c-kzg-4844 project path, removing 3 last elem
kzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/"
+ rustKzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 5)[0] & "/"
blstPath = kzgPath & "blst/"
srcPath = kzgPath & "src/"
bindingsPath = blstPath & "bindings"
@@ -20,7 +21,9 @@ when not defined(kzgExternalBlst):
{.compile: blstPath & "src/server.c"}
{.passc: "-D__BLST_PORTABLE__"}

-{.compile: srcPath & "c_kzg_4844.c"}
+{.passl: "-L" & rustKzgPath & "target/release" .}
+{.passl: "-l:rust_kzg_constantine.a" .}
+{.passl: "-lm" .}

{.passc: "-I" & bindingsPath .}
{.passc: "-I" & srcPath .}
--
2.34.1

29 changes: 10 additions & 19 deletions constantine/rust.patch
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
From c3d4cb77f5a797bd8f454a0d88e034391514ebd7 Mon Sep 17 00:00:00 2001
From e7d529a9ba017de920555ae9b4ab05a18174cdcf Mon Sep 17 00:00:00 2001
From: sirse <[email protected]>
Date: Thu, 26 Oct 2023 13:46:19 +0300
Subject: [PATCH] Patch rust binding
Date: Thu, 25 Jan 2024 11:42:12 +0200
Subject: [PATCH] Patch rust bindings

---
bindings/rust/Cargo.toml | 1 +
bindings/rust/build.rs | 29 +++++------------------------
2 files changed, 6 insertions(+), 24 deletions(-)
bindings/rust/build.rs | 22 +++-------------------
2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/bindings/rust/Cargo.toml b/bindings/rust/Cargo.toml
index ab1f5b8..44e410e 100644
index 98bd814..9391f27 100644
--- a/bindings/rust/Cargo.toml
+++ b/bindings/rust/Cargo.toml
@@ -1,3 +1,4 @@
Expand All @@ -18,7 +18,7 @@ index ab1f5b8..44e410e 100644
name = "c-kzg"
version = "0.1.0"
diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs
index 692305a..e874ccd 100644
index 5148333..ec42e21 100644
--- a/bindings/rust/build.rs
+++ b/bindings/rust/build.rs
@@ -15,24 +15,7 @@ fn main() {
Expand All @@ -27,7 +27,7 @@ index 692305a..e874ccd 100644

- let mut cc = cc::Build::new();
-
- #[cfg(windows)]
- #[cfg(all(windows, target_env = "msvc"))]
- {
- cc.flag("-D_CRT_SECURE_NO_WARNINGS");
-
Expand All @@ -47,7 +47,7 @@ index 692305a..e874ccd 100644

let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let bindings_out_path = out_dir.join("generated.rs");
@@ -46,14 +29,12 @@ fn main() {
@@ -46,7 +29,8 @@ fn main() {
);

// Finally, tell cargo this provides ckzg/ckzg_min
Expand All @@ -56,16 +56,7 @@ index 692305a..e874ccd 100644
+ println!("cargo:rustc-link-arg=-l:rust_kzg_constantine.a");
}

-fn make_bindings<P>(
- header_path: &str,
- blst_headers_dir: &str,
- bindings_out_path: P,
-) where
+fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
+where
P: AsRef<std::path::Path>,
{
use bindgen::Builder;
fn make_bindings<P>(header_path: &str, blst_headers_dir: &str, bindings_out_path: P)
--
2.34.1

24 changes: 22 additions & 2 deletions run-c-kzg-4844-tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/opt/homebrew/bin/bash
#!/bin/bash

set -e

Expand Down Expand Up @@ -43,6 +43,7 @@ else
cargo rustc --release --crate-type=staticlib
fi

rm -f ../target/release/rust_kzg_$backend.a
mv ../target/release/librust_kzg_$backend.a ../target/release/rust_kzg_$backend.a

###################### cloning c-kzg-4844 ######################
Expand Down Expand Up @@ -149,7 +150,26 @@ cd bindings/go || exit

print_msg "Running go tests"
CGO_CFLAGS="-O2 -D__BLST_PORTABLE__" go test
cd ../../..
cd ../..

###################### nim tests ######################

if [ "$backend" != "constantine" ]; then
print_msg "Patching nim binding"
git apply < ../nim.patch

print_msg "Installing nim dependencies"
nimble install -y stew
nimble install -y unittest2
nimble install -y yaml

print_msg "Running nim tests"
cd bindings/nim || exit
nim test
cd ../../..
else
print_msg "Currently, nim bindings are not supported for constantine backend"
fi

###################### cleaning up ######################

Expand Down
Loading

0 comments on commit 33989b7

Please sign in to comment.