AztecProtocol / aztec-packages

Apache License 2.0
195 stars 206 forks source link

Proper handling of leaf index in kernel trace #8287

Open IlyasRidhuan opened 2 months ago

IlyasRidhuan commented 2 months ago

Kernel outputs in the AVM are organised into columns based on a specific offset and are sorted by an incrementing side_effect_counter.

Changes to NOTEHASHEXISTS and L1TOL2MSGEXISTS means we no longer use the side_effect_counter here but instead use the leaf_index to check against. For now, I've replaced the side_effect_counter with leaf_index so that the columns contain the correct information when verifying. However, I've also had to relax some constraints as well as not make the full set of changes to the AVM hints structure.

To properly handle this we need to re-organise the kernel outputs columns, where the side_effect_counter based opcodes are kept contiguous. This means that the NOTEHASHEXISTS and L1TOL2MSGEXISTS would likely be in their own structure.

  1. Changes to side_effect_trace.ts to accomodate "hinting" for leaf index based opcodes
  2. Changes to ordering within kernel_trace.pil - maybe putting the leaf index based slots at the start or relaxing the incrementing constraints for these two opcodes
  3. Changes to the hints_map, no longer keyed by side_effect_counter
IlyasRidhuan commented 2 months ago

Additionally, we will need to update the way #[KERNEL_OUTPUT_LOOKUP] works, specifically the columns ia and kernel_value_out, as well as side_effect_counter and kernel_side_effect_out.

The former has to change since TreeReadRequests now has the following behaviour if checking that value a exists at index i.