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 <memory>
4#include <span>
5#include <vector>
6
10
11namespace bb::avm2::simulation {
12
13// Forward declarations
14class MemoryInterface;
15class BytecodeManagerInterface;
16class InternalCallStackManagerInterface;
17class SideEffectTrackerInterface;
18struct ContextEvent;
19
21 public:
22 virtual ~ContextInterface() = default;
23
24 // Machine state.
26 virtual const MemoryInterface& get_memory() const = 0;
29 virtual uint32_t get_pc() const = 0;
30 virtual void set_pc(uint32_t new_pc) = 0;
31 virtual uint32_t get_next_pc() const = 0;
32 virtual void set_next_pc(uint32_t new_next_pc) = 0;
33 virtual bool halted() const = 0;
34 virtual void halt() = 0;
35 virtual uint32_t get_context_id() const = 0;
36 virtual uint32_t get_parent_id() const = 0;
37 virtual uint32_t get_last_child_id() const = 0;
38 virtual bool has_parent() const = 0;
39
40 // Environment.
41 virtual const AztecAddress& get_address() const = 0;
42 virtual const AztecAddress& get_msg_sender() const = 0;
43 virtual const FF& get_transaction_fee() const = 0;
44 virtual bool get_is_static() const = 0;
47 virtual const GlobalVariables& get_globals() const = 0;
48
49 virtual TransactionPhase get_phase() const = 0;
50
51 virtual std::vector<MemoryValue> get_calldata(uint32_t cd_offset, uint32_t cd_size) const = 0;
52 virtual std::vector<MemoryValue> get_returndata(uint32_t rd_addr, uint32_t rd_size) const = 0;
54 virtual const ContextInterface& get_child_context() const = 0;
55 // The child context needs to be accessible by this context in order to access the child
56 // memory for returndata. We own it so that it's lifetime is as long as decided by this context
57 // (i.e. if it is replaced by another child OR this parent context falls out of scope)
59
60 virtual MemoryAddress get_parent_cd_addr() const = 0;
61 virtual uint32_t get_parent_cd_size() const = 0;
62
63 virtual MemoryAddress get_last_rd_addr() const = 0;
64 virtual void set_last_rd_addr(MemoryAddress rd_addr) = 0;
65
66 virtual uint32_t get_last_rd_size() const = 0;
67 virtual void set_last_rd_size(MemoryAddress rd_size) = 0;
68
69 virtual bool get_last_success() const = 0;
70 virtual void set_last_success(bool success) = 0;
71
72 virtual Gas get_gas_used() const = 0;
73 virtual Gas get_gas_limit() const = 0;
74 virtual void set_gas_used(Gas gas_used) = 0;
75
76 virtual Gas get_parent_gas_used() const = 0;
77 virtual Gas get_parent_gas_limit() const = 0;
78
79 virtual Gas gas_left() const = 0;
80
81 virtual uint32_t get_checkpoint_id_at_creation() const = 0;
82
83 // Events
85};
86
87} // namespace bb::avm2::simulation
virtual uint32_t get_pc() const =0
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(uint32_t 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 uint32_t get_next_pc() const =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 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
virtual void set_next_pc(uint32_t new_next_pc)=0
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