Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <span>
6#include <vector>
7
11
12namespace bb::avm2::simulation {
13
14// Forward declarations
15class MemoryInterface;
16class BytecodeManagerInterface;
17class InternalCallStackManagerInterface;
18class SideEffectTrackerInterface;
19struct ContextEvent;
20
22 public:
23 virtual ~ContextInterface() = default;
24
25 // Machine state.
27 virtual const MemoryInterface& get_memory() const = 0;
30 virtual PC get_pc() const = 0;
31 virtual void set_pc(PC new_pc) = 0;
32 virtual PC get_next_pc() const = 0;
33 virtual void set_next_pc(PC new_next_pc) = 0;
34 virtual bool halted() const = 0;
35 virtual void halt() = 0;
36 virtual uint32_t get_context_id() const = 0;
37 virtual uint32_t get_parent_id() const = 0;
38 virtual uint32_t get_last_child_id() const = 0;
39 virtual bool has_parent() const = 0;
40
41 // Environment.
42 virtual const AztecAddress& get_address() const = 0;
43 virtual const AztecAddress& get_msg_sender() const = 0;
44 virtual const FF& get_transaction_fee() const = 0;
45 virtual bool get_is_static() const = 0;
48 virtual const GlobalVariables& get_globals() const = 0;
49
50 virtual TransactionPhase get_phase() const = 0;
51
52 // Should not throw.
53 virtual std::vector<MemoryValue> get_calldata(uint32_t cd_offset, uint32_t cd_size) const = 0;
54 virtual std::vector<MemoryValue> get_returndata(uint32_t rd_addr, uint32_t rd_size) const = 0;
56 virtual const ContextInterface& get_child_context() const = 0;
57 // The child context needs to be accessible by this context in order to access the child
58 // memory for returndata. We own it so that it's lifetime is as long as decided by this context
59 // (i.e. if it is replaced by another child OR this parent context falls out of scope)
61
62 virtual MemoryAddress get_parent_cd_addr() const = 0;
63 virtual uint32_t get_parent_cd_size() const = 0;
64
65 virtual MemoryAddress get_last_rd_addr() const = 0;
66 virtual void set_last_rd_addr(MemoryAddress rd_addr) = 0;
67
68 virtual uint32_t get_last_rd_size() const = 0;
69 virtual void set_last_rd_size(MemoryAddress rd_size) = 0;
70
71 virtual bool get_last_success() const = 0;
72 virtual void set_last_success(bool success) = 0;
73
74 virtual Gas get_gas_used() const = 0;
75 virtual Gas get_gas_limit() const = 0;
76 virtual void set_gas_used(Gas gas_used) = 0;
77
78 virtual Gas get_parent_gas_used() const = 0;
79 virtual Gas get_parent_gas_limit() const = 0;
80
81 virtual Gas gas_left() const = 0;
82
83 virtual uint32_t get_checkpoint_id_at_creation() const = 0;
84
85 // Events
87};
88
89} // namespace bb::avm2::simulation
virtual MemoryAddress get_last_rd_addr() const =0
virtual const AztecAddress & get_msg_sender() const =0
virtual ContextInterface & get_child_context()=0
virtual bool get_last_success() const =0
virtual Gas get_gas_used() const =0
virtual const MemoryInterface & get_memory() const =0
virtual void set_child_context(std::unique_ptr< ContextInterface > child_ctx)=0
virtual Gas get_parent_gas_limit() const =0
virtual void set_pc(PC new_pc)=0
virtual uint32_t get_checkpoint_id_at_creation() const =0
virtual MemoryInterface & get_memory()=0
virtual void set_last_rd_size(MemoryAddress rd_size)=0
virtual InternalCallStackManagerInterface & get_internal_call_stack_manager()=0
virtual ContextEvent serialize_context_event()=0
virtual const FF & get_transaction_fee() const =0
virtual uint32_t get_parent_cd_size() const =0
virtual SideEffectTrackerInterface & get_side_effect_tracker()=0
virtual uint32_t get_last_child_id() const =0
virtual std::vector< MemoryValue > get_returndata(uint32_t rd_addr, uint32_t rd_size) const =0
virtual MemoryAddress get_parent_cd_addr() const =0
virtual void set_next_pc(PC new_next_pc)=0
virtual AppendOnlyTreeSnapshot get_written_public_data_slots_tree_snapshot()=0
virtual const GlobalVariables & get_globals() const =0
virtual std::vector< MemoryValue > get_calldata(uint32_t cd_offset, uint32_t cd_size) const =0
virtual void set_gas_used(Gas gas_used)=0
virtual uint32_t get_parent_id() const =0
virtual uint32_t get_last_rd_size() const =0
virtual bool get_is_static() const =0
virtual BytecodeManagerInterface & get_bytecode_manager()=0
virtual bool has_parent() const =0
virtual const ContextInterface & get_child_context() const =0
virtual Gas get_gas_limit() const =0
virtual const AztecAddress & get_address() const =0
virtual uint32_t get_context_id() const =0
virtual Gas get_parent_gas_used() const =0
virtual void set_last_rd_addr(MemoryAddress rd_addr)=0
virtual void set_last_success(bool success)=0
virtual TransactionPhase get_phase() const =0
uint32_t PC
uint32_t MemoryAddress
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
uint32_t cd_offset