Modifiers code is copied in all instances where it's used, increasing bytecode size.
The bytecode size is reduced, which saves a lot of deployment gas. The gas required to call the modifier increases slightly. However, in the current implementation, each function is called at most once, so reducing deploy gas is better than reducing call gas.
The code written in the modifier is then included in the code at deployment time. This increases the deploy gas.
original gas report
Deployment Cost | Deployment Size |
---|---|
656473 | 4085 |
Function Name | min | avg | median | max | # calls |
---|---|---|---|---|---|
initiateDispute | 356 | 16991 | 23772 | 23772 | 10 |
resolveDispute | 397 | 27562 | 22808 | 63620 | 8 |
You can replace the inState modifier with the following
optimized gas report
Deployment Cost | Deployment Size |
---|---|
631032 | 3951 |
Function Name | min | avg | median | max | # calls |
---|---|---|---|---|---|
initiateDispute | 351 | 16971 | 23752 | 23752 | 10 |
resolveDispute | 410 | 27564 | 22794 | 63638 | 8 |
Reduced the deployment gas by 25441, but the increased call gas is negligible, less than 100.
Reduce the deployment gas that the buyer has to pay.
VS Code
Refactor a modifier to call a local function instead of directly having the code in the modifier
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.