12struct IntermediateGas {
16 IntermediateGas
operator+(
const IntermediateGas& other)
const
18 return IntermediateGas{ .l2Gas =
l2Gas + other.l2Gas, .daGas =
daGas + other.daGas };
21 IntermediateGas
operator*(
const IntermediateGas& other)
const
23 return IntermediateGas{ .l2Gas =
l2Gas * other.l2Gas, .daGas =
daGas * other.daGas };
28 assert(l2Gas <= std::numeric_limits<uint32_t>::max());
29 assert(daGas <= std::numeric_limits<uint32_t>::max());
30 return Gas{ .l2Gas =
static_cast<uint32_t
>(
l2Gas), .daGas =
static_cast<uint32_t
>(daGas) };
34IntermediateGas to_intermediate_gas(
const Gas& gas)
36 return IntermediateGas{ .l2Gas =
static_cast<uint64_t
>(gas.l2Gas), .
daGas =
static_cast<uint64_t
>(gas.daGas) };
61 IntermediateGas base_actual_gas_used =
62 to_intermediate_gas(prev_gas_used) +
64 IntermediateGas gas_limit = to_intermediate_gas(
context.get_gas_limit());
66 bool oog_base_l2 = base_actual_gas_used.l2Gas > gas_limit.l2Gas;
67 bool oog_base_da = base_actual_gas_used.daGas > gas_limit.daGas;
75 IntermediateGas total_gas_used =
76 base_actual_gas_used +
77 (to_intermediate_gas(
Gas{ dynamic_l2_gas, dynamic_da_gas }) * to_intermediate_gas(dynamic_gas_factor));
85 if (oog_base_l2 || oog_base_da) {
87 base_actual_gas_used.l2Gas,
91 base_actual_gas_used.daGas,
102 total_gas_used.daGas,
108 context.set_gas_used(total_gas_used.to_gas());
122 .l2Gas = is_l2_gas_allocated_lt_left ? allocated_gas.
l2Gas : gas_left.
l2Gas,
123 .daGas = is_da_gas_allocated_lt_left ? allocated_gas.
daGas : gas_left.
daGas,
Gas compute_gas_limit_for_call(const Gas &allocated_gas) override
GreaterThanInterface & greater_than
const ExecInstructionSpec & spec
void consume_gas(const Gas &dynamic_gas_factor={ 0, 0 }) override
GasTracker(GasEvent &gas_event, const Instruction &instruction, const InstructionInfoDBInterface &instruction_info_db, ContextInterface &context, GreaterThanInterface &greater_than)
virtual bool gt(const FF &a, const FF &b)=0
std::string format(Args... args)
InstructionInfoDB instruction_info_db
testing::StrictMock< MockGreaterThan > greater_than
uint32_t compute_addressing_gas(uint16_t indirect_flag)
Univariate< Fr, domain_end, domain_start, skip_count > operator+(const Fr &ff, const Univariate< Fr, domain_end, domain_start, skip_count > &uv)
Univariate< Fr, domain_end, domain_start, skip_count > operator*(const Fr &ff, const Univariate< Fr, domain_end, domain_start, skip_count > &uv)
uint64_t total_gas_used_l2
uint64_t total_gas_used_da