diff --git a/src/Act/HEVM.hs b/src/Act/HEVM.hs index e2352959..3b4222e6 100644 --- a/src/Act/HEVM.hs +++ b/src/Act/HEVM.hs @@ -146,6 +146,7 @@ translateConstructor bytecode (Constructor _ iface preconds _ _ upds) = do calldata = makeCtrCalldata iface initcontract = EVM.C { EVM.code = EVM.RuntimeCode (EVM.ConcreteRuntimeCode bytecode) , EVM.storage = EVM.ConcreteStore mempty + , EVM.tStorage = EVM.ConcreteStore mempty , EVM.balance = EVM.Lit 0 , EVM.nonce = Just 1 } @@ -212,12 +213,12 @@ applyUpdate readMap writeMap (Update typ (Item _ _ ref) e) = do where updateStorage :: (EVM.Expr EVM.Storage -> EVM.Expr EVM.Storage) -> EVM.Expr EVM.EContract -> EVM.Expr EVM.EContract - updateStorage updfun (EVM.C code storage bal nonce) = EVM.C code (updfun storage) bal nonce + updateStorage updfun (EVM.C code storage tstorage bal nonce) = EVM.C code (updfun storage) tstorage bal nonce updateStorage _ (EVM.GVar _) = error "Internal error: contract cannot be a global variable" updateNonce :: EVM.Expr EVM.EContract -> EVM.Expr EVM.EContract - updateNonce (EVM.C code storage bal (Just n)) = EVM.C code storage bal (Just (n + 1)) - updateNonce c@(EVM.C _ _ _ Nothing) = c + updateNonce (EVM.C code storage tstorage bal (Just n)) = EVM.C code storage tstorage bal (Just (n + 1)) + updateNonce c@(EVM.C _ _ _ _ Nothing) = c updateNonce (EVM.GVar _) = error "Internal error: contract cannot be a global variable" createContract :: ContractMap -> ContractMap -> EVM.Expr EVM.EAddr -> Exp AContract -> ActM ContractMap @@ -227,6 +228,7 @@ createContract readMap writeMap freshAddr (Create _ cid args) = do Just (Contract (Constructor _ iface _ _ _ upds) _, _, bytecode) -> do let contract = EVM.C { EVM.code = EVM.RuntimeCode (EVM.ConcreteRuntimeCode bytecode) , EVM.storage = EVM.ConcreteStore mempty + , EVM.tStorage = EVM.ConcreteStore mempty , EVM.balance = EVM.Lit 0 , EVM.nonce = Just 1 } @@ -369,7 +371,7 @@ refAddr :: ContractMap -> StorageRef -> ActM (EVM.Expr EVM.EAddr) refAddr cmap (SVar _ c x) = do caddr <- getCaddr case M.lookup caddr cmap of - Just (EVM.C _ storage _ _) -> do + Just (EVM.C _ storage _ _ _) -> do layout <- getLayout let slot = EVM.Lit $ fromIntegral $ getSlot layout c x case simplify (EVM.SLoad slot storage) of @@ -381,7 +383,7 @@ refAddr cmap (SField _ ref c x) = do layout <- getLayout caddr' <- refAddr cmap ref case M.lookup caddr' cmap of - Just (EVM.C _ storage _ _) -> do + Just (EVM.C _ storage _ _ _) -> do let slot = EVM.Lit $ fromIntegral $ getSlot layout c x case simplify (EVM.SLoad slot storage) of EVM.WAddr symaddr -> pure symaddr @@ -528,7 +530,7 @@ toExpr cmap = liftM stripMods . go caddr' <- baseAddr cmap ref let contract = fromMaybe (error "Internal error: contract not found") $ M.lookup caddr' cmap let storage = case contract of - EVM.C _ s _ _ -> s + EVM.C _ s _ _ _ -> s EVM.GVar _ -> error "Internal error: contract cannot be a global variable" pure $ EVM.SLoad slot storage @@ -638,13 +640,14 @@ createStorage cmap = traverseStorage _ _ = error "Internal error: unexpected storage shape" makeContract :: EVM.Expr EVM.EAddr -> EVM.Expr EVM.EContract -> EVM.Expr EVM.EContract - makeContract addr (EVM.C code storage _ _) = EVM.C code (traverseStorage addr storage) (EVM.Balance addr) (Just 0) + makeContract addr (EVM.C code storage tstorage _ _) = EVM.C code (traverseStorage addr storage) tstorage (EVM.Balance addr) (Just 0) makeContract _ (EVM.GVar _) = error "Internal error: contract cannot be gvar" toContract :: EVM.Expr EVM.EContract -> EVM.Contract - toContract (EVM.C code storage balance nonce) = EVM.Contract + toContract (EVM.C code storage tstorage balance nonce) = EVM.Contract { EVM.code = code , EVM.storage = storage + , EVM.tStorage = tstorage , EVM.origStorage = storage , EVM.balance = balance , EVM.nonce = nonce diff --git a/src/Act/HEVM_utils.hs b/src/Act/HEVM_utils.hs index 47f55bab..d6bb0d92 100644 --- a/src/Act/HEVM_utils.hs +++ b/src/Act/HEVM_utils.hs @@ -184,4 +184,6 @@ loadSymVM (entryaddr, entrycontract) othercontracts callvalue cd create = , create = create , txAccessList = mempty , allowFFI = False + , freshAddresses = 0 + , beaconRoot = 0 })