I'm at a very puzzling scenario.
While using Remix, I noticed that adding a few assert
s has caused a significant increase in execution cost (from ~50K to ~59K). And not only did it increase the execution cost of the updated function, but also of any other (public) function!!!
The only solid conclusion that I came up with, is that there's a "gas penalty" which takes effect as soon as the global number of assert
s in the contract exceeds a certain threshold. BTW, the exact same behavior occurs when I replace the assert
s with require
s.
My current Solidity version is 0.4.16+commit.d7661dd9.Emscripten.clang, and I am compiling with optimization enabled. However, it seems to happen on previous compiler versions as well (I've tried a few of them, down to v0.4.11).
Unfortunately, I am unable to reproduce this problem within a minimal working code snippet, and pasting the entire contract here would probably mess up the entire question. So if possible to get an answer (or any other suggestion regarding the source of this problem) without a coding example, then I would be grateful.
Thank you very much.
assert
s using expensive operations like calling function as part of theassert
?