-
Notifications
You must be signed in to change notification settings - Fork 61
[Testing] : Gas Cost Benchmarks for Diamond events #246
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
[Testing] : Gas Cost Benchmarks for Diamond events #246
Conversation
👷 Deploy request for compose-diamonds pending review.Visit the deploys page to approve it
|
Coverage Report
Last updated: Wed, 10 Dec 2025 08:38:40 GMT for commit |
Gas ReportNo gas usage changes detected between All functions maintain the same gas costs. ✅ Last updated: Wed, 10 Dec 2025 08:39:29 GMT for commit |
|
Wow! These gas results are surprising! I would have thought that emitting a single It seems to me that the other two approaches would cost a lot more gas because they emit a lot more events that have more indexes. But it is not true so I researched why. The reason why the Single Event approach in this case costs so much gas is because Solidity has to ABI encode the _diamondCut argument to emit it in an event, and that is very expensive.
|
|
@AnInsaneJimJam Thank you for this very valuable work. Merged into main. |
|
Yeah, at first I also thought it was a fluke, then I verified for 200,500,1000 facets and percentages rose slowly but steadily. At 1000, it was around 1%. Thank you for providing reason of this behaviour. It is a valuable insight. |
|
@AnInsaneJimJam Can I see the results for 200, 500, 1000 facets too? |
|
Yeah, sure . I also included 2000 (bcz why not). Here is the complete table
|
|
@AnInsaneJimJam Thank you! |
The gas benchmarks were run for these scenarios:
Using three event stratergies:
1.) Single Event for whole operation:
2.) 1 event per facet( in our case => 10,50,100)
3.)1 event per function( in our case => 80, 400, 800)
Result are as follows:

Analysis:
Facet Event is the cheapest and scales with the increase of facets.
Percentages are with comparison with facet event.
Closes the issue #245