Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hevm: handle contracts with boolean mappings #118

Open
d-xo opened this issue Jul 21, 2021 · 1 comment
Open

hevm: handle contracts with boolean mappings #118

d-xo opened this issue Jul 21, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@d-xo
Copy link
Collaborator

d-xo commented Jul 21, 2021

If I attempt to prove the following spec:

constructor of Auth
interface constructor()

creates

    mapping (address => bool) wards := []

behaviour rely of Auth
interface rely(address usr)

iff

    wards[CALLER]
    CALLVALUE == 0

storage

    wards[usr] => true
    wards[CALLER]

behaviour deny of Auth
interface deny(address usr)

iff

    wards[CALLER]
    CALLVALUE == 0

storage

    wards[usr] => false
    wards[CALLER]

against this contract:

// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.4;

contract Auth {
    mapping (address => bool) public wards;

    modifier auth {
        require(wards[msg.sender], "auth/unauthorized");
        _;
    }

    function rely(address usr) external auth {
        wards[usr] = true;
    }

    function deny(address usr) external auth {
        wards[usr] = false;
    }
}

I get the following error:

> act hevm --spec src/auth.act --soljson out/dapp.sol.json
act: "Auth_rely_wards-Auth_rely_CALLER" not found in fromList []
CallStack (from HasCallStack):
  error, called at HEVM.hs:479:28 in main:HEVM

This is because locateStorage always returns a pair of integers, even if the storage item we want to locate is a boolean type. Later when we try to lookup these storage values in SymExpBool they are stripped because they have type SymInteger instead of SymBool.

@d-xo d-xo added the bug Something isn't working label Jul 21, 2021
@d-xo d-xo changed the title hevm: handle contracts with non boolean mappings hevm: handle contracts with boolean mappings Jul 22, 2021
@rdotterer09
Copy link

have you already changed this in the contract or what do i need to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants