Barretenberg
The ZK-SNARK library at the core of Aztec
|
#include "barretenberg/crypto/merkle_tree/append_only_tree/content_addressed_append_only_tree.hpp"
#include "../fixtures.hpp"
#include "../memory_tree.hpp"
#include "../test_fixtures.hpp"
#include "barretenberg/common/streams.hpp"
#include "barretenberg/common/test.hpp"
#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_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>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <memory>
#include <optional>
#include <stdexcept>
#include <vector>
Go to the source code of this file.
Classes | |
class | PersistedContentAddressedAppendOnlyTreeTest |
Typedefs | |
using | Store = ContentAddressedCachedTreeStore< bb::fr > |
using | TreeType = ContentAddressedAppendOnlyTree< Store, Poseidon2HashPolicy > |
using | LMDBStoreType = LMDBTreeStore |
Functions | |
void | check_size (TreeType &tree, index_t expected_size, bool includeUncommitted=true) |
void | check_finalized_block_height (TreeType &tree, block_number_t expected_finalized_block) |
void | check_block_height (TreeType &tree, index_t expected_block_height) |
void | check_root (TreeType &tree, fr expected_root, bool includeUncommitted=true) |
void | check_sibling_path (TreeType &tree, index_t index, fr_sibling_path expected_sibling_path, bool includeUncommitted=true, bool expected_result=true) |
void | check_sibling_path_by_value (TreeType &tree, fr value, fr_sibling_path expected_sibling_path, index_t expected_index, bool includeUncommitted=true, bool expected_result=true) |
void | check_historic_sibling_path (TreeType &tree, index_t index, fr_sibling_path expected_sibling_path, block_number_t blockNumber, bool expected_success=true) |
void | check_historic_sibling_path_by_value (TreeType &tree, fr value, fr_sibling_path expected_sibling_path, index_t expected_index, block_number_t blockNumber, bool expected_success=true) |
void | commit_tree (TreeType &tree, bool expected_success=true) |
void | remove_historic_block (TreeType &tree, const block_number_t &blockNumber, bool expected_success=true) |
void | unwind_block (TreeType &tree, const block_number_t &blockNumber, bool expected_success=true) |
void | add_value (TreeType &tree, const fr &value) |
void | add_values (TreeType &tree, const std::vector< fr > &values) |
void | finalize_block (TreeType &tree, const block_number_t &blockNumber, bool expected_success=true) |
void | check_leaf (TreeType &tree, const fr &leaf, index_t leaf_index, bool expected_success, bool includeUncommitted=true) |
void | check_historic_leaf (TreeType &tree, const block_number_t &blockNumber, const fr &leaf, index_t leaf_index, bool expected_success, bool includeUncommitted=true) |
void | check_sibling_path (fr expected_root, fr node, index_t index, fr_sibling_path sibling_path) |
void | get_blocks_for_indices (TreeType &tree, const std::vector< index_t > &indices, std::vector< std::optional< block_number_t > > &blockNumbers) |
void | get_blocks_for_indices (TreeType &tree, const block_number_t &blockNumber, const std::vector< index_t > &indices, std::vector< std::optional< block_number_t > > &blockNumbers) |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_create) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, committing_with_no_changes_should_succeed) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_only_recreate_with_same_name_and_depth) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_add_value_and_get_sibling_path) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, reports_an_error_if_tree_is_overfilled) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, errors_are_caught_and_handled) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_commit_and_restore) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, test_size) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, test_find_leaf_index) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_add_multiple_values) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_add_multiple_values_in_a_batch) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_pad_with_zero_leaves) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_retrieve_zero_leaf_indices) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_commit_multiple_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_add_varying_size_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_retrieve_historic_sibling_paths) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, retrieves_historic_leaves) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, test_find_historic_leaf_index) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_be_filled) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_add_single_whilst_reading) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_get_inserted_leaves) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, returns_sibling_path) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_create_images_at_historic_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_remove_historic_block_data) | |
void | test_unwind (std::string directory, std::string name, uint64_t mapSize, uint64_t maxReaders, uint32_t depth, uint32_t blockSize, uint32_t numBlocks, uint32_t numBlocksToUnwind, std::vector< fr > values) |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_unwind_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_unwind_all_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_unwind_initial_blocks_that_are_full_of_zeros) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_sync_and_unwind_large_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_commit_and_unwind_empty_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_commit_and_remove_historic_empty_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_retrieve_block_numbers_by_index) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_advance_finalized_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_finalize_multiple_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_finalize_block_beyond_pending_chain) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_fork_from_unwound_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_fork_from_expired_historical_blocks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_fork_from_block_zero_when_not_latest) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_unwind_finalized_block) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_not_historically_remove_finalized_block) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_checkpoint_and_revert_forks) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_commit_all_checkpoints) | |
TEST_F (PersistedContentAddressedAppendOnlyTreeTest, can_revert_all_checkpoints) | |
using LMDBStoreType = LMDBTreeStore |
Definition at line 36 of file content_addressed_append_only_tree.test.cpp.
using Store = ContentAddressedCachedTreeStore<bb::fr> |
Definition at line 34 of file content_addressed_append_only_tree.test.cpp.
Definition at line 35 of file content_addressed_append_only_tree.test.cpp.
Definition at line 218 of file content_addressed_append_only_tree.test.cpp.
Definition at line 230 of file content_addressed_append_only_tree.test.cpp.
Definition at line 83 of file content_addressed_append_only_tree.test.cpp.
void check_finalized_block_height | ( | TreeType & | tree, |
block_number_t | expected_finalized_block | ||
) |
Definition at line 71 of file content_addressed_append_only_tree.test.cpp.
void check_historic_leaf | ( | TreeType & | tree, |
const block_number_t & | blockNumber, | ||
const fr & | leaf, | ||
index_t | leaf_index, | ||
bool | expected_success, | ||
bool | includeUncommitted = true |
||
) |
Definition at line 270 of file content_addressed_append_only_tree.test.cpp.
void check_historic_sibling_path | ( | TreeType & | tree, |
index_t | index, | ||
fr_sibling_path | expected_sibling_path, | ||
block_number_t | blockNumber, | ||
bool | expected_success = true |
||
) |
Definition at line 146 of file content_addressed_append_only_tree.test.cpp.
void check_historic_sibling_path_by_value | ( | TreeType & | tree, |
fr | value, | ||
fr_sibling_path | expected_sibling_path, | ||
index_t | expected_index, | ||
block_number_t | blockNumber, | ||
bool | expected_success = true |
||
) |
Definition at line 164 of file content_addressed_append_only_tree.test.cpp.
void check_leaf | ( | TreeType & | tree, |
const fr & | leaf, | ||
index_t | leaf_index, | ||
bool | expected_success, | ||
bool | includeUncommitted = true |
||
) |
Definition at line 256 of file content_addressed_append_only_tree.test.cpp.
Definition at line 95 of file content_addressed_append_only_tree.test.cpp.
void check_sibling_path | ( | fr | expected_root, |
fr | node, | ||
index_t | index, | ||
fr_sibling_path | sibling_path | ||
) |
Definition at line 288 of file content_addressed_append_only_tree.test.cpp.
void check_sibling_path | ( | TreeType & | tree, |
index_t | index, | ||
fr_sibling_path | expected_sibling_path, | ||
bool | includeUncommitted = true , |
||
bool | expected_result = true |
||
) |
Definition at line 107 of file content_addressed_append_only_tree.test.cpp.
void check_sibling_path_by_value | ( | TreeType & | tree, |
fr | value, | ||
fr_sibling_path | expected_sibling_path, | ||
index_t | expected_index, | ||
bool | includeUncommitted = true , |
||
bool | expected_result = true |
||
) |
Definition at line 125 of file content_addressed_append_only_tree.test.cpp.
Definition at line 59 of file content_addressed_append_only_tree.test.cpp.
void commit_tree | ( | TreeType & | tree, |
bool | expected_success = true |
||
) |
Definition at line 185 of file content_addressed_append_only_tree.test.cpp.
void finalize_block | ( | TreeType & | tree, |
const block_number_t & | blockNumber, | ||
bool | expected_success = true |
||
) |
Definition at line 242 of file content_addressed_append_only_tree.test.cpp.
void get_blocks_for_indices | ( | TreeType & | tree, |
const block_number_t & | blockNumber, | ||
const std::vector< index_t > & | indices, | ||
std::vector< std::optional< block_number_t > > & | blockNumbers | ||
) |
Definition at line 321 of file content_addressed_append_only_tree.test.cpp.
void get_blocks_for_indices | ( | TreeType & | tree, |
const std::vector< index_t > & | indices, | ||
std::vector< std::optional< block_number_t > > & | blockNumbers | ||
) |
Definition at line 309 of file content_addressed_append_only_tree.test.cpp.
void remove_historic_block | ( | TreeType & | tree, |
const block_number_t & | blockNumber, | ||
bool | expected_success = true |
||
) |
Definition at line 196 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_add_multiple_values | |||
) |
Definition at line 727 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_add_multiple_values_in_a_batch | |||
) |
Definition at line 750 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_add_single_whilst_reading | |||
) |
Definition at line 1051 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_add_value_and_get_sibling_path | |||
) |
Definition at line 400 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_add_varying_size_blocks | |||
) |
Definition at line 863 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_advance_finalized_blocks | |||
) |
Definition at line 1738 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_be_filled | |||
) |
Definition at line 1028 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_checkpoint_and_revert_forks | |||
) |
Definition at line 2007 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_commit_all_checkpoints | |||
) |
Definition at line 2116 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_commit_and_remove_historic_empty_blocks | |||
) |
Definition at line 1581 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_commit_and_restore | |||
) |
Definition at line 557 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_commit_and_unwind_empty_blocks | |||
) |
Definition at line 1519 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_commit_multiple_blocks | |||
) |
Definition at line 826 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_create | |||
) |
Definition at line 334 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_create_images_at_historic_blocks | |||
) |
Definition at line 1156 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_finalize_multiple_blocks | |||
) |
Definition at line 1782 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_fork_from_block_zero_when_not_latest | |||
) |
Definition at line 1899 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_get_inserted_leaves | |||
) |
Definition at line 1094 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_finalize_block_beyond_pending_chain | |||
) |
Definition at line 1815 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_fork_from_expired_historical_blocks | |||
) |
Definition at line 1877 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_fork_from_unwound_blocks | |||
) |
Definition at line 1855 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_historically_remove_finalized_block | |||
) |
Definition at line 1969 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_retrieve_zero_leaf_indices | |||
) |
Definition at line 801 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_not_unwind_finalized_block | |||
) |
Definition at line 1931 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_only_recreate_with_same_name_and_depth | |||
) |
Definition at line 389 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_pad_with_zero_leaves | |||
) |
Definition at line 775 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_remove_historic_block_data | |||
) |
Definition at line 1249 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_retrieve_block_numbers_by_index | |||
) |
Definition at line 1643 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_retrieve_historic_sibling_paths | |||
) |
Definition at line 901 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_revert_all_checkpoints | |||
) |
Definition at line 2168 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_sync_and_unwind_large_blocks | |||
) |
Definition at line 1504 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_unwind_all_blocks | |||
) |
Definition at line 1468 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_unwind_blocks | |||
) |
Definition at line 1462 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
can_unwind_initial_blocks_that_are_full_of_zeros | |||
) |
Definition at line 1476 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
committing_with_no_changes_should_succeed | |||
) |
Definition at line 350 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
errors_are_caught_and_handled | |||
) |
Definition at line 453 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
reports_an_error_if_tree_is_overfilled | |||
) |
Definition at line 423 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
retrieves_historic_leaves | |||
) |
Definition at line 952 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
returns_sibling_path | |||
) |
Definition at line 1113 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
test_find_historic_leaf_index | |||
) |
Definition at line 986 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
test_find_leaf_index | |||
) |
Definition at line 655 of file content_addressed_append_only_tree.test.cpp.
TEST_F | ( | PersistedContentAddressedAppendOnlyTreeTest | , |
test_size | |||
) |
Definition at line 627 of file content_addressed_append_only_tree.test.cpp.
void test_unwind | ( | std::string | directory, |
std::string | name, | ||
uint64_t | mapSize, | ||
uint64_t | maxReaders, | ||
uint32_t | depth, | ||
uint32_t | blockSize, | ||
uint32_t | numBlocks, | ||
uint32_t | numBlocksToUnwind, | ||
std::vector< fr > | values | ||
) |
Definition at line 1337 of file content_addressed_append_only_tree.test.cpp.
void unwind_block | ( | TreeType & | tree, |
const block_number_t & | blockNumber, | ||
bool | expected_success = true |
||
) |
Definition at line 207 of file content_addressed_append_only_tree.test.cpp.