assert (false)
and an additional log statement emit AssertionFailed("..")
. For example, given this annotated code:scribble
from emitting assert(false)
with the --no-assert
option.view
function. In such cases adding an emit
statement changes the mutability of the instrumented function, which can change the interfaces of the compiled contracts and may break tests. For this reason scribble
(and Mythril and Harvey) support an alternative mode for signaling custom property violations using memory stores with specially crafted bit-strings. You can select this mode with the --user-assert-mode mstore
command line option. If you were to instrument our earlier exmaple in this mode the instrumented code would look as such:_v.__mstore_scratch__
on line 12. Tools such as Myhtril and Harvey can watch for assignments to memory with the 0xcafe
pattern appended with the id of the failing assertion.