Repository navigation
fix(browser): resume bounded translated gas slices - #73
Merged
Merged
Conversation
replghost
force-pushed
the
fix/resume-translated-out-of-gas
branch
from
October 5, 2026 02:11
1323718 to
144b77e
Compare
# Conflicts: # rust/crates/polkavm-host-runtime-assets/assets/SHA256SUMS # rust/crates/polkavm-host-runtime-assets/src/lib.rs
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The translated (browser compiler) backend executes an update in loop-bounded
gas slices (
MAX_TRANSLATED_LOOPS_PER_UPDATE, 50M) but treated the end of thefirst slice as fatal out-of-gas, even though the ABI call budget is
MAX_GAS_PER_UPDATE(10G). Heavy guests had to split their work artificially:OpenHV world loading needed one startup operation per frame and took
2,560 s to become playable in Chromium.
Change
TranslatedPolkaVmRuntimetakes amaxGasSlicescount. When a slice endswith
STATUS_OUT_OF_GASand slices remain, it records a pendingcontinuation instead of failing; the next tick resumes the same call with
pvm_resume, preserving PC, registers, memory and remaining budget.scheduleTick(0)) while acontinuation is pending, so the scheduler, input and cancellation still run
between slices.
Calls with a reduced budget get no extra slices.
only exhausting the complete call budget is gas exhaustion.
Verification
npm testinjs/packages/polkavm-browser-runtime: 310/310, including thenew "translated execution resumes after exhausting a gas slice" test
(resume preserves state; a single-slice runtime still fails).
(was 2,560.16 s), move, production, placement and play through tick 420
without runtime failure.