diff --git a/.ci/build_test.sh b/.ci/build_test.sh new file mode 100755 index 0000000..b3b6ade --- /dev/null +++ b/.ci/build_test.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +cd ../ + +run_build() { + build_type=$1 + build_dir=$2 + + echo "Building with BUILD_TYPE=$build_type..." + + make -B build BUILD_TYPE="$build_type" BUILD_DIR="$build_dir" + + if [ $? -ne 0 ]; then + echo "Error: Build failed for BUILD_TYPE=$build_type." + exit 1 + else + echo "Success: Build completed successfully for BUILD_TYPE=$build_type." + fi +} + +run_build Debug build-debug +run_build Release build + +echo "All build tests completed successfully." +exit 0 diff --git a/.ci/cargo_tests.sh b/.ci/cargo_tests.sh new file mode 100755 index 0000000..e5f1957 --- /dev/null +++ b/.ci/cargo_tests.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +export HEADER_FILE="/dev/null" +export CBINDGEN_CONFIG="../../cbindgen.toml" + +CRATES_DIR="../crates" + +for dir in "$CRATES_DIR"/*; do + if [ -d "$dir" ]; then + echo "Entering directory: $dir" + cd "$dir" || exit + + cargo test + + if [ $? -ne 0 ]; then + echo "Error: cargo test failed in $dir" + exit 1 + fi + + cd - || exit + fi +done + +echo "All tests completed successfully." \ No newline at end of file diff --git a/.ci/check_files.py b/.ci/check_files.py new file mode 100644 index 0000000..3528f6d --- /dev/null +++ b/.ci/check_files.py @@ -0,0 +1,38 @@ +import os + +required_structure = { + 'install': { + 'include': { + 'arkworks': ['arkworks.h'], + 'bandersnatch_vrfs': ['bandersnatch_vrfs.h'], + 'schnorrkel': ['schnorrkel.h'] + }, + 'lib': { + 'cmake': { + 'arkworks': ['arkworksConfig.cmake'], + 'bandersnatch_vrfs': ['bandersnatch_vrfsConfig.cmake'], + 'schnorrkel': ['schnorrkelConfig.cmake'] + }, + '': ['libarkworks_crust.a', 'libbandersnatch_vrfs_crust.a', 'libschnorrkel_crust.a'] + } + } +} + +def check_structure(base_path, structure): + for folder, contents in structure.items(): + current_path = os.path.join(base_path, folder) + + if isinstance(contents, dict): + if not os.path.isdir(current_path): + print(f"Missing directory: {current_path}") + else: + check_structure(current_path, contents) + else: + for file in contents: + file_path = os.path.join(base_path, folder, file) + if not os.path.isfile(file_path): + print(f"Missing file: {file_path}") + +base_path = '../' + +check_structure(base_path, required_structure) diff --git a/.ci/run_all_tests.sh b/.ci/run_all_tests.sh new file mode 100755 index 0000000..8b5e332 --- /dev/null +++ b/.ci/run_all_tests.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +scripts=("build_test.sh" "check_files.py" "cargo_tests.sh") + +error_found=0 + +for script in "${scripts[@]}"; do + echo "Running $script..." + + if [[ "$script" == *.py ]]; then + python3 "$script" + elif [[ "$script" == *.sh ]]; then + bash "$script" + else + echo "Unknown file type for script: $script" + error_found=1 + continue + fi + + if [ $? -ne 0 ]; then + echo "Error: $script failed." + error_found=1 + else + echo "Success: $script completed successfully." + fi +done + +if [ $error_found -ne 0 ]; then + echo "One or more scripts failed." + exit 1 +else + echo "All scripts ran successfully." + exit 0 +fi diff --git a/.gitignore b/.gitignore index 2991e37..0fa0401 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ target /build /generated +/install +/.idea +/build-* + +**/Cargo.lock \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..46023c2 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +BUILD_DIR ?= build +BUILD_TYPE ?= Release + +BUILD_THREADS := $$(nproc 2>/dev/null || sysctl -n hw.ncpu) + + +build: + if [ "$$(uname)" = "Darwin" ]; then \ + export SDKROOT=$$(xcrun --sdk macosx --show-sdk-path) ; \ + fi ; \ + cmake . -B"$(BUILD_DIR)" -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) ; \ + cmake --build "$(BUILD_DIR)" -- -j$(BUILD_THREADS) ; \ + cmake --install "$(BUILD_DIR)" + \ No newline at end of file diff --git a/crates/schnorrkel/Cargo.toml b/crates/schnorrkel/Cargo.toml index df34c7e..2106a25 100644 --- a/crates/schnorrkel/Cargo.toml +++ b/crates/schnorrkel/Cargo.toml @@ -13,11 +13,10 @@ crate-type = ["cdylib", "staticlib"] cpp = { path = "../cpp" } schnorrkel = { version="0.9.1", features = ["preaudit_deprecated"] } ed25519-dalek = { version="1.0.0" } -rand_chacha = "0.3.1" -rand_core = "0.6.2" +rand_chacha = "0.2.1" merlin = { version = "2.0", default-features = false } parity-scale-codec = { version = "3.6.1", default-features = false, features = ["bit-vec", "derive"] } -rand = "0.8" +rand = "0.7" bitvec = { version = "1.0.0", default-features = false, features = ["alloc"] } scale-info = { version = "2.11.1", default-features = false, features = ["derive"] } itertools = "0.10.5"