Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gas_tracker.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
barretenberg/vm2/common/aztec_types.hpp
"
4
#include "
barretenberg/vm2/simulation/context.hpp
"
5
#include "
barretenberg/vm2/simulation/events/gas_event.hpp
"
6
#include "
barretenberg/vm2/simulation/lib/instruction_info.hpp
"
7
#include "
barretenberg/vm2/simulation/lib/serialization.hpp
"
8
#include "
barretenberg/vm2/simulation/range_check.hpp
"
9
10
namespace
bb::avm2::simulation
{
11
12
class
GasTrackerInterface
{
13
public
:
14
virtual
~GasTrackerInterface
() =
default
;
15
// @throws OutOfGasException.
16
virtual
void
consume_gas
(
const
Gas
& dynamic_gas_factor = { 0, 0 }) = 0;
17
18
virtual
Gas
compute_gas_limit_for_call
(
const
Gas
& allocated_gas) = 0;
19
};
20
21
class
GasTracker
final :
public
GasTrackerInterface
{
22
public
:
23
GasTracker
(
GasEvent
&
gas_event
,
24
const
Instruction
&
instruction
,
25
const
InstructionInfoDBInterface
&
instruction_info_db
,
26
ContextInterface
&
context
,
27
RangeCheckInterface
&
range_check
);
28
29
void
consume_gas
(
const
Gas
& dynamic_gas_factor = { 0, 0 })
override
;
30
Gas
compute_gas_limit_for_call
(
const
Gas
& allocated_gas)
override
;
31
32
private
:
33
ContextInterface
&
context
;
34
const
ExecInstructionSpec
&
spec
;
35
RangeCheckInterface
&
range_check
;
36
GasEvent
&
gas_event
;
37
};
38
39
}
// namespace bb::avm2::simulation
aztec_types.hpp
bb::avm2::context
Definition
context.hpp:37
bb::avm2::range_check
Definition
range_check.hpp:34
bb::avm2::simulation::ContextInterface
Definition
context.hpp:23
bb::avm2::simulation::GasTracker
Definition
gas_tracker.hpp:21
bb::avm2::simulation::GasTracker::compute_gas_limit_for_call
Gas compute_gas_limit_for_call(const Gas &allocated_gas) override
Definition
gas_tracker.cpp:121
bb::avm2::simulation::GasTracker::gas_event
GasEvent & gas_event
Definition
gas_tracker.hpp:36
bb::avm2::simulation::GasTracker::spec
const ExecInstructionSpec & spec
Definition
gas_tracker.hpp:34
bb::avm2::simulation::GasTracker::consume_gas
void consume_gas(const Gas &dynamic_gas_factor={ 0, 0 }) override
Definition
gas_tracker.cpp:54
bb::avm2::simulation::GasTracker::context
ContextInterface & context
Definition
gas_tracker.hpp:33
bb::avm2::simulation::GasTracker::range_check
RangeCheckInterface & range_check
Definition
gas_tracker.hpp:35
bb::avm2::simulation::GasTrackerInterface
Definition
gas_tracker.hpp:12
bb::avm2::simulation::GasTrackerInterface::~GasTrackerInterface
virtual ~GasTrackerInterface()=default
bb::avm2::simulation::GasTrackerInterface::consume_gas
virtual void consume_gas(const Gas &dynamic_gas_factor={ 0, 0 })=0
bb::avm2::simulation::GasTrackerInterface::compute_gas_limit_for_call
virtual Gas compute_gas_limit_for_call(const Gas &allocated_gas)=0
bb::avm2::simulation::InstructionInfoDBInterface
Definition
instruction_info.hpp:11
bb::avm2::simulation::RangeCheckInterface
Definition
range_check.hpp:11
gas_event.hpp
instruction_info_db
InstructionInfoDB instruction_info_db
Definition
gas_tracker.test.cpp:29
instruction
Instruction instruction
Definition
gas_tracker.test.cpp:32
instruction_info.hpp
bb::avm2::simulation
Definition
address_derivation.cpp:8
serialization.hpp
context.hpp
range_check.hpp
bb::avm2::ExecInstructionSpec
Definition
instruction_spec.hpp:16
bb::avm2::Gas
Definition
aztec_types.hpp:154
bb::avm2::simulation::GasEvent
Definition
gas_event.hpp:22
bb::avm2::simulation::Instruction
Definition
serialization.hpp:30
src
barretenberg
vm2
simulation
gas_tracker.hpp
Generated by
1.9.8