You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some variables in the contract use uints with widths that may be larger than necessary. For example, with the tree depth set at 20, the number of elements in the membership set cannot exceed 2^20. This means that MAX_MEMBERSHIP_SET_SIZE could be stored in a uint24 instead of a uint32. (Solidity supports "uint8 to uint256 in steps of 8 (unsigned of 8 up to 256 bits)" - source).
However, it’s important to consider how the EVM packs storage variables into 256-bit words, which it operates on natively. Over-optimizing individual variable sizes could lead to inefficient storage usage due to misalignment with 256-bit boundaries.
Additionally, upgradability should be taken into account. For example, if the tree depth might increase to 32 in the future, it would make sense to use uint32 for the membership set size from the beginning to avoid the need for changes later.
The text was updated successfully, but these errors were encountered:
Some variables in the contract use
uint
s with widths that may be larger than necessary. For example, with the tree depth set at20
, the number of elements in the membership set cannot exceed2^20
. This means thatMAX_MEMBERSHIP_SET_SIZE
could be stored in auint24
instead of auint32
. (Solidity supports "uint8 to uint256 in steps of 8 (unsigned of 8 up to 256 bits)" - source).However, it’s important to consider how the EVM packs storage variables into 256-bit words, which it operates on natively. Over-optimizing individual variable sizes could lead to inefficient storage usage due to misalignment with 256-bit boundaries.
Additionally, upgradability should be taken into account. For example, if the tree depth might increase to
32
in the future, it would make sense to useuint32
for the membership set size from the beginning to avoid the need for changes later.The text was updated successfully, but these errors were encountered: