Skip to content

Avoid fixpoint for literals and concrete storage #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions bench/bench-perf.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ main = do
, ("contractCreation", contractCreation, Nothing)
, ("contractCreationMem", contractCreationMem, Nothing)
, ("arrayCreationMem", arrayCreationMem, Just 9)
, ("mapStorage", mapStorage, Nothing)
]
defaultMain =<< mapM f benchmarks

Expand Down Expand Up @@ -301,3 +302,20 @@ arrayCreationMem n = do
}
|]
fmap fromJust (runApp $ solcRuntime "A" src)

-- Create large map in storage
mapStorage :: Int -> IO ByteString
mapStorage n = do
let src =
[i|
struct C { uint256 a; uint256 b; }
contract A {
mapping(uint256 => mapping(uint256 => C)) m;
function main() public {
for (uint i = 0; i < ${n}; i++) {
m[i][${n}-i] = C(i, ${n});
}
}
}
|]
fmap fromJust (runApp $ solcRuntime "A" src)
2 changes: 2 additions & 0 deletions src/EVM/Expr.hs
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,8 @@ simplify :: Expr a -> Expr a
simplify e = untilFixpoint (simplifyNoLitToKeccak . litToKeccak) e

simplifyNoLitToKeccak :: Expr a -> Expr a
simplifyNoLitToKeccak l@(Lit _) = l
simplifyNoLitToKeccak s@(ConcreteStore _) = s
simplifyNoLitToKeccak e = untilFixpoint (mapExpr go) e
where
go :: Expr a -> Expr a
Expand Down
Loading