Skip to content

Commit

Permalink
HEVM: start from concrete store for constructors (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoep authored Sep 5, 2023
1 parent 02ee6bd commit a15d717
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/HEVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ translateActConstr (Act _ _) _ = error "TODO multiple contracts"

translateConstructor :: Layout -> Constructor -> BS.ByteString -> (Id, [EVM.Expr EVM.End], Calldata)
translateConstructor layout (Constructor cid iface preconds _ _ upds _) bytecode =
(cid, [EVM.Success (snd calldata <> (fmap (toProp layout) $ preconds)) mempty (EVM.ConcreteBuf bytecode) (updatesToExpr layout cid upds)],
(cid, [EVM.Success (snd calldata <> (fmap (toProp layout) $ preconds)) mempty (EVM.ConcreteBuf bytecode) (updatesToExpr layout cid upds (EVM.ConcreteStore mempty))],
calldata)
where calldata = makeCtrCalldata iface

Expand Down Expand Up @@ -149,8 +149,8 @@ rewriteToExpr :: Layout -> Id -> Rewrite -> EVM.Expr EVM.Storage -> EVM.Expr EVM
rewriteToExpr _ _ (Constant _) state = state
rewriteToExpr layout cid (Rewrite upd) state = updateToExpr layout cid upd state

updatesToExpr :: Layout -> Id -> [StorageUpdate] -> EVM.Expr EVM.Storage
updatesToExpr layout cid upds = foldl (flip $ updateToExpr layout cid) EVM.AbstractStore upds
updatesToExpr :: Layout -> Id -> [StorageUpdate] -> EVM.Expr EVM.Storage -> EVM.Expr EVM.Storage
updatesToExpr layout cid upds initstore = foldl (flip $ updateToExpr layout cid) initstore upds

updateToExpr :: Layout -> Id -> StorageUpdate -> EVM.Expr EVM.Storage -> EVM.Expr EVM.Storage
updateToExpr layout cid (Update typ i@(Item _ _ ref) e) state =
Expand Down Expand Up @@ -365,7 +365,7 @@ checkEquiv solvers opts l1 l2 =
checkConstructors :: SolverGroup -> VeriOpts -> ByteString -> ByteString -> Act -> IO ()
checkConstructors solvers opts initcode runtimecode act = do
let (_, actbehvs, calldata) = translateActConstr act runtimecode
let initVM = abstractVM calldata initcode Nothing EVM.AbstractStore True
let initVM = abstractVM calldata initcode Nothing (EVM.ConcreteStore mempty) True
expr <- interpret (Fetch.oracle solvers Nothing) Nothing 1 StackBased initVM runExpr
let simpl = if True then (simplify expr) else expr
let solbehvs = removeFails $ flattenExpr simpl
Expand Down

0 comments on commit a15d717

Please sign in to comment.