Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gas_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
6
7namespace bb::avm2 {
8
9template <typename FF_>
10template <typename ContainerOverSubrelations, typename AllEntities>
11void gasImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
12 const AllEntities& in,
13 [[maybe_unused]] const RelationParameters<FF_>&,
14 [[maybe_unused]] const FF_& scaling_factor)
15{
16 using C = ColumnAndShifts;
17
18 const auto execution_BASE_L2_GAS = in.get(C::execution_opcode_gas) + in.get(C::execution_addressing_gas);
19 const auto execution_DYNAMIC_L2_GAS_USED =
20 in.get(C::execution_dynamic_l2_gas) * in.get(C::execution_dynamic_l2_gas_factor);
21 const auto execution_DYNAMIC_DA_GAS_USED =
22 in.get(C::execution_dynamic_da_gas) * in.get(C::execution_dynamic_da_gas_factor);
23 const auto execution_L2_GAS_USED = execution_BASE_L2_GAS + execution_DYNAMIC_L2_GAS_USED;
24 const auto execution_DA_GAS_USED = in.get(C::execution_base_da_gas) + execution_DYNAMIC_DA_GAS_USED;
25
26 {
27 using View = typename std::tuple_element_t<0, ContainerOverSubrelations>::View;
28 auto tmp = static_cast<View>(in.get(C::execution_sel_should_check_gas)) *
29 ((static_cast<View>(in.get(C::execution_prev_l2_gas_used)) + CView(execution_L2_GAS_USED)) -
30 static_cast<View>(in.get(C::execution_total_gas_l2)));
31 std::get<0>(evals) += (tmp * scaling_factor);
32 }
33 {
34 using View = typename std::tuple_element_t<1, ContainerOverSubrelations>::View;
35 auto tmp = static_cast<View>(in.get(C::execution_sel_should_check_gas)) *
36 ((static_cast<View>(in.get(C::execution_prev_da_gas_used)) + CView(execution_DA_GAS_USED)) -
37 static_cast<View>(in.get(C::execution_total_gas_da)));
38 std::get<1>(evals) += (tmp * scaling_factor);
39 }
40 {
41 using View = typename std::tuple_element_t<2, ContainerOverSubrelations>::View;
42 auto tmp = (static_cast<View>(in.get(C::execution_sel_out_of_gas)) -
43 (FF(1) - (FF(1) - static_cast<View>(in.get(C::execution_out_of_gas_l2))) *
44 (FF(1) - static_cast<View>(in.get(C::execution_out_of_gas_da)))));
45 std::get<2>(evals) += (tmp * scaling_factor);
46 }
47 {
48 using View = typename std::tuple_element_t<3, ContainerOverSubrelations>::View;
49 auto tmp = (FF(1) - static_cast<View>(in.get(C::execution_sel_should_check_gas))) *
50 static_cast<View>(in.get(C::execution_sel_out_of_gas));
51 std::get<3>(evals) += (tmp * scaling_factor);
52 }
53}
54
55} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
Definition gas_impl.hpp:11
ColumnAndShifts
Definition columns.hpp:34
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define CView(v)
Container for parameters used by the grand product (permutation, lookup) Honk relations.