40,000 USDC
View results
Submission Details
Severity: gas

Modifier gas optimization for inState modifier

Summary

Modifier gas optimization for inState modifier
It is recommended to move the modifiers checks into an internal virtual function. This reduces the size of compiled contracts that use the modifiers. Putting the check in an internal function decreases contract size when a modifier is used multiple times.

- modifier inState(State expectedState) {
- if (s_state != expectedState) {
- revert Escrow__InWrongState(s_state, expectedState);
- }
- _;
- }
+ modifier inState(State expectedState) {
+ checkState(expectedState);
+ _;
+ }
+ function checkState(State expectedState) internal view virtual {
+ if (s_state != expectedState) {
+ revert Escrow__InWrongState(s_state, expectedState);
+ }
+ }

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.