Skip to content

Commit 63655fc

Browse files
authored
feat: merge-train/barretenberg (#18107)
BEGIN_COMMIT_OVERRIDE Improve pairing point tagging testing chore: audit ram/rom in stdlib (#18023) fix: Add AVM build to ci-barretenberg (#18109) chore: merge merge verifiers (#18086) feat(bb): upload benchmark breakdowns to CI disk storage (#17871) fix: biggroup `batch_mul` fixes and cleanup (#17903) fix: disable AVM in bb merge train again (#18118) I chore: Add ecdsa batch mul documentation (#17983) chore: Ec operations audit, part 2 (#18088) END_COMMIT_OVERRIDE
2 parents b57e59c + 4c61bea commit 63655fc

File tree

72 files changed

+1922
-1702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+1922
-1702
lines changed

barretenberg/cpp/scripts/ci_benchmark_ivc_flows.sh

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# Performs the chonk private transaction proving benchmarks for our 'realistic apps'.
33
# This is called by yarn-project/end-to-end/bootstrap.sh bench, which creates these inputs from end-to-end tests.
44
source $(git rev-parse --show-toplevel)/ci3/source
5+
source $(git rev-parse --show-toplevel)/ci3/source_redis
6+
source $(git rev-parse --show-toplevel)/ci3/source_cache
57

68
if [[ $# -ne 2 ]]; then
79
echo "Usage: $0 <runtime> <benchmark_folder>"
@@ -45,15 +47,16 @@ function run_bb_cli_bench {
4547
shift 2
4648

4749
if [[ "$runtime" == "native" ]]; then
48-
memusage "./$native_build_dir/bin/bb" "$@" || {
49-
echo "bb native failed with args: $@"
50+
# Add --bench_out_hierarchical flag for native builds to capture hierarchical op counts and timings
51+
memusage "./$native_build_dir/bin/bb" "$@" "--bench_out_hierarchical" "$output/benchmark_breakdown.json" || {
52+
echo "bb native failed with args: $@ --bench_out_hierarchical $output/benchmark_breakdown.json"
5053
exit 1
5154
}
5255
else # wasm
5356
export WASMTIME_ALLOWED_DIRS="--dir=$flow_folder --dir=$output"
54-
# TODO support wasm op count time preset
55-
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb "$@" || {
56-
echo "bb wasm failed with args: $@"
57+
# Add --bench_out_hierarchical flag for wasm builds to capture hierarchical op counts and timings
58+
memusage scripts/wasmtime.sh $WASMTIME_ALLOWED_DIRS ./build-wasm-threads/bin/bb "$@" "--bench_out_hierarchical" "$output/benchmark_breakdown.json" || {
59+
echo "bb wasm failed with args: $@ --bench_out_hierarchical $output/benchmark_breakdown.json"
5760
exit 1
5861
}
5962
fi
@@ -102,3 +105,37 @@ EOF
102105
export -f verify_ivc_flow run_bb_cli_bench
103106

104107
chonk_flow $1 $2
108+
109+
# Upload benchmark breakdown (op counts and timings) to disk if running in CI
110+
if [[ "${CI:-}" == "1" ]] && [[ "${CI_ENABLE_DISK_LOGS:-0}" == "1" ]]; then
111+
echo_header "Uploading Barretenberg benchmark breakdowns"
112+
113+
runtime="$1"
114+
flow_name="$(basename $2)"
115+
benchmark_breakdown_file="bench-out/app-proving/$flow_name/$runtime/benchmark_breakdown.json"
116+
117+
if [[ -f "$benchmark_breakdown_file" ]]; then
118+
current_sha=$(git rev-parse HEAD)
119+
120+
# Create cache key: bench-bb-breakdown-<runtime>-<flow_name>-<sha>
121+
# This will be accessible at: http://ci.aztec-labs.com/bench-bb-breakdown-<runtime>-<flow_name>-<sha>
122+
cache_key="bench-bb-breakdown-${runtime}-${flow_name}-${current_sha}"
123+
124+
# Upload to Redis (30 day retention) and disk (bench/bb-breakdown subfolder)
125+
{
126+
# Write to Redis for ci.aztec-labs.com access
127+
cat "$benchmark_breakdown_file" | gzip | redis_cli -x SETEX "$cache_key" 2592000 &>/dev/null
128+
129+
# Write to disk in explicit subfolder (only if disk logging enabled)
130+
if [[ "${CI_ENABLE_DISK_LOGS:-0}" == "1" ]]; then
131+
# Strip the prefix from key when writing to disk subfolder
132+
disk_key="${cache_key#bench-bb-breakdown-}"
133+
cat "$benchmark_breakdown_file" | gzip | cache_disk_transfer_to "bench/bb-breakdown" "$disk_key"
134+
fi
135+
} &
136+
137+
echo "Uploaded benchmark breakdown: http://ci.aztec-labs.com/$cache_key"
138+
else
139+
echo "Warning: benchmark breakdown file not found at $benchmark_breakdown_file"
140+
fi
141+
fi

barretenberg/cpp/scripts/test_chonk_standalone_vks_havent_changed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cd ..
1313
# - Generate a hash for versioning: sha256sum bb-chonk-inputs.tar.gz
1414
# - Upload the compressed results: aws s3 cp bb-chonk-inputs.tar.gz s3://aztec-ci-artifacts/protocol/bb-chonk-inputs-[hash(0:8)].tar.gz
1515
# Note: In case of the "Test suite failed to run ... Unexpected token 'with' " error, need to run: docker pull aztecprotocol/build:3.0
16-
pinned_short_hash="07b5558d"
16+
pinned_short_hash="fde8277f"
1717
pinned_chonk_inputs_url="https://aztec-ci-artifacts.s3.us-east-2.amazonaws.com/protocol/bb-chonk-inputs-${pinned_short_hash}.tar.gz"
1818

1919
function compress_and_upload {

barretenberg/cpp/src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ add_subdirectory(barretenberg/wasi)
113113
add_subdirectory(barretenberg/world_state)
114114
add_subdirectory(barretenberg/lmdblib)
115115

116-
if(AVM)
116+
# NOTE: Do not conditionally base this on the AVM flag as it defines a necessary vm2_sim library.
117+
if(NOT WASM)
117118
add_subdirectory(barretenberg/vm2)
118119
if(FUZZING)
119120
add_subdirectory(barretenberg/avm_fuzzer)
@@ -176,7 +177,6 @@ set(BARRETENBERG_TARGET_OBJECTS
176177
$<TARGET_OBJECTS:stdlib_circuit_builders_objects>
177178
$<TARGET_OBJECTS:stdlib_chonk_verifier_objects>
178179
$<TARGET_OBJECTS:stdlib_eccvm_verifier_objects>
179-
$<TARGET_OBJECTS:stdlib_merge_verifier_objects>
180180
$<TARGET_OBJECTS:stdlib_honk_verifier_objects>
181181
$<TARGET_OBJECTS:stdlib_goblin_verifier_objects>
182182
$<TARGET_OBJECTS:stdlib_keccak_objects>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
barretenberg_module(boomerang_value_detection stdlib_circuit_builders circuit_checker
22
stdlib_primitives numeric stdlib_aes128 stdlib_sha256 stdlib_blake2s
3-
stdlib_blake3s stdlib_poseidon2 stdlib_honk_verifier stdlib_merge_verifier
3+
stdlib_blake3s stdlib_poseidon2 stdlib_honk_verifier
44
stdlib_goblin_verifier stdlib_pedersen_hash goblin
55
commitment_schemes)

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_dynamic_array.test.cpp

Lines changed: 0 additions & 88 deletions
This file was deleted.

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_merge_recursive_verifier.test.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "barretenberg/common/test.hpp"
44
#include "barretenberg/ecc/fields/field_conversion.hpp"
55
#include "barretenberg/goblin/mock_circuits.hpp"
6-
#include "barretenberg/stdlib/merge_verifier/merge_recursive_verifier.hpp"
76
#include "barretenberg/stdlib/primitives/curves/bn254.hpp"
87
#include "barretenberg/ultra_honk/merge_prover.hpp"
98
#include "barretenberg/ultra_honk/merge_verifier.hpp"
@@ -24,9 +23,9 @@ namespace bb::stdlib::recursion::goblin {
2423
template <class RecursiveBuilder> class BoomerangRecursiveMergeVerifierTest : public testing::Test {
2524

2625
// Types for recursive verifier circuit
27-
using RecursiveMergeVerifier = MergeRecursiveVerifier_<RecursiveBuilder>;
28-
using RecursiveTableCommitments = MergeRecursiveVerifier_<RecursiveBuilder>::TableCommitments;
29-
using RecursiveMergeCommitments = MergeRecursiveVerifier_<RecursiveBuilder>::InputCommitments;
26+
using RecursiveMergeVerifier = MergeRecursiveVerifier<RecursiveBuilder>;
27+
using RecursiveTableCommitments = MergeRecursiveVerifier<RecursiveBuilder>::TableCommitments;
28+
using RecursiveMergeCommitments = MergeRecursiveVerifier<RecursiveBuilder>::InputCommitments;
3029

3130
// Define types relevant for inner circuit
3231
using InnerFlavor = MegaFlavor;
@@ -89,10 +88,10 @@ template <class RecursiveBuilder> class BoomerangRecursiveMergeVerifierTest : pu
8988
}
9089

9190
// Create a recursive merge verification circuit for the merge proof
92-
RecursiveMergeVerifier verifier{ &outer_circuit, settings };
93-
verifier.transcript->enable_manifest();
91+
auto merge_transcript = std::make_shared<StdlibTranscript<RecursiveBuilder>>();
92+
RecursiveMergeVerifier verifier{ settings, merge_transcript };
9493
const stdlib::Proof<RecursiveBuilder> stdlib_merge_proof(outer_circuit, merge_proof);
95-
[[maybe_unused]] auto [pairing_points, recursive_merged_table_commitments] =
94+
[[maybe_unused]] auto [pairing_points, recursive_merged_table_commitments, degree_check_verified] =
9695
verifier.verify_proof(stdlib_merge_proof, recursive_merge_commitments);
9796

9897
// Check for a failure flag in the recursive verifier circuit

barretenberg/cpp/src/barretenberg/boomerang_value_detection/graph_description_ultra_recursive_verifier.test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ template <typename RecursiveFlavor> class BoomerangRecursiveVerifierTest : publi
4545
using RecursiveVerifier = UltraRecursiveVerifier_<RecursiveFlavor>;
4646
using VerificationKey = typename RecursiveVerifier::VerificationKey;
4747

48-
using PairingObject = PairingPoints<OuterBuilder>;
48+
using PairingObject = PairingPoints<bn254<OuterBuilder>>;
4949
using VerifierOutput = bb::stdlib::recursion::honk::UltraRecursiveVerifierOutput<OuterBuilder>;
5050
using StdlibProof = bb::stdlib::Proof<OuterBuilder>;
5151

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Chonk : public IVCBase {
6060
using RecursiveVerificationKey = RecursiveFlavor::VerificationKey;
6161
using RecursiveVKAndHash = RecursiveFlavor::VKAndHash;
6262
using RecursiveTranscript = RecursiveFlavor::Transcript;
63-
using PairingPoints = stdlib::recursion::PairingPoints<ClientCircuit>;
63+
using PairingPoints = stdlib::recursion::PairingPoints<stdlib::bn254<ClientCircuit>>;
6464
using KernelIO = bb::stdlib::recursion::honk::KernelIO;
6565
using HidingKernelIO = bb::stdlib::recursion::honk::HidingKernelIO<ClientCircuit>;
6666
using AppIO = bb::stdlib::recursion::honk::AppIO;

barretenberg/cpp/src/barretenberg/circuit_checker/circuit_checker.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ class CircuitChecker {
1717
template <typename Builder> static bool check(const Builder& builder)
1818
{
1919
static_assert(IsCheckable<Builder>);
20-
if constexpr (IsUltraBuilder<Builder> || IsMegaBuilder<Builder>) {
20+
if (IsUltraOrMegaBuilder<Builder>) {
2121
return UltraCircuitChecker::check(builder);
22-
} else {
23-
return false;
2422
}
23+
return false;
2524
}
2625
};
2726

barretenberg/cpp/src/barretenberg/commitment_schemes/kzg/kzg.hpp

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
#include "barretenberg/commitment_schemes/claim.hpp"
1010
#include "barretenberg/commitment_schemes/commitment_key.hpp"
11+
#include "barretenberg/commitment_schemes/pairing_points.hpp"
1112
#include "barretenberg/commitment_schemes/utils/batch_mul_native.hpp"
1213
#include "barretenberg/commitment_schemes/verification_key.hpp"
14+
#include "barretenberg/stdlib/primitives/pairing_points.hpp"
1315
#include "barretenberg/transcript/transcript.hpp"
1416

1517
#include <memory>
@@ -26,7 +28,8 @@ template <typename Curve_> class KZG {
2628
using Commitment = typename Curve::AffineElement;
2729
using GroupElement = typename Curve::Element;
2830
using Polynomial = bb::Polynomial<Fr>;
29-
using VerifierAccumulator = std::array<GroupElement, 2>;
31+
using PairingPointsType =
32+
std::conditional_t<Curve::is_stdlib_type, stdlib::recursion::PairingPoints<Curve>, bb::PairingPoints<Curve>>;
3033

3134
/**
3235
* @brief Computes the KZG commitment to an opening proof polynomial at a single evaluation point
@@ -59,6 +62,10 @@ template <typename Curve_> class KZG {
5962
// future we might need to adjust this to use the incoming alternative to work queue (i.e. variation of
6063
// pthreads) or even the work queue itself
6164
prover_trancript->send_to_verifier("KZG:W", quotient_commitment);
65+
66+
// Masking challenge is used in the recursive setting to perform batch_mul. This is not used
67+
// by the prover directly, we just need it for consistent transcript state with the verifier.
68+
prover_trancript->template get_challenge<Fr>("KZG:masking_challenge");
6269
};
6370

6471
/**
@@ -67,13 +74,13 @@ template <typename Curve_> class KZG {
6774
* @details This is used in the recursive setting where we want to "aggregate" proofs, not verify them.
6875
*
6976
* @param claim OpeningClaim ({r, v}, C)
70-
* @return {P₀, P₁} where
77+
* @return PairingPoints {P₀, P₁} where
7178
* - P₀ = C − v⋅[1]₁ + r⋅[W(x)]₁
7279
* - P₁ = - [W(x)]₁
7380
*/
7481
template <typename Transcript>
75-
static VerifierAccumulator reduce_verify(const OpeningClaim<Curve>& claim,
76-
const std::shared_ptr<Transcript>& verifier_transcript)
82+
static PairingPointsType reduce_verify(const OpeningClaim<Curve>& claim,
83+
const std::shared_ptr<Transcript>& verifier_transcript)
7784
{
7885
auto quotient_commitment = verifier_transcript->template receive_from_prover<Commitment>("KZG:W");
7986

@@ -98,7 +105,7 @@ template <typename Curve_> class KZG {
98105
}
99106

100107
auto P_1 = -quotient_commitment;
101-
return { P_0, P_1 };
108+
return PairingPointsType(P_0, P_1);
102109
};
103110

104111
/**
@@ -114,16 +121,19 @@ template <typename Curve_> class KZG {
114121
*
115122
* @param batch_opening_claim \f$(\text{commitments}, \text{scalars}, \text{shplonk_evaluation_challenge})\f$
116123
* A struct containing the commitments, scalars, and the Shplonk evaluation challenge.
117-
* @return \f$ \{P_0, P_1\}\f$ where:
124+
* @return PairingPoints \f$ \{P_0, P_1\}\f$ where:
118125
* - \f$ P_0 = C + [W(x)]_1 \cdot z \f$
119126
* - \f$ P_1 = - [W(x)]_1 \f$
120127
*/
121128
template <typename Transcript>
122-
static VerifierAccumulator reduce_verify_batch_opening_claim(BatchOpeningClaim<Curve> batch_opening_claim,
123-
const std::shared_ptr<Transcript>& transcript)
129+
static PairingPointsType reduce_verify_batch_opening_claim(BatchOpeningClaim<Curve> batch_opening_claim,
130+
const std::shared_ptr<Transcript>& transcript)
124131
{
125132
auto quotient_commitment = transcript->template receive_from_prover<Commitment>("KZG:W");
126133

134+
// This challenge is used to compute offset generators in the batch_mul call below
135+
const Fr masking_challenge = transcript->template get_challenge<Fr>("KZG:masking_challenge");
136+
127137
// The pairing check can be expressed as
128138
// e(C + [W]₁ ⋅ z, [1]₂) * e(−[W]₁, [X]₂) = 1, where C = ∑ commitmentsᵢ ⋅ scalarsᵢ.
129139
GroupElement P_0;
@@ -136,13 +146,15 @@ template <typename Curve_> class KZG {
136146
P_0 = GroupElement::batch_mul(batch_opening_claim.commitments,
137147
batch_opening_claim.scalars,
138148
/*max_num_bits=*/0,
139-
/*with_edgecases=*/true);
149+
/*with_edgecases=*/true,
150+
/*masking_scalar=*/masking_challenge);
140151
} else {
141152
P_0 = batch_mul_native(batch_opening_claim.commitments, batch_opening_claim.scalars);
142153
}
143154
auto P_1 = -quotient_commitment;
144155

145-
return { P_0, P_1 };
156+
return PairingPointsType(P_0, P_1);
146157
}
147158
};
159+
148160
} // namespace bb

0 commit comments

Comments
 (0)