Skip to content

Conversation

@franciszekjob
Copy link
Contributor

@franciszekjob franciszekjob commented Oct 23, 2025

Closes #3824

Introduced changes

Introduce get_current_vm_step as part of snforge_std::testing

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

@franciszekjob franciszekjob marked this pull request as ready for review October 23, 2025 16:57
@franciszekjob franciszekjob requested a review from a team as a code owner October 23, 2025 16:57
@franciszekjob franciszekjob changed the base branch from master to fix-native-meta-tx-v0-tests October 24, 2025 15:37
Base automatically changed from fix-native-meta-tx-v0-tests to master October 24, 2025 16:34
@franciszekjob franciszekjob requested a review from ksew1 October 28, 2025 08:00
Copy link
Contributor

@ddoktorski ddoktorski left a comment

Choose a reason for hiding this comment

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

In the current implementation this doesn't actually work for contracts since each contract call is executed in a separate VM. Was it intended to support contract testing at all?

Copy link
Member

@cptartur cptartur left a comment

Choose a reason for hiding this comment

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

Please re-request after changes from slack discussion are addressed

@franciszekjob
Copy link
Contributor Author

In the current implementation this doesn't actually work for contracts since each contract call is executed in a separate VM. Was it intended to support contract testing at all?

Good catch! I've changed the code so now it also adds steps from calls's resource, should be fine. Please take a look.

@franciszekjob franciszekjob changed the title Add get_current_step Add get_current_vm_step Nov 6, 2025
Copy link
Member

Choose a reason for hiding this comment

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

Can we add some kind of sanity check where we assert specific value of used steps (or a delta of steps)? So we detect eventually regressions if these change significantly.

Copy link
Member

Choose a reason for hiding this comment

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

I see that we have a test below that does this for contracts but let's have one for top level calls as well.

Copy link
Contributor Author

@franciszekjob franciszekjob Nov 10, 2025

Choose a reason for hiding this comment

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

I've extended test_get_current_vm_step so now it checks steps after two possible scenarios: syscalls only in top call + syscalls both in top call and inner calls. It should cover this and the comment below, pls TAL.

Copy link
Member

Choose a reason for hiding this comment

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

Also, let's add a test where we have inner calls and these inner calls do some expensive computation (not just increment some counter, but call some more expensive syscalls). Check if steps value is "large enough" there.

Copy link
Member

Choose a reason for hiding this comment

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

We should be able to roughly estimate the steps value from fee mechanism docs https://docs.starknet.io/learn/protocol/fees#vm-resources similarly as we do in our gas integration tests and check if values in the test are roughly withing the expected range.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Responded in comment above.

Copy link
Member

Choose a reason for hiding this comment

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

I'd reword this so it's more of a reference than a tutorial, explanations like that fit more in the snforge Overview section and we can assume users looking at the reference are familiar with these docs.

Take a look at fuzzable docs for example, let's show an reference for what get_current_vm_step shows and does and keep a simple example without too much explanations.

Copy link
Contributor Author

@franciszekjob franciszekjob Nov 10, 2025

Choose a reason for hiding this comment

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

I'd reword this so it's more of a reference than a tutorial, explanations like that fit more in the snforge Overview section and we can assume users looking at the reference are familiar with these docs.

Take a look at fuzzable docs for example, let's show an reference for what get_current_vm_step shows and does and keep a simple example without too much explanations.

It's not shown in snforge Overview, hence the example here has more detailed explanation.

I've reduced the textual description, but kept contract and test code (13f1af4).

We could put a small tutorial to snforge overview section if you really want, lmk

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.

Function allowing to assert steps

6 participants