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

Merged
merged 3 commits into from
Jul 5, 2020

Conversation

sorawit
Copy link
Member

@sorawit sorawit commented Jul 4, 2020

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:

  • The pull request is targeted against the correct target branch
  • The pull request is linked to an issue with appropriate discussion and an accepted design OR is linked to a spec that describes the work.
  • The pull request includes a description of the implementation/work done in detail.
  • You have added a relevant changelog entry to CHANGELOG_UNRELEASED.md
  • You have re-reviewed the files affected by the pull request (e.g. using the Files changed tab in the Github PR explorer)

@sorawit sorawit requested review from tansawit, Benzbeeb and taobun July 4, 2020 18:27
@render
Copy link

render bot commented Jul 4, 2020

@sorawit sorawit changed the title chain/owasm: Increase wasm gas limit and consume gas when reading / w… chain/owasm: Increase wasm gas limit and consume gas when reading / writing Jul 4, 2020
@taobun taobun merged commit 78c5cf1 into master Jul 5, 2020
@taobun taobun deleted the owasm-gas-impv branch July 5, 2020 05:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants