Skip to content

Commit

Permalink
Split core implementation into multiple files (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
asn-d6 authored Aug 1, 2024
1 parent 3644ae9 commit cf997e0
Show file tree
Hide file tree
Showing 40 changed files with 5,222 additions and 4,727 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/c-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ jobs:
check-path: 'src'
exclude-regex: 'tinytest.h'

# Build and test.
- name: Build
run: make test_c_kzg_4844
# Run tests.
- name: Test
run: make test

Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_c_kzg_4844
test_c_kzg_4844_*
src/tests
src/tests_*
coverage.html
analysis-report/
*.profraw
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This is a manifest for the Python bindings
include bindings/python/ckzg.c
include bindings/python/ckzg_wrap.c
include bindings/python/README.md
recursive-include blst *
recursive-include lib *
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ All the bindings are tested against the [KZG reference
tests](https://github.com/ethereum/consensus-spec-tests/tree/master/tests/general/deneb/kzg),
which are defined in the consensus-spec-tests. Additionally, a suite of unit
tests for internal C functions is located
[here](https://github.com/ethereum/c-kzg-4844/blob/main/src/test_c_kzg_4844.c).
[here](https://github.com/ethereum/c-kzg-4844/blob/main/src/tests.c).

### Parallelization

Expand Down
4 changes: 2 additions & 2 deletions bindings/csharp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ifeq ($(OS),Windows_NT)
CLANG_EXECUTABLE = clang
EXTENSION ?= ".dll"
CKZG_LIBRARY_PATH = Ckzg.Bindings\runtimes\$(LOCATION)\native\ckzg$(EXTENSION)
CFLAGS += -Wl,/def:ckzg.def
CFLAGS += -Wl,/def:ckzg_wrap.def
else
BLST_BUILDSCRIPT = ./build.sh
BLST_OBJ = libblst.a
Expand Down Expand Up @@ -39,7 +39,7 @@ else
endif

INCLUDE_DIRS = ../../src ../../blst/bindings
TARGETS = ckzg.c ../../src/c_kzg_4844.c ../../blst/$(BLST_OBJ)
TARGETS = ckzg_wrap.c ../../src/ckzg.c ../../blst/$(BLST_OBJ)

CFLAGS += -O2 -Wall -Wextra -shared
CFLAGS += ${addprefix -I,${INCLUDE_DIRS}}
Expand Down
25 changes: 0 additions & 25 deletions bindings/csharp/ckzg.c

This file was deleted.

9 changes: 0 additions & 9 deletions bindings/csharp/ckzg.h

This file was deleted.

30 changes: 30 additions & 0 deletions bindings/csharp/ckzg_wrap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "ckzg_wrap.h"
#include <stdlib.h>

KZGSettings *load_trusted_setup_wrap(const char *file, size_t precompute) {
KZGSettings *out = malloc(sizeof(KZGSettings));

if (out == NULL)
return NULL;

FILE *f = fopen(file, "r");

if (f == NULL) {
free(out);
return NULL;
}

if (load_trusted_setup_file(out, f, precompute) != C_KZG_OK) {
free(out);
fclose(f);
return NULL;
}

fclose(f);
return out;
}

void free_trusted_setup_wrap(KZGSettings *s) {
free_trusted_setup(s);
free(s);
}
File renamed without changes.
5 changes: 5 additions & 0 deletions bindings/csharp/ckzg_wrap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "ckzg.h"

KZGSettings *load_trusted_setup_wrap(const char *file, size_t precompute);

void free_trusted_setup_wrap(KZGSettings *s);
2 changes: 1 addition & 1 deletion bindings/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package ckzg4844

// #cgo CFLAGS: -I${SRCDIR}/../../src
// #cgo CFLAGS: -I${SRCDIR}/blst_headers
// #include "c_kzg_4844.c"
// #include "ckzg.c"
import "C"

import (
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
INCLUDE_DIRS = ../../src ../../blst/bindings

TARGETS=c_kzg_4844_jni.c ../../src/c_kzg_4844.c ../../lib/libblst.a
TARGETS=ckzg_jni.c ../../src/ckzg.c ../../lib/libblst.a

CC_FLAGS=
OPTIMIZATION_LEVEL=-O2
Expand Down
Loading

0 comments on commit cf997e0

Please sign in to comment.