Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
memory_manager.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <map>
5#include <optional>
6#include <vector>
7
11
13 private:
14 // map of Tag -> vector of memory addresses
16 // inverse map MemoryAddress -> Tag
17 std::map<uint32_t, bb::avm2::MemoryTag> memory_address_to_tag;
18
19 // Public Storage used addresses
20 std::vector<bb::avm2::FF> storage_addresses;
21
22 std::vector<bb::avm2::FF> emitted_note_hashes;
23
26 ResolvedAddress resolve_address(VariableRef address, uint32_t absolute_address, uint32_t max_operand_address);
27 ResolvedAddress resolve_address(AddressRef address, uint32_t max_operand_address);
29
30 public:
31 MemoryManager() = default;
32 MemoryManager(const MemoryManager& other) = default;
34 MemoryManager(MemoryManager&& other) = default;
36 ~MemoryManager() = default;
40 bool is_memory_address_set(uint16_t address);
41
54
55 // Append used slot to storage_addresses
57 // Get slot from storage_addresses
58 std::optional<bb::avm2::FF> get_slot(uint16_t slot_offset_index);
59
60 // Append emitted note hash to emitted_note_hashes
62 // Get emitted note hash from emitted_note_hashes
63 std::optional<bb::avm2::FF> get_emitted_note_hash(uint16_t note_hash_index);
64 // Get leaf index from emitted_note_hashes, nullopt if emitted_note_hashes is empty
65 // note_hash_index % length(emitted_note_hashes)
66 std::optional<uint16_t> get_leaf_index(uint16_t note_hash_index);
67};
bb::avm2::testing::OperandBuilder get_memory_address_operand(bb::avm2::testing::OperandBuilder operand, AddressingMode mode)
std::optional< uint16_t > get_memory_offset_16(bb::avm2::MemoryTag tag, uint32_t address_index)
std::map< bb::avm2::MemoryTag, std::vector< uint32_t > > stored_variables
~MemoryManager()=default
MemoryManager & operator=(const MemoryManager &other)
std::optional< std::pair< ResolvedAddress, bb::avm2::testing::OperandBuilder > > get_resolved_address_and_operand_8(ParamRef address)
MemoryManager & operator=(MemoryManager &&other)=default
MemoryManager(MemoryManager &&other)=default
std::vector< bb::avm2::FF > emitted_note_hashes
std::optional< bb::avm2::FF > get_emitted_note_hash(uint16_t note_hash_index)
std::map< uint32_t, bb::avm2::MemoryTag > memory_address_to_tag
ResolvedAddress resolve_address(VariableRef address, uint32_t absolute_address, uint32_t max_operand_address)
std::optional< bb::avm2::FF > get_slot(uint16_t slot_offset_index)
bool is_memory_address_set(uint16_t address)
MemoryManager()=default
MemoryManager(const MemoryManager &other)=default
std::optional< uint16_t > get_leaf_index(uint16_t note_hash_index)
void set_memory_address(bb::avm2::MemoryTag tag, uint32_t address)
void append_slot(bb::avm2::FF slot)
std::optional< uint32_t > get_variable_address(bb::avm2::MemoryTag tag, uint32_t index, uint32_t max_value)
std::optional< uint8_t > get_memory_offset_8(bb::avm2::MemoryTag tag, uint32_t address_index)
void append_emitted_note_hash(bb::avm2::FF note_hash)
std::vector< bb::avm2::FF > storage_addresses
std::optional< std::pair< ResolvedAddress, bb::avm2::testing::OperandBuilder > > get_resolved_address_and_operand_16(ParamRef address)
AddressingMode
std::variant< VariableRef, AddressRef > ParamRef
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
Output of resolving an address in the memory manager In order to resolve a given absolute address wit...