Skip to content

fix(acir): Unify empty vector handling in pop#11688

Merged
TomAFrench merged 4 commits intomasterfrom
af/fix-vector-pop-back-empty
Feb 26, 2026
Merged

fix(acir): Unify empty vector handling in pop#11688
TomAFrench merged 4 commits intomasterfrom
af/fix-vector-pop-back-empty

Conversation

@aakoshh
Copy link
Copy Markdown
Contributor

@aakoshh aakoshh commented Feb 25, 2026

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_front and vector_pop_back.

Additional Context

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:

  • No user documentation needed.
  • Changes in docs/ included in this PR.
  • [For Experimental Features] Changes in docs/ to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@aakoshh aakoshh marked this pull request as ready for review February 25, 2026 16:11
@aakoshh aakoshh requested a review from a team February 25, 2026 16:11
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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

@github-actions
Copy link
Copy Markdown
Contributor

Changes to circuit sizes

Generated at commit: 00749a2e8e7cec3ab251c3584104325c5539f212, compared to commit: 71c03848e5f26c478bea51e2ed36f0e759aa4e7f

🧾 Summary (10% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
regression_10446 +4 ❌ +23.53% +3 ❌ +3.09%
regression_10170 +10 ❌ +5.95% +5 ❌ +0.15%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
regression_10446 21 (+4) +23.53% 100 (+3) +3.09%
regression_10170 178 (+10) +5.95% 3,432 (+5) +0.15%
vector_dynamic_index 806 (+5) +0.62% 5,162 (+4) +0.08%
regression_9312 28 (+2) +7.69% 2,861 (+1) +0.03%
vectors 325 (+2) +0.62% 3,936 (+1) +0.03%

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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

Copy link
Copy Markdown
Collaborator

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@TomAFrench TomAFrench added this pull request to the merge queue Feb 26, 2026
Merged via the queue into master with commit 79e5f95 Feb 26, 2026
147 checks passed
@TomAFrench TomAFrench deleted the af/fix-vector-pop-back-empty branch February 26, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants