Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
sstore_impl.hpp
Go to the documentation of this file.
1// AUTOGENERATED FILE
2#pragma once
3
5
6namespace bb::avm2 {
7
8template <typename FF_>
9template <typename ContainerOverSubrelations, typename AllEntities>
10void sstoreImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
11 const AllEntities& in,
12 [[maybe_unused]] const RelationParameters<FF_>&,
13 [[maybe_unused]] const FF_& scaling_factor)
14{
15 using C = ColumnAndShifts;
16
17 PROFILE_THIS_NAME("accumulate/sstore");
18
19 const auto constants_MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX = FF(63);
20 const auto constants_AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_SIZE = FF(1);
21 const auto execution_REMAINING_DATA_WRITES = ((constants_MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX +
22 constants_AVM_WRITTEN_PUBLIC_DATA_SLOTS_TREE_INITIAL_SIZE) -
23 in.get(C::execution_prev_written_public_data_slots_tree_size));
24
25 {
26 using Accumulator = typename std::tuple_element_t<0, ContainerOverSubrelations>;
27 auto tmp =
28 in.get(C::execution_max_data_writes_reached) * (FF(1) - in.get(C::execution_max_data_writes_reached));
29 tmp *= scaling_factor;
30 std::get<0>(evals) += typename Accumulator::View(tmp);
31 }
32 { // SSTORE_MAX_DATA_WRITES_REACHED
33 using Accumulator = typename std::tuple_element_t<1, ContainerOverSubrelations>;
34 auto tmp = in.get(C::execution_sel_execute_sstore) *
35 ((execution_REMAINING_DATA_WRITES * (in.get(C::execution_max_data_writes_reached) *
36 (FF(1) - in.get(C::execution_remaining_data_writes_inv)) +
37 in.get(C::execution_remaining_data_writes_inv)) -
38 FF(1)) +
39 in.get(C::execution_max_data_writes_reached));
40 tmp *= scaling_factor;
41 std::get<1>(evals) += typename Accumulator::View(tmp);
42 }
43 { // OPCODE_ERROR_IF_OVERFLOW_OR_STATIC
44 using Accumulator = typename std::tuple_element_t<2, ContainerOverSubrelations>;
45 auto tmp =
46 in.get(C::execution_sel_execute_sstore) *
47 ((FF(1) - in.get(C::execution_max_data_writes_reached) * in.get(C::execution_dynamic_da_gas_factor)) *
48 (FF(1) - in.get(C::execution_is_static)) -
49 (FF(1) - in.get(C::execution_sel_opcode_error)));
50 tmp *= scaling_factor;
51 std::get<2>(evals) += typename Accumulator::View(tmp);
52 }
53 {
54 using Accumulator = typename std::tuple_element_t<3, ContainerOverSubrelations>;
55 auto tmp = in.get(C::execution_sel_execute_sstore) *
56 ((FF(1) - in.get(C::execution_sel_opcode_error)) - in.get(C::execution_sel_write_public_data));
57 tmp *= scaling_factor;
58 std::get<3>(evals) += typename Accumulator::View(tmp);
59 }
60 { // SSTORE_WRITTEN_SLOTS_ROOT_NOT_CHANGED
61 using Accumulator = typename std::tuple_element_t<4, ContainerOverSubrelations>;
62 auto tmp = in.get(C::execution_sel_execute_sstore) * in.get(C::execution_sel_opcode_error) *
63 (in.get(C::execution_prev_written_public_data_slots_tree_root) -
64 in.get(C::execution_written_public_data_slots_tree_root));
65 tmp *= scaling_factor;
66 std::get<4>(evals) += typename Accumulator::View(tmp);
67 }
68 { // SSTORE_WRITTEN_SLOTS_SIZE_NOT_CHANGED
69 using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
70 auto tmp = in.get(C::execution_sel_execute_sstore) * in.get(C::execution_sel_opcode_error) *
71 (in.get(C::execution_prev_written_public_data_slots_tree_size) -
72 in.get(C::execution_written_public_data_slots_tree_size));
73 tmp *= scaling_factor;
74 std::get<5>(evals) += typename Accumulator::View(tmp);
75 }
76 { // SSTORE_PUBLIC_DATA_TREE_ROOT_NOT_CHANGED
77 using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
78 auto tmp = in.get(C::execution_sel_execute_sstore) * in.get(C::execution_sel_opcode_error) *
79 (in.get(C::execution_prev_public_data_tree_root) - in.get(C::execution_public_data_tree_root));
80 tmp *= scaling_factor;
81 std::get<6>(evals) += typename Accumulator::View(tmp);
82 }
83 { // SSTORE_PUBLIC_DATA_TREE_SIZE_NOT_CHANGED
84 using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
85 auto tmp = in.get(C::execution_sel_execute_sstore) * in.get(C::execution_sel_opcode_error) *
86 (in.get(C::execution_prev_public_data_tree_size) - in.get(C::execution_public_data_tree_size));
87 tmp *= scaling_factor;
88 std::get<7>(evals) += typename Accumulator::View(tmp);
89 }
90}
91
92} // namespace bb::avm2
static void accumulate(ContainerOverSubrelations &evals, const AllEntities &in, const RelationParameters< FF > &, const FF &scaling_factor)
ColumnAndShifts
Definition columns.hpp:35
AvmFlavorSettings::FF FF
Definition field.hpp:10
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
#define PROFILE_THIS_NAME(name)
Definition op_count.hpp:16
Container for parameters used by the grand product (permutation, lookup) Honk relations.