Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Optimize array ops for arrays of structs (#4027)
# Description Omit the mapping of SSA indexes to flat indexes for arrays of structs. ## Problem\* ## Summary\* The mapping of SSA indexes to flat indexes is only necessary when arrays contain arrays or slices. The SSA indexing is a flat indexing for arrays that do not contain arrays in them. This PR omits the mapping for arrays of structs (that do not contain arrays in them), that previously were generating an identity mapping, increasing the number of constraints. ## Additional Context This reduces significantly the constraint counts in aztec protocol circuits: ### 🧾 Summary (100% most significant diffs) | Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % | |:-|-:|-:|-:|-:| | **private_kernel_init** | -11,663 ✅ | **-24.27%** | -45,467 ✅ | **-11.89%** | | **rollup_base** | -55,441 ✅ | **-18.84%** | -221,585 ✅ | **-13.26%** | | **private_kernel_inner** | -58,582 ✅ | **-38.79%** | -231,376 ✅ | **-30.70%** | | **public_kernel_private_previous** | -34,847 ✅ | **-42.62%** | -136,451 ✅ | **-32.68%** | | **public_kernel_public_previous** | -34,847 ✅ | **-42.63%** | -136,451 ✅ | **-32.68%** | | **private_kernel_ordering** | -101,425 ✅ | **-34.13%** | -430,563 ✅ | **-46.33%** | --- <details> <summary><strong>Full diff report</strong> 👇</summary> <br /> | Program | ACIR opcodes (+/-) | % | Circuit size (+/-) | % | |:-|-:|-:|-:|-:| | **private_kernel_init** | 36,399 (-11,663) | **-24.27%** | 337,069 (-45,467) | **-11.89%** | | **rollup_base** | 238,760 (-55,441) | **-18.84%** | 1,449,334 (-221,585) | **-13.26%** | | **private_kernel_inner** | 92,434 (-58,582) | **-38.79%** | 522,230 (-231,376) | **-30.70%** | | **public_kernel_private_previous** | 46,913 (-34,847) | **-42.62%** | 281,066 (-136,451) | **-32.68%** | | **public_kernel_public_previous** | 46,905 (-34,847) | **-42.63%** | 281,058 (-136,451) | **-32.68%** | | **private_kernel_ordering** | 195,747 (-101,425) | **-34.13%** | 498,850 (-430,563) | **-46.33%** | </details> ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information