You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes an off-by-one error in the step count subtraction when calculating used_resources.n_steps. The - 1 was incorrectly applied when removing header and footer steps from the relocated trace, causing the step count to be under-subtracted by 1 for both the forward and reverse trace position lookups.
Type of change
Please check one:
Bug fix (fixes incorrect behavior)
New feature
Performance improvement
Documentation change with concrete technical impact
Style, wording, formatting, or typo-only change
Why is this change needed?
The position() call on the relocated trace already returns a 0-based index representing the number of steps to exclude. Subtracting an additional 1 from each result caused the reported step count to be 2 steps higher than the actual number of steps executed by the user's code (1 step over-counted from the header, 1 from the footer).
What was the behavior or documentation before?
used_resources.n_steps was reduced by (position - 1) for both the header and footer, leaving 2 extra steps attributed to the user's function execution.
What is the behavior or documentation after?
used_resources.n_steps is now correctly reduced by the full position value for both the header and footer, accurately reflecting only the steps belonging to the user's code.
Related issue or discussion (if any)
Additional context
The fix applies symmetrically to both the forward trace scan (header exclusion) and the reverse trace scan (footer exclusion).
Low Risk
Small accounting fix in runner metrics only; no execution, auth, or contract semantics change.
Overview
Corrects how used_resources.n_steps is computed after a Sierra function run by stripping entry header and footer steps from the VM relocated trace.
Previously each subtraction used position(...) - 1, which under-counted excluded steps by one on both the forward (header) and reverse (footer) scans—reported step usage was two steps too high relative to user code only. The logic now subtracts the full position values from both iterators.
Reviewed by Cursor Bugbot for commit 8a421c1. Bugbot is set up for automated code reviews on this repo. Configure here.
The reason will be displayed to describe this comment to others. Learn more.
@TomerStarkware reviewed 1 file and all commit messages, and made 1 comment. Reviewable status: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).
orizi
deleted the
orizi/05-28-fix_runner_correct_n_steps_by_removing_erroneous_-1_offsets
branch
May 29, 2026 16:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an off-by-one error in the step count subtraction when calculating
used_resources.n_steps. The- 1was incorrectly applied when removing header and footer steps from the relocated trace, causing the step count to be under-subtracted by 1 for both the forward and reverse trace position lookups.Type of change
Please check one:
Why is this change needed?
The
position()call on the relocated trace already returns a 0-based index representing the number of steps to exclude. Subtracting an additional1from each result caused the reported step count to be 2 steps higher than the actual number of steps executed by the user's code (1 step over-counted from the header, 1 from the footer).What was the behavior or documentation before?
used_resources.n_stepswas reduced by(position - 1)for both the header and footer, leaving 2 extra steps attributed to the user's function execution.What is the behavior or documentation after?
used_resources.n_stepsis now correctly reduced by the fullpositionvalue for both the header and footer, accurately reflecting only the steps belonging to the user's code.Related issue or discussion (if any)
Additional context
The fix applies symmetrically to both the forward trace scan (header exclusion) and the reverse trace scan (footer exclusion).