26 return max_index == 0 ? 0 : result % max_index;
30 CacheType& cache,
index_t leaf_offset, uint64_t num_leaves, uint64_t num_nodes, uint64_t max_index = 0)
32 for (uint64_t i = 0; i < num_leaves; i++) {
44 for (uint64_t i = 0; i < num_nodes; i++) {
49 uint32_t level = uint32_t(i % uint64_t(cache.
get_meta().
depth));
51 max_index_at_level <<= level;
58 meta.
size += num_leaves;
74 constexpr uint32_t depth = 10;
88 EXPECT_THROW(cache.
revert(), std::runtime_error);
94 EXPECT_THROW(cache.
commit(), std::runtime_error);
117 return { node_hash_1, node_hash_2, node_hash_3, node_hash_4 };
128 fr node_hash_4 = hashes[3];
149 fr node_hash_4 = hashes[3];
171 fr node_hash_4 = hashes[3];
172 fr node_hash_2 = hashes[1];
194 fr node_hash_4 = hashes[3];
195 fr node_hash_2 = hashes[1];
250 return { leaf_preimage1, leaf_preimage2, leaf_preimage3, leaf_preimage4 };
402 EXPECT_NO_THROW(cache.
revert());
415 EXPECT_NO_THROW(cache.
revert());
436 EXPECT_THROW(cache.
commit(), std::runtime_error);
437 EXPECT_THROW(cache.
revert(), std::runtime_error);
456 EXPECT_THROW(cache.
commit(), std::runtime_error);
457 EXPECT_THROW(cache.
revert(), std::runtime_error);
464 uint64_t num_levels = 10;
470 for (uint64_t i = 0; i < num_levels; i++) {
471 copies.push_back(cache);
476 for (uint64_t i = 0; i < num_levels; i++) {
478 EXPECT_TRUE(copies[num_levels - i - 1].is_equivalent_to(cache));
484 uint64_t num_levels = 10;
488 for (uint64_t i = 0; i < num_levels; i++) {
495 for (uint64_t i = 0; i < num_levels; i++) {
514 for (uint64_t i = 1; i < num_levels; i++) {
516 add_to_cache(cache, (i + 1) * 1000, 1000, 10000, max_index);
522 for (uint64_t i = 1; i < num_levels; i++) {
541 uint64_t num_levels = 10;
543 for (uint64_t max_index : max_indices) {
560 for (uint64_t i = 1; i < num_levels; i++) {
562 add_to_cache(cache, (i + 1) * 1000, 1000, 10000, max_index);
565 for (uint64_t i = 1; i < num_levels; i++) {
586 uint64_t num_levels = 10;
589 for (uint64_t max_index : max_indices) {
void put_leaf_by_index(const index_t &index, const IndexedLeafValueType &leaf_pre_image)
bool get_leaf_by_index(const index_t &index, IndexedLeafValueType &leaf_pre_image) const
void put_meta(const TreeMeta &meta)
void update_leaf_key_index(const index_t &index, const fr &leaf_key)
void put_leaf_preimage_by_hash(const fr &leaf_hash, const IndexedLeafValueType &leaf_pre_image)
std::optional< fr > get_node_by_index(uint32_t level, const index_t &index) const
std::optional< index_t > get_leaf_key_index(const fr &leaf_key) const
void put_node(const fr &node_hash, const NodePayload &node)
const TreeMeta & get_meta() const
bool is_equivalent_to(const ContentAddressedCache &other) const
void put_node_by_index(uint32_t level, const index_t &index, const fr &node)
void test_reverts_remove_all_deeper_commits(uint64_t max_index, uint32_t depth, uint64_t num_levels)
uint64_t get_index(uint64_t max_index=0)
PublicDataLeafValue LeafValueType
CacheType create_cache(uint32_t depth)
std::vector< fr > setup_nodes_test(uint32_t level, uint64_t index, CacheType &cache)
void add_to_cache(CacheType &cache, index_t leaf_offset, uint64_t num_leaves, uint64_t num_nodes, uint64_t max_index=0)
IndexedLeaf< PublicDataLeafValue > IndexedLeafType
std::optional< IndexedLeafType > get_leaf_by_index(CacheType &cache, index_t index)
void reverts_remove_all_deeper_commits_2(uint64_t max_index, uint32_t depth, uint64_t num_levels)
std::vector< IndexedLeafType > setup_leaves_tests(uint32_t index, CacheType &cache)
Entry point for Barretenberg command-line interface.
TEST_F(IPATest, ChallengesAreZero)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
static field random_element(numeric::RNG *engine=nullptr) noexcept