Skip to content

starknet_os: use expect! to assert the blake constants for easy fixing#14033

Closed
dorimedini-starkware wants to merge 1 commit into
05-15-starknet_os_recompute_and_assert_the_blake_constantsfrom
05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing
Closed

starknet_os: use expect! to assert the blake constants for easy fixing#14033
dorimedini-starkware wants to merge 1 commit into
05-15-starknet_os_recompute_and_assert_the_blake_constantsfrom
05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing

Conversation

@dorimedini-starkware
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Collaborator Author

dorimedini-starkware commented May 15, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

@dorimedini-starkware dorimedini-starkware self-assigned this May 15, 2026
@dorimedini-starkware dorimedini-starkware marked this pull request as ready for review May 15, 2026 15:36
@cursor
Copy link
Copy Markdown

cursor Bot commented May 15, 2026

PR Summary

Low Risk
Low risk: this mainly refactors how empirical Blake2s step constants are stored and asserted, without changing the underlying estimation logic or constant values.

Overview
Switches the Blake2s CASM hash step “constants” in blockifier::casm_hash_estimation from hardcoded usize values to expect-test-backed expectations, exposed as lazily-parsed LazyLock<usize> statics.

Updates unit tests in both blockifier and starknet_os to assert against the expect! snapshots (supporting UPDATE_EXPECT=1 workflows) and adjusts Cargo.toml so expect-test is a normal dependency (since the expectations are used in non-test code).

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

"from",
"into_iterator",
] }
expect-test.workspace = true
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test-only crate promoted to production dependency

Medium Severity

The expect-test crate — a snapshot testing library — is moved from [dev-dependencies] to [dependencies], making it a production dependency. The Expect type and expect! macro embed source file paths, line numbers, and column numbers, and are designed exclusively for test assertions with UPDATE_EXPECT=1 auto-fixing. The _EXPECT constants are only consumed by LazyLock parsers and test assertions — they serve no production purpose. This also downgrades six compile-time const usize values to runtime-parsed LazyLock<usize> statics, introducing a panic path (.parse().expect(...)) that previously could not exist.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit a3359be. Configure here.

@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing branch from a3359be to c984a31 Compare May 15, 2026 15:42
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_recompute_and_assert_the_blake_constants branch from 7d9a724 to 3f84cb4 Compare May 15, 2026 15:42
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing branch from c984a31 to a8d3338 Compare May 15, 2026 16:53
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_recompute_and_assert_the_blake_constants branch 2 times, most recently from 94c6189 to af285f6 Compare May 16, 2026 09:40
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing branch from a8d3338 to 3afee9b Compare May 16, 2026 09:40
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_use_expect_to_assert_the_blake_constants_for_easy_fixing branch from 3afee9b to 1286e2e Compare May 16, 2026 09:43
@dorimedini-starkware dorimedini-starkware force-pushed the 05-15-starknet_os_recompute_and_assert_the_blake_constants branch from af285f6 to 30206ec Compare May 16, 2026 09:43
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1286e2e. Configure here.

pub const STEPS_PER_2_U32_REMINDER_EXPECT: Expect = expect!["3"];
pub static STEPS_PER_2_U32_REMINDER: LazyLock<usize> = LazyLock::new(|| {
STEPS_PER_2_U32_REMINDER_EXPECT.data.parse().expect("Expected data is a usize")
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Compile-time constants replaced with runtime-parsed lazy statics

Medium Severity

Six constants that were previously const usize (e.g., const STEPS_EMPTY_INPUT: usize = 169) are now LazyLock<usize> statics that parse strings at runtime via .data.parse(). This converts compile-time-checked values into runtime-initialized values that can panic on first access, adds lock overhead on every dereference, and relies on #[doc(hidden)] internals of expect-test. The expect! pattern is intended for test assertions, not for defining production constants.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1286e2e. Configure here.

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.

2 participants