AztecProtocol / aztec-packages

Apache License 2.0
181 stars 184 forks source link

Circuit Optimisations Tasklist #7167

Open iAmMichaelConnor opened 3 months ago

iAmMichaelConnor commented 3 months ago

All conceivable optimisations for all circuits: aztec.nr, protocol circuits.

Please feel free to directly edit the tasklist, and if something needs a long description, please create a linked issue to describe the optimisation.

Feel free to move tasks between the two categories (quite often the work will overlap both)

See also https://hackmd.io/@aztec-network/ryPlh16-A?type=view#Circuits

cc. @LeilaWang @LHerskind @sirasistant @MirandaWood @benesjan et al.

### Aztec.nr
- [ ] https://github.com/AztecProtocol/aztec-packages/issues/7092
- [ ] https://github.com/AztecProtocol/aztec-packages/issues/3057
- [ ] Consider removing siloed _viewing_ keys to remove derivation constraints and header encryption constraints. (Needs discussion around whether this feature is worth keeping)
- [ ] Consider state var methods which don't create redundant new notes & nullifiers. (See old debates).
- [ ] https://github.com/AztecProtocol/aztec-packages/issues/7142
- [ ] https://github.com/AztecProtocol/aztec-packages/issues/7272
- [ ] https://github.com/AztecProtocol/aztec-packages/issues/5491
### Protocol Circuits
- [ ] Hash logs with poseidon client-side, and then prove they've been 'blobbed' sequencer-side (blobbing is a separate issue). (Needs discussion on whether logs are blobbed or simply emitted on L2 or both. Until then, we could implement sequencer-side hashing with sha256?).
- [x] Fix poseidon2 so it's ~71 gates to hash two fields (as per bberg blackbox benchmarks)
- [ ] Switch to the data bus
- [ ] Introducing tree epochs would shrink tree heights, but there's lots to understand before deciding to do that.
- [ ] Introduce multiple sizes of Kernel Circuit (this might impact Base & Merge rollup designs, and cause us to require multiple versions of those).
- [ ] Consider whether the current tree structure for the "Parity Circuits" is optimal (and consider renaming to make it clear that they relate to L1->L2 messaging)
- [ ] Find out: "wen honkish `verify_proof()` function?" for cheap recursion
- [ ] Consider this proposal to remove key derivation requests https://hackmd.io/Y7eEMJ5_RVmfyrJv1qjEJQ
- [ ] Verify pre-constructed output (instead of constructing it in the circuit).
- [ ] Combine all types of side effects and check their counters are incremented by 1 (instead of using range checks).
- [ ] Reduce redundant is_empty() checks.
- [ ] Create a sensitivity testing tool: for a selection of changes to the circuit constants, measure the impact on constraint counts