-
Notifications
You must be signed in to change notification settings - Fork 240
Add get_current_vm_step
#3868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add get_current_vm_step
#3868
Conversation
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
… into 3824-get-current-step
…/starknet-foundry into 3824-get-current-step
ddoktorski
left a comment
There was a problem hiding this 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?
cptartur
left a comment
There was a problem hiding this 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
Good catch! I've changed the code so now it also adds steps from calls's resource, should be fine. Please take a look. |
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/cheatcodes/testing.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
crates/cheatnet/src/runtime_extensions/forge_runtime_extension/mod.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Responded in comment above.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 Overviewsection 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_stepshows 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
Closes #3824
Introduced changes
Introduce
get_current_vm_stepas part ofsnforge_std::testingChecklist
CHANGELOG.md