Skip to content

Commit

Permalink
fix review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMlashkin committed Jul 19, 2024
1 parent 66054fb commit 8933672
Show file tree
Hide file tree
Showing 24 changed files with 366 additions and 277 deletions.
124 changes: 18 additions & 106 deletions .github/workflows/nix_build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,51 +55,19 @@ jobs:
!${{ github.workspace }}/
!${{ github.workspace }}/**/.git/**
# nix is taken from the cloud-init template, no need to install it.
- name: Setup build
run: |
nix develop .?submodules=1# -c cmake -G Ninja -B build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ENABLE_TESTS=TRUE -DGENERATE_EVM_VERIFIER=TRUE -DZKLLVM_VERSION=0.1.18
- name: Build zkllvm
run: |
nix develop -c ninja -C build assigner clang transpiler
- name: Build circuits(.crct) of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_crct
ls -al ./examples/cpp
- name: Build assignment tables(.tbl) of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_tbl_no_check
ls -al ./examples/cpp
- name: Copy assigner output from separate generation mode
run: |
bash ./tests/copy_assigner_outputs.sh ./build/examples/cpp/ build/separate_generatuon
- name: Run simultaneous .tbl and .crct generation of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_both
ls -al ./examples/cpp
- name: Copy assigner output from simultaneous generation mode
run: |
bash ./tests/copy_assigner_outputs.sh ./build/examples/cpp/ build/simultaneous_generation
- name: Compare different assigner modes output
run: |
bash ./tests/compare_folders_content.sh build/separate_generatuon build/simultaneous_generation
- name: Run size estimation for C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_estimate_size
- name: Copy examples' circuits and assignments for uploading
run: |
chmod +x ./examples/copy_artifacts.sh
./examples/copy_artifacts.sh build/examples/cpp examples_output
ls -al examples_output/
- name: Build zkLLVM, run local tests, prepare for integration testing
run: |
nix build -L .?submodules=1#checks.x86_64-linux.debug-tests
ls
ls -al result/
ls -al result/artifacts/
cd result
find -name "*.ll"
find -name "*.tbl"
find -name "transpiler_output_*"
cd -
ls -al result/artifacts/examples_output
cp -r result/artifacts/examples_output .
- name: Set aritfacts' names
id: artifact-names
Expand All @@ -113,71 +81,15 @@ jobs:
name: ${{ steps.artifact-names.outputs.examples }}
path: |
examples_output
- name: Compile tests as cpp code
run: |
nix develop -c ninja -C build -k 0 all_tests_compile_as_cpp_code
- name: Compile tests as circuits
run: |
nix develop -c ninja -C build -k 0 all_tests_compile_as_circuits
- name: Run tests as cpp code (expected res calculation)
run: |
nix develop -c ninja -C build -k 0 all_tests_run_expected_res_calculation
- name: Get transpiler output for integration testing
run: |
targets_str=$(echo "${{ env.INTEGRATION_TESTING_TARGETS }}" | awk 'NF {printf " %s_evm_verifier ", $0}' | sed 's/[[:space:]]*$//')
echo "targets: ${targets_str}"
nix develop -c ninja -C build -k 0 ${targets_str}
ls -al build/examples/cpp/
if-no-files-found: error

- name: Upload examples' circuits and assignments artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-names.outputs.transpiler }}
path: |
build/examples/cpp/transpiler_output_*
- name: Run tests as circuits (real res calculation)
run: |
nix develop -c ninja -C build -k 0 all_tests_assign_circuits
- name: Compare expected and real test results
run: |
chmod +x ./tests/run_test_results_comparison.sh
bash ./tests/run_test_results_comparison.sh
- name: Run tests on faulty inputs
run: |
chmod +x ./tests/run_tests_faulty_input.sh
bash ./tests/run_tests_faulty_input.sh pallas
- name: Run assigner unit tests
run: |
nix develop -c ninja -C build -k 0 check-crypto3-assigner
- name: Build proof for the circuit of the C++ examples
run: |
nix develop -c ninja -C build -k 0 prove_cpp_examples
- name: Build recursive gen
run: |
nix develop -c ninja -C build -k 0 recursive_gen
- name: Build and run transpiler test
run: |
nix develop -c ninja -C build -k 0 compile_and_run_transpiler_tests
- name: Run recursive verifier tests
run: |
nix develop -c ninja -C build -k 0 recursion
- name: Build IR of the C++ examples
run: |
nix develop -c ninja -C build -k 0 compile_cpp_examples
ls -al ./examples/cpp
result/artifacts/cpp/transpiler_output_*
if-no-files-found: error

- name: Set targets for integration testing
id: get-targets
Expand Down Expand Up @@ -216,11 +128,11 @@ jobs:
always() && !cancelled() &&
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') &&
needs.build-and-test-with-nix.result == 'success'
uses: NilFoundation/proof-producer/.github/workflows/reusable-generate-proofs-linux.yml@ef8cd9152b4bec871e7efdc1d6b606e445bad274
uses: NilFoundation/proof-producer/.github/workflows/reusable-generate-proofs-linux.yml@f3e985dabe0d20ecb75375f86d8cf2a71e2eb58b
with:
artifact-name: ${{ needs.build-and-test-with-nix.outputs.examples-artifact-name }}
# Update next line if you need new version of proof producer
proof-producer-ref: ef8cd9152b4bec871e7efdc1d6b606e445bad274
proof-producer-ref: f3e985dabe0d20ecb75375f86d8cf2a71e2eb58b
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
targets: ${{ needs.build-and-test-with-nix.outputs.prover-targets }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ install_manifest.txt
compile_commands.json
CTestTestfile.cmake
build
*build
build*
result

### LaTeX ###
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "cmake-modules"]
path = cmake/modules
url = ../../BoostCMake/cmake_modules.git
[submodule "zkllvm-assigner"]
path = libs/assigner
url = ../../NilFoundation/zkllvm-assigner.git
Expand Down
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ cmake_policy(SET CMP0028 NEW)
cmake_policy(SET CMP0057 NEW)
cmake_policy(SET CMP0063 NEW)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake"
"${CMAKE_CURRENT_LIST_DIR}/cmake/packages"
"${CMAKE_CURRENT_LIST_DIR}/cmake/modules/share/modules/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

include(CMConfig)
find_package(CM)
include(CMSetupVersion)

cm_workspace(zkllvm)
Expand All @@ -44,6 +42,7 @@ include(CircuitCompile)
find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)

find_package(crypto3 REQUIRED)
find_package(crypto3_blueprint REQUIRED)
find_package(Boost COMPONENTS REQUIRED filesystem log log_setup program_options thread system random unit_test_framework timer)

if(BUILD_WITH_BOOST_STATIC_LIBS)
Expand Down Expand Up @@ -118,7 +117,7 @@ configure_file("${CMAKE_CURRENT_LIST_DIR}/cmake/zkllvm.conf.in"
"${CMAKE_CURRENT_BINARY_DIR}/zkllvm.conf"
NO_SOURCE_PERMISSIONS
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zkllvm.conf" DESTINATION /etc/ld.so.conf.d)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/zkllvm.conf" DESTINATION etc/ld.so.conf.d)

set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_LIST_DIR}/cmake/triggers")
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
Expand Down Expand Up @@ -196,3 +195,5 @@ add_custom_target(rslang_dist
COMMENT "Building rslang distribution package"
USES_TERMINAL
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/libs/rslang)

add_executable(test_package bin/test_package.cpp)
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,27 @@ Languages currently supported are:

#### Install Dependencies

* [Boost](https://www.boost.org/) >= 1.76.0
* [CMake](https://cmake.org/) >= 3.5
* [Clang](https://clang.llvm.org/) >= 12.0
* [Python](https://www.python.org/) >= 3.7
* [Rust](https://www.rust-lang.org/) >= 1.68 (if you want to build Rust compiler)
Install nix using the following command:

On Debian systems, everything except Boost and Rust can be installed with the following command:
```
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```

for most cases, you want to have an incremental build:
```
nix develop
eval "$configurePhase"
eval "$buildPhase"
eval "$checkPhase"
```

only build:
```
nix build -L .?submodules=1
```
sudo apt install build-essential libssl-dev cmake clang-12 git curl pkg-config
build and test:
```
nix build -L .?submodules=1#checks.x86_64-linux.debug-tests
```

#### 1. Clone the repository
Expand Down Expand Up @@ -282,4 +293,4 @@ Ninja:
```bash
ninja -C ${ZKLLVM_BUILD:-build} arithmetics_cpp_example -j$(sysctl -n hw.logicalcpu)
${ZKLLVM_BUILD:-build}/bin/assigner/assigner -b ${ZKLLVM_BUILD:-build}/examples/cpp/arithmetics_cpp_example.ll -i examples/inputs/arithmetics.inp -t assignment.tbl -c circuit.crct -e pallas --check
```
```
2 changes: 1 addition & 1 deletion bin/assigner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ target_link_libraries(${CURRENT_PROJECT_NAME}
LLVMCore
LLVMSupport
crypto3::all
crypto3::blueprint
${Boost_LIBRARIES})

target_include_directories(${CURRENT_PROJECT_NAME} PUBLIC
Expand All @@ -50,7 +51,6 @@ target_include_directories(${CURRENT_PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}/libs/circifier/llvm/include
${CMAKE_SOURCE_DIR}/libs/circifier/utils/bazel/llvm-project-overlay/llvm/include
${CMAKE_SOURCE_DIR}/libs/assigner/include
${CMAKE_SOURCE_DIR}/libs/blueprint/include
${CMAKE_BINARY_DIR}/libs/circifier/llvm/include
${Boost_INCLUDE_DIRS})

Expand Down
6 changes: 3 additions & 3 deletions bin/recursive_gen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ set_target_properties(${CURRENT_PROJECT_NAME} PROPERTIES

target_link_libraries(${CURRENT_PROJECT_NAME}
crypto3::all
crypto3::blueprint
crypto3::assigner
crypto3::transpiler
${Boost_LIBRARIES})

target_include_directories(${CURRENT_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${CMAKE_SOURCE_DIR}/libs/circifier/llvm/include
${CMAKE_SOURCE_DIR}/libs/circifier/utils/bazel/llvm-project-overlay/llvm/include
${CMAKE_SOURCE_DIR}/libs/assigner/include
${CMAKE_SOURCE_DIR}/libs/blueprint/include
${CMAKE_SOURCE_DIR}/libs/transpiler/include
${CMAKE_BINARY_DIR}/libs/circifier/llvm/include

${Boost_INCLUDE_DIRS})
Expand Down
5 changes: 5 additions & 0 deletions bin/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

int main()
{
return 0;
}
4 changes: 2 additions & 2 deletions bin/transpiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ set_target_properties(${CURRENT_PROJECT_NAME} PROPERTIES

target_link_libraries(${CURRENT_PROJECT_NAME}
crypto3::all
crypto3::blueprint
crypto3::assigner
${Boost_LIBRARIES})

target_include_directories(${CURRENT_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
${CMAKE_SOURCE_DIR}/libs/circifier/llvm/include
${CMAKE_SOURCE_DIR}/libs/assigner/include
${CMAKE_SOURCE_DIR}/libs/blueprint/include
${CMAKE_SOURCE_DIR}/libs/transpiler/include
${CMAKE_SOURCE_DIR}/libs/circifier/utils/bazel/llvm-project-overlay/llvm/include
${Boost_INCLUDE_DIRS})
Expand Down
4 changes: 2 additions & 2 deletions cmake/CircuitCompile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function(add_circuit)
set(libcpp_stdlib ${CMAKE_BINARY_DIR}/libs/stdlib/libcpp/zkllvm-libcpp.ll)
else()
set(LINKER llvm-link-zkllvm)
set(libc_stdlib "/usr/lib/zkllvm/lib/zkllvm/zkllvm-libc.ll")
set(libcpp_stdlib "/usr/lib/zkllvm/lib/zkllvm/zkllvm-libcpp.ll")
set(libc_stdlib "/var/empty/lib/zkllvm/lib/zkllvm/zkllvm-libc.ll")
set(libcpp_stdlib "/var/empty/lib/zkllvm/lib/zkllvm/zkllvm-libcpp.ll")
endif()
if (NOT ${CIRCUIT_BINARY_OUTPUT})
set(link_options "-S")
Expand Down
1 change: 0 additions & 1 deletion cmake/modules
Submodule modules deleted from 576397
Empty file removed cmake/packages/FindCrypto3.cmake
Empty file.
23 changes: 0 additions & 23 deletions cmake/packages/FindValgrind.cmake

This file was deleted.

51 changes: 51 additions & 0 deletions examples/move_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

usage() {
echo "Usage: $0 <base-directory> <target-directory>"
exit 1
}

if [ "$#" -ne 2 ]; then
usage
fi

base_dir=$1
target_dir=$(realpath "$2")

if [ ! -d "$base_dir" ]; then
echo "Error: Base directory '$base_dir' does not exist."
exit 1
fi

mkdir -p "$target_dir"

cd "$base_dir" || exit

declare -A base_names
for ll_file in *.ll; do
base_name=$(echo "$ll_file" | sed -E 's/_no_stdlib.*//' | sed -E 's/\.ll$//')
base_names["$base_name"]=1
done

for base_name in "${!base_names[@]}"; do
echo "Processing $base_name"

mkdir -p "$target_dir/$base_name"

for variant in "$base_name"*".ll"; do
if [[ -f "$variant" ]]; then
suffix=$(echo "$variant" | sed -E "s/${base_name}(_no_stdlib.*)?\.ll/\1/")
suffix=${suffix:-""}
mv "$variant" "$target_dir/$base_name/bytecode${suffix}.ll"
fi
done

if [[ -f "circuit_${base_name}.crct" ]]; then
mv "circuit_${base_name}.crct" "$target_dir/$base_name/circuit.crct"
fi
if [[ -f "assignment_${base_name}.tbl" ]]; then
mv "assignment_${base_name}.tbl" "$target_dir/$base_name/assignment.tbl"
fi
done

echo "Files have been moved from $base_dir to $target_dir"
Loading

0 comments on commit 8933672

Please sign in to comment.