diff --git a/barretenberg/cpp/CMakePresets.json b/barretenberg/cpp/CMakePresets.json index 140b5780ed0..643e4590ae2 100644 --- a/barretenberg/cpp/CMakePresets.json +++ b/barretenberg/cpp/CMakePresets.json @@ -264,6 +264,9 @@ "description": "Build with thread sanitizer on clang16 with debugging information", "inherits": "clang16-dbg", "binaryDir": "build-tsan", + "cacheVariables": { + "HAVE_STD_REGEX": "ON" + }, "environment": { "CFLAGS": "-fsanitize=thread", "CXXFLAGS": "-fsanitize=thread", diff --git a/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp b/barretenberg/cpp/src/barretenberg/crypto/merkle_tree/signal.hpp index 0c313b06614..b9ff1e7a201 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 IndexedTree. Workers signal to other following workes as they move up + * @brief Used in parallel insertions in the the IndexedTree. Workers signal to other following workes as they move up * the level of the tree. * */ class Signal { public: - explicit Signal(uint32_t initial_level = 1) - : signal_(std::make_unique>(initial_level)){}; + Signal(uint32_t initial_level = 1) + : signal_(initial_level){}; ~Signal() = default; Signal(const Signal& other) - : signal_(std::make_unique>(other.signal_->load())) + : signal_(other.signal_.load()) {} - Signal(Signal&& other) = default; + Signal(const Signal&& other) = delete; Signal& operator=(const Signal& other) { if (this != &other) { - signal_->store(other.signal_->load()); + signal_.store(other.signal_.load()); } return *this; } - Signal& operator=(Signal&& other) = default; + Signal& operator=(const Signal&& other) = delete; /** * @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,18 +47,17 @@ 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: - // apple clang has issues if this cannot be move-constructed, so we wrap in unique_ptr - std::unique_ptr> signal_; + std::atomic signal_; }; } // namespace bb::crypto::merkle_tree diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_internal.hpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_internal.hpp index 4659dce991d..15a6fc90752 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_internal.hpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_prover_internal.hpp @@ -252,7 +252,7 @@ template class ProtogalaxyProverInternal { * time) assumes the value G(1) is 0, which is true in the case where the witness to be folded is valid. * @todo (https://github.com/AztecProtocol/barretenberg/issues/968) Make combiner tests better * - * @tparam skip_zero_computations whether to use the the optimization that skips computing zero. + * @tparam skip_zero_computations whether to use the optimization that skips computing zero. * @param * @param gate_separators * @return ExtendedUnivariateWithRandomization diff --git a/barretenberg/cpp/src/barretenberg/world_state/world_state.cpp b/barretenberg/cpp/src/barretenberg/world_state/world_state.cpp index 94a3f7024ea..4a093e5067d 100644 --- a/barretenberg/cpp/src/barretenberg/world_state/world_state.cpp +++ b/barretenberg/cpp/src/barretenberg/world_state/world_state.cpp @@ -97,13 +97,11 @@ StateReference WorldState::get_state_reference(WorldStateRevision revision) cons { Signal signal(static_cast(_trees.size())); StateReference state_reference; - // multiple threads want to write to state_reference - std::mutex state_ref_mutex; bool uncommitted = include_uncommitted(revision); for (const auto& [id, tree] : _trees) { - auto callback = [&signal, &state_reference, &state_ref_mutex, id](const TypedResponse& meta) { + auto callback = [&](const TypedResponse& meta) { std::lock_guard lock(state_ref_mutex); state_reference.insert({ id, { meta.inner.root, meta.inner.size } }); signal.signal_decrement(); diff --git a/barretenberg/cpp/src/barretenberg/world_state/world_state.hpp b/barretenberg/cpp/src/barretenberg/world_state/world_state.hpp index 4ab6455131b..df4880e0058 100644 --- a/barretenberg/cpp/src/barretenberg/world_state/world_state.hpp +++ b/barretenberg/cpp/src/barretenberg/world_state/world_state.hpp @@ -198,6 +198,8 @@ class WorldState { std::unique_ptr _lmdb_env; std::unordered_map _trees; bb::ThreadPool _workers; + // Guards state reference access, flagged as mutable as used in otherwise const methods + mutable std::mutex state_ref_mutex; TreeStateReference get_tree_snapshot(MerkleTreeId id); diff --git a/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp b/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp index 89687d296a2..f4cd18003a1 100644 --- a/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp +++ b/barretenberg/cpp/src/barretenberg/world_state/world_state.test.cpp @@ -13,7 +13,6 @@ class WorldStateTest : public testing::Test { protected: void SetUp() override { - GTEST_SKIP(); // setup with 1MB max db size, 1 max database and 2 maximum concurrent readers _directory = random_temp_directory(); std::filesystem::create_directories(_directory); diff --git a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md b/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md index 426bc1227b0..9c4d0c06c77 100644 --- a/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md +++ b/docs/docs/tutorials/codealong/cli_wallet/faceid_wallet.md @@ -12,7 +12,7 @@ Aztec is in active development and this has only been tested on MacOS. Please re ## Prerequisites -For this tutorial, we will need to have the the [Sandbox](../../../reference/developer_references/sandbox_reference/index.md) installed. +For this tutorial, we will need to have the [Sandbox](../../../reference/developer_references/sandbox_reference/index.md) installed. We also need to install Secretive, a nice open-source package that allows us to store keys on the Secure Enclave. You can head to the [secretive releases page](https://github.com/maxgoedjen/secretive/releases) and get the last release's `zip`, unzip and move to Applications, or use [Homebrew](https://brew.sh/): diff --git a/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol b/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol index 74469a1e9ee..c5a986c3944 100644 --- a/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol +++ b/l1-contracts/src/core/interfaces/messagebridge/IOutbox.sol @@ -72,7 +72,7 @@ interface IOutbox { * @param _l2BlockNumber - The block number to fetch the root data for * * @return root - The root of the merkle tree containing the L2 to L1 messages - * @return minHeight - The min height for the the merkle tree that the root corresponds to + * @return minHeight - The min height for the merkle tree that the root corresponds to */ function getRootData(uint256 _l2BlockNumber) external diff --git a/l1-contracts/src/core/messagebridge/Outbox.sol b/l1-contracts/src/core/messagebridge/Outbox.sol index 5b0e1ebe47c..eeb56348450 100644 --- a/l1-contracts/src/core/messagebridge/Outbox.sol +++ b/l1-contracts/src/core/messagebridge/Outbox.sol @@ -149,7 +149,7 @@ contract Outbox is IOutbox { * @param _l2BlockNumber - The block number to fetch the root data for * * @return root - The root of the merkle tree containing the L2 to L1 messages - * @return minHeight - The min height for the the merkle tree that the root corresponds to + * @return minHeight - The min height for the merkle tree that the root corresponds to */ function getRootData(uint256 _l2BlockNumber) external