Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
bb::avm2::simulation::GasTracker Class Referencefinal

#include <gas_tracker.hpp>

Inheritance diagram for bb::avm2::simulation::GasTracker:
bb::avm2::simulation::GasTrackerInterface

Public Member Functions

 GasTracker (GasEvent &gas_event, const Instruction &instruction, const InstructionInfoDBInterface &instruction_info_db, ContextInterface &context, GreaterThanInterface &greater_than)
 
void consume_gas (const Gas &dynamic_gas_factor={ 0, 0 }) override
 Consumes gas for the current instruction.
 
Gas compute_gas_limit_for_call (const Gas &allocated_gas) override
 Computes the gas limit for a call (CALL and STATICCALL opcodes) as the minimum between the gas allocated to the call by the user, and the gas left. This applies to both gas dimensions independently. This method does not emit a gas event.
 
- Public Member Functions inherited from bb::avm2::simulation::GasTrackerInterface
virtual ~GasTrackerInterface ()=default
 

Private Attributes

ContextInterfacecontext
 
const ExecInstructionSpecspec
 
GreaterThanInterfacegreater_than
 
GasEventgas_event
 

Detailed Description

Definition at line 14 of file gas_tracker.hpp.

Constructor & Destructor Documentation

◆ GasTracker()

bb::avm2::simulation::GasTracker::GasTracker ( GasEvent gas_event,
const Instruction instruction,
const InstructionInfoDBInterface instruction_info_db,
ContextInterface context,
GreaterThanInterface greater_than 
)

Definition at line 46 of file gas_tracker.cpp.

Member Function Documentation

◆ compute_gas_limit_for_call()

Gas bb::avm2::simulation::GasTracker::compute_gas_limit_for_call ( const Gas allocated_gas)
overridevirtual

Computes the gas limit for a call (CALL and STATICCALL opcodes) as the minimum between the gas allocated to the call by the user, and the gas left. This applies to both gas dimensions independently. This method does not emit a gas event.

Parameters
allocated_gasThe allocated gas.
Returns
Gas The gas limit.

Implements bb::avm2::simulation::GasTrackerInterface.

Definition at line 112 of file gas_tracker.cpp.

◆ consume_gas()

void bb::avm2::simulation::GasTracker::consume_gas ( const Gas dynamic_gas_factor = { 0, 0 })
overridevirtual

Consumes gas for the current instruction.

Parameters
dynamic_gas_factorThe dynamic gas factor. Defaults to { 0, 0 } if not provided.
Exceptions
OutOfGasExceptionif the gas is depleted.

Implements bb::avm2::simulation::GasTrackerInterface.

Definition at line 65 of file gas_tracker.cpp.

Member Data Documentation

◆ context

ContextInterface& bb::avm2::simulation::GasTracker::context
private

Definition at line 26 of file gas_tracker.hpp.

◆ gas_event

GasEvent& bb::avm2::simulation::GasTracker::gas_event
private

Definition at line 29 of file gas_tracker.hpp.

◆ greater_than

GreaterThanInterface& bb::avm2::simulation::GasTracker::greater_than
private

Definition at line 28 of file gas_tracker.hpp.

◆ spec

const ExecInstructionSpec& bb::avm2::simulation::GasTracker::spec
private

Definition at line 27 of file gas_tracker.hpp.


The documentation for this class was generated from the following files: