Skip to content

feat: merge-train/barretenberg#21474

Merged
AztecBot merged 22 commits into
nextfrom
merge-train/barretenberg
Mar 16, 2026
Merged

feat: merge-train/barretenberg#21474
AztecBot merged 22 commits into
nextfrom
merge-train/barretenberg

Conversation

@AztecBot

@AztecBot AztecBot commented Mar 13, 2026

Copy link
Copy Markdown
Collaborator

BEGIN_COMMIT_OVERRIDE
chore: merkle tree audit (#21251)
chore: Ecc/curves audit - remove unused members (#21476)
feat: add debug-only asserts for 2p coarse modular form in field arithmetic (#21178)
chore: clean up native field audit scope (#21490)
feat!: integrate batched honk-translator proving into chonk (#21263)
fix: Fix tests in debug mode (#21542)
chore: bench compressed chonk proof size (#21616)
END_COMMIT_OVERRIDE

Addresses the following in the merkle tree module:
- thread failures in `perform_updates_without_witness` were not
propagated, making the update path to report success even when threads
failed
- `NullifierMemoryTree` did not enforce its leaf capacity bound and
allowed inserts beyond the maximum tree size
- Add tests to validate the above two
- `execute_and_report` does not report exceptions thrown by completion
callbacks, which could hide failures and potentially lead to hangs
  - update `execute_and_report` to log the error and abort the process
federicobarbacovi and others added 10 commits March 13, 2026 09:16
### 🧾 Audit Context

Final PR in the ecc/curves audit. Removes the `small_elements` member
which is now unused. Add `bb::g2` to element.test.cpp so that we don't
duplicate tests.

### 🛠️ Changes Made

- Remove `small_elements` member from curves (unused)
- Add `bb::g2` to `element.test.cpp` to avoid duplicating tests

### ✅ Checklist

- [ ] Audited all methods of the relevant module/class
- [ ] Audited the interface of the module/class with other (relevant)
components
- [ ] Documented existing functionality and any changes made (as per
Doxygen requirements)
- [ ] Resolved and/or closed all issues/TODOs pertaining to the audited
files
- [ ] Confirmed and documented any security or other issues found (if
applicable)
- [ ] Verified that tests cover all critical paths (and added tests if
necessary)
- [ ] Updated audit tracking for the files audited (check the start of
each file you audited)

### 📌 Notes for Reviewers
…hmetic (#21178)

* Adds debug-only assertions (`BB_ASSERT_DEBUG`) to verify that field
elements remain within the coarse representation range `[0, 2p)` after
arithmetic operations. This serves as partially checked documentation of
the coarse-form invariant used by 254-bit fields (base and scalar fields
of BN-254).
* killed a bit of dead code
* micro-optimization in unary negation, which was easiest way of fixing
the debug-assert being triggered in an edge case.
** This was _not_ a real issue, but the debug assert nonetheless was
triggered: formerly, the computation `-(x)` would first compute `2p - x`
and then `reduce_once()`, and the debug-assert would fail when `x==0`
for the first computation. Instead, we just compute `p-x` and let the
asm handle the underflow.

## Changes

- **`field_declarations.hpp`**: Added `assert_coarse_form()` helper that
checks `val < twice_modulus` for small moduli in debug builds. Compiles
to nothing in release (`NDEBUG`).

- **`field_declarations.hpp`**: Removed dead code:
`conditionally_subtract_from_double_modulus` (never called, had the same
2p bug pattern), `sqr_512` (declared but never defined), `__swap` (never
called), `wnaf_table` (never instantiated). Removed `#include
<execinfo.h>` and backtrace instrumentation (non-portable, redundant
with ASAN).

- **`field_impl.hpp`**: Added `assert_coarse_form()` calls after every
asm coarse-reduction path (`operator+`, `+=`, `-`, `-=`, `*`, `*=`,
`sqr`, `self_sqr`).

- **`field_impl.hpp`**: Micro-optimization in `operator-()` and
`self_neg()`: use `p` instead of `2p` as minuend. `subtract(p, x)`
already handles `x > p` via underflow correction (+2p), so the result is
always in `[0, 2p)` strict without needing `reduce_once()`. This removes
one conditional subtraction per negation (~5% faster on `fr_bench`) and
avoids the false-positive `assert_coarse_form()` trigger when `x = 0`.

- **`field_impl_generic.hpp`**: Added output assertions to the generic
`add()`, `subtract()`, `montgomery_mul()`, and `montgomery_square()`
implementations for the small-modulus branch, guarded by `if
(!std::is_constant_evaluated())`.

## Testing

- `ecc_tests`: all 809 tests pass (both ASAN and Release builds)
- `fr_bench`: no performance regression; unary negation ~5% faster

Resolves AztecProtocol/barretenberg#1429

ClaudeBox log: http://ci.aztec-labs.com/d1479c5106ce0b7a-1

---------

Co-authored-by: notnotraju <raju@aztec-labs.com>
Cleaned up audit scope docs and added audit status headers to field
source files.

---------

Co-authored-by: notnotraju <raju@aztec-labs.com>
@iakovenkos iakovenkos requested a review from LeilaWang as a code owner March 13, 2026 16:25

@ludamad ludamad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Auto-approved

@AztecBot AztecBot added this pull request to the merge queue Mar 13, 2026
@AztecBot

Copy link
Copy Markdown
Collaborator Author

🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 13, 2026
@AztecBot AztecBot enabled auto-merge March 16, 2026 16:20
@AztecBot

Copy link
Copy Markdown
Collaborator Author

🤖 Auto-merge enabled after 4 hours of inactivity. This PR will be merged automatically once all checks pass.

we use ProofCompression module to reduce Chonk proof size without PI,
the PI are padded
(`PRIVATE_TO_ROLLUP_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH = 1281`), and
most of these fields are zero, so gz compresses those efficiently, now
we can track this size in the main flows' benches
@AztecBot AztecBot added this pull request to the merge queue Mar 16, 2026
Merged via the queue into next with commit 158dd84 Mar 16, 2026
19 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants