Omniscia Nevermined Audit
DIDRegistryLibrary Code Style Findings
DIDRegistryLibrary Code Style Findings
DIL-01C: Variable Tight Packing
Type | Severity | Location |
---|---|---|
Gas Optimization | Informational | DIDRegistryLibrary.sol:L16-L41 |
Description:
The DIDRegister
struct can be tight-packed.
Example:
contracts/registry/DIDRegistryLibrary.sol
16struct DIDRegister {17 // DIDRegistry entry owner18 address owner;19 // DIDRegistry original creator, this can't be modified after the asset is registered 20 address creator; 21 // Checksum associated to the DID22 bytes32 lastChecksum;23 // URL to the metadata associated to the DID24 string url;25 // Who was the last one updated the entry26 address lastUpdatedBy;27 // When was the last time was updated28 uint256 blockNumberUpdated;29 // Providers able to manage this entry30 address[] providers;31 // Delegates able to register provenance events on behalf of the owner or providers32 address[] delegates;33 // The NFTs supply associated to the DID 34 uint256 nftSupply; 35 // The max number of NFTs associated to the DID that can be minted 36 uint256 mintCap;37 // The percent of the sale that is going back to the original `creator` in the secondary market 38 uint8 royalties; 39 // Flag to control if NFTs config was already initialized40 bool nftInitialized;41}
Recommendation:
We advise the royalties
and nftInitialized
variables to be re-ordered right after an address
member such as owner
to ensure those variables are tight-packed into the same slot.
Alleviation:
The variables were properly reordered to tight pack and thus optimize the codebase.