Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
execution_event.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <cstdint>
4
#include <vector>
5
6
#include "
barretenberg/vm2/common/memory_types.hpp
"
7
#include "
barretenberg/vm2/common/opcodes.hpp
"
8
#include "
barretenberg/vm2/simulation/events/addressing_event.hpp
"
9
#include "
barretenberg/vm2/simulation/events/context_events.hpp
"
10
#include "
barretenberg/vm2/simulation/events/gas_event.hpp
"
11
#include "
barretenberg/vm2/simulation/lib/serialization.hpp
"
12
13
namespace
bb::avm2::simulation
{
14
15
// Possible mutually exclusive execution errors.
16
enum class
ExecutionError
: uint8_t {
17
NONE
,
18
BYTECODE_RETRIEVAL
,
19
INSTRUCTION_FETCHING
,
20
ADDRESSING
,
21
REGISTER_READ
,
22
GAS
,
23
OPCODE_EXECUTION
24
};
25
26
struct
ExecutionEvent
{
27
ExecutionError
error
=
ExecutionError::NONE
;
28
Instruction
wire_instruction
;
29
30
// Inputs and Outputs for a gadget/subtrace used when allocating registers in the execution trace.
31
std::vector<MemoryValue>
inputs
;
32
MemoryValue
output
;
33
34
// Context Id for the next context.
35
uint32_t
next_context_id
= 0;
36
37
// Sub-events.
38
AddressingEvent
addressing_event
;
39
ContextEvent
before_context_event
;
40
ContextEvent
after_context_event
;
41
42
GasEvent
gas_event
;
43
44
// function to determine whether the event was a context "failure"
45
bool
is_failure
()
const
46
{
47
// WARNING: it is important that we check for error first here because
48
// if instruction fetching fails, we cannot do `wire_instruction.get_exec_opcode()`
49
return
error
!=
ExecutionError::NONE
||
wire_instruction
.
get_exec_opcode
() ==
ExecutionOpCode::REVERT
;
50
}
51
52
// function to determine whether the event represents a context "exit"
53
bool
is_exit
()
const
{
return
is_failure
() ||
wire_instruction
.
get_exec_opcode
() ==
ExecutionOpCode::RETURN
; }
54
};
55
56
}
// namespace bb::avm2::simulation
addressing_event.hpp
bb::avm2::TaggedValue
Definition
tagged_value.hpp:70
context_events.hpp
gas_event.hpp
memory_types.hpp
bb::avm2::simulation
Definition
address_derivation_event.hpp:6
bb::avm2::simulation::ExecutionError
ExecutionError
Definition
execution_event.hpp:16
bb::avm2::simulation::ExecutionError::ADDRESSING
@ ADDRESSING
bb::avm2::simulation::ExecutionError::GAS
@ GAS
bb::avm2::simulation::ExecutionError::REGISTER_READ
@ REGISTER_READ
bb::avm2::simulation::ExecutionError::OPCODE_EXECUTION
@ OPCODE_EXECUTION
bb::avm2::simulation::ExecutionError::INSTRUCTION_FETCHING
@ INSTRUCTION_FETCHING
bb::avm2::simulation::ExecutionError::BYTECODE_RETRIEVAL
@ BYTECODE_RETRIEVAL
bb::avm2::simulation::ExecutionError::NONE
@ NONE
bb::avm2::ExecutionOpCode::RETURN
@ RETURN
bb::avm2::ExecutionOpCode::REVERT
@ REVERT
std::get
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition
tuple.hpp:13
opcodes.hpp
serialization.hpp
bb::avm2::simulation::AddressingEvent
Definition
addressing_event.hpp:52
bb::avm2::simulation::ContextEvent
Definition
context_events.hpp:10
bb::avm2::simulation::ExecutionEvent
Definition
execution_event.hpp:26
bb::avm2::simulation::ExecutionEvent::error
ExecutionError error
Definition
execution_event.hpp:27
bb::avm2::simulation::ExecutionEvent::next_context_id
uint32_t next_context_id
Definition
execution_event.hpp:35
bb::avm2::simulation::ExecutionEvent::is_exit
bool is_exit() const
Definition
execution_event.hpp:53
bb::avm2::simulation::ExecutionEvent::gas_event
GasEvent gas_event
Definition
execution_event.hpp:42
bb::avm2::simulation::ExecutionEvent::after_context_event
ContextEvent after_context_event
Definition
execution_event.hpp:40
bb::avm2::simulation::ExecutionEvent::is_failure
bool is_failure() const
Definition
execution_event.hpp:45
bb::avm2::simulation::ExecutionEvent::output
MemoryValue output
Definition
execution_event.hpp:32
bb::avm2::simulation::ExecutionEvent::addressing_event
AddressingEvent addressing_event
Definition
execution_event.hpp:38
bb::avm2::simulation::ExecutionEvent::before_context_event
ContextEvent before_context_event
Definition
execution_event.hpp:39
bb::avm2::simulation::ExecutionEvent::inputs
std::vector< MemoryValue > inputs
Definition
execution_event.hpp:31
bb::avm2::simulation::ExecutionEvent::wire_instruction
Instruction wire_instruction
Definition
execution_event.hpp:28
bb::avm2::simulation::GasEvent
Definition
gas_event.hpp:22
bb::avm2::simulation::Instruction
Definition
serialization.hpp:32
bb::avm2::simulation::Instruction::get_exec_opcode
ExecutionOpCode get_exec_opcode() const
Definition
serialization.cpp:372
src
barretenberg
vm2
simulation
events
execution_event.hpp
Generated by
1.9.8