Skip to content

blockifier_test_utils,blockifier: add minimal add and mul circuit entry points - #15124

Open
avi-starkware wants to merge 1 commit into
main-v0.14.4from
avi/prover/mod-builtin-circuit-entry-points
Open

avi-starkware wants to merge 1 commit into
main-v0.14.4from
avi/prover/mod-builtin-circuit-entry-points

Conversation

@avi-starkware

@avi-starkware avi-starkware commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

What

Two minimal circuit entry points in the Cairo1 feature test contract, next to test_circuit:

  • test_add_mod: one add gate over modulus 7 (3 + 6 = 2). Writes add_mod instances and also mul_mod instances, because every circuit input is reduced modulo the modulus through a mul gate before any add gate can run.
  • test_mul_mod: one mul gate over modulus 7 (3 * 6 = 4). Writes only mul_mod instances. The entry point still declares add_mod because eval_circuit takes both builtins as implicits, but with no add gates the add_mod pointer is never advanced, so its PIE instance count is 0.

They exist so proving tests can exercise each mod builtin as narrowly as the compiler allows (the stacked PR above uses them).

Fallout

The contract grew, so the two migration-gas expect! values in crates/blockifier/src/bouncer_test.rs moved (111447819 → 114653623, 241056552 → 248313469). The compiled-class-hash estimation margin test did not move.

Verification

  • cargo test -p blockifier_test_utils --test feature_contracts_compatibility_test: 3 passed
  • cargo test -p blockifier bouncer::test: 30 passed
  • cargo test -p starknet_os compiled_class_test: 20 passed
  • PIE counters measured in the stacked PR's flow tests: test_mul_modadd_mod: 0, mul_mod: 3; test_add_modadd_mod: 1, mul_mod: 2.

🤖 Generated with Claude Code

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@github-actions

github-actions Bot commented Sep 15, 2026

Copy link
Copy Markdown

@avi-starkware avi-starkware changed the title blockifier_test_utils,blockifier: add add_mod-only and mul_mod-only circuit entry points blockifier_test_utils,blockifier: add minimal add and mul circuit entry points Sep 15, 2026
@avi-starkware
avi-starkware force-pushed the avi/prover/mod-builtin-circuit-entry-points branch from bf12ae8 to 536ac89 Compare September 15, 2026 13:45
…ry points

Two minimal circuit entry points in the Cairo1 test contract: `test_add_mod`
(one add gate; writes add_mod instances and, because circuit inputs are
reduced through mul gates, mul_mod instances too) and `test_mul_mod` (one
mul gate; writes only mul_mod instances). They let proving tests exercise
each mod builtin as narrowly as the compiler allows.

The contract grew, so the two migration-gas expectations in bouncer_test
moved accordingly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@avi-starkware
avi-starkware force-pushed the avi/prover/mod-builtin-circuit-entry-points branch from 536ac89 to 371661a Compare September 15, 2026 19:40
@avi-starkware
avi-starkware removed this pull request from stack #15126 September 15, 2026 19:41
@avi-starkware
avi-starkware changed the base branch from main to main-v0.14.4 September 15, 2026 19:42
@avi-starkware
avi-starkware added this pull request to stack #15130 September 15, 2026 19:42
@avi-starkware
avi-starkware removed this pull request from stack #15130 September 15, 2026 20:42
@avi-starkware
avi-starkware added this pull request to stack #15132 September 15, 2026 20:42
@avi-starkware
avi-starkware marked this pull request as ready for review September 16, 2026 08:01
@cursor

cursor Bot commented Sep 16, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only contract entry points and updated gas snapshot expectations; no production execution or bouncer behavior changes.

Overview
Adds two narrow Cairo1 feature-contract entry points—test_add_mod and test_mul_mod—so proving tests can hit add_mod and mul_mod with minimal circuits (modulus 7), instead of only the broader test_circuit.

test_add_mod runs a single add gate (3 + 6 ≡ 2); test_mul_mod runs a single mul gate (3 × 6 ≡ 4). Comments document that input reduction still uses mul_mod, and that eval keeps both builtins as implicits even when no add gates run.

Because the compiled test contract is larger, the CASM hash migration gas snapshots in bouncer_test.rs are bumped (Sierra 111447819 → 114653623, proving 241056552 → 248313469); no bouncer logic changes.

Reviewed by Cursor Bugbot for commit 371661a. Bugbot is set up for automated code reviews on this repo. Configure here.

@Yoni-Starkware Yoni-Starkware left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 1 of 2 files reviewed, 1 unresolved discussion (waiting on avi-starkware).


crates/blockifier_test_utils/resources/feature_contracts/cairo1/test_contract.cairo line 1270 at r1 (raw file):

    /// used because every circuit input is reduced modulo the modulus through a mul gate.
    #[external(v0)]
    fn test_add_mod(ref self: ContractState) {

Make sure this is not duplicated

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