Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
world_state.test.cpp File Reference
#include "barretenberg/world_state/world_state.hpp"
#include "barretenberg/crypto/merkle_tree/fixtures.hpp"
#include "barretenberg/crypto/merkle_tree/indexed_tree/indexed_leaf.hpp"
#include "barretenberg/crypto/merkle_tree/node_store/tree_meta.hpp"
#include "barretenberg/crypto/merkle_tree/response.hpp"
#include "barretenberg/ecc/curves/bn254/fr.hpp"
#include "barretenberg/vm2/common/aztec_constants.hpp"
#include "barretenberg/world_state/fork.hpp"
#include "barretenberg/world_state/types.hpp"
#include <array>
#include <cstdint>
#include <filesystem>
#include <gtest/gtest.h>
#include <optional>
#include <stdexcept>
#include <sys/types.h>
#include <unordered_map>

Go to the source code of this file.

Classes

class  WorldStateTest
 

Functions

template<typename Leaf >
void assert_leaf_status (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, index_t leaf_index, bool exists)
 
template<typename Leaf >
void assert_leaf_value (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, index_t leaf_index, const Leaf &expected_value)
 
template<typename Leaf >
void assert_leaf_exists (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, const Leaf &expected_value, bool exists)
 
template<typename Leaf >
void assert_leaf_index (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, const Leaf &value, index_t expected_index)
 
void assert_tree_size (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, size_t expected_size)
 
void assert_sibling_path (const WorldState &ws, WorldStateRevision revision, MerkleTreeId tree_id, fr root, fr leaf, index_t index)
 
void assert_fork_state_unchanged (const WorldState &ws, Fork::Id forkId, bool includeUncommitted, const std::vector< MerkleTreeId > &trees={ MerkleTreeId::NULLIFIER_TREE, MerkleTreeId::NOTE_HASH_TREE, MerkleTreeId::PUBLIC_DATA_TREE, MerkleTreeId::L1_TO_L2_MESSAGE_TREE, MerkleTreeId::ARCHIVE })
 
 TEST_F (WorldStateTest, GetInitialTreeInfoForAllTrees)
 
 TEST_F (WorldStateTest, GetInitialTreeInfoWithPrefilledPublicData)
 
 TEST_F (WorldStateTest, GetStateReference)
 
 TEST_F (WorldStateTest, GetInitialStateReference)
 
 TEST_F (WorldStateTest, AppendOnlyTrees)
 
 TEST_F (WorldStateTest, AppendOnlyAllowDuplicates)
 
 TEST_F (WorldStateTest, NullifierTree)
 
 TEST_F (WorldStateTest, NullifierTreeDuplicates)
 
 TEST_F (WorldStateTest, NullifierBatchInsert)
 
 TEST_F (WorldStateTest, PublicDataTree)
 
 TEST_F (WorldStateTest, CommitsAndRollsBackAllTrees)
 
 TEST_F (WorldStateTest, SyncExternalBlockFromEmpty)
 
 TEST_F (WorldStateTest, SyncBlockFromDirtyState)
 
 TEST_F (WorldStateTest, SyncCurrentBlock)
 
 TEST_F (WorldStateTest, RejectSyncBlockWithBadPublicWriteBatches)
 
 TEST_F (WorldStateTest, RejectSyncBlockWithInvalidStateRef)
 
 TEST_F (WorldStateTest, SyncEmptyBlock)
 
 TEST_F (WorldStateTest, ForkingAtBlock0SameState)
 
 TEST_F (WorldStateTest, ForkingAtBlock0AndAdvancingFork)
 
 TEST_F (WorldStateTest, ForkingAtBlock0AndAdvancingCanonicalState)
 
 TEST_F (WorldStateTest, BuildsABlockInAFork)
 
 TEST_F (WorldStateTest, GetBlockForIndex)
 

Function Documentation

◆ assert_fork_state_unchanged()

void assert_fork_state_unchanged ( const WorldState ws,
Fork::Id  forkId,
bool  includeUncommitted,
const std::vector< MerkleTreeId > &  trees = { MerkleTreeId::NULLIFIER_TREE, MerkleTreeId::NOTE_HASH_TREE, MerkleTreeId::PUBLIC_DATA_TREE, MerkleTreeId::L1_TO_L2_MESSAGE_TREE, MerkleTreeId::ARCHIVE } 
)

Definition at line 126 of file world_state.test.cpp.

◆ assert_leaf_exists()

template<typename Leaf >
void assert_leaf_exists ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
const Leaf &  expected_value,
bool  exists 
)

Definition at line 74 of file world_state.test.cpp.

◆ assert_leaf_index()

template<typename Leaf >
void assert_leaf_index ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
const Leaf &  value,
index_t  expected_index 
)

Definition at line 84 of file world_state.test.cpp.

◆ assert_leaf_status()

template<typename Leaf >
void assert_leaf_status ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
index_t  leaf_index,
bool  exists 
)

Definition at line 54 of file world_state.test.cpp.

◆ assert_leaf_value()

template<typename Leaf >
void assert_leaf_value ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
index_t  leaf_index,
const Leaf &  expected_value 
)

Definition at line 62 of file world_state.test.cpp.

◆ assert_sibling_path()

void assert_sibling_path ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
fr  root,
fr  leaf,
index_t  index 
)

Definition at line 103 of file world_state.test.cpp.

◆ assert_tree_size()

void assert_tree_size ( const WorldState ws,
WorldStateRevision  revision,
MerkleTreeId  tree_id,
size_t  expected_size 
)

Definition at line 97 of file world_state.test.cpp.

◆ TEST_F() [1/22]

TEST_F ( WorldStateTest  ,
AppendOnlyAllowDuplicates   
)

Definition at line 402 of file world_state.test.cpp.

◆ TEST_F() [2/22]

TEST_F ( WorldStateTest  ,
AppendOnlyTrees   
)

Definition at line 343 of file world_state.test.cpp.

◆ TEST_F() [3/22]

TEST_F ( WorldStateTest  ,
BuildsABlockInAFork   
)

Definition at line 869 of file world_state.test.cpp.

◆ TEST_F() [4/22]

TEST_F ( WorldStateTest  ,
CommitsAndRollsBackAllTrees   
)

Definition at line 542 of file world_state.test.cpp.

◆ TEST_F() [5/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0AndAdvancingCanonicalState   
)

Definition at line 811 of file world_state.test.cpp.

◆ TEST_F() [6/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0AndAdvancingFork   
)

Definition at line 783 of file world_state.test.cpp.

◆ TEST_F() [7/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0SameState   
)

Definition at line 774 of file world_state.test.cpp.

◆ TEST_F() [8/22]

TEST_F ( WorldStateTest  ,
GetBlockForIndex   
)

Definition at line 892 of file world_state.test.cpp.

◆ TEST_F() [9/22]

TEST_F ( WorldStateTest  ,
GetInitialStateReference   
)

Definition at line 329 of file world_state.test.cpp.

◆ TEST_F() [10/22]

TEST_F ( WorldStateTest  ,
GetInitialTreeInfoForAllTrees   
)

Definition at line 150 of file world_state.test.cpp.

◆ TEST_F() [11/22]

TEST_F ( WorldStateTest  ,
GetInitialTreeInfoWithPrefilledPublicData   
)

Definition at line 195 of file world_state.test.cpp.

◆ TEST_F() [12/22]

TEST_F ( WorldStateTest  ,
GetStateReference   
)

Definition at line 260 of file world_state.test.cpp.

◆ TEST_F() [13/22]

TEST_F ( WorldStateTest  ,
NullifierBatchInsert   
)

Definition at line 482 of file world_state.test.cpp.

◆ TEST_F() [14/22]

TEST_F ( WorldStateTest  ,
NullifierTree   
)

Definition at line 429 of file world_state.test.cpp.

◆ TEST_F() [15/22]

TEST_F ( WorldStateTest  ,
NullifierTreeDuplicates   
)

Definition at line 467 of file world_state.test.cpp.

◆ TEST_F() [16/22]

TEST_F ( WorldStateTest  ,
PublicDataTree   
)

Definition at line 522 of file world_state.test.cpp.

◆ TEST_F() [17/22]

TEST_F ( WorldStateTest  ,
RejectSyncBlockWithBadPublicWriteBatches   
)

Definition at line 705 of file world_state.test.cpp.

◆ TEST_F() [18/22]

TEST_F ( WorldStateTest  ,
RejectSyncBlockWithInvalidStateRef   
)

Definition at line 732 of file world_state.test.cpp.

◆ TEST_F() [19/22]

TEST_F ( WorldStateTest  ,
SyncBlockFromDirtyState   
)

Definition at line 624 of file world_state.test.cpp.

◆ TEST_F() [20/22]

TEST_F ( WorldStateTest  ,
SyncCurrentBlock   
)

Definition at line 666 of file world_state.test.cpp.

◆ TEST_F() [21/22]

TEST_F ( WorldStateTest  ,
SyncEmptyBlock   
)

Definition at line 760 of file world_state.test.cpp.

◆ TEST_F() [22/22]

TEST_F ( WorldStateTest  ,
SyncExternalBlockFromEmpty   
)

Definition at line 579 of file world_state.test.cpp.