11struct IntermediateGas {
15 IntermediateGas
operator+(
const IntermediateGas& other)
const
17 return IntermediateGas{ .l2_gas = this->l2_gas + other.l2_gas, .da_gas = this->da_gas + other.da_gas };
20 IntermediateGas
operator*(
const IntermediateGas& other)
const
22 return IntermediateGas{ .l2_gas = this->l2_gas * other.l2_gas, .da_gas = this->da_gas * other.da_gas };
27 BB_ASSERT_LTE(l2_gas, std::numeric_limits<uint32_t>::max(),
"L2 gas out of bounds");
28 BB_ASSERT_LTE(da_gas, std::numeric_limits<uint32_t>::max(),
"DA gas out of bounds");
29 return Gas{ .l2_gas =
static_cast<uint32_t
>(
l2_gas), .da_gas =
static_cast<uint32_t
>(da_gas) };
39IntermediateGas to_intermediate_gas(
const Gas& gas)
41 return IntermediateGas{ .l2_gas =
static_cast<uint64_t
>(gas.l2_gas), .
da_gas =
static_cast<uint64_t
>(gas.da_gas) };
69 const IntermediateGas total_gas_used =
70 to_intermediate_gas(
context.get_gas_used()) +
73 to_intermediate_gas(dynamic_gas_factor));
79 const IntermediateGas gas_limit = to_intermediate_gas(
context.get_gas_limit());
91 total_gas_used.l2_gas,
95 total_gas_used.da_gas,
101 context.set_gas_used(total_gas_used.to_gas());
120 .l2_gas = is_l2_gas_left_gt_allocated ? allocated_gas.
l2_gas : gas_left.
l2_gas,
121 .da_gas = is_da_gas_left_gt_allocated ? allocated_gas.
da_gas : gas_left.
da_gas,
#define BB_ASSERT_LTE(left, right,...)
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 alloca...
GreaterThanInterface & greater_than
const ExecInstructionSpec & spec
void consume_gas(const Gas &dynamic_gas_factor={ 0, 0 }) override
Consumes gas for the current instruction.
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
uint16_t compute_addressing_gas(uint16_t addressing_mode)
Computes the gas cost for addressing.
Univariate< Fr, domain_end > operator+(const Fr &ff, const Univariate< Fr, domain_end > &uv)
Univariate< Fr, domain_end > operator*(const Fr &ff, const Univariate< Fr, domain_end > &uv)
uint64_t total_gas_used_l2
uint64_t total_gas_used_da