From 81065acd41d9695b9b2ec71943328c520b3991d5 Mon Sep 17 00:00:00 2001 From: akokoshn Date: Sun, 24 Mar 2024 17:31:14 +0200 Subject: [PATCH 1/9] Fix miss connectness of components --- libs/assigner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/assigner b/libs/assigner index da77d320..38f2f055 160000 --- a/libs/assigner +++ b/libs/assigner @@ -1 +1 @@ -Subproject commit da77d320a90ca8602a2f7e0e6eed00e8cb02bbb4 +Subproject commit 38f2f05559200faaa615f945d016e5776bd8b53e From 5d45e55c39eabb9c45443ce2064add521353e5e6 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 28 Mar 2024 17:16:34 +0000 Subject: [PATCH 2/9] test different generate-type modes outputs #589 --- .github/workflows/build_linux.yml | 17 ++++++++++++++++ tests/compare_folders_content.sh | 20 +++++++++++++++++++ tests/copy_assigner_outputs.sh | 11 ++++++++++ ...n_different_generation_modes_comparison.sh | 8 ++++++++ 4 files changed, 56 insertions(+) create mode 100755 tests/compare_folders_content.sh create mode 100755 tests/copy_assigner_outputs.sh create mode 100755 tests/run_different_generation_modes_comparison.sh diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 5a3dcab4..07f5fd92 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -166,6 +166,23 @@ jobs: cmake --build build -t cpp_examples_generate_tbl ls -al ./build/examples/cpp + - name: Copy assigner output from separate generation mode + run: | + bash ./tests/copy_assigner_outputs.sh build/separate_generatuon + + - name: Run simultaneous .tbl and .crct generation of the C++ examples + run: | + cmake --build build -t cpp_examples_generate_both + ls -al ./build/examples/cpp + + - name: Copy assigner output from simultaneous generation mode + run: | + bash ./tests/copy_assigner_outputs.sh 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: | cmake --build build -t cpp_examples_estimate_size diff --git a/tests/compare_folders_content.sh b/tests/compare_folders_content.sh new file mode 100755 index 00000000..13cab478 --- /dev/null +++ b/tests/compare_folders_content.sh @@ -0,0 +1,20 @@ +# check that the number of files in both directories is equal +count1=$(find "$1" -type f | wc -l) +count2=$(find "$2" -type f | wc -l) + +if [ "$count1" -eq "$count2" ]; then + echo "The number of files in both directories is equal." +else + echo "The number of files differs: $1 has $count1 files, $2 has $count2 files." + exit 1 +fi + +# Check that both directories contain identical list of files +diff -qr "$1" "$2" | grep 'Only in' && exit 1 +echo "Both directories contain files with the same names." + +diff -r "$1" "$2" +if [ $? -ne 0 ]; then + exit 1 +fi +echo "Comparison completed." diff --git a/tests/copy_assigner_outputs.sh b/tests/copy_assigner_outputs.sh new file mode 100755 index 00000000..049b58b3 --- /dev/null +++ b/tests/copy_assigner_outputs.sh @@ -0,0 +1,11 @@ +SRC_DIR="build/examples/cpp" +DEST_DIR="$1" + +if [ ! -d "$DEST_DIR" ]; then + mkdir -p "$DEST_DIR" +fi + +find "$SRC_DIR" -type f -name "*.crct*" -exec cp {} "$DEST_DIR" \; +find "$SRC_DIR" -type f -name "*.tbl*" -exec cp {} "$DEST_DIR" \; + +echo "All .crct and .tbl files have been copied from $SRC_DIR to $DEST_DIR." diff --git a/tests/run_different_generation_modes_comparison.sh b/tests/run_different_generation_modes_comparison.sh new file mode 100755 index 00000000..477c7cda --- /dev/null +++ b/tests/run_different_generation_modes_comparison.sh @@ -0,0 +1,8 @@ +rm -r build/examples/cpp +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_tbl -- +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_crct -- +bash tests/copy_assigner_outputs.sh build/1 +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_crct -- +bash tests/copy_assigner_outputs.sh build/2 + +bash tests/compare_folders_content.sh build/1 build/2 \ No newline at end of file From f1dfee4767f4491445dc85098c2a84c2ce76e0a7 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 28 Mar 2024 19:46:37 +0000 Subject: [PATCH 3/9] delete balance example --- examples/cpp/CMakeLists.txt | 1 - examples/cpp/balance.cpp | 24 ------------------------ examples/inputs/balance.inp | 3 --- 3 files changed, 28 deletions(-) delete mode 100644 examples/cpp/balance.cpp delete mode 100644 examples/inputs/balance.inp diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 8ee3ea56..7c7ce348 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -138,7 +138,6 @@ add_example_with_proving(merkle_poseidon_21prover_3layers_cpp_example SOURCES me add_example_without_proving(merkle_tree_sha2_256_cpp_example SOURCES merkle_tree_sha2_256.cpp INPUT merkle_tree_sha2_256.inp CURVE_TYPE pallas) add_example_without_proving(validate_merkle_path_sha2_256_cpp_example SOURCES validate_merkle_path_sha2_256.cpp INPUT validate_merkle_path_sha2_256.inp CURVE_TYPE pallas) add_example_without_proving(sha256_cpp_example SOURCES sha2_256.cpp INPUT sha2_256.inp CURVE_TYPE pallas) -add_example_with_proving(balance_cpp_example SOURCES balance.cpp INPUT balance.inp CURVE_TYPE pallas) add_example_with_proving(memory_cpp_example SOURCES memory.cpp INPUT memory.inp CURVE_TYPE pallas) add_example_with_proving(polynomial_cpp_example SOURCES polynomial.cpp INPUT polynomial.inp COMPILER_OPTIONS -std=c++20 CURVE_TYPE pallas) add_example_with_proving(pallas_curve_addition_cpp_example diff --git a/examples/cpp/balance.cpp b/examples/cpp/balance.cpp deleted file mode 100644 index 7918a8ee..00000000 --- a/examples/cpp/balance.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include - -using namespace nil::crypto3::algebra::curves; - -constexpr std::size_t VertexAmount = 5; -[[circuit]] std::array - balance(std::array vertexes, - std::array - weights) { - - std::array balance_point = {0,0}; - typename pallas::base_field_type::value_type balance_weight = 0; - - for (std::size_t VertexIndex = 0; VertexIndex < VertexAmount; VertexIndex++) { - balance_point[0] += vertexes[VertexIndex + VertexIndex] * weights[VertexIndex]; - balance_point[1] += vertexes[VertexIndex + VertexIndex + 1] * weights[VertexIndex]; - balance_weight += weights[VertexIndex]; - } - - balance_point[0] /= balance_weight; - balance_point[1] /= balance_weight; - - return balance_point; -} diff --git a/examples/inputs/balance.inp b/examples/inputs/balance.inp deleted file mode 100644 index cd4aac0b..00000000 --- a/examples/inputs/balance.inp +++ /dev/null @@ -1,3 +0,0 @@ -[ {"array": [1230,1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239 ]}, - {"array": [ 1240, 1241, 1242, 1243, 1244]} -] From fe90aff74e3fb3ed35aa3bbc1d10a31483867bd4 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 28 Mar 2024 19:57:35 +0000 Subject: [PATCH 4/9] --check did not work in assigner generate-type mode. Fixed --- bin/assigner/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/assigner/src/main.cpp b/bin/assigner/src/main.cpp index 7e00fc24..cc9c394e 100644 --- a/bin/assigner/src/main.cpp +++ b/bin/assigner/src/main.cpp @@ -703,7 +703,7 @@ int curve_dependent_main(std::string bytecode_file_name, BOOST_LOG_TRIVIAL(debug) << "overall_table_printing_duration: " << overall_table_printing_duration.count() << "ms"; auto check_validity_start = std::chrono::high_resolution_clock::now(); - if (check_validity && gen_mode.has_assignments() && gen_mode.has_circuit()) { + if (check_validity && gen_mode.has_assignments()) { if (assigner_instance.assignments.size() == 1 && (target_prover == 0 || target_prover == invalid_target_prover)) { ASSERT_MSG(nil::blueprint::is_satisfied(assigner_instance.circuits[0].get(), assigner_instance.assignments[0].get()), "The circuit is not satisfied"); From 76b48c6a96209b5e7cc07a094de1079a68374241 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Thu, 28 Mar 2024 20:16:38 +0000 Subject: [PATCH 5/9] update assigner --- libs/assigner | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/assigner b/libs/assigner index 38f2f055..0e716254 160000 --- a/libs/assigner +++ b/libs/assigner @@ -1 +1 @@ -Subproject commit 38f2f05559200faaa615f945d016e5776bd8b53e +Subproject commit 0e716254827df7424e960325c8eee78a1b6cce33 From a7afb205bda2d596e4389f8e44c6e499851c446f Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Mon, 1 Apr 2024 18:22:03 +0000 Subject: [PATCH 6/9] fix typo in different gen nodes comp script --- tests/run_different_generation_modes_comparison.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run_different_generation_modes_comparison.sh b/tests/run_different_generation_modes_comparison.sh index 477c7cda..5e56da81 100755 --- a/tests/run_different_generation_modes_comparison.sh +++ b/tests/run_different_generation_modes_comparison.sh @@ -2,7 +2,7 @@ rm -r build/examples/cpp /usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_tbl -- /usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_crct -- bash tests/copy_assigner_outputs.sh build/1 -/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_crct -- +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_both -- bash tests/copy_assigner_outputs.sh build/2 bash tests/compare_folders_content.sh build/1 build/2 \ No newline at end of file From 7c2c0c21680733e38e8dc37f8e628b136784cb18 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Mon, 1 Apr 2024 18:28:41 +0000 Subject: [PATCH 7/9] add _no_check targets --- .github/workflows/build_linux.yml | 4 ++-- .github/workflows/build_macos.yml | 2 +- examples/CMakeLists.txt | 27 +++++++++++++++++++++++++++ examples/cpp/CMakeLists.txt | 4 ++++ 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 07f5fd92..d3c6f1c6 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -163,7 +163,7 @@ jobs: - name: Build assignment tables(.tbl) of the C++ examples run: | - cmake --build build -t cpp_examples_generate_tbl + cmake --build build -t cpp_examples_generate_tbl_no_check ls -al ./build/examples/cpp - name: Copy assigner output from separate generation mode @@ -172,7 +172,7 @@ jobs: - name: Run simultaneous .tbl and .crct generation of the C++ examples run: | - cmake --build build -t cpp_examples_generate_both + cmake --build build -t cpp_examples_generate_both_no_check ls -al ./build/examples/cpp - name: Copy assigner output from simultaneous generation mode diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index c54ab50f..6af61919 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -120,7 +120,7 @@ jobs: - name: Build assignment tables(.tbl) of the C++ examples run: | - cmake --build build -t cpp_examples_generate_tbl + cmake --build build -t cpp_examples_generate_tbl_no_check ls -al ./build/examples/cpp - name: Run size estimation for C++ examples diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7ecb382b..bc381ce8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -56,6 +56,20 @@ function(assign_ir) COMMAND_EXPAND_LISTS VERBATIM) + add_custom_target(${target}_generate_both_no_check + COMMAND $ + -b ${binary_name} + -i ${INPUTS_DIR}/${input} + ${minus_p} ${private_input_string} + -c circuit_${target}.crct + -t assignment_${target}.tbl -e ${curve_type} + --generate-type circuit-assignment + ${max_num_provers_flag} ${max_num_provers_amount} + ${arithmetization_flag} ${arithmetization_amount} + DEPENDS ${target} ${INPUTS_DIR}/${input} $ + COMMAND_EXPAND_LISTS + VERBATIM) + add_custom_target(${target}_generate_tbl COMMAND $ -b ${binary_name} @@ -69,6 +83,19 @@ function(assign_ir) COMMAND_EXPAND_LISTS VERBATIM) + add_custom_target(${target}_generate_tbl_no_check + COMMAND $ + -b ${binary_name} + -i ${INPUTS_DIR}/${input} + ${minus_p} ${private_input_string} + -t assignment_${target}.tbl -e ${curve_type} + --generate-type assignment + ${max_num_provers_flag} ${max_num_provers_amount} + ${arithmetization_flag} ${arithmetization_amount} + DEPENDS ${target} ${INPUTS_DIR}/${input} $ + COMMAND_EXPAND_LISTS + VERBATIM) + add_custom_target(${target}_estimate_size COMMAND $ -b ${binary_name} diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 7c7ce348..29235f07 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -1,7 +1,9 @@ add_custom_target(compile_cpp_examples) add_custom_target(cpp_examples_generate_tbl) +add_custom_target(cpp_examples_generate_tbl_no_check) add_custom_target(cpp_examples_generate_crct) add_custom_target(cpp_examples_generate_both) +add_custom_target(cpp_examples_generate_both_no_check) add_custom_target(prove_cpp_examples) add_custom_target(cpp_examples_estimate_size) @@ -68,8 +70,10 @@ function(add_example_without_proving example_target) assign_ir(${example_target} ${binary_name} ${ARG_INPUT} ${ARG_PRIVATE_INPUT} ${ARG_CURVE_TYPE} ${ARG_ARITHMETIZARION} ${ARG_MAX_NUM_PROVERS}) add_dependencies(cpp_examples_generate_tbl ${example_target}_generate_tbl) + add_dependencies(cpp_examples_generate_tbl_no_check ${example_target}_generate_tbl_no_check) add_dependencies(cpp_examples_generate_crct ${example_target}_generate_crct) add_dependencies(cpp_examples_generate_both ${example_target}_generate_both) + add_dependencies(cpp_examples_generate_both_no_check ${example_target}_generate_both_no_check) add_dependencies(cpp_examples_estimate_size ${example_target}_estimate_size) endfunction() From 4e47fec8839d33e65a9c13653a0898a9c2a4dc98 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Mon, 1 Apr 2024 18:35:59 +0000 Subject: [PATCH 8/9] update tests/run_different_generation_modes_comparison.sh --- tests/run_different_generation_modes_comparison.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/run_different_generation_modes_comparison.sh b/tests/run_different_generation_modes_comparison.sh index 5e56da81..096be818 100755 --- a/tests/run_different_generation_modes_comparison.sh +++ b/tests/run_different_generation_modes_comparison.sh @@ -1,8 +1,10 @@ rm -r build/examples/cpp -/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_tbl -- +rm -r build/1 +rm -r build/2 +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_tbl_no_check -- /usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_crct -- bash tests/copy_assigner_outputs.sh build/1 -/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_both -- +/usr/bin/cmake --build "$(pwd)/build" --config Debug --target cpp_examples_generate_both_no_check -- bash tests/copy_assigner_outputs.sh build/2 bash tests/compare_folders_content.sh build/1 build/2 \ No newline at end of file From 3f5f9a56acebc33d97a51967317d70885a58bb91 Mon Sep 17 00:00:00 2001 From: Aleksandr Cherenkov Date: Tue, 2 Apr 2024 11:37:53 +0000 Subject: [PATCH 9/9] assigner update --- .github/workflows/build_linux.yml | 7 ------- .github/workflows/build_macos.yml | 7 ------- libs/assigner | 2 +- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index d3c6f1c6..86dae5ec 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -247,13 +247,6 @@ jobs: run: | cmake --build build -t check-crypto3-assigner - - name: Run assigner tests - run: | - cd libs/assigner/test - chmod +x run_tests.py - python3 run_tests.py ../../../build/bin/assigner/assigner - cd ../../../ - - name: Build proof for the circuit of the C++ examples run: | cmake --build build -t prove_cpp_examples diff --git a/.github/workflows/build_macos.yml b/.github/workflows/build_macos.yml index 6af61919..84606f80 100644 --- a/.github/workflows/build_macos.yml +++ b/.github/workflows/build_macos.yml @@ -157,13 +157,6 @@ jobs: run: | cmake --build build -t check-crypto3-assigner - - name: Run assigner tests - run: | - cd libs/assigner/test - chmod +x run_tests.py - python3 run_tests.py ../../../build/bin/assigner/assigner - cd ../../../ - - name: Build proof for the circuit of the C++ examples run: | cmake --build build -t prove_cpp_examples diff --git a/libs/assigner b/libs/assigner index 0e716254..98bb1c0f 160000 --- a/libs/assigner +++ b/libs/assigner @@ -1 +1 @@ -Subproject commit 0e716254827df7424e960325c8eee78a1b6cce33 +Subproject commit 98bb1c0f0a8577d6051f1f3549a757265cecf366