Unverified Commit f3a6b6dc authored by Alexander Theißen's avatar Alexander Theißen Committed by GitHub
Browse files

contracts: Fix double charge of gas for host functions (#3361)



This PR is fixing a bug in the sync mechanism between wasmi and
pallet-contracts. This bug leads to essentially double charging all the
gas that was used during the execution of the host function. When the
`call` host function is used for recursion this will lead to a quadratic
amount of gas consumption with regard to the nesting depth.We also took
the chance to refactor the code in question and improve the rust docs.

The bug was caused by not updating `GasMeter::executor_consumed`
(previously `engine_consumed`) when leaving the host function. This lead
to the value being stale (too low) when entering another host function.

---------

Co-authored-by: default avatarPG Herveou <[email protected]>
parent 579ef32d
Pipeline #447448 failed with stages
in 34 minutes and 39 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment