New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tight Variable Packing #32
Comments
While there could be some benefits had here I think it's less than it seems at first glance. It's a similar story with the factory, maybe I'm unsure how to classify this issue (disputed vs acknowledged), I leaning towards disputed because:
|
Warden's suggestion is valid but could certainly use some more detail. Leaving as a valid optimization none the less. |
Changing to acknowledged based on judges feedback. |
Handle
leastwood
Vulnerability details
Impact
While there is no reward for gas optimizations, it could still prove useful to suggest relatively easy to implement optimizations with decent gas savings. Solidity contracts have contiguous 32 byte (256 bit) slots used in storage. By arranging the variables, it is possible to minimize the number of slots used within a contract's storage and therefore reduce deployment costs. The contract variables in
RCMarket.sol
andRCFactory.sol
can be optimized in such a way. i.e. thebools
can be packed alongside theenums
inRCMarket.sol
. Similarly, theuint32
types can be packed with thebools
inRCFactory.sol
.Proof of Concept
https://github.com/code-423n4/2021-08-realitycards/blob/main/contracts/RCMarket.sol#L24-L132
https://github.com/code-423n4/2021-08-realitycards/blob/main/contracts/RCFactory.sol#L23-L89
Tools Used
Manual code review
Recommended Mitigation Steps
Pack the variables in
RCFactory.sol
andRCMarket.sol
, such that the number of slots used in deployment is minimised.The text was updated successfully, but these errors were encountered: