From e6285d083d434393a6a6893a2bb2a433f45e0a22 Mon Sep 17 00:00:00 2001 From: Mate Soos Date: Tue, 30 Jul 2024 11:26:29 +0200 Subject: [PATCH] Fixing fetching RPC --- CHANGELOG.md | 1 + src/EVM.hs | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8baf0a55b..d58880d55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PAnd props are now recursively flattened - Double negation in Prop are removed - Updated forge to modern version, thereby fixing JSON parsing of new forge JSONs +- Fixed RPC fetching of contract data ## Fixed - `concat` is a 2-ary, not an n-ary function in SMT2LIB, declare-const does not exist in QF_AUFBV, replacing diff --git a/src/EVM.hs b/src/EVM.hs index 51d3be796..08b6e1ecb 100644 --- a/src/EVM.hs +++ b/src/EVM.hs @@ -1315,13 +1315,15 @@ accessStorage addr slot continue = do fetchAccount addr $ \_ -> accessStorage addr slot continue where - rpcCall c slotConc = if c.external + rpcCall c slotConc = fetchAccount addr $ \_ -> + if c.external then forceConcreteAddr addr "cannot read storage from symbolic addresses via rpc" $ \addr' -> forceConcrete slotConc "cannot read symbolic slots via RPC" $ \slot' -> do -- check if the slot is cached - contract <- preuse (#cache % #fetched % ix addr') - case contract of - Nothing -> internalError "contract marked external not found in cache" + use (#env % #contracts % at (LitAddr addr')) >>= \case + -- contract <- preuse (#cache % #fetched % ix addr') + -- case contract of + Nothing -> internalError $ "contract addr " <> show addr' <> " marked external not found in cache" Just fetched -> case readStorage (Lit slot') fetched.storage of Nothing -> mkQuery addr' slot' Just val -> continue val @@ -1665,7 +1667,7 @@ cheatActions = Map.fromList Just a -> assign (#config % #overrideCaller) (Just a) Nothing -> vmError (BadCheatCode sig) _ -> vmError (BadCheatCode sig) - + , action "startPrank(address)" $ \sig _ _ input -> case decodeStaticArgs 0 1 input of [addr] -> case wordToAddr addr of