Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
concrete_dbs.hpp
Go to the documentation of this file.
1#pragma once
2
8
9namespace bb::avm2::simulation {
10
11// Forward declaration.
12class WrittenPublicDataSlotsInterface;
13
14// Does not generate events.
27
28// Does not generate events.
30 public:
38
39 // Unconstrained.
40 TreeStates get_tree_state() const override;
41 void create_checkpoint() override;
42 void commit_checkpoint() override;
43 void revert_checkpoint() override;
44 uint32_t get_checkpoint_id() const override;
45
46 // Constrained.
47 FF storage_read(const AztecAddress& contract_address, const FF& slot) const override;
49 const FF& slot,
50 const FF& value,
51 bool is_protocol_write) override;
52 bool was_storage_written(const AztecAddress& contract_address, const FF& slot) const override;
53
54 bool nullifier_exists(const AztecAddress& contract_address, const FF& nullifier) const override;
55 bool siloed_nullifier_exists(const FF& nullifier) const override;
56 // Throws if the nullifier already exists.
57 void nullifier_write(const AztecAddress& contract_address, const FF& nullifier) override;
58 void siloed_nullifier_write(const FF& nullifier) override;
59
60 // Returns a unique note hash stored in the tree at leaf_index.
61 bool note_hash_exists(uint64_t leaf_index, const FF& unique_note_hash) const override;
62 void note_hash_write(const AztecAddress& contract_address, const FF& note_hash) override;
63 void siloed_note_hash_write(const FF& note_hash) override;
64 void unique_note_hash_write(const FF& note_hash) override;
65 bool l1_to_l2_msg_exists(uint64_t leaf_index, const FF& msg_hash) const override;
66
67 void pad_trees() override;
68
69 void add_checkpoint_listener(CheckpointNotifiable& listener) { checkpoint_listeners.push_back(&listener); }
70
72
73 private:
76
79 // TODO: when you have a merkle gadget, consider marking it "mutable" so that read can be const.
80 // It's usually ok for mutexes but a gadget is big...
82
83 // Set for semantics.
84 using Slot = FF;
86
87 // Stack of tree counters for checkpoints. Starts empty.
89 { { .note_hash_counter = 0, .nullifier_counter = 0, .l2_to_l1_msg_counter = 0 } }
90 };
91};
92
93} // namespace bb::avm2::simulation
PureContractDB(ContractDBInterface &raw_contract_db)
ContractDBInterface & raw_contract_db
std::optional< ContractClass > get_contract_class(const ContractClassId &class_id) const override
PureMerkleDB(const FF &first_nullifier, LowLevelMerkleDBInterface &raw_merkle_db, WrittenPublicDataSlotsInterface &written_public_data_slots)
WrittenPublicDataSlotsInterface & written_public_data_slots
void nullifier_write(const AztecAddress &contract_address, const FF &nullifier) override
FF storage_read(const AztecAddress &contract_address, const FF &slot) const override
void storage_write(const AztecAddress &contract_address, const FF &slot, const FF &value, bool is_protocol_write) override
std::stack< TreeCounters > tree_counters_stack
void add_checkpoint_listener(CheckpointNotifiable &listener)
TreeStates get_tree_state() const override
bool nullifier_exists_internal(std::optional< AztecAddress > contract_address, const FF &nullifier) const
void siloed_note_hash_write(const FF &note_hash) override
void siloed_nullifier_write(const FF &nullifier) override
bool note_hash_exists(uint64_t leaf_index, const FF &unique_note_hash) const override
std::vector< CheckpointNotifiable * > checkpoint_listeners
void note_hash_write(const AztecAddress &contract_address, const FF &note_hash) override
void nullifier_write_internal(std::optional< AztecAddress > contract_address, const FF &nullifier)
bool l1_to_l2_msg_exists(uint64_t leaf_index, const FF &msg_hash) const override
bool was_storage_written(const AztecAddress &contract_address, const FF &slot) const override
void unique_note_hash_write(const FF &note_hash) override
bool siloed_nullifier_exists(const FF &nullifier) const override
LowLevelMerkleDBInterface & as_unconstrained() const override
LowLevelMerkleDBInterface & raw_merkle_db
uint32_t get_checkpoint_id() const override
FF ContractClassId
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13