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

Medusa vs Echidna gas usage #497

Open
rappie opened this issue Oct 21, 2024 · 5 comments
Open

Medusa vs Echidna gas usage #497

rappie opened this issue Oct 21, 2024 · 5 comments

Comments

@rappie
Copy link

rappie commented Oct 21, 2024

Medusa's gas usage metrics seem to be higher than Echidna.

I'm testing this using:

        uint256 gasBefore = gasleft();
        doSomething();
        fl.log("gas used", gasBefore - gasleft());

Here's an example output for the same function call with a complex state:

  • Echidna: 688957
  • Medusa: 716057

There is also the possibility that somehow the state is built different due to small differences between medusa/echidna's setup or initial values. I'm trying to have everything exactly the same, like setting block number/timestamp to 1 before deploying anything.

Is this a known issue? Any tips for debugging?

@ggrieco-tob
Copy link
Member

I'm not sure gas usage in hevm is very precise. I think medusa should give a more realistic estimation compared to geth.

@elopez
Copy link
Member

elopez commented Oct 21, 2024

Are you using any cheatcodes as part of doSomething? I'm not sure how they're priced in medusa, but that might be different.

@rappie
Copy link
Author

rappie commented Oct 21, 2024

I'm not using any cheatcodes. I'm trying to keep it as clean as possible.

It's a pretty straightforward function that just does a lot, based on a complex state. Things like looping over arrays, calculating shares, transfering tokens, etc.

@rappie
Copy link
Author

rappie commented Oct 21, 2024

I'm debating whether or not to do a more precise benchmark, and also including Foundry. Would this be helpful? Or is this information already available somewhere?

@rappie
Copy link
Author

rappie commented Oct 22, 2024

Here are the benchmark results:

  • Echidna: 592767
  • Medusa: 601767
  • Foundry: 601817

Looks like Medusa is very accurate (assuming Foundry is accurate).

Repo:
https://github.com/rappie/fuzzer-gas-metric-benchmark

Any feedback is welcome :)

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

No branches or pull requests

3 participants