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 124 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 72 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 82 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 52 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 60 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 101 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 95 of file world_state.test.cpp.

◆ TEST_F() [1/22]

TEST_F ( WorldStateTest  ,
AppendOnlyAllowDuplicates   
)

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

◆ TEST_F() [2/22]

TEST_F ( WorldStateTest  ,
AppendOnlyTrees   
)

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

◆ TEST_F() [3/22]

TEST_F ( WorldStateTest  ,
BuildsABlockInAFork   
)

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

◆ TEST_F() [4/22]

TEST_F ( WorldStateTest  ,
CommitsAndRollsBackAllTrees   
)

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

◆ TEST_F() [5/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0AndAdvancingCanonicalState   
)

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

◆ TEST_F() [6/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0AndAdvancingFork   
)

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

◆ TEST_F() [7/22]

TEST_F ( WorldStateTest  ,
ForkingAtBlock0SameState   
)

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

◆ TEST_F() [8/22]

TEST_F ( WorldStateTest  ,
GetBlockForIndex   
)

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

◆ TEST_F() [9/22]

TEST_F ( WorldStateTest  ,
GetInitialStateReference   
)

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

◆ TEST_F() [10/22]

TEST_F ( WorldStateTest  ,
GetInitialTreeInfoForAllTrees   
)

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

◆ TEST_F() [11/22]

TEST_F ( WorldStateTest  ,
GetInitialTreeInfoWithPrefilledPublicData   
)

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

◆ TEST_F() [12/22]

TEST_F ( WorldStateTest  ,
GetStateReference   
)

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

◆ TEST_F() [13/22]

TEST_F ( WorldStateTest  ,
NullifierBatchInsert   
)

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

◆ TEST_F() [14/22]

TEST_F ( WorldStateTest  ,
NullifierTree   
)

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

◆ TEST_F() [15/22]

TEST_F ( WorldStateTest  ,
NullifierTreeDuplicates   
)

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

◆ TEST_F() [16/22]

TEST_F ( WorldStateTest  ,
PublicDataTree   
)

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

◆ TEST_F() [17/22]

TEST_F ( WorldStateTest  ,
RejectSyncBlockWithBadPublicWriteBatches   
)

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

◆ TEST_F() [18/22]

TEST_F ( WorldStateTest  ,
RejectSyncBlockWithInvalidStateRef   
)

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

◆ TEST_F() [19/22]

TEST_F ( WorldStateTest  ,
SyncBlockFromDirtyState   
)

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

◆ TEST_F() [20/22]

TEST_F ( WorldStateTest  ,
SyncCurrentBlock   
)

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

◆ TEST_F() [21/22]

TEST_F ( WorldStateTest  ,
SyncEmptyBlock   
)

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

◆ TEST_F() [22/22]

TEST_F ( WorldStateTest  ,
SyncExternalBlockFromEmpty   
)

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