Skip to content
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

fix: hardcode max vm cycles in keeper #1807

Merged
merged 7 commits into from
Mar 30, 2024

Conversation

deelawn
Copy link
Contributor

@deelawn deelawn commented Mar 21, 2024

This hardcodes the maximum VM cycles in the keeper to ten million, the same that is currently being used from genesis. It doesn't seem like there is a reason why we should want people to be able to adjust this.

Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Mar 21, 2024
@deelawn deelawn requested a review from leohhhn March 21, 2024 02:15
Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 28.57143% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 47.50%. Comparing base (0f2e755) to head (e03cf44).
Report is 18 commits behind head on master.

Files Patch % Lines
gno.land/pkg/gnoland/node_inmemory.go 0.00% 3 Missing ⚠️
gno.land/pkg/gnoland/app.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1807      +/-   ##
==========================================
+ Coverage   47.49%   47.50%   +0.01%     
==========================================
  Files         388      388              
  Lines       61311    61345      +34     
==========================================
+ Hits        29117    29144      +27     
- Misses      29756    29761       +5     
- Partials     2438     2440       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

I'm not entirely sure about these changes.

If you execute these on Gno.land, these will fail, I'm pretty sure, as you'd get "cpu cycle overrun" already. So these fail in gno run and gno test, which from this PR would be excluded with the new limit.

The way I see it, we should have a limit on the amount of frames that can be created (ie. a stack overflow error), which is for both local testing and the blockchain context, but nothing more than the existing CPU overrun checks for infinte for loops. wdyt?

gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
@harry-hov harry-hov self-requested a review March 21, 2024 15:46
@thehowl
Copy link
Member

thehowl commented Mar 21, 2024

Initial comment

From the review meeting:

  • Let's make sure that gno run and gno test are not limited in VM cycles execution
  • And have a default value for max VM cycles

TBD w/ @deelawn @piux2

Copy link
Contributor

@petar-dambovaliev petar-dambovaliev left a comment

Choose a reason for hiding this comment

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

In my opinion, the bottom of infinite recursion/loop should be when there is no more gas. That means that the check needs to be added in the VM.

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looks good 💯

Please see @thehowl's suggestions, otherwise good to go

gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
@piux2
Copy link
Contributor

piux2 commented Mar 26, 2024

also we need to remove the code that configs VM parameters from command flag.

@github-actions github-actions bot added the 📦 ⛰️ gno.land Issues or PRs gno.land package related label Mar 26, 2024
@deelawn
Copy link
Contributor Author

deelawn commented Mar 26, 2024

In my opinion, the bottom of infinite recursion/loop should be when there is no more gas. That means that the check needs to be added in the VM.

This will be the fallback value if, for some reason, something prevents the machine from halting execution when the gas runs out.

@deelawn deelawn requested a review from gfanton as a code owner March 27, 2024 23:24
@deelawn deelawn changed the title fix: guard against infinite loops and recursion fix: hardcode max vm cycles in keeper Mar 28, 2024
@moul
Copy link
Member

moul commented Mar 28, 2024

Hey,

I support this change. But in the long time, I believe we should make it configurable by the blockchain instead of hardcoding it. See #1856.

Also, linked with #828.

@zivkovicmilos
Copy link
Member

Hey,

I support this change. But in the long time, I believe we should make it configurable by the blockchain instead of hardcoding it. See #1856.

Also, linked with #828.

💯 % agreed. I'll see to tackle this soon

@deelawn deelawn merged commit 6760265 into gnolang:master Mar 30, 2024
184 of 186 checks passed
@deelawn deelawn deleted the bug/infinite-cycles branch March 30, 2024 01:00
Copy link
Contributor

@piux2 piux2 left a comment

Choose a reason for hiding this comment

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

LGTM

gnovm/pkg/gnolang/machine.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants