From 7af80ff98313a20ed18dc15fd5e4c22c82828a98 Mon Sep 17 00:00:00 2001 From: ludamad Date: Fri, 30 Aug 2024 10:58:33 -0400 Subject: [PATCH] chore(bb): make compile on stock mac clang (#8278) xcode clang does not support all of c++20 it seems e.g. can't do Constructor(A,B,C) where A B and C are the members of a struct with only default constructors. Some common issues that come up like the uint64_t/size_t split --- .../src/barretenberg/aztec_ivc/aztec_ivc.cpp | 2 +- .../commitment_schemes/ipa/ipa.test.cpp | 4 +-- .../commitment_schemes/kzg/kzg.test.cpp | 4 +-- .../merkle_tree/indexed_tree/indexed_tree.hpp | 2 +- .../lmdb_store/lmdb_store.test.cpp | 1 + .../crypto/merkle_tree/signal.hpp | 31 ++++++++++--------- .../barretenberg/crypto/merkle_tree/types.hpp | 4 +-- .../src/barretenberg/sumcheck/sumcheck.hpp | 10 ++---- .../vm/avm/tests/helpers.test.cpp | 1 - .../barretenberg/vm/avm/tests/slice.test.cpp | 2 +- 10 files changed, 29 insertions(+), 32 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp b/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp index 62b1975d1e5..71a4719e44f 100644 --- a/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp +++ b/barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp @@ -14,7 +14,7 @@ void AztecIVC::complete_kernel_circuit_logic(ClientCircuit& circuit) { circuit.databus_propagation_data.is_kernel = true; - // Peform recursive verification and databus consistency checks for each entry in the verification queue + // Perform recursive verification and databus consistency checks for each entry in the verification queue for (auto& [proof, vkey, type] : verification_queue) { // Construct stdlib verification key and proof auto stdlib_proof = bb::convert_proof_to_witness(&circuit, proof); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp index 97c701075cc..d05e7abbc29 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/ipa/ipa.test.cpp @@ -300,9 +300,9 @@ TEST_F(IPATest, GeminiShplonkIPAWithShift) std::string label = "Gemini:a_" + std::to_string(l); const auto& evaluation = gemini_opening_pairs[l + 1].evaluation; prover_transcript->send_to_verifier(label, evaluation); - opening_claims.emplace_back(gemini_witnesses[l], gemini_opening_pairs[l]); + opening_claims.push_back({ gemini_witnesses[l], gemini_opening_pairs[l] }); } - opening_claims.emplace_back(gemini_witnesses[log_n], gemini_opening_pairs[log_n]); + opening_claims.push_back({ gemini_witnesses[log_n], gemini_opening_pairs[log_n] }); const auto opening_claim = ShplonkProver::prove(this->ck(), opening_claims, prover_transcript); IPA::compute_opening_proof(this->ck(), opening_claim, prover_transcript); diff --git a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp index 42cf6b9f8fb..19ead96b61f 100644 --- a/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp +++ b/barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.test.cpp @@ -134,9 +134,9 @@ TYPED_TEST(KZGTest, GeminiShplonkKzgWithShift) std::string label = "Gemini:a_" + std::to_string(l); const auto& evaluation = gemini_opening_pairs[l + 1].evaluation; prover_transcript->send_to_verifier(label, evaluation); - opening_claims.emplace_back(gemini_witnesses[l], gemini_opening_pairs[l]); + opening_claims.push_back({ gemini_witnesses[l], gemini_opening_pairs[l] }); } - opening_claims.emplace_back(gemini_witnesses[log_n], gemini_opening_pairs[log_n]); + opening_claims.push_back({ gemini_witnesses[log_n], gemini_opening_pairs[log_n] }); // Shplonk prover output: // - opening pair: (z_challenge, 0) diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/indexed_tree/indexed_tree.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/indexed_tree/indexed_tree.hpp index 6f561553968..5c88c5b86be 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/indexed_tree/indexed_tree.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/indexed_tree/indexed_tree.hpp @@ -446,7 +446,7 @@ void IndexedTree::perform_insertions(size_t total_leaves, // We now kick off multiple workers to perform the low leaf updates // We create set of signals to coordinate the workers as the move up the tree - std::shared_ptr> signals = std::make_shared>(); + auto signals = std::make_shared>(); std::shared_ptr status = std::make_shared(); // The first signal is set to 0. This ensures the first worker up the tree is not impeded signals->emplace_back(0); diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_store.test.cpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_store.test.cpp index ee81fec390d..b08aa03fefd 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_store.test.cpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/lmdb_store/lmdb_store.test.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "barretenberg/common/serialize.hpp" diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp index b9ff1e7a201..0c313b06614 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp @@ -4,27 +4,27 @@ namespace bb::crypto::merkle_tree { /** - * @brief Used in parallel insertions in the the IndexedTree. Workers signal to other following workes as they move up + * @brief Used in parallel insertions in the IndexedTree. Workers signal to other following workes as they move up * the level of the tree. * */ class Signal { public: - Signal(uint32_t initial_level = 1) - : signal_(initial_level){}; + explicit Signal(uint32_t initial_level = 1) + : signal_(std::make_unique>(initial_level)){}; ~Signal() = default; Signal(const Signal& other) - : signal_(other.signal_.load()) + : signal_(std::make_unique>(other.signal_->load())) {} - Signal(const Signal&& other) = delete; + Signal(Signal&& other) = default; Signal& operator=(const Signal& other) { if (this != &other) { - signal_.store(other.signal_.load()); + signal_->store(other.signal_->load()); } return *this; } - Signal& operator=(const Signal&& other) = delete; + Signal& operator=(Signal&& other) = default; /** * @brief Causes the thread to wait until the required level has been signalled @@ -33,10 +33,10 @@ class Signal { */ void wait_for_level(uint32_t level = 0) { - uint32_t current_level = signal_.load(); + uint32_t current_level = signal_->load(); while (current_level > level) { - signal_.wait(current_level); - current_level = signal_.load(); + signal_->wait(current_level); + current_level = signal_->load(); } } @@ -47,17 +47,18 @@ class Signal { */ void signal_level(uint32_t level = 0) { - signal_.store(level); - signal_.notify_all(); + signal_->store(level); + signal_->notify_all(); } void signal_decrement(uint32_t delta = 1) { - signal_.fetch_sub(delta); - signal_.notify_all(); + signal_->fetch_sub(delta); + signal_->notify_all(); } private: - std::atomic signal_; + // apple clang has issues if this cannot be move-constructed, so we wrap in unique_ptr + std::unique_ptr> signal_; }; } // namespace bb::crypto::merkle_tree diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/types.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/types.hpp index 9cf32fafff0..e714f782eb4 100644 --- a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/types.hpp +++ b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/types.hpp @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace bb::crypto::merkle_tree { -using index_t = uint64_t; +using index_t = size_t; } // namespace bb::crypto::merkle_tree \ No newline at end of file diff --git a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp index 28ec75fdf14..a71bcb1f2c8 100644 --- a/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp +++ b/barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp @@ -431,13 +431,9 @@ polynomials that are sent in clear. std::vector libra_evaluations; libra_evaluations.reserve(multivariate_d); - zk_sumcheck_data = ZKSumcheckData(eval_masking_scalars, - masking_terms_evaluations, - libra_univariates, - libra_scaling_factor, - libra_challenge, - libra_running_sum, - libra_evaluations); + zk_sumcheck_data = ZKSumcheckData{ eval_masking_scalars, masking_terms_evaluations, libra_univariates, + libra_scaling_factor, libra_challenge, libra_running_sum, + libra_evaluations }; }; /** diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/helpers.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/helpers.test.cpp index 86af0009b5a..509a0adae4b 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/helpers.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/helpers.test.cpp @@ -3,7 +3,6 @@ #include "barretenberg/vm/avm/trace/helper.hpp" #include "barretenberg/vm/constants.hpp" #include "common.test.hpp" -#include namespace tests_avm { diff --git a/barretenberg/cpp/src/barretenberg/vm/avm/tests/slice.test.cpp b/barretenberg/cpp/src/barretenberg/vm/avm/tests/slice.test.cpp index ab5d20a6ca2..c5fa9a831b0 100644 --- a/barretenberg/cpp/src/barretenberg/vm/avm/tests/slice.test.cpp +++ b/barretenberg/cpp/src/barretenberg/vm/avm/tests/slice.test.cpp @@ -100,7 +100,7 @@ class AvmSliceTests : public ::testing::Test { } // Check that the extra final row is well-formed. - EXPECT_THAT(trace.at(static_cast(last_row_idx + 1)), + EXPECT_THAT(trace.at(static_cast(last_row_idx + 1)), AllOf(SLICE_ROW_FIELD_EQ(addr, FF(dst_offset) + FF(copy_size)), SLICE_ROW_FIELD_EQ(col_offset, col_offset + copy_size), SLICE_ROW_FIELD_EQ(cnt, 0),