Skip to content
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

Index CoverageMap and SignatureMap by codehash (for performance) #1160

Merged
merged 13 commits into from
Jan 11, 2024

Conversation

samalws-tob
Copy link
Collaborator

@samalws-tob samalws-tob commented Jan 9, 2024

This PR makes it so the CoverageMap and SignatureMap are indexed by contracts' codehashes, rather than their bytecode metadata. As a result:

  • This contract ran 60% faster on my computer, producing the same output as before.
  • This contract ran 18% faster on my computer, producing the same output as before.

Additional changes:

  • Removes the bytecode metadata cache, since this is no longer needed
  • Adds a codehash cache. This is because we need to index maps by a contract's "real" / "original" / "compile-time" codehash, rather than its .codehash property (which can be different if Solidity's immutables feature, which changes bytecode during compile time, is used). The real codehash is found using hevm's findSrc function, and the results are cached in the codehash map
  • Adds an additional test for immutables.
  • Uses codeContract rather than contract to determine the current contract while keeping track of coverage (after talking this over with @arcz ). Beforehand, this was done in some places but not in others. I believe this should fix some delegate call behavior.

Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. The immutable.sol seems to fail because contractAList in genTx is empty, so it looks like a bug with SignatureMap.

lib/Echidna/Exec.hs Outdated Show resolved Hide resolved
lib/Echidna/Types/Coverage.hs Outdated Show resolved Hide resolved
lib/Echidna/Types/Signature.hs Outdated Show resolved Hide resolved
lib/Echidna/Transaction.hs Outdated Show resolved Hide resolved
@samalws-tob samalws-tob marked this pull request as ready for review January 11, 2024 19:27
Copy link
Member

@arcz arcz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work!

@arcz arcz merged commit e0d243a into crytic:master Jan 11, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants