diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp b/barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp index b7ed640ce3a2..e4f6adb5cc71 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_format/gate_count_constants.hpp @@ -114,7 +114,7 @@ constexpr std::tuple HONK_RECURSION_CONSTANTS( // ======================================== // Gate count for Chonk recursive verification (Ultra with RollupIO) -inline constexpr size_t CHONK_RECURSION_GATES = 1563538; +inline constexpr size_t CHONK_RECURSION_GATES = 1563553; // ======================================== // Hypernova Recursion Constants diff --git a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp index 1511e72ba132..b590e0ff5634 100644 --- a/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp +++ b/barretenberg/cpp/src/barretenberg/translator_vm/translator_flavor.hpp @@ -30,6 +30,13 @@ namespace bb { +namespace detail { +template struct ref_array_extent; +template struct ref_array_extent> { + static constexpr std::size_t value = N; +}; +} // namespace detail + class TranslatorFlavor { public: @@ -586,7 +593,12 @@ class TranslatorFlavor { /** * @brief All unshifted polynomials for PCS (excludes computable precomputed, includes concatenated). - * @details masking(1) + ordered_extra(1) + op(1) + ordered(5) + z_perm(1) + concat(5) = 14 + * @details masking(1) + ordered_extra(1) + op(1) + op_queue_tbs(3) + ordered(5) + z_perm(1) + concat(5) = 17 + * + * The op-queue to-be-shifted wires (x_lo_y_hi, x_hi_z_1, y_lo_z_2) appear here in addition to + * get_pcs_to_be_shifted because the decomposition relation reads them both unshifted (e.g. `x_lo`) + * and shift-by-1 (e.g. `y_hi`) at the same row. Without registering the unshifted opening, the + * unshifted MLE evaluations at the sumcheck point would be unconstrained. */ auto get_pcs_unshifted() { @@ -594,9 +606,10 @@ class TranslatorFlavor { MaskingEntities::get_all(), // gemini_masking_poly RefArray{ this->ordered_extra_range_constraints_numerator }, // non-computable precomputed WireNonshiftedEntities::get_all(), // op (from merge protocol) - OrderedRangeConstraints::get_all(), // ordered_0..4 - DerivedWitnessEntities::get_all(), // z_perm - ConcatenatedPolynomials::get_all()); // concat_0..4 + OpQueueWiresToBeShiftedEntities::get_all(), // x_lo_y_hi, x_hi_z_1, y_lo_z_2 + OrderedRangeConstraints::get_all(), // ordered_0..4 + DerivedWitnessEntities::get_all(), // z_perm + ConcatenatedPolynomials::get_all()); // concat_0..4 } /** @@ -711,9 +724,11 @@ class TranslatorFlavor { "Range constraint wires must fill exactly 4 concatenation groups"); // PCS batch sizes - static constexpr size_t NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED = WireNonshiftedEntities::_members_size + - OrderedRangeConstraints::_members_size + - DerivedWitnessEntities::_members_size; + // Note: op-queue to-be-shifted wires (x_lo_y_hi, x_hi_z_1, y_lo_z_2) are registered in BOTH the + // unshifted and shifted PCS batches because the decomposition relation reads them in both forms. + static constexpr size_t NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED = + WireNonshiftedEntities::_members_size + OpQueueWiresToBeShiftedEntities::_members_size + + OrderedRangeConstraints::_members_size + DerivedWitnessEntities::_members_size; static constexpr size_t NUM_TO_BE_SHIFTED = OpQueueWiresToBeShiftedEntities::_members_size + OrderedRangeConstraints::_members_size + DerivedWitnessEntities::_members_size; @@ -731,17 +746,20 @@ class TranslatorFlavor { // A container to be fed to ShpleminiVerifier to avoid redundant scalar muls. // Identifies commitments that appear in both the unshifted and shifted batches: - // Unshifted batch: masking(1) + ordered_extra(1) + op(1) + ordered(5) + z_perm(1) + concat(5) = 14 + // Unshifted batch: masking(1) + ordered_extra(1) + op(1) + op_queue_tbs(3) + ordered(5) + z_perm(1) + concat(5) + // = 17 // Shifted batch: op_queue(3) + ordered(5) + z_perm(1) + concat(5) = 14 - // Range 1: ordered(5) + z_perm(1) — stored indices 2..7 (unshifted) ↔ 16..21 (shifted) - // Range 2: concatenated(5) — stored indices 8..12 (unshifted) ↔ 22..26 (shifted) + // Range 1: op_queue_tbs(3) + ordered(5) + z_perm(1) = 9 (contiguous in both batches) + // stored indices 2..10 (unshifted) ↔ 16..24 (shifted) + // Range 2: concatenated(5) — stored indices 11..15 (unshifted) ↔ 25..29 (shifted) // (Stored indices are 0-based after ZK offset; offset=2 accounts for Q_commitment + gemini_masking_poly) + static constexpr size_t NUM_OP_QUEUE_TO_BE_SHIFTED = OpQueueWiresToBeShiftedEntities::_members_size; static constexpr RepeatedCommitmentsData REPEATED_COMMITMENTS = RepeatedCommitmentsData(2, 2 + NUM_PCS_TO_BE_SHIFTED, - NUM_ORDERED_RANGE + 1, - 2 + NUM_ORDERED_RANGE + 1, - 2 + NUM_PCS_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1, + NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1, + 2 + NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1, + 2 + NUM_PCS_TO_BE_SHIFTED + NUM_OP_QUEUE_TO_BE_SHIFTED + NUM_ORDERED_RANGE + 1, NUM_CONCATENATED_POLYS); static constexpr size_t PROOF_LENGTH = @@ -1249,4 +1267,17 @@ class TranslatorFlavor { using VerifierCommitments = VerifierCommitments_; }; +// Guard against drift between the runtime PCS entity lists and their compile-time counts; +// REPEATED_COMMITMENTS and PROOF_LENGTH depend on these counts and desync silently otherwise. +static_assert(detail::ref_array_extent&>() + .get_pcs_unshifted())>::value == + TranslatorFlavor::NUM_PCS_UNSHIFTED, + "get_pcs_unshifted() entity count must equal NUM_PCS_UNSHIFTED. If you added a witness entity, " + "update both the runtime list and NUM_UNSHIFTED_WITNESSES_WITHOUT_CONCATENATED."); +static_assert(detail::ref_array_extent&>() + .get_pcs_to_be_shifted())>::value == + TranslatorFlavor::NUM_PCS_TO_BE_SHIFTED, + "get_pcs_to_be_shifted() entity count must equal NUM_PCS_TO_BE_SHIFTED. If you added a to-be-shifted " + "entity, update both the runtime list and NUM_TO_BE_SHIFTED."); + } // namespace bb