Skip to content

Commit 420fd55

Browse files
authored
feat: merge-train/barretenberg (#22969)
BEGIN_COMMIT_OVERRIDE chore: skip zero-init and reserve copy_cycle vectors (#22963) feat: Multi app per kernel (#22640) END_COMMIT_OVERRIDE
2 parents 72c125c + 22231d5 commit 420fd55

33 files changed

Lines changed: 516 additions & 404 deletions

barretenberg/cpp/src/barretenberg/chonk/batched_honk_translator/batched_honk_translator.test.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ class BatchedHonkTranslatorTests : public ::testing::Test {
140140
m.add_entry(round, "ECC_OP_WIRE_" + std::to_string(i), G);
141141
}
142142
// DataBus entities:
143-
for (const auto& label : { "CALLDATA",
144-
"CALLDATA_READ_COUNTS",
145-
"SECONDARY_CALLDATA",
146-
"SECONDARY_CALLDATA_READ_COUNTS",
147-
"RETURN_DATA",
148-
"RETURN_DATA_READ_COUNTS" }) {
143+
for (const auto& label : { "KERNEL_CALLDATA",
144+
"KERNEL_CALLDATA_READ_COUNTS",
145+
"APP_CALLDATA",
146+
"APP_CALLDATA_READ_COUNTS",
147+
"RETURNDATA",
148+
"RETURNDATA_READ_COUNTS" }) {
149149
m.add_entry(round, label, G);
150150
}
151151
m.add_challenge(round, "eta");
@@ -160,9 +160,9 @@ class BatchedHonkTranslatorTests : public ::testing::Test {
160160

161161
// ── Round 2: MegaZK logderiv inverses + Z_PERM + translator Oink ─────────
162162
m.add_entry(round, "LOOKUP_INVERSES", G);
163-
m.add_entry(round, "CALLDATA_INVERSES", G);
164-
m.add_entry(round, "SECONDARY_CALLDATA_INVERSES", G);
165-
m.add_entry(round, "RETURN_DATA_INVERSES", G);
163+
m.add_entry(round, "KERNEL_CALLDATA_INVERSES", G);
164+
m.add_entry(round, "APP_CALLDATA_INVERSES", G);
165+
m.add_entry(round, "RETURNDATA_INVERSES", G);
166166
m.add_entry(round, "Z_PERM", G);
167167
// Translator Oink: vk_hash, masking commitment, 10 wire commitments
168168
m.add_entry(round, "vk_hash", Fr);

barretenberg/cpp/src/barretenberg/chonk/chonk.cpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,19 @@ Chonk::PublicInputsResult Chonk::process_public_inputs_and_consistency_checks(
171171
<< witness_commitments.calldata.get_value());
172172
kernel_input.kernel_return_data.incomplete_assert_equal(witness_commitments.calldata);
173173

174-
// App return data
175-
bool app_return_data_match =
176-
kernel_input.app_return_data.get_value() == witness_commitments.secondary_calldata.get_value();
177-
BB_ASSERT_DEBUG(app_return_data_match,
178-
"app_return_data mismatch: proof contains "
179-
<< kernel_input.app_return_data.get_value() << " but secondary_calldata commitment is "
180-
<< witness_commitments.secondary_calldata.get_value());
181-
kernel_input.app_return_data.incomplete_assert_equal(witness_commitments.secondary_calldata);
174+
// App return data. Mega currently exposes a single app calldata witness commitment
175+
// (`secondary_calldata`), so MAX_APPS_PER_KERNEL remains 1.
176+
static_assert(MAX_APPS_PER_KERNEL == 1, "Multiple app calldata witness columns are not wired yet");
177+
for (size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
178+
bool app_return_data_match =
179+
kernel_input.app_return_data[idx].get_value() == witness_commitments.secondary_calldata.get_value();
180+
BB_ASSERT_DEBUG(app_return_data_match,
181+
"app_return_data mismatch: proof contains "
182+
<< kernel_input.app_return_data[idx].get_value()
183+
<< " but secondary_calldata commitment is "
184+
<< witness_commitments.secondary_calldata.get_value());
185+
kernel_input.app_return_data[idx].incomplete_assert_equal(witness_commitments.secondary_calldata);
186+
}
182187

183188
// ============= Perform accumulator hash consistency check =========================
184189

@@ -202,7 +207,7 @@ Chonk::PublicInputsResult Chonk::process_public_inputs_and_consistency_checks(
202207
AppIO app_input; // pairing points
203208
app_input.reconstruct_from_public(public_inputs);
204209

205-
// Set the app return data commitment to be propagated via the public inputs
210+
// Set the app return data commitment to be propagated via the public inputs. The depot owns slot allocation.
206211
bus_depot.set_app_return_data_commitment(witness_commitments.return_data);
207212

208213
return { std::move(app_input.pairing_inputs), std::nullopt };
@@ -318,6 +323,9 @@ void Chonk::complete_kernel_circuit_logic(ClientCircuit& circuit)
318323

319324
// Step 2: VERIFICATION LOOP - Recursively verify each proof in the queue
320325

326+
BB_ASSERT(bus_depot.app_return_data_slots_are_empty(),
327+
"DataBusDepot has stale app return-data slots at kernel-completion boundary");
328+
321329
std::vector<PairingPoints> points_accumulator;
322330
std::optional<RecursiveVerifierAccumulator> current_stdlib_verifier_accumulator;
323331
if (!is_init_kernel) {
@@ -376,9 +384,11 @@ void Chonk::complete_kernel_circuit_logic(ClientCircuit& circuit)
376384
// Extract native verifier accumulator from the stdlib accum to use it in the next round
377385
recursive_verifier_native_accum = current_stdlib_verifier_accumulator->get_value<VerifierAccumulator>();
378386

379-
// Get databus commitments
380387
auto kernel_return_data_commitment = bus_depot.get_kernel_return_data_commitment(circuit);
381-
auto app_return_data_commitment = bus_depot.get_app_return_data_commitment(circuit);
388+
KernelIO::AppReturnDataCommitments app_return_data_commitments;
389+
for (size_t idx = 0; idx < MAX_APPS_PER_KERNEL; ++idx) {
390+
app_return_data_commitments[idx] = bus_depot.get_app_return_data_commitment(circuit, idx);
391+
}
382392

383393
// Compute hash of output accumulator
384394
RecursiveTranscript hash_transcript;
@@ -394,7 +404,7 @@ void Chonk::complete_kernel_circuit_logic(ClientCircuit& circuit)
394404
// Propagate public inputs
395405
KernelIO kernel_output{ pairing_points_aggregator,
396406
kernel_return_data_commitment,
397-
app_return_data_commitment,
407+
app_return_data_commitments,
398408
running_hash.value(),
399409
current_verifier_accum_hash };
400410
kernel_output.set_public();

0 commit comments

Comments
 (0)