There are currently several strings that are larger than 32 bytes.
Revert strings above 32 characters would need an additional mstore.
This would incur cost for an additional mstore, along with cost for
memory expansion, as well as cost for additional stack operations. This
cost is only relevant when the revert condition is met.
Shortening would also reduce the deploy cost for the contract in all
cases.
Consider using Custom
errors from
solidity 0.8.4, which is more gas efficient than revert strings.
It is a good practice to make public functions that are not referenced
inside the code to external. In very old Solidity versions, in some
cases, this lead to a decrease in gas. However, this is unlikely to be
the case now.
Handle
hrkrshnn
Vulnerability details
Avoid long revert strings.
There are currently several strings that are larger than 32 bytes.
Revert strings above 32 characters would need an additional
mstore
. This would incur cost for an additionalmstore
, along with cost for memory expansion, as well as cost for additional stack operations. This cost is only relevant when the revert condition is met.Shortening would also reduce the deploy cost for the contract in all cases.
Consider using Custom errors from solidity 0.8.4, which is more gas efficient than revert strings.
Examples of lengthy revert strings
Functions that can be made external
It is a good practice to make
public
functions that are not referenced inside the code toexternal
. In very old Solidity versions, in some cases, this lead to a decrease in gas. However, this is unlikely to be the case now.Examples