crytic / echidna

Ethereum smart contract fuzzer
GNU Affero General Public License v3.0
2.65k stars 346 forks source link

Shrink on one worker #1280

Closed arcz closed 1 week ago

arcz commented 2 weeks ago

There was a high contention while shrinking with multiple workers at the same time. This locks shrinking to the same worker which solved the test. Fixes https://github.com/crytic/echidna/issues/1105.

Changes and implications:

  1. Only the worker which solved a test will shrink the test. Worker number is displayed in the UI while shrinking.
  2. If there is shrinking work, do it until the shrink limit and then go back to fuzzing. Fuzzing will be put on pause when all workers are shrinking.
  3. Test limit is unevenly distributed. When worker shrinks it doesn't work on its portion of test limit. This will be fixed in another PR.
  4. Refactored selectMainContract, mkTests and mkSignatureMap out of loadSpecified. This allows for more granular control to easier construct Env. Moved world to the Env and tests can be created before Env.
  5. Merged Campaign.updateTest and Test.updateOpenTest into Campaign.updateOpenTest.

TODO: Look into reintroducing multicore shrinking with better synchronization (https://github.com/crytic/echidna/issues/1249).

ggrieco-tob commented 2 weeks ago

Let's update the number of workers to 3. We can probably pick a better number, but it should work while we determinate how to do that.