This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
chain/owasm: Increase wasm gas limit and consume gas when reading / writing #2150
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.
Implementation details
This PR bumps the Wasm gas limit of Prepare to 1M and Execute to 5M. Reason being that generally, a wasm opcode on average takes a few nanosecs to run. From a quick experiment on my local machine, 5M gas takes ~10ms. This is in line with what other projects, such as Near (1 Wasm gas = 3856371gas = ~3.85ns) or CosmWasm (100 Wasm gas = 1 SDK gas) is doing at the moment.
Additionally, to prevent attackers repeated calling into heavy OEI operation (such as read calldata), the PR also makes it consume gas equal to span size. This should generally not be an issue for normal users as span size is ~1024. Even 100 reads still only cost 100k gas.
Please ensure the following requirements are met before submitting a pull request:
CHANGELOG_UNRELEASED.md
Files changed
tab in the Github PR explorer)