Skip to content

Conversation

@sirasistant
Copy link
Contributor

@sirasistant sirasistant commented Nov 28, 2025

Previously, we were only checking local uniqueness of counters (within a single sideffect type of a single call) to keep gate counts low.
However, some code in the reset circuits assumes global uniqueness of counters, and in general, this is a big source of issues. This PR implements validation for global uniqueness of sideffect counters, by checking in a call request that all counters of all sideffects are unique, that they are within the call sideffect counter bounds, and that they don't fall within the allocated counters for any nested call. This three things ensure that no sideffect counters can repeat in a TX, other than padded side effects that are always injected with MAX_U32_VALUE counter.
The cost of verifying global uniqueness of counters this way is ~5000 gates (~10% of init, ~5% of inner)

let counter_start = public_inputs.start_side_effect_counter;
let counter_end = public_inputs.end_side_effect_counter;

assert(counter_start < counter_end, "private call has incorrect counter range");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this check is redundant since it'd fail on validate_increasing_ranges, but it's cheap and we'd get a better error message

Copy link
Contributor

@LeilaWang LeilaWang left a comment

Choose a reason for hiding this comment

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

Perfect!

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