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.
36
37// Does not generate events.
39 public:
47
48 // Unconstrained.
49 TreeStates get_tree_state() const override;
50 void create_checkpoint() override;
51 void commit_checkpoint() override;
52 void revert_checkpoint() override;
53 uint32_t get_checkpoint_id() const override;
54
55 // Constrained.
56 FF storage_read(const AztecAddress& contract_address, const FF& slot) const override;
58 const FF& slot,
59 const FF& value,
60 bool is_protocol_write) override;
61 bool was_storage_written(const AztecAddress& contract_address, const FF& slot) const override;
62
63 bool nullifier_exists(const AztecAddress& contract_address, const FF& nullifier) const override;
64 bool siloed_nullifier_exists(const FF& nullifier) const override;
65 // Throws if the nullifier already exists.
66 void nullifier_write(const AztecAddress& contract_address, const FF& nullifier) override;
67 void siloed_nullifier_write(const FF& nullifier) override;
68
69 // Returns a unique note hash stored in the tree at leaf_index.
70 bool note_hash_exists(uint64_t leaf_index, const FF& unique_note_hash) const override;
71 void note_hash_write(const AztecAddress& contract_address, const FF& note_hash) override;
72 void siloed_note_hash_write(const FF& note_hash) override;
73 void unique_note_hash_write(const FF& note_hash) override;
74 bool l1_to_l2_msg_exists(uint64_t leaf_index, const FF& msg_hash) const override;
75
76 void pad_trees() override;
77
78 void add_checkpoint_listener(CheckpointNotifiable& listener) { checkpoint_listeners.push_back(&listener); }
79
81
82 private:
85
88 // TODO: when you have a merkle gadget, consider marking it "mutable" so that read can be const.
89 // It's usually ok for mutexes but a gadget is big...
91
92 // Set for semantics.
93 using Slot = FF;
95
96 // Stack of tree counters for checkpoints. Starts empty.
98 { { .note_hash_counter = 0, .nullifier_counter = 0, .l2_to_l1_msg_counter = 0 } }
99 };
100};
101
102} // namespace bb::avm2::simulation
std::shared_ptr< Napi::ThreadSafeFunction > add_contracts
Interface for a checkpoint notifiable.
Definition db.hpp:131
std::optional< FF > get_bytecode_commitment(const ContractClassId &class_id) const override
std::optional< std::string > get_debug_function_name(const AztecAddress &address, const FunctionSelector &selector) const override
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
FF FunctionSelector
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13