fix(avm): relax constraints for leaf_index kernel opcodes#8288
fix(avm): relax constraints for leaf_index kernel opcodes#8288IlyasRidhuan merged 4 commits intolw/public_validation_requestsfrom
Conversation
274c735 to
c1d1f44
Compare
c1d1f44 to
3f702ba
Compare
Benchmark resultsMetrics with a significant change:
Detailed resultsAll benchmarks are run on txs on the This benchmark source data is available in JSON format on S3 here. Proof generationEach column represents the number of threads used in proof generation.
L2 block published to L1Each column represents the number of txs on an L2 block published to L1.
L2 chain processingEach column represents the number of blocks on the L2 chain where each block has 8 txs.
Circuits statsStats on running time and I/O sizes collected for every kernel circuit run across all benchmarks.
Stats on running time collected for app circuits
AVM SimulationTime to simulate various public functions in the AVM.
Public DB AccessTime to access various public DBs.
Tree insertion statsThe duration to insert a fixed batch of leaves into each tree type.
MiscellaneousTransaction sizes based on how many contract classes are registered in the tx.
Transaction size based on fee payment method | Metric | | |
3f702ba to
8c6b6af
Compare
| // TODO(#8287): Reintroduce constraints | ||
| #[KERNEL_OUTPUT_LOOKUP] | ||
| sel_q_kernel_output_lookup {kernel_out_offset, ia, side_effect_counter, ib} in sel_kernel_out {clk, kernel_value_out, kernel_side_effect_out, kernel_metadata_out}; | ||
| sel_q_kernel_output_lookup {kernel_out_offset, /*ia,*/ /*side_effect_counter,*/ ib } in sel_kernel_out {clk, /*kernel_value_out,*/ /*kernel_side_effect_out,*/ kernel_metadata_out}; |
There was a problem hiding this comment.
Had to turn off the kernel_value_out and side_effect parts of the lookup
| } | ||
|
|
||
| // Leaf index -> exists | ||
| std::unordered_map<uint32_t, FF> get_leaf_index_hints() const |
There was a problem hiding this comment.
Splitting out leaf index hints since they now use the leaf index instead of side effect counters which would likely collide in a single map
| uint32_t offset = START_NOTE_HASH_EXISTS_WRITE_OFFSET + note_hash_exists_offset; | ||
| perform_kernel_output_lookup(offset, side_effect_counter, note_hash, FF(result)); | ||
| // TODO(#8287)Lookups are heavily underconstrained atm | ||
| if (result == 1) { |
There was a problem hiding this comment.
This whole section is a bit messy atm while the lookups are still "half-on". Will be resolved when we clean up the hints/public inputs stuff and if we give the trace.cpp access to the public inputs as well
| expect(results.output).toEqual([expectFound ? Fr.ONE : Fr.ZERO]); | ||
|
|
||
| expect(trace.traceL1ToL2MessageCheck).toHaveBeenCalledTimes(1); | ||
| const foundOrUndefined = mockAtLeafIndex === undefined || results.output[0].equals(Fr.ONE); |
There was a problem hiding this comment.
This is similar to what we do now for the accrued_substate.test.ts, because of the new way we handle non-exists criteria for leaf indices
8c6b6af to
4f54b7f
Compare
| const exists = gotLeafIndex === leafIndex.toBigInt(); | ||
| this.log.debug(`noteHashes(${storageAddress})@${noteHash} ?? leafIndex: ${leafIndex}, exists: ${exists}.`); | ||
| this.trace.traceNoteHashCheck(storageAddress, noteHash, leafIndex, exists); | ||
| const gotLeafValue = await this.hostStorage.commitmentsDb.getCommitmentValue(leafIndex.toBigInt()); |
There was a problem hiding this comment.
We now get the value given the index rather than the other way around, if the values do not match, we return the value that we found (this way the kernel can verify the merkle path).
We constrain equality in the VM (eventually)
)" This reverts commit 62bd9dc.
Re-constraining this is being tracked in #8287