From 8829f7c2baf316baaeadefa9040369f282bf08a3 Mon Sep 17 00:00:00 2001 From: Rumata888 Date: Mon, 31 Jul 2023 16:48:03 +0000 Subject: [PATCH] fix: Fixing fuzzing build after composer splitting --- .../barretenberg/acir_tests/run_acir_tests.sh | 4 +- circuits/cpp/barretenberg/cpp/bootstrap.sh | 13 +- .../cpp/barretenberg/cpp/scripts/run_tests | 1 + .../cpp/src/barretenberg/common/fuzzer.hpp | 8 +- .../cpp/src/barretenberg/common/serialize.hpp | 3 +- .../cpp/src/barretenberg/common/streams.hpp | 3 +- .../dsl/acir_format/acir_format.hpp | 4 +- .../dsl/acir_format/block_constraint.test.cpp | 2 +- .../dsl/acir_format/ecdsa_secp256k1.test.cpp | 2 +- .../dsl/acir_format/ecdsa_secp256r1.test.cpp | 2 +- .../acir_format/recursion_constraint.test.cpp | 2 +- .../dsl/acir_proofs/acir_composer.cpp | 12 +- .../dsl/acir_proofs/acir_composer.hpp | 16 +- .../ecc/curves/grumpkin/grumpkin.hpp | 2 +- .../barretenberg/examples/simple/simple.cpp | 2 +- .../barretenberg/examples/simple/simple.hpp | 2 +- .../examples/simple/simple.test.cpp | 2 +- .../grumpkin_srs_gen/CMakeLists.txt | 24 +- .../grumpkin_srs_gen/grumpkin_srs_gen.cpp | 4 +- .../honk/composer/standard_composer.hpp | 19 +- .../honk/composer/standard_composer.test.cpp | 195 ++--- .../honk/composer/ultra_composer.hpp | 9 +- .../honk/composer/ultra_composer.test.cpp | 9 +- .../barretenberg/honk/flavor/goblin_ultra.hpp | 14 +- .../src/barretenberg/honk/flavor/standard.hpp | 14 +- .../honk/flavor/standard_grumpkin.hpp | 16 +- .../src/barretenberg/honk/flavor/ultra.hpp | 17 +- .../honk/flavor/ultra_grumpkin.hpp | 19 +- .../barretenberg/honk/pcs/commitment_key.hpp | 61 +- .../honk/pcs/commitment_key.test.hpp | 26 +- .../honk/pcs/gemini/gemini.test.cpp | 3 +- .../cpp/src/barretenberg/honk/pcs/ipa/ipa.hpp | 18 +- .../barretenberg/honk/pcs/ipa/ipa.test.cpp | 93 +++ .../barretenberg/honk/pcs/kzg/kzg.test.cpp | 2 +- .../honk/pcs/shplonk/shplonk.test.cpp | 5 +- .../honk/pcs/shplonk/shplonk_single.hpp | 8 +- .../honk/proof_system/composer_lib.hpp | 2 +- .../honk/proof_system/ultra_verifier.cpp | 2 +- .../honk/proof_system/verifier.cpp | 2 +- .../relations/relation_correctness.test.cpp | 3 +- .../sumcheck/relations/relation_types.hpp | 20 +- .../honk/sumcheck/sumcheck.test.cpp | 3 +- .../honk/sumcheck/sumcheck_round.hpp | 5 +- .../honk/transcript/transcript.test.cpp | 8 +- .../proofs/compute_circuit_data.hpp | 4 +- .../join_split/compute_circuit_data.cpp | 3 +- .../join_split/compute_circuit_data.hpp | 3 +- .../proofs/join_split/join_split.cpp | 5 +- .../proofs/join_split/join_split.hpp | 5 +- .../proofs/join_split/join_split.test.cpp | 5 +- .../join_split/join_split_js_parity.test.cpp | 5 +- .../plonk/composer/composer_lib.cpp | 3 +- .../plonk/composer/composer_lib.hpp | 15 +- .../plonk/composer/standard_composer.cpp | 3 +- .../plonk/composer/standard_composer.hpp | 11 +- .../plonk/composer/standard_composer.test.cpp | 28 +- .../plonk/composer/turbo_composer.hpp | 10 +- .../plonk/composer/turbo_composer.test.cpp | 131 ++-- .../plonk/composer/ultra_composer.hpp | 7 +- .../plonk/composer/ultra_composer.test.cpp | 9 +- .../src/barretenberg/plonk/flavor/flavor.hpp | 9 + .../commitment_scheme.test.cpp | 6 +- .../proving_key/proving_key.test.cpp | 4 +- .../verification_key/verification_key.cpp | 4 +- .../verification_key/verification_key.hpp | 7 +- .../proof_system/verifier/verifier.test.cpp | 2 +- .../polynomials/evaluation_domain.cpp | 12 +- .../polynomials/evaluation_domain.hpp | 42 +- .../polynomial_arithmetic.test.cpp | 1 + .../arithmetization/arithmetization.hpp | 7 + .../arithmetization/gate_data.hpp | 20 +- .../circuit_builder/circuit_builder_base.cpp | 1 + .../circuit_builder/circuit_builder_base.hpp | 7 +- .../goblin_translator_circuit_builder.hpp | 699 ++++++++++++++++++ ...goblin_translator_circuit_builder.test.cpp | 432 +++++++++++ .../standard_circuit_builder.cpp | 27 +- .../standard_circuit_builder.hpp | 14 +- .../standard_circuit_builder.test.cpp | 67 +- .../circuit_builder/turbo_circuit_builder.cpp | 44 +- .../circuit_builder/turbo_circuit_builder.hpp | 33 +- .../turbo_circuit_builder.test.cpp | 95 ++- .../circuit_builder/ultra_circuit_builder.cpp | 19 +- .../circuit_builder/ultra_circuit_builder.hpp | 33 +- .../ultra_circuit_builder.test.cpp | 12 +- .../proof_system/composer/composer_lib.hpp | 10 +- .../composer/composer_lib.test.cpp | 2 +- .../proof_system/composer/permutation_lib.hpp | 11 +- .../composer/permutation_lib.test.cpp | 3 +- .../serialize/msgpack_impl/concepts.hpp | 24 +- .../serialize/msgpack_impl/func_traits.hpp | 7 +- .../serialize/msgpack_impl/schema_impl.hpp | 14 +- .../solidity_helpers/CMakeLists.txt | 22 +- .../srs/factories/crs_factory.hpp | 48 +- .../srs/factories/file_crs_factory.cpp | 58 +- .../srs/factories/file_crs_factory.hpp | 76 +- .../srs/factories/mem_crs_factory.cpp | 17 +- .../srs/factories/mem_crs_factory.hpp | 9 +- .../srs/factories/mem_crs_factory.test.cpp | 7 +- .../cpp/src/barretenberg/srs/global_crs.cpp | 25 +- .../cpp/src/barretenberg/srs/global_crs.hpp | 8 +- .../benchmarks/external/external.bench.cpp | 23 +- .../hash/benchmarks/sha256/sha256.bench.cpp | 14 +- .../stdlib/hash/pedersen/pedersen.cpp | 49 +- .../stdlib/hash/pedersen/pedersen_gates.hpp | 7 +- .../stdlib/hash/pedersen/pedersen_plookup.cpp | 12 +- .../primitives/bigfield/bigfield.fuzzer.hpp | 20 +- .../primitives/bit_array/bit_array.fuzzer.hpp | 13 +- .../stdlib/primitives/bool/bool.cpp | 59 +- .../stdlib/primitives/bool/bool.fuzzer.hpp | 4 +- .../byte_array/byte_array.fuzzer.hpp | 4 +- .../circuit_builders/circuit_builders_fwd.hpp | 2 + .../stdlib/primitives/field/field.cpp | 150 ++-- .../stdlib/primitives/field/field.fuzzer.hpp | 126 ++-- .../stdlib/primitives/field/field.test.cpp | 34 +- .../stdlib/primitives/group/group.hpp | 28 +- .../primitives/safe_uint/safe_uint.fuzzer.hpp | 5 +- .../stdlib/primitives/uint/arithmetic.cpp | 41 +- .../stdlib/primitives/uint/logic.cpp | 68 +- .../primitives/uint/plookup/arithmetic.cpp | 57 +- .../stdlib/primitives/uint/plookup/uint.hpp | 1 + .../stdlib/primitives/uint/uint.cpp | 56 +- .../stdlib/primitives/uint/uint.fuzzer.hpp | 4 +- .../stdlib/primitives/uint/uint.test.cpp | 27 +- .../verification_key/verification_key.hpp | 2 +- .../verification_key.test.cpp | 4 +- 125 files changed, 2548 insertions(+), 1128 deletions(-) create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.hpp create mode 100644 circuits/cpp/barretenberg/cpp/src/barretenberg/proof_system/circuit_builder/goblin_translator_circuit_builder.test.cpp diff --git a/circuits/cpp/barretenberg/acir_tests/run_acir_tests.sh b/circuits/cpp/barretenberg/acir_tests/run_acir_tests.sh index 6531a28b6bd8..2767f2ec909c 100755 --- a/circuits/cpp/barretenberg/acir_tests/run_acir_tests.sh +++ b/circuits/cpp/barretenberg/acir_tests/run_acir_tests.sh @@ -18,10 +18,10 @@ if [ ! -d acir_tests ]; then git clone -b $BRANCH --filter=blob:none --no-checkout https://github.com/noir-lang/noir.git cd noir git sparse-checkout init --cone - git sparse-checkout set crates/nargo_cli/tests/test_data_ssa_refactor + git sparse-checkout set crates/nargo_cli/tests/test_data git checkout cd .. - mv noir/crates/nargo_cli/tests/test_data_ssa_refactor acir_tests + mv noir/crates/nargo_cli/tests/test_data acir_tests rm -rf noir fi fi diff --git a/circuits/cpp/barretenberg/cpp/bootstrap.sh b/circuits/cpp/barretenberg/cpp/bootstrap.sh index 0b81033372d1..f81477ff7388 100755 --- a/circuits/cpp/barretenberg/cpp/bootstrap.sh +++ b/circuits/cpp/barretenberg/cpp/bootstrap.sh @@ -8,10 +8,8 @@ rm -rf ./build-wasm # Install formatting git hook. HOOKS_DIR=$(git rev-parse --git-path hooks) # The pre-commit script will live in a barretenberg-specific hooks directory -# That may be just in the top level of this repository, -# or may be in a .git/modules/barretenberg subdirectory when this is actually a submodule -# Either way, running `git rev-parse --show-toplevel` from the hooks directory gives the path to barretenberg -echo "cd \$(git rev-parse --show-toplevel)/cpp && ./format.sh staged" > $HOOKS_DIR/pre-commit +# Find it based on the current working directory. +echo "cd $(pwd)/cpp && ./format.sh staged" > $HOOKS_DIR/pre-commit chmod +x $HOOKS_DIR/pre-commit # Determine system. @@ -50,6 +48,13 @@ echo "#################################" cmake --preset $PRESET -DCMAKE_BUILD_TYPE=RelWithAssert cmake --build --preset $PRESET ${@/#/--target } +cd ./build +# The Grumpkin SRS is generated manually at the moment, only up to a large enough size for tests +# If tests require more points, the parameter can be increased here. +cmake --build . --parallel --target grumpkin_srs_gen +./bin/grumpkin_srs_gen 8192 +echo "Generated Grumpkin SRS successfully" + # Install wasi-sdk. ./scripts/install-wasi-sdk.sh diff --git a/circuits/cpp/barretenberg/cpp/scripts/run_tests b/circuits/cpp/barretenberg/cpp/scripts/run_tests index 7459879b2c12..409379f4e015 100755 --- a/circuits/cpp/barretenberg/cpp/scripts/run_tests +++ b/circuits/cpp/barretenberg/cpp/scripts/run_tests @@ -25,4 +25,5 @@ docker run --rm -t $IMAGE_URI /bin/sh -c "\ cd /usr/src/barretenberg/cpp/srs_db; \ ./download_ignition.sh $NUM_TRANSCRIPTS; \ cd /usr/src/barretenberg/cpp/build; \ + ./bin/grumpkin_srs_gen 1048576; \ for BIN in $TESTS; do ./bin/\$BIN $@; done" diff --git a/circuits/cpp/barretenberg/cpp/src/barretenberg/common/fuzzer.hpp b/circuits/cpp/barretenberg/cpp/src/barretenberg/common/fuzzer.hpp index 079ae269f7fc..1a2fcda97c4c 100644 --- a/circuits/cpp/barretenberg/cpp/src/barretenberg/common/fuzzer.hpp +++ b/circuits/cpp/barretenberg/cpp/src/barretenberg/common/fuzzer.hpp @@ -1,6 +1,6 @@ #pragma once -#include "barretenberg/plonk/composer/standard_composer.hpp" -#include "barretenberg/plonk/composer/turbo_composer.hpp" +#include "barretenberg/proof_system/circuit_constructors/standard_circuit_constructor.hpp" +#include "barretenberg/proof_system/circuit_constructors/turbo_circuit_constructor.hpp" #include #define PARENS () @@ -590,9 +590,9 @@ template