Skip to content

blockifier: test CAIRO1_SUPPORTED_BUILTINS stays in sync with the compiler builtin order#14875

Open
Yoni-Starkware wants to merge 1 commit into
main-v0.14.3from
yonatan/cairo-2.19.4/builtins-compiler-sync-test
Open

blockifier: test CAIRO1_SUPPORTED_BUILTINS stays in sync with the compiler builtin order#14875
Yoni-Starkware wants to merge 1 commit into
main-v0.14.3from
yonatan/cairo-2.19.4/builtins-compiler-sync-test

Conversation

@Yoni-Starkware

@Yoni-Starkware Yoni-Starkware commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a unit test, cairo1_supported_builtins_in_sync_with_compiler_order, that asserts the blockifier's CAIRO1_SUPPORTED_BUILTINS (from #14841) is identical — same set and canonical order — to the Cairo compiler's ENTRY_POINT_BUILTIN_ORDER (cairo_lang_starknet_classes::casm_contract_class). Each Sierra generic type id is mapped to its BuiltinName, mirroring the naming the compiler itself emits in CasmContractClass::from_contract_class. A newly-added compiler builtin with no mapping arm trips a panic!, forcing both the map and CAIRO1_SUPPORTED_BUILTINS to be updated together.

Why

Follow-up to a review comment on #14841: CAIRO1_SUPPORTED_BUILTINS is hand-maintained (mirroring the OS SelectableBuiltins). This test keeps it from silently drifting from the compiler's source-of-truth ordering as the Cairo compiler evolves. ENTRY_POINT_BUILTIN_ORDER only became pub in cairo 2.19.4, which is why the reviewer asked for this "after bumping to 2.19.4".

Base

Targets main-v0.14.3, which now contains both #14841 (CAIRO1_SUPPORTED_BUILTINS) and the merged #14873 (cairo compiler v2.19.4, providing the now-pub ENTRY_POINT_BUILTIN_ORDER). This PR adds only the sync test — one file.

Testing

cargo test -p blockifier cairo1_supported_builtins_in_sync_with_compiler_order passes. cargo clippy -p blockifier --all-targets and rust_fmt clean.

🤖 Generated with Claude Code

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

@Yoni-Starkware
Yoni-Starkware force-pushed the yonatan/cairo-2.19.4/builtins-compiler-sync-test branch from 1bba8d4 to aac9d86 Compare July 22, 2026 14:30
@Yoni-Starkware
Yoni-Starkware force-pushed the yonatan/cairo-2.19.4/builtins-compiler-sync-test branch from aac9d86 to dc50c5d Compare July 22, 2026 14:44
@Yoni-Starkware
Yoni-Starkware marked this pull request as ready for review July 22, 2026 14:54
@cursor

cursor Bot commented Jul 22, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Test-only change in blockifier; no production execution path is modified.

Overview
Adds cairo1_supported_builtins_in_sync_with_compiler_order, a unit test that compares blockifier’s hand-maintained CAIRO1_SUPPORTED_BUILTINS to the Cairo compiler’s public ENTRY_POINT_BUILTIN_ORDER, including canonical order, using a casing-agnostic string comparison so snake_case and compiler generic ids align.

Test imports are updated to pull validate_entry_point_builtins and CAIRO1_SUPPORTED_BUILTINS from entry_point_execution explicitly (instead of a super re-export).

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

@Yoni-Starkware
Yoni-Starkware force-pushed the yonatan/cairo-2.19.4/builtins-compiler-sync-test branch from dc50c5d to 03f7c0a Compare July 22, 2026 17:14
@Yoni-Starkware
Yoni-Starkware changed the base branch from yoni/cairo-2.19.4 to main-v0.14.3 July 22, 2026 17:14
@Yoni-Starkware
Yoni-Starkware force-pushed the yonatan/cairo-2.19.4/builtins-compiler-sync-test branch from 03f7c0a to f0bc787 Compare July 22, 2026 17:43
@Yoni-Starkware Yoni-Starkware self-assigned this Jul 22, 2026
@Yoni-Starkware
Yoni-Starkware enabled auto-merge July 22, 2026 17:49

@avi-starkware avi-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.

@avi-starkware reviewed 4 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Yoni-Starkware).


Cargo.toml line 271 at r1 (raw file):

colored = "3"
const_format = "0.2.30"
convert_case = "0.11.0"

Consider avoiding this new external dep

Code quote:

convert_case = "0.11.0"

crates/blockifier/src/execution/entry_point_execution_test.rs line 13 at r1 (raw file):

use starknet_api::transaction::fields::Calldata;

use super::{validate_entry_point_builtins, CAIRO1_SUPPORTED_BUILTINS};

Avoid using super::

Code quote:

use super::{validate_entry_point_builtins, CAIRO1_SUPPORTED_BUILTINS};

crates/blockifier/src/execution/entry_point_execution_test.rs line 144 at r1 (raw file):

        .iter()
        .map(|builtin| builtin.to_str().to_case(Case::UpperCamel))
        .collect();

Converting to UpperCamel might create false negatives: blake2s -> Blake2S
Consider converting the compiler builtins to snake case instead.

Alternatively, we can avoid using the convert_case external dep for this comparison and just remove all underscores from the blockifier builtins and lowercase the compiler builtins to compare them:

let supported_builtins: Vec<String> = CAIRO1_SUPPORTED_BUILTINS
    .iter()
    .map(|builtin| builtin.to_str().replace('_', ""))
    .collect();
let compiler_builtins: Vec<String> = ENTRY_POINT_BUILTIN_ORDER
    .iter()
    .map(|generic_id| generic_id.0.to_ascii_lowercase())
    .collect();

@avi-starkware avi-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.

Reviewable status: all files reviewed, 3 unresolved discussions (waiting on Yoni-Starkware).

…piler builtin order

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Yoni-Starkware
Yoni-Starkware force-pushed the yonatan/cairo-2.19.4/builtins-compiler-sync-test branch from f0bc787 to b824480 Compare July 23, 2026 10:42

@avi-starkware avi-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.

@avi-starkware reviewed 4 files and all commit messages, and resolved 3 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Yoni-Starkware).

@avi-starkware avi-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.

:lgtm:

@avi-starkware made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on Yoni-Starkware).

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