Skip to content

Commit 1141ca5

Browse files
committed
Implement check that all symbolic addesses are unique, until we do internal renaming
1 parent f464723 commit 1141ca5

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ hevm_buggy=tests/hevm/pass/transfer/transfer.act
4747
hevm_pass=$(filter-out $(hevm_buggy), $(wildcard tests/hevm/pass/*/*.act))
4848
# supposed to fail
4949
hevm_fail=$(wildcard tests/hevm/fail/*/*.act)
50-
# slow tests
50+
# slow passing tests
5151
hevm_slow=tests/hevm/pass/amm/amm.act tests/hevm/pass/amm-2/amm-2.act
5252
# supposed to pass, run fust
5353
hevm_fast=$(filter-out $(hevm_slow), $(hevm_pass))

src/Act/Decompile.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
{-|
1313
Module : Decompile
14-
Description : Decompile EVM bytecode into Act378
14+
Description : Decompile EVM bytecode into Act
1515
1616
This module decompiles EVM bytecode into an Act spec. It operates as follows
1717

src/Act/HEVM.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module Act.HEVM where
1818
import Prelude hiding (GT, LT)
1919

2020
import qualified Data.Map as M
21+
import qualified Data.Set as S
2122
import Data.List
2223
import Data.Containers.ListUtils (nubOrd)
2324
import qualified Data.Text as T
@@ -658,8 +659,9 @@ getInitContractState solvers iface pointers preconds cmap = do
658659
(cmaps, checks) <- unzip <$> mapM getContractState (fmap nub casts')
659660

660661
let finalmap = M.unions (cmap:cmaps)
662+
661663
check <- checkAliasing finalmap cmaps
662-
pure (finalmap, check <* sequenceA_ checks)
664+
pure (finalmap, check <* sequenceA_ checks <* checkUniqueAddr (cmap:cmaps))
663665

664666
where
665667

@@ -710,7 +712,15 @@ getInitContractState solvers iface pointers preconds cmap = do
710712

711713
msg = "\x1b[1mThe following addresses cannot be proved distinct:\x1b[m"
712714

715+
-- currently we check that all symbolic addresses are globaly unique, and fail otherwise
716+
-- (this is required for aliasing check to be sound when merging graphs
717+
-- In the future, we should implement an internal renaming of variables to ensure global
718+
-- uniqueness of symbolic a)ddresses.
713719

720+
checkUniqueAddr :: [ContractMap] -> Error String ()
721+
checkUniqueAddr cmaps =
722+
let pairs = comb cmaps in
723+
assert (nowhere, "Names of symbolic adresses must be unique") (foldl (\b (c1, c2) -> S.disjoint (M.keysSet c1) (M.keysSet c2) && b) True pairs)
714724

715725
checkConstructors :: App m => SolverGroup -> ByteString -> ByteString -> Contract -> ActT m (Error String ContractMap)
716726
checkConstructors solvers initcode runtimecode (Contract ctor@(Constructor _ iface pointers preconds _ _ _) _) = do

0 commit comments

Comments
 (0)