This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
contracts: Switch to wasmi's builtin metering #13639
Labels
I9-optimisation
An enhancement to provide better overall performance in terms of time-to-completion for a task.
Z4-involved
Can be fixed by an expert coder with good knowledge of the codebase.
Our approach to gas metering so far is to instrument the wasm code on upload to the chain. We parse the code and inject wasm instructions that meter a contract. The alternative is to let the execution engine (wasmi) handle the metering. That is a way more efficient way of doing it. However, we decided to go with instrumentation anyways because the execution engine (wasmi) originally resided within the client. Doing the instrumentation within the runtime was a way to make the metering algorithm part of consensus instead of specifying it and have any client conform to it. That might lead to consensus issues when (accidental) changes were made to it between versions.
Since we moved wasmi into the runtime there is no longer a need to rely on instrumentation. Hence we move to a wasmi builtin metering. This will also allow us to remove the whole caching logic for instrumented code. The wasmi instrumentation is fast enough to just do it on every call. This is because it needs to parse the code anyways instead of having an additional pass just for instrumentation.
The text was updated successfully, but these errors were encountered: