code-423n4 / 2022-06-putty-findings

5 stars 0 forks source link

Gas Optimizations #368

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

USING PRIVATE RATHER THAN PUBLIC FOR CONSTANTS, SAVES GAS

If needed, the value can be read from the verified contract source code. Savings are due to the compiler not having to create non-payable getter functions for deployment calldata, and not adding another entry to the method ID table

In Putty's codebase constants are not explicit values but will be computed on compilation, so this can be a matter of preference if a public getter is desired for the exact hash value.

There are three instances of this:

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L89

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L95

https://github.com/code-423n4/2022-06-putty/blob/3b6b844bc39e897bd0bbb69897f2deff12dc3893/contracts/src/PuttyV2.sol#L101

JeeberC4 commented 2 years ago

Warden submitted multiple Gas Optimizations. Will not be judged.