fix(ssa): accept tainted arguments to no_predicates calls in flatten_post_check - #13430
Open
asterite wants to merge 1 commit into
Open
fix(ssa): accept tainted arguments to no_predicates calls in flatten_post_check#13430asterite wants to merge 1 commit into
asterite wants to merge 1 commit into
Conversation
…post_check The post-flattening validator flagged predicated values flowing into calls to `no_predicates` functions as ungated escapes. Flattening wraps such calls in `enable_side_effects u1 1` on purpose (the callee runs unpredicated), so the escape is deliberate and safe: a pure callee cannot be over-constrained by a disabled-branch value. The call's results still inherit the argument's predicate and stay tracked until guarded. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Compiling contracts in Aztec-Packages (e.g.
token_contract) with a debug-built compiler aborts with 11 SSA validation errors:The
flatten_post_checkvalidator (debug-assertions only, added in #13084) did not account for theenable_side_effects u1 1wrapper that flattening itself emits around calls to#[no_predicates]functions. Aztec contracts hit this constantly: oracle (Brillig) results fetched under a branch predicate — e.g.get_public_keys_and_partial_addressinside conditionally-executed note logic — are passed to#[no_predicates]poseidon2 hash helpers:The escape is deliberate and safe: the callee runs unpredicated by design, and a pure callee cannot be over-constrained by a disabled-branch value. This was a false positive in the validator, not a miscompilation — release builds are unaffected since the check is
#[cfg(debug_assertions)].Minimal reproduction (fails to compile with a debug nargo before this fix):
Solution
Exempt argument uses at
no_predicatescall sites from the escape check. The exemption only skips the violation: the call's results still inherit the argument's predicate and stay tracked until guarded, since they are arbitrary on the disabled branch.Tests:
accepts_tainted_argument_to_no_predicates_call— the distilled Aztec shape above (fails without the fix).rejects_unguarded_result_of_no_predicates_call— same SSA minus the result guard, pinning that the exemption does not leak to the call's results.Verified that the
token_contractin Aztec-Packages compiles with zero validation failures after this change (previously aborted with 11 errors).🤖 Generated with Claude Code