Skip to content

starknet_os: os resources test - remove all fee transfer syscalls#14137

Merged
dorimedini-starkware merged 1 commit into
mainfrom
05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls
Jun 7, 2026
Merged

starknet_os: os resources test - remove all fee transfer syscalls#14137
dorimedini-starkware merged 1 commit into
mainfrom
05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls

Conversation

@dorimedini-starkware

Copy link
Copy Markdown
Collaborator

No description provided.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

@dorimedini-starkware dorimedini-starkware self-assigned this May 24, 2026
@dorimedini-starkware dorimedini-starkware marked this pull request as ready for review May 24, 2026 07:03
@cursor

cursor Bot commented May 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to test contracts and OS resource measurement helpers; no production execution or fee logic is modified.

Overview
Improves OS syscall resource measurement by treating the fee-transfer tail of each measurement transaction as a fixed, known syscall sequence instead of ad-hoc trimming.

The OS resources test contract’s __execute__ now no-ops when both calldata args are zero, so an invoke can exercise only account fee transfer without running the syscall benchmark loop.

In os_resources_test.rs, a FEE_TRANSFER_SYSCALLS constant documents the 10 syscalls emitted during fee transfer. A new test_fee_transfer_syscalls regression runs a zero-calldata invoke and asserts the trace matches that list. The main test_os_resources_regression path splits off the last 10 syscall traces, asserts they match FEE_TRANSFER_SYSCALLS, and measures only the remaining syscalls—replacing the previous approach of popping the last EmitEvent and filtering UNMEASURABLE_SYSCALLS during iteration.

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

Comment thread crates/starknet_os_flow_tests/src/os_resources_test.rs
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch from 2587a2e to a547012 Compare June 1, 2026 10:24
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_add_emit_event branch from 07b4e34 to 6683ff3 Compare June 1, 2026 10:24

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yoavGrs made 3 comments.
Reviewable status: 0 of 1 files reviewed, 4 unresolved discussions (waiting on dorimedini-starkware).


crates/starknet_os_flow_tests/src/os_resources_test.rs line 121 at r3 (raw file):

///    the measurements, we use a stable dummy contract (that is not recompiled when the Cairo1
///    compiler's version changes), and we set the `deploy_from_zero` flag to `true` to make sure
///    changes in the deploying contract address are not reflected in the measurements.

Move this doc down.
Doc this new test.

Code quote:

/// Measure the OS overhead for each syscall, and compare the results with the latest VC.
///
/// This test relies on the [starknet_os::hint_processor::os_logger::OsLogger] to capture the
/// resources used by the OS when running a syscall. A "checkpoint" is made before entering a
/// syscall implementation, and after the syscall execution returns, the difference between the two
/// is stored in the logger's traces.
///
/// Some notes about these measurements:
/// 1. Some syscalls incur inner calls ([Selector::CallContract], for example). The resources
///    consumed by the inner logic must be subtracted from the measured overhead to get the actual
///    OS overhead.
/// 2. Some syscalls incur overhead that depends linearly on the length of the input to the syscall.
///    In these cases, the measuring contract calls the syscall twice in a row, the second call
///    having "one more" input than the first call; subtracting the sequential measurements gives
///    the linear factor of the syscall. One caveat here is that the linear factor of
///    [Selector::Keccak] is stored as a separate syscall cost ([Selector::KeccakRound]).
/// 3. The SHA family syscalls are implemented as "virtual builtins": the syscall execution only
///    pushes the inputs to a special memory segment, and the "heavy lifting" is done later. This
///    means that the overhead of the syscall is not captured by the `OsLogger`. These syscalls have
///    separate tests to measure their overhead.
/// 4. The [Selector::Deploy] syscall's overhead depends on the deployed contract address in a non-
///    trivial way (see the `normalize_address` function in the cairo-lang core). To avoid noise in
///    the measurements, we use a stable dummy contract (that is not recompiled when the Cairo1
///    compiler's version changes), and we set the `deploy_from_zero` flag to `true` to make sure
///    changes in the deploying contract address are not reflected in the measurements.

crates/starknet_os_flow_tests/src/os_resources_test.rs line 275 at r3 (raw file):

    let all_syscalls = test_output.runner_output.txs_trace.last().unwrap().get_syscalls().clone();
    let (syscall_traces, fee_transfer_syscall_traces) =
        all_syscalls.split_at(all_syscalls.len() - FEE_TRANSFER_SYSCALLS.len());

Consider splitting the iterator (take / skip) instead of the syscalls vector.
non-blocking

Code quote:

    let all_syscalls = test_output.runner_output.txs_trace.last().unwrap().get_syscalls().clone();
    let (syscall_traces, fee_transfer_syscall_traces) =
        all_syscalls.split_at(all_syscalls.len() - FEE_TRANSFER_SYSCALLS.len());

crates/starknet_os_flow_tests/src/os_resources_test.rs line 360 at r3 (raw file):

    // Make sure there are no more dangling syscalls.
    let dangling_syscall = syscalls_iter.next();

How can it happen after while let Some(syscall_trace) = syscalls_iter.next()?

Code quote:

    // Make sure there are no more dangling syscalls.
    let dangling_syscall = syscalls_iter.next();

@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_add_emit_event branch from 6683ff3 to 3ee3ec7 Compare June 2, 2026 10:21
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch from a547012 to 18f0bed Compare June 2, 2026 10:21
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_add_emit_event branch from 3ee3ec7 to 8a9154e Compare June 2, 2026 15:17
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch from 18f0bed to 21be0eb Compare June 2, 2026 15:17

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@dorimedini-starkware made 4 comments.
Reviewable status: 0 of 1 files reviewed, 4 unresolved discussions (waiting on dorimedini-starkware, yoavGrs, and Yoni-Starkware).


crates/starknet_os_flow_tests/src/os_resources_test.rs line 80 at r2 (raw file):

Previously, Yoni-Starkware (Yoni) wrote…

You can run this tx with trivial fee bounds and make this test a bit cleaner

I don't want to break if for some reason we want to avoid trivial resource bounds... we need to override the VC already to run in cairo-steps mode, I can imagine a scenario in which we will no longer allow "free" txs in cairo-steps mode. the current way adds more code but it is closer to a "real flow"


crates/starknet_os_flow_tests/src/os_resources_test.rs line 121 at r3 (raw file):

Previously, yoavGrs wrote…

Move this doc down.
Doc this new test.

Done.


crates/starknet_os_flow_tests/src/os_resources_test.rs line 275 at r3 (raw file):

Previously, yoavGrs wrote…

Consider splitting the iterator (take / skip) instead of the syscalls vector.
non-blocking

what is the benefit? I want to verify the second part is equal to the expected fee-transfer syscalls, and iterate over the first part


crates/starknet_os_flow_tests/src/os_resources_test.rs line 360 at r3 (raw file):

Previously, yoavGrs wrote…

How can it happen after while let Some(syscall_trace) = syscalls_iter.next()?

can't, leftover code. thanks

@yoavGrs yoavGrs left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yoavGrs reviewed 1 file and all commit messages, made 1 comment, and resolved 3 discussions.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on Yoni-Starkware).


crates/starknet_os_flow_tests/src/os_resources_test.rs line 275 at r3 (raw file):

Previously, dorimedini-starkware wrote…

what is the benefit? I want to verify the second part is equal to the expected fee-transfer syscalls, and iterate over the first part

Avoid cloning, but that's not important enough in tests

@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_add_emit_event branch from 8a9154e to fa3879f Compare June 3, 2026 07:17
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch 2 times, most recently from 98571a1 to cc6f1b8 Compare June 3, 2026 07:51
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_add_emit_event branch from fa3879f to b72cdb7 Compare June 3, 2026 07:51
@dorimedini-starkware dorimedini-starkware changed the base branch from 05-23-starknet_os_os_resources_test_-_add_emit_event to graphite-base/14137 June 7, 2026 12:33
@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch from cc6f1b8 to 3fe49f1 Compare June 7, 2026 13:29
@dorimedini-starkware dorimedini-starkware changed the base branch from graphite-base/14137 to main June 7, 2026 13:29

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

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 3fe49f1. Configure here.

Comment thread crates/starknet_os_flow_tests/src/os_resources_test.rs

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

:lgtm:

@Yoni-Starkware reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on dorimedini-starkware).

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator Author

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: :shipit: complete! all files reviewed, all discussions resolved (waiting on dorimedini-starkware).

@dorimedini-starkware dorimedini-starkware force-pushed the 05-23-starknet_os_os_resources_test_-_remove_all_fee_transfer_syscalls branch from 3fe49f1 to 1b6cf5e Compare June 7, 2026 13:40

@dorimedini-starkware dorimedini-starkware left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@dorimedini-starkware reviewed 2 files and all commit messages.
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 Jun 7, 2026
Merged via the queue into main with commit 39d2dc3 Jun 7, 2026
29 checks passed
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.

4 participants