Skip to content

Commit 119efb2

Browse files
committed
fix
1 parent a29e279 commit 119efb2

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

barretenberg/cpp/pil/vm2/bytecode/bc_retrieval.pil

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ instance_exists {
110110
retrieved_bytecodes_tree_check.root
111111
};
112112

113+
sel * (1 - instance_exists) * new_bytecode = 0;
114+
113115
pol TOO_MANY_BYTECODES = no_remaining_bytecodes * new_bytecode;
114116

115117
// We error if instance doesn't exist or if we have too many bytecodes.

barretenberg/cpp/src/barretenberg/vm2/generated/relations/bc_retrieval.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ template <typename FF_> class bc_retrievalImpl {
1414
public:
1515
using FF = FF_;
1616

17-
static constexpr std::array<size_t, 13> SUBRELATION_PARTIAL_LENGTHS = { 3, 4, 3, 3, 5, 5, 3, 4, 3, 3, 3, 3, 3 };
17+
static constexpr std::array<size_t, 14> SUBRELATION_PARTIAL_LENGTHS = { 3, 4, 3, 3, 5, 4, 5, 3, 4, 3, 3, 3, 3, 3 };
1818

1919
template <typename AllEntities> inline static bool skip(const AllEntities& in)
2020
{
@@ -41,13 +41,13 @@ template <typename FF> class bc_retrieval : public Relation<bc_retrievalImpl<FF>
4141
return "TRACE_CONTINUITY";
4242
case 4:
4343
return "NO_REMAINING_BYTECODES";
44-
case 7:
45-
return "CURRENT_CLASS_ID_IS_ZERO_IF_INSTANCE_DOES_NOT_EXIST";
4644
case 8:
47-
return "ARTIFACT_HASH_IS_ZERO_IF_ERROR";
45+
return "CURRENT_CLASS_ID_IS_ZERO_IF_INSTANCE_DOES_NOT_EXIST";
4846
case 9:
49-
return "PRIVATE_FUNCTION_ROOT_IS_ZERO_IF_ERROR";
47+
return "ARTIFACT_HASH_IS_ZERO_IF_ERROR";
5048
case 10:
49+
return "PRIVATE_FUNCTION_ROOT_IS_ZERO_IF_ERROR";
50+
case 11:
5151
return "BYTECODE_ID_IS_ZERO_IF_ERROR";
5252
}
5353
return std::to_string(index);
@@ -56,10 +56,10 @@ template <typename FF> class bc_retrieval : public Relation<bc_retrievalImpl<FF>
5656
// Subrelation indices constants, to be used in tests.
5757
static constexpr size_t SR_TRACE_CONTINUITY = 1;
5858
static constexpr size_t SR_NO_REMAINING_BYTECODES = 4;
59-
static constexpr size_t SR_CURRENT_CLASS_ID_IS_ZERO_IF_INSTANCE_DOES_NOT_EXIST = 7;
60-
static constexpr size_t SR_ARTIFACT_HASH_IS_ZERO_IF_ERROR = 8;
61-
static constexpr size_t SR_PRIVATE_FUNCTION_ROOT_IS_ZERO_IF_ERROR = 9;
62-
static constexpr size_t SR_BYTECODE_ID_IS_ZERO_IF_ERROR = 10;
59+
static constexpr size_t SR_CURRENT_CLASS_ID_IS_ZERO_IF_INSTANCE_DOES_NOT_EXIST = 8;
60+
static constexpr size_t SR_ARTIFACT_HASH_IS_ZERO_IF_ERROR = 9;
61+
static constexpr size_t SR_PRIVATE_FUNCTION_ROOT_IS_ZERO_IF_ERROR = 10;
62+
static constexpr size_t SR_BYTECODE_ID_IS_ZERO_IF_ERROR = 11;
6363
};
6464

6565
} // namespace bb::avm2

barretenberg/cpp/src/barretenberg/vm2/generated/relations/bc_retrieval_impl.hpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,57 +63,64 @@ void bc_retrievalImpl<FF_>::accumulate(ContainerOverSubrelations& evals,
6363
}
6464
{
6565
using Accumulator = typename std::tuple_element_t<5, ContainerOverSubrelations>;
66+
auto tmp = in.get(C::bc_retrieval_sel) * (FF(1) - in.get(C::bc_retrieval_instance_exists)) *
67+
in.get(C::bc_retrieval_new_bytecode);
68+
tmp *= scaling_factor;
69+
std::get<5>(evals) += typename Accumulator::View(tmp);
70+
}
71+
{
72+
using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
6673
auto tmp = in.get(C::bc_retrieval_sel) *
6774
(in.get(C::bc_retrieval_instance_exists) * (FF(1) - bc_retrieval_TOO_MANY_BYTECODES) -
6875
(FF(1) - in.get(C::bc_retrieval_error)));
6976
tmp *= scaling_factor;
70-
std::get<5>(evals) += typename Accumulator::View(tmp);
77+
std::get<6>(evals) += typename Accumulator::View(tmp);
7178
}
7279
{
73-
using Accumulator = typename std::tuple_element_t<6, ContainerOverSubrelations>;
80+
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
7481
auto tmp = (in.get(C::bc_retrieval_should_retrieve) -
7582
in.get(C::bc_retrieval_sel) * (FF(1) - in.get(C::bc_retrieval_error)));
7683
tmp *= scaling_factor;
77-
std::get<6>(evals) += typename Accumulator::View(tmp);
84+
std::get<7>(evals) += typename Accumulator::View(tmp);
7885
}
7986
{ // CURRENT_CLASS_ID_IS_ZERO_IF_INSTANCE_DOES_NOT_EXIST
80-
using Accumulator = typename std::tuple_element_t<7, ContainerOverSubrelations>;
87+
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
8188
auto tmp = in.get(C::bc_retrieval_sel) * (FF(1) - in.get(C::bc_retrieval_instance_exists)) *
8289
in.get(C::bc_retrieval_current_class_id);
8390
tmp *= scaling_factor;
84-
std::get<7>(evals) += typename Accumulator::View(tmp);
91+
std::get<8>(evals) += typename Accumulator::View(tmp);
8592
}
8693
{ // ARTIFACT_HASH_IS_ZERO_IF_ERROR
87-
using Accumulator = typename std::tuple_element_t<8, ContainerOverSubrelations>;
94+
using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
8895
auto tmp = in.get(C::bc_retrieval_error) * in.get(C::bc_retrieval_artifact_hash);
8996
tmp *= scaling_factor;
90-
std::get<8>(evals) += typename Accumulator::View(tmp);
97+
std::get<9>(evals) += typename Accumulator::View(tmp);
9198
}
9299
{ // PRIVATE_FUNCTION_ROOT_IS_ZERO_IF_ERROR
93-
using Accumulator = typename std::tuple_element_t<9, ContainerOverSubrelations>;
100+
using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
94101
auto tmp = in.get(C::bc_retrieval_error) * in.get(C::bc_retrieval_private_function_root);
95102
tmp *= scaling_factor;
96-
std::get<9>(evals) += typename Accumulator::View(tmp);
103+
std::get<10>(evals) += typename Accumulator::View(tmp);
97104
}
98105
{ // BYTECODE_ID_IS_ZERO_IF_ERROR
99-
using Accumulator = typename std::tuple_element_t<10, ContainerOverSubrelations>;
106+
using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
100107
auto tmp = in.get(C::bc_retrieval_error) * in.get(C::bc_retrieval_bytecode_id);
101108
tmp *= scaling_factor;
102-
std::get<10>(evals) += typename Accumulator::View(tmp);
109+
std::get<11>(evals) += typename Accumulator::View(tmp);
103110
}
104111
{
105-
using Accumulator = typename std::tuple_element_t<11, ContainerOverSubrelations>;
112+
using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
106113
auto tmp = in.get(C::bc_retrieval_error) * (in.get(C::bc_retrieval_next_retrieved_bytecodes_tree_root) -
107114
in.get(C::bc_retrieval_prev_retrieved_bytecodes_tree_root));
108115
tmp *= scaling_factor;
109-
std::get<11>(evals) += typename Accumulator::View(tmp);
116+
std::get<12>(evals) += typename Accumulator::View(tmp);
110117
}
111118
{
112-
using Accumulator = typename std::tuple_element_t<12, ContainerOverSubrelations>;
119+
using Accumulator = typename std::tuple_element_t<13, ContainerOverSubrelations>;
113120
auto tmp = in.get(C::bc_retrieval_error) * (in.get(C::bc_retrieval_next_retrieved_bytecodes_tree_size) -
114121
in.get(C::bc_retrieval_prev_retrieved_bytecodes_tree_size));
115122
tmp *= scaling_factor;
116-
std::get<12>(evals) += typename Accumulator::View(tmp);
123+
std::get<13>(evals) += typename Accumulator::View(tmp);
117124
}
118125
}
119126

0 commit comments

Comments
 (0)