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;
17struct ContextEvent;
18
20 public:
21 virtual ~ContextInterface() = default;
22
23 // Machine state.
27 virtual uint32_t get_pc() const = 0;
28 virtual void set_pc(uint32_t new_pc) = 0;
29 virtual uint32_t get_next_pc() const = 0;
30 virtual void set_next_pc(uint32_t new_next_pc) = 0;
31 virtual bool halted() const = 0;
32 virtual void halt() = 0;
33 virtual uint32_t get_context_id() const = 0;
34 virtual uint32_t get_parent_id() const = 0;
35 virtual uint32_t get_last_child_id() const = 0;
36 virtual bool has_parent() const = 0;
37
38 // Environment.
39 virtual const AztecAddress& get_address() const = 0;
40 virtual const AztecAddress& get_msg_sender() const = 0;
41 virtual const FF& get_transaction_fee() const = 0;
42 virtual bool get_is_static() const = 0;
45 virtual void set_side_effect_states(SideEffectStates side_effect_states) = 0;
46 virtual const GlobalVariables& get_globals() const = 0;
47
48 virtual TransactionPhase get_phase() const = 0;
49
50 virtual std::vector<FF> get_calldata(uint32_t cd_offset, uint32_t cd_size) const = 0;
51 virtual std::vector<FF> get_returndata(uint32_t rd_addr, uint32_t rd_size) = 0;
53 // The child context needs to be accessible by this context in order to access the child
54 // memory for returndata. We own it so that it's lifetime is as long as decided by this context
55 // (i.e. if it is replaced by another child OR this parent context falls out of scope)
57
58 virtual MemoryAddress get_parent_cd_addr() const = 0;
59 virtual uint32_t get_parent_cd_size() const = 0;
60
61 virtual MemoryAddress get_last_rd_addr() const = 0;
62 virtual void set_last_rd_addr(MemoryAddress rd_addr) = 0;
63
64 virtual uint32_t get_last_rd_size() const = 0;
65 virtual void set_last_rd_size(MemoryAddress rd_size) = 0;
66
67 virtual bool get_last_success() const = 0;
68 virtual void set_last_success(bool success) = 0;
69
70 virtual Gas get_gas_used() const = 0;
71 virtual Gas get_gas_limit() const = 0;
72 virtual void set_gas_used(Gas gas_used) = 0;
73
74 virtual Gas get_parent_gas_used() const = 0;
75 virtual Gas get_parent_gas_limit() const = 0;
76
77 virtual Gas gas_left() const = 0;
78
79 virtual uint32_t get_checkpoint_id_at_creation() const = 0;
80
81 // Events
83};
84
85} // 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 std::vector< FF > get_returndata(uint32_t rd_addr, uint32_t rd_size)=0
virtual ContextInterface & get_child_context()=0
virtual bool get_last_success() const =0
virtual Gas get_gas_used() 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 uint32_t get_last_child_id() const =0
virtual MemoryAddress get_parent_cd_addr() const =0
virtual AppendOnlyTreeSnapshot get_written_public_data_slots_tree_snapshot()=0
virtual SideEffectStates & get_side_effect_states()=0
virtual const GlobalVariables & get_globals() 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 Gas get_gas_limit() const =0
virtual std::vector< FF > get_calldata(uint32_t cd_offset, uint32_t cd_size) const =0
virtual const AztecAddress & get_address() const =0
virtual uint32_t get_context_id() const =0
virtual void set_side_effect_states(SideEffectStates side_effect_states)=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