fix(acir): Unify empty vector handling in pop#11688
Conversation
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 18412cd | Previous: 34e3758 | Ratio |
|---|---|---|---|
test_report_zkpassport_noir-ecdsa_ |
2 s |
1 s |
2 |
test_report_zkpassport_noir_rsa_ |
2 s |
1 s |
2 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
Changes to circuit sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 189e473 | Previous: 71c0384 | Ratio |
|---|---|---|---|
rollup-checkpoint-merge |
0.003 s |
0.002 s |
1.50 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
Description
Problem
Resolves https://cantina.xyz/code/50033e8c-8b46-41bc-b019-62098708057b/findings?finding=18
Summary
Unifies the handling of empty-vector checks in
vector_pop_frontandvector_pop_back.Additional Context
slice_pop_back#10455 added some prevention but it only worked for the disabled case.vector_pop_frontand an integration test forvector_pop_back, but the latter failed with theFailed to solve program: 'Index out of bounds, array has size 2, but index was -1'instead ofAssertion failed: Attempt to pop_back from an empty vector.I was a bit preplexed why we need both of the above fixes, but we do, otherwise integration tests fail. If we have a non-constant length, we add an assertion that the length is not zero, which only kicks in if the side effects are enabled, but if they are disabled, we return 0 for the new length, so we end up reading item 0 in both pop versions, rather than item -1.
But how can we read item 0 from an empty vector? The reason this is needed is because we are reading item 0 from a vector which is merged across multiple branches, and isn't actually physically empty, just its semantic length is 0. So we can read item 0 without a problem on the disabled branch. This is illustrated in the first PR linked above.
If we didn't have a case of merging vectors of different lengths, at least one of which is non-zero, then the compiler would know that the length is constant 0, and it would return early from the
convert_vector_pop_*methods.User Documentation
Check one:
PR Checklist
cargo fmton default settings.