Skip to content

Commit

Permalink
chore(bb): make compile on stock mac clang (#8278)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ludamad authored Aug 30, 2024
1 parent 6194b94 commit 7af80ff
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 32 deletions.
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/aztec_ivc/aztec_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void IndexedTree<Store, HashingPolicy>::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<std::vector<Signal>> signals = std::make_shared<std::vector<Signal>>();
auto signals = std::make_shared<std::vector<Signal>>();
std::shared_ptr<Status> status = std::make_shared<Status>();
// The first signal is set to 0. This ensures the first worker up the tree is not impeded
signals->emplace_back(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdlib>
#include <filesystem>
#include <stdexcept>
#include <thread>
#include <vector>

#include "barretenberg/common/serialize.hpp"
Expand Down
31 changes: 16 additions & 15 deletions barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::atomic<uint32_t>>(initial_level)){};
~Signal() = default;
Signal(const Signal& other)
: signal_(other.signal_.load())
: signal_(std::make_unique<std::atomic<uint32_t>>(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
Expand All @@ -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();
}
}

Expand All @@ -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<uint32_t> signal_;
// apple clang has issues if this cannot be move-constructed, so we wrap in unique_ptr
std::unique_ptr<std::atomic<uint32_t>> signal_;
};
} // namespace bb::crypto::merkle_tree
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <cstdint>
#include <cstddef>
namespace bb::crypto::merkle_tree {
using index_t = uint64_t;
using index_t = size_t;
} // namespace bb::crypto::merkle_tree
10 changes: 3 additions & 7 deletions barretenberg/cpp/src/barretenberg/sumcheck/sumcheck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,9 @@ polynomials that are sent in clear.

std::vector<FF> libra_evaluations;
libra_evaluations.reserve(multivariate_d);
zk_sumcheck_data = ZKSumcheckData<Flavor>(eval_masking_scalars,
masking_terms_evaluations,
libra_univariates,
libra_scaling_factor,
libra_challenge,
libra_running_sum,
libra_evaluations);
zk_sumcheck_data = ZKSumcheckData<Flavor>{ eval_masking_scalars, masking_terms_evaluations, libra_univariates,
libra_scaling_factor, libra_challenge, libra_running_sum,
libra_evaluations };
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "barretenberg/vm/avm/trace/helper.hpp"
#include "barretenberg/vm/constants.hpp"
#include "common.test.hpp"
#include <bits/utility.h>

namespace tests_avm {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AvmSliceTests : public ::testing::Test {
}

// Check that the extra final row is well-formed.
EXPECT_THAT(trace.at(static_cast<size_t>(last_row_idx + 1)),
EXPECT_THAT(trace.at(static_cast<uint64_t>(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),
Expand Down

0 comments on commit 7af80ff

Please sign in to comment.