Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
raw_data_dbs.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <span>
4#include <stack>
5#include <tuple>
6
18
19namespace bb::avm2::simulation {
20
21// This class interacts with the external world, without emiting any simulation events.
22// It is used for a given TX and its hinting structure assumes that the content cannot
23// change during the TX.
38
39// This class interacts with the external world, without emiting any simulation events.
41 public:
43
44 const TreeSnapshots& get_tree_roots() const override { return tree_roots; }
45
46 // Query methods.
47 SiblingPath get_sibling_path(MerkleTreeId tree_id, index_t leaf_index) const override;
49 FF get_leaf_value(MerkleTreeId tree_id, index_t leaf_index) const override;
52
53 // State modification methods.
55 const PublicDataLeafValue& leaf_value) override;
57 const NullifierLeafValue& leaf_value) override;
59 void pad_tree(MerkleTreeId tree_id, size_t num_leaves) override;
60
61 void create_checkpoint() override;
62 void commit_checkpoint() override;
63 void revert_checkpoint() override;
64 uint32_t get_checkpoint_id() const override;
65
66 private:
69 // We start with a checkpoint id of 0, which is the assumed initial state checkpoint.
70 // This stack is for debugging purposes only.
71 std::stack<uint32_t> checkpoint_stack{ { 0 } };
72
73 // Query hints.
83 // State modification hints.
95
96 // Private helper methods.
100};
101
102} // namespace bb::avm2::simulation
103
104// Specialization of std::hash for std::vector<FF> to be used as a key in unordered_flat_map.
105namespace std {
106template <> struct hash<std::vector<bb::avm2::FF>> {
107 size_t operator()(const std::vector<bb::avm2::FF>& vec) const
108 {
109 size_t seed = vec.size();
110 for (const auto& item : vec) {
111 seed ^= std::hash<bb::avm2::FF>{}(item) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
112 }
113 return seed;
114 }
115};
116} // namespace std
unordered_flat_map< ContractClassId, FF > bytecode_commitments
FF get_bytecode_commitment(const ContractClassId &class_id) const
std::optional< ContractClass > get_contract_class(const ContractClassId &class_id) const override
unordered_flat_map< ContractClassId, ContractClassHint > contract_classes
unordered_flat_map< AztecAddress, ContractInstanceHint > contract_instances
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, std::vector< FF > > AppendLeavesHintKey
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, NullifierLeafValue > SequentialInsertHintNullifierTreeKey
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, FF > GetPreviousValueIndexKey
unordered_flat_map< GetLeafValueKey, FF > get_leaf_value_hints
unordered_flat_map< uint32_t, RevertCheckpointHint > revert_checkpoint_hints
unordered_flat_map< SequentialInsertHintNullifierTreeKey, SequentialInsertHint< NullifierLeafValue > > sequential_insert_hints_nullifier_tree
GetLowIndexedLeafResponse get_low_indexed_leaf(MerkleTreeId tree_id, const FF &value) const override
unordered_flat_map< AppendLeavesHintKey, AppendOnlyTreeSnapshot > append_leaves_hints
SiblingPath get_sibling_path(MerkleTreeId tree_id, index_t leaf_index) const override
unordered_flat_map< uint32_t, CommitCheckpointHint > commit_checkpoint_hints
unordered_flat_map< GetSiblingPathKey, SiblingPath > get_sibling_path_hints
SequentialInsertionResult< NullifierLeafValue > insert_indexed_leaves_nullifier_tree(const NullifierLeafValue &leaf_value) override
unordered_flat_map< uint32_t, CreateCheckpointHint > create_checkpoint_hints
std::vector< AppendLeafResult > append_leaves(MerkleTreeId tree_id, std::span< const FF > leaves) override
AppendLeafResult appendLeafInternal(MerkleTreeId tree_id, const FF &leaf)
IndexedLeaf< PublicDataLeafValue > get_leaf_preimage_public_data_tree(index_t leaf_index) const override
IndexedLeaf< NullifierLeafValue > get_leaf_preimage_nullifier_tree(index_t leaf_index) const override
FF get_leaf_value(MerkleTreeId tree_id, index_t leaf_index) const override
unordered_flat_map< GetLeafPreimageKey, IndexedLeaf< NullifierLeafValue > > get_leaf_preimage_hints_nullifier_tree
unordered_flat_map< SequentialInsertHintPublicDataTreeKey, SequentialInsertHint< PublicDataLeafValue > > sequential_insert_hints_public_data_tree
const TreeSnapshots & get_tree_roots() const override
unordered_flat_map< GetLeafPreimageKey, IndexedLeaf< PublicDataLeafValue > > get_leaf_preimage_hints_public_data_tree
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, index_t > GetLeafValueKey
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, index_t > GetSiblingPathKey
std::tuple< AppendOnlyTreeSnapshot, index_t > GetLeafPreimageKey
uint32_t get_checkpoint_id() const override
std::tuple< AppendOnlyTreeSnapshot, MerkleTreeId, PublicDataLeafValue > SequentialInsertHintPublicDataTreeKey
SequentialInsertionResult< PublicDataLeafValue > insert_indexed_leaves_public_data_tree(const PublicDataLeafValue &leaf_value) override
unordered_flat_map< GetPreviousValueIndexKey, GetLowIndexedLeafResponse > get_previous_value_index_hints
const AppendOnlyTreeSnapshot & get_tree_info(MerkleTreeId tree_id) const
void pad_tree(MerkleTreeId tree_id, size_t num_leaves) override
void hash(State &state) noexcept
::bb::crypto::merkle_tree::fr_sibling_path SiblingPath
::bb::crypto::merkle_tree::index_t index_t
FF ContractClassId
AvmFlavorSettings::FF FF
Definition field.hpp:10
::ankerl::unordered_dense::map< Key, T > unordered_flat_map
Definition map.hpp:15
STL namespace.
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
size_t operator()(const std::vector< bb::avm2::FF > &vec) const