Skip to content

starknet_os_flow_tests: fuzz test get block hash scenario#13155

Merged
dorimedini-starkware merged 1 commit into
mainfrom
03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario
Apr 9, 2026
Merged

starknet_os_flow_tests: fuzz test get block hash scenario#13155
dorimedini-starkware merged 1 commit into
mainfrom
03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario

Conversation

@dorimedini-starkware
Copy link
Copy Markdown
Collaborator

@dorimedini-starkware dorimedini-starkware commented Mar 10, 2026

Note

Medium Risk
Adds a new fuzz scenario that exercises get_block_hash syscall behavior and modifies block advancement/address expectations, which could make the fuzz harness more brittle if block-number assumptions change.

Overview
Adds a new fuzz operation/scenario (17) to exercise the get_block_hash syscall: Cairo1 contracts now call syscalls::get_block_hash_syscall and validate both expected success (retrospective block) and expected failure (out-of-range), while Cairo0 explicitly reverts with get_block_hash_cairo0.

Updates the orchestrator contract to expose new unexpected-error panic messages and improves error/OOB handling, plus refactors Cairo1 immediate-syscall failure handling via maybe_unwrap_error.

Enhances the Rust fuzz harness to generate GetBlockHash operations, track the test block_number, advance blocks to pass STORED_BLOCK_HASH_BUFFER, and adds TestManager::get_current_block_number; this changes expected deployed contract addresses and updates the Cairo0 compiled artifact accordingly.

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

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@dorimedini-starkware dorimedini-starkware self-assigned this Mar 10, 2026
@dorimedini-starkware dorimedini-starkware marked this pull request as ready for review March 10, 2026 15:27
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 0a49942 to 7988531 Compare March 11, 2026 09:01
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario branch from d4f0ad4 to ff032c0 Compare March 11, 2026 16:19
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 2908864 to f464e9b Compare March 11, 2026 16:19
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario branch from ff032c0 to 9941f34 Compare March 15, 2026 14:30
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from f464e9b to 2cd2c2c Compare March 15, 2026 14:30
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario branch from 9941f34 to 3f3bd7c Compare March 16, 2026 13:01
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 2cd2c2c to 46d6f19 Compare March 16, 2026 13:01
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 46d6f19 to f53991f Compare March 24, 2026 15:57
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario branch 2 times, most recently from 04c43c5 to 8a163d3 Compare March 31, 2026 07:16
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch 2 times, most recently from 1d2ec81 to 8d11fbc Compare March 31, 2026 08:57
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario branch from 8a163d3 to 5f143fe Compare March 31, 2026 08:57
@graphite-app graphite-app Bot changed the base branch from 03-09-starknet_os_flow_tests_fuzz_test_emit_event_scenario to graphite-base/13155 April 5, 2026 08:13
@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 8d11fbc to 198d30e Compare April 5, 2026 09:37
@dorimedini-starkware dorimedini-starkware changed the base branch from graphite-base/13155 to main April 5, 2026 09:38
Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

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


crates/blockifier_test_utils/resources/feature_contracts/cairo1/fuzz_revert_orchestrator.cairo line 133 at r3 (raw file):

                if contains_unexpected_error {
                    panic(error);
                }

wat? no in or .contains in cairo?

Code quote:

                let mut contains_unexpected_error = false;
                for error_value in error
                    .span() {
                        for unexpected_error in unexpected_errors {
                            if error_value == unexpected_error {
                                contains_unexpected_error = true;
                                break;
                            }
                        }
                    }

                if contains_unexpected_error {
                    panic(error);
                }

Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware reviewed 2 files.
Reviewable status: 6 of 14 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).

Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware made 1 comment.
Reviewable status: 6 of 14 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware and Yoni-Starkware).


crates/blockifier_test_utils/resources/feature_contracts/cairo1/fuzz_revert_orchestrator.cairo line 133 at r3 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

wat? no in or .contains in cairo?

claude says no, can't see anything in the cairo book

@dorimedini-starkware dorimedini-starkware force-pushed the 03-09-starknet_os_flow_tests_fuzz_test_get_block_hash_scenario branch from 198d30e to ff5ef8e Compare April 9, 2026 15:10
Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@Yoni-Starkware reviewed 2 files and all commit messages, and made 2 comments.
Reviewable status: 7 of 14 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware).


crates/blockifier_test_utils/resources/feature_contracts/cairo1/fuzz_revert_orchestrator.cairo line 133 at r3 (raw file):

Previously, dorimedini-starkware wrote…

claude says no, can't see anything in the cairo book

According to claude there's this

let found = array![1_u8, 2, 3].into_iter().any(|e| e == needle);

Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware made 1 comment.
Reviewable status: 7 of 14 files reviewed, 1 unresolved discussion (waiting on dorimedini-starkware and Yoni-Starkware).


crates/blockifier_test_utils/resources/feature_contracts/cairo1/fuzz_revert_orchestrator.cairo line 133 at r3 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

According to claude there's this

let found = array![1_u8, 2, 3].into_iter().any(|e| e == needle);

yes, that's still two loops: iterate over array and iterate over the heystack

Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware resolved 1 discussion.
Reviewable status: 7 of 14 files reviewed, all discussions resolved (waiting on dorimedini-starkware).

Copy link
Copy Markdown
Collaborator Author

@dorimedini-starkware dorimedini-starkware left a comment

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 7 files.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on dorimedini-starkware).

@dorimedini-starkware dorimedini-starkware added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 4e95b30 Apr 9, 2026
31 of 50 checks passed
Copy link
Copy Markdown
Collaborator

@Yoni-Starkware Yoni-Starkware left a comment

Choose a reason for hiding this comment

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

@Yoni-Starkware made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved.


crates/blockifier_test_utils/resources/feature_contracts/cairo1/fuzz_revert_orchestrator.cairo line 133 at r3 (raw file):

Previously, dorimedini-starkware wrote…

yes, that's still two loops: iterate over array and iterate over the heystack

What? How do you know it's two loops and not one?

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants