Skip to content

Commit 6c6b979

Browse files
committed
Fixes for booleans
1 parent 5b3cdae commit 6c6b979

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/Act/Enrich.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,5 @@ mkStorageBoundsLoc refs = concatMap mkBound refs
9696
mkCallDataBounds :: [Decl] -> [Exp ABoolean]
9797
mkCallDataBounds = concatMap $ \(Decl typ name) -> case fromAbiType typ of
9898
AInteger -> [bound typ (_Var Pre typ name)]
99+
ABoolean -> [bound typ (_Var Pre typ name)]
99100
_ -> []

src/Act/HEVM.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ import EVM.Effects
5858
import EVM.Format as Format
5959
import EVM.Traversals
6060

61+
import Debug.Trace
62+
6163
type family ExprType a where
6264
ExprType 'AInteger = EVM.EWord
6365
ExprType 'ABoolean = EVM.EWord
@@ -234,7 +236,7 @@ translateBehv cmap (Behaviour _ _ _ _ preconds caseconds _ upds ret) = do
234236
cmap' <- applyUpdates cmap cmap upds
235237
fresh' <- getFresh
236238
let acmap = abstractCmap initAddr cmap'
237-
pure (simplify $ EVM.Success (preconds' <> caseconds' <> symAddrCnstr (fresh+1) fresh') mempty ret' (M.map fst cmap'), acmap)
239+
pure (EVM.Success (preconds' <> caseconds' <> symAddrCnstr (fresh+1) fresh') mempty ret' (M.map fst cmap'), acmap)
238240

239241
applyUpdates :: Monad m => ContractMap -> ContractMap -> [StorageUpdate] -> ActT m ContractMap
240242
applyUpdates readMap writeMap upds = foldM (applyUpdate readMap) writeMap upds
@@ -427,7 +429,7 @@ expToBuf cmap styp e = do
427429
pure $ EVM.WriteWord (EVM.Lit 0) e' (EVM.ConcreteBuf "")
428430
SBoolean -> do
429431
e' <- toExpr cmap e
430-
pure $ EVM.WriteWord (EVM.Lit 0) e' (EVM.ConcreteBuf "")
432+
pure $ EVM.WriteWord (EVM.Lit 0) (EVM.IsZero $ EVM.IsZero e') (EVM.ConcreteBuf "")
431433
SByteStr -> toExpr cmap e
432434

433435
-- | Get the slot and the offset of a storage variable in storage
@@ -791,6 +793,13 @@ checkBehaviours solvers (Contract _ behvs) actstorage = do
791793

792794
solbehvs <- lift $ removeFails <$> getRuntimeBranches solvers hevmstorage calldata fresh
793795

796+
797+
-- when (name == "setg") (do
798+
-- traceM "Act behvs:"
799+
-- traceM $ showBehvs behvs'
800+
-- traceM "Sol behvs:"
801+
-- traceM $ showBehvs solbehvs)
802+
794803
lift $ showMsg $ "\x1b[1mChecking behavior \x1b[4m" <> name <> "\x1b[m of Act\x1b[m"
795804
-- equivalence check
796805
lift $ showMsg "\x1b[1mChecking if behaviour is matched by EVM\x1b[m"

src/Act/Syntax.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import qualified Act.Syntax.Annotated as Annotated
1818
import qualified Act.Syntax.Typed as Typed
1919
import Act.Syntax.Untyped hiding (Contract)
2020
import qualified Act.Syntax.Untyped as Untyped
21+
import EVM.ABI (AbiValue(AbiBool))
2122

2223
-----------------------------------------
2324
-- * Extract from fully refined ASTs * --
@@ -468,4 +469,5 @@ upperBound (AbiUIntType n) = UIntMax nowhere n
468469
upperBound (AbiIntType n) = IntMax nowhere n
469470
upperBound AbiAddressType = UIntMax nowhere 160
470471
upperBound (AbiBytesType n) = UIntMax nowhere (8 * n)
472+
upperBound AbiBoolType = LitInt nowhere 1
471473
upperBound typ = error $ "upperBound not implemented for " ++ show typ

0 commit comments

Comments
 (0)