Skip to content

vm.assume(bool) should revert with FOUNDRY::ASSUME cheatcode when condition is false #963

@BowTiedRadone

Description

@BowTiedRadone

Currently, hevm's implementation of vm.assume(bool) returns successfully (via doStop) when the condition is false, rather than reverting with the magic code "FOUNDRY::ASSUME". This breaks Foundry test compatibility and makes it impossible for fuzzers to properly filter out invalid inputs:

hevm/src/EVM.hs

Lines 1833 to 1838 in 1f02fd8

, action "assume(bool)" $
\sig input -> case decodeStaticArgs 0 1 input of
[c] -> do
modifying #constraints ((:) (PEq (Lit 1) c))
doStop
_ -> vmError (BadCheatCode "assume(bool) parameter decoding failed." sig)

When vm.assume(false) is called, it should revert with the magic string "FOUNDRY::ASSUME\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".

This is how Foundry implements it: https://github.com/foundry-rs/foundry/blob/e589ccfc404f878b77c1e6a5ea85023ad99482b6/crates/cheatcodes/src/test/assume.rs#L46-L51

Proposed fix:

vmError (Revert (ConcreteBuf "FOUNDRY::ASSUME\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"))

Identified this together with @gustavo-grieco when working on Echdina's Foundry test generation feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions