diff --git a/.github/workflows/build_linux.yml b/.github/workflows/build_linux.yml index 5a3dcab4..86dae5ec 100644 --- a/.github/workflows/build_linux.yml +++ b/.github/workflows/build_linux.yml @@ -163,9 +163,26 @@ 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 + 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_no_check + 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 @@ -230,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 c54ab50f..84606f80 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 @@ -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/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"); 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 8ee3ea56..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() @@ -138,7 +142,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]} -] diff --git a/libs/assigner b/libs/assigner index da77d320..98bb1c0f 160000 --- a/libs/assigner +++ b/libs/assigner @@ -1 +1 @@ -Subproject commit da77d320a90ca8602a2f7e0e6eed00e8cb02bbb4 +Subproject commit 98bb1c0f0a8577d6051f1f3549a757265cecf366 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..096be818 --- /dev/null +++ b/tests/run_different_generation_modes_comparison.sh @@ -0,0 +1,10 @@ +rm -r build/examples/cpp +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_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