Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: change data store backend to use liblmdb directly #11357

Merged
merged 70 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
dce4701
Moving files
PhilWindle Jan 15, 2025
be77033
Moving files around
PhilWindle Jan 15, 2025
d02755f
Renamed transactions
PhilWindle Jan 15, 2025
124682b
Initial LMDBStore class
PhilWindle Jan 15, 2025
321543c
fix: remove circular includes
alexghr Jan 15, 2025
18c3945
chore: move files
alexghr Jan 15, 2025
2b5a514
refactor: extract module init outside of world_state
alexghr Jan 15, 2025
67de053
refactor!: rename world_state_napi -> nodejs_module
alexghr Jan 15, 2025
1878207
WIP
PhilWindle Jan 15, 2025
b41e3e3
Merge branch 'feat/lmdb-wrapper' of github.com:AztecProtocol/aztec-pa…
PhilWindle Jan 15, 2025
df48bf5
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
PhilWindle Jan 15, 2025
2b4e4ae
feat: first pass
alexghr Jan 15, 2025
9ccfd36
refactor: extract msg processing
alexghr Jan 16, 2025
6f063a6
feat: add @aztec/native
alexghr Jan 16, 2025
5ab8325
WIP
PhilWindle Jan 16, 2025
0ee01c1
WIP
PhilWindle Jan 17, 2025
d6996f3
Merge branch 'feat/lmdb-wrapper' of github.com:AztecProtocol/aztec-pa…
PhilWindle Jan 17, 2025
58359d3
More work on cursors and duplicates
PhilWindle Jan 17, 2025
bd0702f
Work on duplicates
PhilWindle Jan 18, 2025
35133ed
Refactoring of tree stores
PhilWindle Jan 21, 2025
77d8591
Test refactoring
PhilWindle Jan 21, 2025
8c5e594
Batch put operations
PhilWindle Jan 21, 2025
66e3ec7
feat: nodejs lmdb wrapper (dummy backend)
alexghr Jan 21, 2025
c001e19
refactor: @aztec/native
alexghr Jan 21, 2025
22be98d
Merge branch 'master' into feat/lmdb-wrapper
alexghr Jan 21, 2025
553862e
fix: add dep to external lib
alexghr Jan 21, 2025
37ea38c
fix: remove unused import
alexghr Jan 21, 2025
789d05c
fix: lint
alexghr Jan 21, 2025
797296b
chore: fix boxes/yarn.lock
alexghr Jan 21, 2025
d7d5bb2
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
alexghr Jan 27, 2025
9c766a5
feat: native nodejs module for lmdb
alexghr Jan 27, 2025
d90c544
feat: new store
alexghr Jan 27, 2025
ca5438e
feat: add map and single value
alexghr Jan 27, 2025
654d4ee
feat: Archiver uses new store backend
alexghr Jan 27, 2025
8a4ef33
feat: ProvingBroker using new store backend
alexghr Jan 27, 2025
57ecd47
feat: mempool using new store backend
alexghr Jan 27, 2025
1cde8a8
refactor: use shared cursor pointer
alexghr Jan 28, 2025
89ca0dc
refactor: use serial queue
alexghr Jan 28, 2025
4327005
fix: add missing file
alexghr Jan 28, 2025
a2f18c0
feat: cursor reads first page
alexghr Jan 28, 2025
502243e
fix: optimize cursor reads
alexghr Jan 28, 2025
25ebae7
fix: guard cursors with a semaphore
alexghr Jan 28, 2025
3d5e3a8
fix: explicit dep on lmdb repo
alexghr Jan 28, 2025
4ade575
feat: port AttestationPool to async store
alexghr Jan 29, 2025
c267964
feat: port p2p stores
alexghr Jan 29, 2025
3db2589
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
alexghr Jan 30, 2025
057da8c
chore: acually commit conflict resolution
alexghr Jan 30, 2025
8d379ac
feat: export db stats
alexghr Jan 30, 2025
43763aa
fix: more merge conflicts
alexghr Jan 30, 2025
ba073d1
chore: lint
alexghr Jan 30, 2025
0b08bd7
Review changes
PhilWindle Jan 30, 2025
1576f1b
Merge branch 'feat/lmdb-wrapper' of github.com:AztecProtocol/aztec-pa…
PhilWindle Jan 30, 2025
0d07764
Review changes
PhilWindle Jan 30, 2025
2beb6ba
fix: await writes
alexghr Jan 30, 2025
15368a4
fix: p2p tests
alexghr Jan 30, 2025
10f2475
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
alexghr Jan 30, 2025
ac6b10d
chore: lint
alexghr Jan 30, 2025
7ce50bf
fix: tx tests
alexghr Jan 30, 2025
cd980f6
fix: sequencer test
alexghr Jan 30, 2025
9eebba3
fix: create recursive dirs
alexghr Jan 30, 2025
07cb95f
fix: cast stats to number
alexghr Jan 30, 2025
231dcb6
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
alexghr Jan 30, 2025
793dca7
chore: epoch cache ref
alexghr Jan 30, 2025
67287f6
Review fixes
PhilWindle Jan 31, 2025
2c0b870
fix: test timeout in e2e_prover_full
alexghr Jan 31, 2025
1a12648
Merge branch 'master' into feat/lmdb-wrapper
alexghr Jan 31, 2025
963271b
chore: fix noir-bb-tests
alexghr Jan 31, 2025
dcfd3ed
chore: drop cache from yarn command
alexghr Jan 31, 2025
45f1138
Revert acir browser tests
alexghr Jan 31, 2025
3a604a7
Merge remote-tracking branch 'origin/master' into feat/lmdb-wrapper
alexghr Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.aztec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ENV BB_WORKING_DIRECTORY=/usr/src/bb
ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb
ENV ACVM_WORKING_DIRECTORY=/usr/src/acvm
ENV ACVM_BINARY_PATH=/usr/src/noir/noir-repo/target/release/acvm
RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY /usr/src/yarn-project/world-state/build
RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY /usr/src/yarn-project/native/build

COPY /usr/src /usr/src

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.end-to-end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb
ENV ACVM_WORKING_DIRECTORY=/usr/src/acvm
ENV ACVM_BINARY_PATH=/usr/src/noir/noir-repo/target/release/acvm
ENV PROVER_AGENT_CONCURRENCY=8
RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY /usr/src/yarn-project/world-state/build
RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY /usr/src/yarn-project/native/build

COPY /usr/src /usr/src
COPY /anvil /opt/foundry/bin/anvil
Expand Down
8 changes: 4 additions & 4 deletions barretenberg/cpp/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ test-cache-read:
--command="exit 1"
SAVE ARTIFACT build/bin

preset-release-world-state:
preset-release-nodejs-module:
FROM +source
DO +CACHE_BUILD_BIN --prefix=preset-release-world-state \
--command="cmake --preset clang16-pic -Bbuild && cmake --build build --target world_state_napi && mv ./build/lib/world_state_napi.node ./build/bin"
DO +CACHE_BUILD_BIN --prefix=preset-release-nodejs-module \
--command="cmake --preset clang16-pic -Bbuild && cmake --build build --target nodejs_module && mv ./build/lib/nodejs_module.node ./build/bin"
SAVE ARTIFACT build/bin

preset-release-assert:
Expand Down Expand Up @@ -317,4 +317,4 @@ build:
BUILD +preset-wasm
BUILD +preset-wasm-threads
BUILD +preset-release
BUILD +preset-release-world-state
BUILD +preset-release-nodejs-module
10 changes: 5 additions & 5 deletions barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ function build_native {
cache_upload barretenberg-release-$hash.tar.gz build/bin
fi

(cd src/barretenberg/world_state_napi && yarn --frozen-lockfile --prefer-offline)
if ! cache_download barretenberg-release-world-state-$hash.tar.gz; then
(cd src/barretenberg/nodejs_module && yarn --frozen-lockfile --prefer-offline)
if ! cache_download barretenberg-release-nodejs-module-$hash.tar.gz; then
rm -f build-pic/CMakeCache.txt
cmake --preset $pic_preset -DCMAKE_BUILD_TYPE=RelWithAssert
cmake --build --preset $pic_preset --target world_state_napi
cache_upload barretenberg-release-world-state-$hash.tar.gz build-pic/lib/world_state_napi.node
cmake --build --preset $pic_preset --target nodejs_module
cache_upload barretenberg-release-nodejs-module-$hash.tar.gz build-pic/lib/nodejs_module.node
fi
}

Expand Down Expand Up @@ -118,4 +118,4 @@ case "$cmd" in
*)
echo "Unknown command: $cmd"
exit 1
esac
esac
3 changes: 2 additions & 1 deletion barretenberg/cpp/cmake/lmdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ include(ExternalProject)
set(LMDB_PREFIX "${CMAKE_BINARY_DIR}/_deps/lmdb")
set(LMDB_INCLUDE "${LMDB_PREFIX}/src/lmdb_repo/libraries/liblmdb")
set(LMDB_LIB "${LMDB_INCLUDE}/liblmdb.a")
set(LMDB_HEADER "${LMDB_INCLUDE}/lmdb.h")
set(LMDB_OBJECT "${LMDB_INCLUDE}/*.o")

ExternalProject_Add(
Expand All @@ -15,7 +16,7 @@ ExternalProject_Add(
BUILD_COMMAND make -C libraries/liblmdb -e XCFLAGS=-fPIC liblmdb.a
INSTALL_COMMAND ""
UPDATE_COMMAND "" # No update step
BUILD_BYPRODUCTS ${LMDB_LIB} ${LMDB_INCLUDE}
BUILD_BYPRODUCTS ${LMDB_LIB} ${LMDB_HEADER}
)

add_library(lmdb STATIC IMPORTED GLOBAL)
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/dockerfiles/Dockerfile.x86_64-linux-clang
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN cmake --build --preset clang16 --target ultra_honk_rounds_bench --target bb

RUN npm install --global yarn
RUN cmake --preset clang16-pic
RUN cmake --build --preset clang16-pic --target world_state_napi
RUN cmake --build --preset clang16-pic --target nodejs_module

FROM ubuntu:lunar
WORKDIR /usr/src/barretenberg/cpp
Expand All @@ -40,4 +40,4 @@ COPY --from=builder /usr/src/barretenberg/cpp/build/bin/grumpkin_srs_gen /usr/sr
# Copy libs for consuming projects.
COPY --from=builder /usr/src/barretenberg/cpp/build/lib/libbarretenberg.a /usr/src/barretenberg/cpp/build/lib/libbarretenberg.a
COPY --from=builder /usr/src/barretenberg/cpp/build/lib/libenv.a /usr/src/barretenberg/cpp/build/lib/libenv.a
COPY --from=builder /usr/src/barretenberg/cpp/build-pic/lib/world_state_napi.node /usr/src/barretenberg/cpp/build-pic/lib/world_state_napi.node
COPY --from=builder /usr/src/barretenberg/cpp/build-pic/lib/nodejs_module.node /usr/src/barretenberg/cpp/build-pic/lib/nodejs_module.node
13 changes: 13 additions & 0 deletions barretenberg/cpp/scripts/lmdblib_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -e

# run commands relative to parent directory
cd $(dirname $0)/..

DEFAULT_TESTS=LMDBStoreTest.*:LMDBEnvironmentTest.*
TEST=${1:-$DEFAULT_TESTS}
PRESET=${PRESET:-clang16}

cmake --build --preset $PRESET --target lmdblib_tests
./build/bin/lmdblib_tests --gtest_filter=$TEST
6 changes: 4 additions & 2 deletions barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (ENABLE_PIC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("Building with Position Independent Code")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
add_subdirectory(barretenberg/world_state_napi)
add_subdirectory(barretenberg/nodejs_module)
endif()

add_subdirectory(barretenberg/bb)
Expand All @@ -78,6 +78,7 @@ add_subdirectory(barretenberg/examples)
add_subdirectory(barretenberg/flavor)
add_subdirectory(barretenberg/goblin)
add_subdirectory(barretenberg/grumpkin_srs_gen)
add_subdirectory(barretenberg/lmdblib)
add_subdirectory(barretenberg/numeric)
add_subdirectory(barretenberg/plonk)
add_subdirectory(barretenberg/plonk_honk_shared)
Expand Down Expand Up @@ -176,8 +177,9 @@ if(NOT DISABLE_AZTEC_VM)
endif()

if(NOT WASM)
# enable merkle trees
# enable merkle trees and lmdb
list(APPEND BARRETENBERG_TARGET_OBJECTS $<TARGET_OBJECTS:crypto_merkle_tree_objects>)
list(APPEND BARRETENBERG_TARGET_OBJECTS $<TARGET_OBJECTS:lmdblib_objects>)
endif()

add_library(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "barretenberg/crypto/merkle_tree/hash.hpp"
#include "barretenberg/crypto/merkle_tree/indexed_tree/content_addressed_indexed_tree.hpp"
#include "barretenberg/crypto/merkle_tree/indexed_tree/indexed_leaf.hpp"
#include "barretenberg/crypto/merkle_tree/lmdb_store/callbacks.hpp"
#include "barretenberg/crypto/merkle_tree/lmdb_store/lmdb_tree_store.hpp"
#include "barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp"
#include "barretenberg/crypto/merkle_tree/response.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# merkle tree is agnostic to hash function
barretenberg_module(
crypto_merkle_tree
lmdb
lmdblib
)

if (NOT FUZZING)
# but the tests use pedersen and poseidon
target_link_libraries(crypto_merkle_tree_tests PRIVATE stdlib_pedersen_hash stdlib_poseidon2)
add_dependencies(crypto_merkle_tree_tests lmdb_repo)
add_dependencies(crypto_merkle_tree_test_objects lmdb_repo)
endif()

add_dependencies(crypto_merkle_tree lmdb_repo)
add_dependencies(crypto_merkle_tree_objects lmdb_repo)

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include "barretenberg/common/thread_pool.hpp"
#include "barretenberg/crypto/merkle_tree/hash.hpp"
#include "barretenberg/crypto/merkle_tree/hash_path.hpp"
#include "barretenberg/crypto/merkle_tree/lmdb_store/lmdb_environment.hpp"
#include "barretenberg/crypto/merkle_tree/lmdb_store/lmdb_tree_store.hpp"
#include "barretenberg/crypto/merkle_tree/node_store/array_store.hpp"
#include "barretenberg/crypto/merkle_tree/node_store/cached_content_addressed_tree_store.hpp"
#include "barretenberg/crypto/merkle_tree/response.hpp"
#include "barretenberg/crypto/merkle_tree/signal.hpp"
#include "barretenberg/crypto/merkle_tree/types.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/lmdblib/lmdb_environment.hpp"
#include "barretenberg/relations/relation_parameters.hpp"
#include <algorithm>
#include <array>
Expand All @@ -29,6 +29,7 @@

using namespace bb;
using namespace bb::crypto::merkle_tree;
using namespace bb::lmdblib;

using Store = ContentAddressedCachedTreeStore<bb::fr>;
using TreeType = ContentAddressedAppendOnlyTree<Store, Poseidon2HashPolicy>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static std::vector<fr> VALUES = create_values();
inline std::string random_string()
{
std::stringstream ss;
ss << random_engine.get_random_uint256();
ss << random_engine.get_random_uint32();
return ss.str();
}

Expand Down

This file was deleted.

This file was deleted.

Loading
Loading