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

Validate correct gas accounting on segfault #393

Closed
Stebalien opened this issue Mar 15, 2022 · 1 comment
Closed

Validate correct gas accounting on segfault #393

Stebalien opened this issue Mar 15, 2022 · 1 comment
Labels
P1 P1: Must be resolved Topic: Gas and limits
Milestone

Comments

@Stebalien
Copy link
Member

Wasmtime accounts for "gas" by aborting once some amount of "fuel" has been consumed. It (likely?) tracks fuel by deducting the amount of fuel used by some "uninterruptible" block of code, then executes that "uninterruptible" block of code.

  • In the case where we exit normally (or even explicitly abort), this works fine.
  • In the case where we run out of gas, this also works fine because we'll simply record that all gas has been used.
  • In the case where some instruction in the middle of that block isn't quite uninterruptible, we may have issues.

Specifically:

  1. Charge gas for the entire block.
  2. Load A.
  3. Load B -> Trap due to out-of-bounds access.
  4. Load C

If this happens, we'll charge the wrong amount of gas. We need to:

  1. Better understand what wasm does here.
  2. Consider charging all remaining gas on out-of-bounds accesses like this. Callers could set hard limits on the amount of gas that can be charged if they need this to be recoverable.
@Stebalien Stebalien added this to the Phase 1 milestone Mar 15, 2022
@raulk raulk removed the Area: FVM label Aug 8, 2022
@Stebalien
Copy link
Member Author

We've implemented our own gas accounting now and this will behave identically to the user calling the exit syscall: we'll use all gas from the rest of the wasm block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 P1: Must be resolved Topic: Gas and limits
Projects
None yet
Development

No branches or pull requests

2 participants