feat(vm): escaped functions cap during preparation#16050
Draft
jakmeier wants to merge 2 commits into
Draft
Conversation
The VM currently has not explicit limit on declared Wasm globals in a contract. However, `MAX_CORE_INSTANCE_SIZE = 1MiB` acts as an implicit limit today. This PR sets the limit to 100k global, which would add 1.6MB to the core instance size, thus is less restrictive than the existing limit. A follow-up PR will make this limit stricter and combine it with other limits that contribute to MAX_CORE_INSTANCE_SIZE. But the goal is to introduce each limit in a separate PR before combining them.
Wasmtime limits the core instance size, whose size increases with the number of escaped functions. To avoid running into it at load time, this introduces a limit at preparation time. This requires counting escaped functions in the preparation phase and if that breaches the configured limit, a new error kind is retured as a CompilationError::PrepareError. Gated behind the unstable nightly version 157 for stabilization together with all other limits regarding the core instance size.
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.
Wasmtime limits the core instance size, whose size increases with the
number of escaped functions.
To avoid running into it at load time, this introduces a limit at
preparation time. This requires counting escaped functions in the
preparation phase and if that breaches the configured limit, a new error
kind is retured as a CompilationError::PrepareError.
Gated behind the unstable nightly version 157 for stabilization together
with all other limits regarding the core instance size.