argotorg / argotorg/act

hevm: handle contracts with boolean mappings

Open
#118 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Haskell
Stars
279
Forks
51
Avg merge
17h 42m
Merged PRs (30d)
1

Description

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`](https://github.com/ethereum/act/blob/75cf12f9b99488fb902a19c1e9225eb75a81f1c4/src/HEVM.hs#L219) 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`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in HEVM.hs at locateStorage and follow the storage lookup into SymExpBool. Reproduce the issue with the act command and the provided Auth example, then inspect how boolean storage entries are represented. Done means the boolean mapping values remain available to the symbolic boolean lookup and the proof no longer fails with the missing-storage error.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.