Skip to content

Commit 7204197

Browse files
author
maramihali
committed
cleanup, fix tests, docs
1 parent 12d59ca commit 7204197

22 files changed

+237
-217
lines changed

barretenberg/cpp/scripts/test_civc_standalone_vks_havent_changed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd ..
1111
# - Generate a hash for versioning: sha256sum bb-civc-inputs.tar.gz
1212
# - Upload the compressed results: aws s3 cp bb-civc-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-civc-inputs-[hash(0:8)].tar.gz
1313
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
14-
pinned_short_hash="869efec4"
14+
pinned_short_hash="9b31056f"
1515
pinned_civc_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-civc-inputs-${pinned_short_hash}.tar.gz"
1616

1717
function compress_and_upload {

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,9 @@ ClientIVC::perform_recursive_verification_and_databus_consistency_checks(
269269
pairing_points.aggregate(nested_pairing_points);
270270
if (is_hiding_kernel) {
271271
pairing_points.aggregate(decider_pairing_points);
272-
// Placeholder for randomness (will be removed)
272+
// Placeholder for randomness at the end of the hiding circuit
273273
circuit.queue_ecc_no_op();
274274
circuit.queue_ecc_no_op();
275-
info("num ops in hiding kernel ", circuit.op_queue->get_unmerged_subtable_size());
276275
}
277276

278277
return { output_verifier_accumulator, pairing_points, merged_table_commitments };
@@ -316,6 +315,7 @@ void ClientIVC::complete_kernel_circuit_logic(ClientCircuit& circuit)
316315
// subtable is at the top of the final aggregate table since it is the last to be prepended).
317316
if (is_tail_kernel) {
318317
circuit.queue_ecc_no_op();
318+
// Placeholder for randomness at the beginning of tail circuit
319319
circuit.queue_ecc_no_op();
320320
circuit.queue_ecc_no_op();
321321
}

barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ TEST_F(ClientIVCTests, BasicStructured)
8888

8989
EXPECT_TRUE(ClientIVC::verify(proof, vk));
9090
};
91+
9192
/**
9293
* @brief Check that the IVC fails if an intermediate fold proof is invalid
9394
* @details When accumulating 4 circuits, there are 3 fold proofs to verify (the first two are recursively verfied and

barretenberg/cpp/src/barretenberg/constants.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace bb {
88
// permutation argument polynomials (sigmas, ids) are unique, e.g. id[i][j] == id[m][n] iff (i == m && j == n)
99
constexpr uint32_t PERMUTATION_ARGUMENT_VALUE_SEPARATOR = 1 << 28;
1010

11+
static constexpr uint32_t CONST_TRANSLATOR_MINI_CIRCUIT_LOG_SIZE = 14;
12+
13+
// -1 as each op occupies two rows in Translator trace
14+
static constexpr uint32_t CONST_OP_QUEUE_LOG_SIZE = CONST_TRANSLATOR_MINI_CIRCUIT_LOG_SIZE - 1;
15+
1116
// The log of the max circuit size assumed in order to achieve constant sized Honk proofs
1217
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1046): Remove the need for const sized proofs
1318
static constexpr uint32_t CONST_PROOF_SIZE_LOG_N = 28;

barretenberg/cpp/src/barretenberg/goblin/goblin.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,14 @@ void Goblin::prove_translator()
4545
auto translator_key = std::make_shared<TranslatorProvingKey>(translator_builder, commitment_key);
4646
TranslatorProver translator_prover(translator_key, transcript);
4747
goblin_proof.translator_proof = translator_prover.construct_proof();
48-
// auto op = op_queue->construct_ultra_ops_table_columns()[0];
49-
// auto op_translator = op_queue->get_ultra_ops();
50-
// info(op.size(), " ", op_translator.size());
51-
// for (size_t i = 0; i < op_translator.size(); i++) {}
52-
53-
// if
54-
// info(op.size(), " ", translator_key->proving_key->polynomials.op.size());
55-
// for (size_t i = 0; i < op.size(); i++) {
56-
// if (op.at(i) != translator_key->proving_key->polynomials.op[i]) {
57-
// info("mismatch at ",
58-
// i,
59-
// " op_queue: ",
60-
// op.at(i),
61-
// " translator_key: ",
62-
// translator_key->proving_key->polynomials.op[i]);
63-
// }
64-
// }
6548
}
6649

6750
GoblinProof Goblin::prove(const MergeSettings merge_settings)
6851
{
6952
PROFILE_THIS_NAME("Goblin::prove");
7053

7154
prove_merge(transcript, merge_settings); // Use shared transcript for merge proving
72-
info("Constructing a Goblin proof with num ultra ops = ", op_queue->get_ultra_ops().size());
55+
info("Constructing a Goblin proof with num ultra ops = ", op_queue->get_ultra_ops_table_num_rows());
7356

7457
BB_ASSERT_EQ(merge_verification_queue.size(),
7558
1U,

barretenberg/cpp/src/barretenberg/op_queue/ecc_op_queue.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ECCOpQueue {
4848
EccvmRowTracker eccvm_row_tracker;
4949

5050
public:
51-
static const size_t OP_QUEUE_SIZE = 1 << 13;
51+
static const size_t OP_QUEUE_SIZE = 1 << CONST_OP_QUEUE_LOG_SIZE;
5252
/**
5353
* @brief Instantiate an initial ECC op subtable.
5454
*/

barretenberg/cpp/src/barretenberg/op_queue/ecc_op_queue.test.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class ECCOpQueueTest {
5454
} else {
5555
// APPEND merge performs concatenation directly to end of previous table or at a specified fixed offset
5656
const size_t prev_table_size = op_queue->get_previous_ultra_ops_table_num_rows(); // k
57-
const size_t shift_magnitude = ultra_fixed_offset.value_or(prev_table_size);
57+
const size_t shift_magnitude = ultra_fixed_offset.has_value()
58+
? ultra_fixed_offset.value() * bb::UltraEccOpsTable::NUM_ROWS_PER_OP
59+
: prev_table_size; // k
5860
// T(x) = T_prev(x) + x^k * t_current(x), where k is the shift magnitude
5961
const Fr prev_table_eval = prev_table_poly.evaluate(eval_challenge); // T_prev(x)
6062
const Fr shifted_subtable_eval =
@@ -74,10 +76,12 @@ class ECCOpQueueTest {
7476
auto ultra_table = op_queue->get_ultra_ops();
7577
auto eccvm_table = op_queue->get_eccvm_ops();
7678

77-
EXPECT_EQ(eccvm_table.size(), ultra_table.size());
78-
79-
for (auto [ultra_op, eccvm_op] : zip_view(ultra_table, eccvm_table)) {
80-
EXPECT_EQ(ultra_op.op_code.value(), eccvm_op.op_code.value());
79+
size_t j = 0;
80+
for (const auto& ultra_op : ultra_table) {
81+
if (ultra_op.op_code.value() == 0) {
82+
continue;
83+
}
84+
EXPECT_EQ(ultra_op.op_code.value(), eccvm_table[j++].op_code.value());
8185
}
8286
};
8387
};

barretenberg/cpp/src/barretenberg/op_queue/ecc_ops_table.hpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ class UltraEccOpsTable {
239239

240240
public:
241241
size_t size() const { return table.size(); }
242-
243242
size_t ultra_table_size() const
244243
{
245244
size_t base_size = table.size() * NUM_ROWS_PER_OP;
@@ -250,7 +249,6 @@ class UltraEccOpsTable {
250249
// The last subtable in deque is the fixed-location one
251250
last_subtable_size = table.get().back().size() * NUM_ROWS_PER_OP;
252251
}
253-
info("here");
254252
return std::max(base_size, (fixed_append_offset.value() * NUM_ROWS_PER_OP) + last_subtable_size);
255253
}
256254
return base_size;
@@ -279,7 +277,7 @@ class UltraEccOpsTable {
279277

280278
std::vector<UltraOp> get_reconstructed() const
281279
{
282-
if (has_fixed_append) {
280+
if (has_fixed_append && fixed_append_offset.has_value()) {
283281
return get_reconstructed_with_fixed_append();
284282
}
285283
return table.get_reconstructed();
@@ -289,7 +287,6 @@ class UltraEccOpsTable {
289287

290288
ASSERT(get_unmerged_subtable_size() == 0,
291289
"current subtable should be merged before reconstructing the full table of operations.");
292-
info("Reconstructing with fixed append");
293290

294291
std::vector<UltraOp> reconstructed_table;
295292
// reconstructed_table.reserve(reconstructed_table_size);
@@ -300,7 +297,6 @@ class UltraEccOpsTable {
300297
reconstructed_table.push_back(op);
301298
}
302299
}
303-
info("Size before shift: ", reconstructed_table.size());
304300

305301
// Add zeros if fixed offset is larger than current size
306302
if (has_fixed_append && fixed_append_offset.has_value()) {
@@ -317,12 +313,10 @@ class UltraEccOpsTable {
317313
}
318314

319315
// Add the final subtable (appended at fixed location)
320-
info("Size before appending final subtable: ", reconstructed_table.size());
321316
const auto& final_subtable = table.get()[table.num_subtables() - 1];
322317
for (const auto& op : final_subtable) {
323318
reconstructed_table.push_back(op);
324319
}
325-
info("Reconstructed table size: ", reconstructed_table.size());
326320
return reconstructed_table;
327321
}
328322

@@ -332,7 +326,6 @@ class UltraEccOpsTable {
332326
const size_t poly_size = ultra_table_size();
333327

334328
if (has_fixed_append) {
335-
info("we should construct with fixed append ", poly_size);
336329
// Handle fixed-location append: prepended tables first, then appended table at fixed offset
337330
return construct_column_polynomials_with_fixed_append(poly_size);
338331
}
@@ -406,8 +399,7 @@ class UltraEccOpsTable {
406399
}
407400

408401
// Place the appended subtable at the fixed offset
409-
size_t append_position = fixed_append_offset.value_or(i) * NUM_ROWS_PER_OP;
410-
info("append position: ", append_position);
402+
size_t append_position = fixed_append_offset.has_value() ? fixed_append_offset.value() * NUM_ROWS_PER_OP : i;
411403
const auto& appended_subtable = table.get()[table.num_subtables() - 1];
412404

413405
size_t j = append_position;

barretenberg/cpp/src/barretenberg/op_queue/ecc_ops_table.test.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ TEST(EccOpsTableTest, UltraOpsFixedLocationAppendWithGap)
267267

268268
// Define a fixed offset at which to append the table (must be greater than the total size of the prepended tables)
269269
const size_t fixed_offset = 20;
270+
const size_t fixed_offset_num_rows = fixed_offset * ULTRA_ROWS_PER_OP;
270271
const size_t prepended_size = (subtable_op_counts[0] + subtable_op_counts[1]) * ULTRA_ROWS_PER_OP;
271-
ASSERT(fixed_offset > prepended_size);
272+
ASSERT(fixed_offset_num_rows > prepended_size);
272273

273274
// Construct the ultra ops table
274275
for (size_t i = 0; i < NUM_SUBTABLES; ++i) {
@@ -290,7 +291,7 @@ TEST(EccOpsTableTest, UltraOpsFixedLocationAppendWithGap)
290291
EXPECT_EQ(ultra_ops_table.size(), expected_num_ops);
291292

292293
// Check that the polynomials have the correct size (including gap)
293-
size_t expected_poly_size = fixed_offset + (subtable_op_counts[2] * ULTRA_ROWS_PER_OP);
294+
size_t expected_poly_size = fixed_offset_num_rows + (subtable_op_counts[2] * ULTRA_ROWS_PER_OP);
294295
EXPECT_EQ(ultra_ops_table.ultra_table_size(), expected_poly_size);
295296

296297
// Construct polynomials corresponding to the columns of the ultra ops table
@@ -316,7 +317,7 @@ TEST(EccOpsTableTest, UltraOpsFixedLocationAppendWithGap)
316317

317318
// Check gap from offset to appended subtable is filled with zeros
318319
for (auto ultra_op_poly : ultra_ops_table_polynomials) {
319-
for (size_t row = prepended_size; row < fixed_offset; ++row) {
320+
for (size_t row = prepended_size; row < fixed_offset_num_rows; ++row) {
320321
EXPECT_EQ(ultra_op_poly.at(row), Fr::zero());
321322
}
322323
}
@@ -325,28 +326,26 @@ TEST(EccOpsTableTest, UltraOpsFixedLocationAppendWithGap)
325326
std::vector<std::vector<UltraOp>> appended_subtables = { subtables[2] };
326327
EccOpsTableTest::MockUltraOpsTable expected_appended_table(appended_subtables);
327328
for (auto [ultra_op_poly, expected_poly] : zip_view(ultra_ops_table_polynomials, expected_appended_table.columns)) {
328-
for (size_t row = 0; row < subtable_op_counts[2] * ULTRA_ROWS_PER_OP; ++row) {
329-
EXPECT_EQ(ultra_op_poly.at(fixed_offset + row), expected_poly[row]);
329+
for (size_t row = 0; row < subtable_op_counts[2] * ULTRA_ROWS_PER_OP; row++) {
330+
EXPECT_EQ(ultra_op_poly.at(fixed_offset_num_rows + row), expected_poly[row]);
330331
}
331332
}
332333

333-
// Mimic get_reconstructed by unifying all the ops from subtables into a single vector with the appropiate gap of
334-
// no-ops
334+
// Mimic get_reconstructed by unifying all the ops from subtables into a single vector with the appropiate append
335+
// offset
335336
{
336-
// Compute how many no-op operations are needed to span the gap (fixed_offset and prepended_size are in rows)
337-
338337
std::vector<UltraOp> expected_reconstructed;
339338
expected_reconstructed.reserve(expected_num_ops + fixed_offset);
340339

341-
// Order: subtable[1], subtable[0], gap (no-ops), subtable[2]
340+
// Order: subtable[1], subtable[0], no-ops range, subtable[2]
342341
for (const auto& op : subtables[1]) {
343342
expected_reconstructed.push_back(op);
344343
}
345344
for (const auto& op : subtables[0]) {
346345
expected_reconstructed.push_back(op);
347346
}
348347

349-
// Construct a canonical "no-op" UltraOp (fields zeroed)
348+
// Add the range of noops
350349
UltraOp no_op = {};
351350
size_t size_before = expected_reconstructed.size();
352351
for (size_t i = size_before; i < fixed_offset; i++) {

barretenberg/cpp/src/barretenberg/relations/translator_vm/translator_decomposition_relation.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ template <typename FF_> class TranslatorDecompositionRelationImpl {
1616

1717
// 1 + polynomial degree of this relation
1818
static constexpr size_t RELATION_LENGTH =
19-
3; // degree(lagrange_even_in_minicircuit_in_minicircuit(a - a_0 - a_1*2¹⁴ ... - a_l⋅2¹⁴ˡ )) = 2
19+
4; // degree(lagrange_even_in_minicircuit_in_minicircuit(a - a_0 - a_1*2¹⁴ ... - a_l⋅2¹⁴ˡ )op) = 3
2020
static constexpr std::array<size_t, 48> SUBRELATION_PARTIAL_LENGTHS{
21-
4, // decomposition of P.x limb 0 into microlimbs subrelation
22-
4, // decomposition of P.x limb 1 into microlimbs subrelation
23-
4, // decomposition of P.x limb 2 into microlimbs subrelation
24-
4, // decomposition of P.x limb 3 into microlimbs subrelation
21+
4, // decomposition of accumulator limb 0 into microlimbs subrelation
22+
4, // decomposition of accumulator limb 1 into microlimbs subrelation
23+
4, // decomposition of accumulator limb 2 into microlimbs subrelation
24+
4, // decomposition of accumulator limb 3 into microlimbs subrelation
2525
3, // decomposition of P.y limb 0 into microlimbs subrelation
2626
3, // decomposition of P.y limb 1 into microlimbs subrelation
2727
3, // decomposition of P.y limb 2 into microlimbs subrelation
@@ -30,10 +30,10 @@ template <typename FF_> class TranslatorDecompositionRelationImpl {
3030
3, // decomposition of z2 limb 0 into microlimbs subrelation
3131
3, // decomposition of z1 limb 1 into microlimbs subrelation
3232
3, // decomposition of z2 limb 1 into microlimbs subrelation
33-
3, // decomposition of accumulator limb 0 into microlimbs subrelation
34-
3, // decomposition of accumulator limb 1 into microlimbs subrelation
35-
3, // decomposition of accumulator limb 2 into microlimbs subrelation
36-
3, // decomposition of accumulator limb 3 into microlimbs subrelation
33+
3, // decomposition of P.x limb 0 into microlimbs subrelation
34+
3, // decomposition of P.x limb 1 into microlimbs subrelation
35+
3, // decomposition of P.x limb 2 into microlimbs subrelation
36+
3, // decomposition of P.x limb 3 into microlimbs subrelation
3737
3, // decomposition of quotient limb 0 into microlimbs subrelation
3838
3, // decomposition of quotient limb 1 into microlimbs subrelation
3939
3, // decomposition of quotient limb 2 into microlimbs subrelation

0 commit comments

Comments
 (0)