code-423n4 / 2022-02-aave-lens-findings

0 stars 0 forks source link

Gas Optimizations #17

Open code423n4 opened 2 years ago

code423n4 commented 2 years ago
  1. In _createComment function of LensHub.sol#L881, use argument ++_profileById[vars.profileId].pubCount in call to PublishingLogic.createComment and remove the Line LensHub.sol#L887 as _profileById[vars.profileId].pubCount++; is no more required now

  2. In mint function of CollectNFT.sol#L51, there is no need to store incremented value of _tokenIdCounter in local variable. Instead remove CollectNFT.sol#L51 and modify CollectNFT.sol#L52 to _mint(to, ++_tokenIdCounter);

  3. In mint function of FollowNFT.sol#L68, there is no need to store incremented value of _tokenIdCounter in local variable. Instead remove FollowNFT.sol#L68 and modify FollowNFT.sol#L69 to _mint(to, ++_tokenIdCounter);

  4. In collect module contract like LimitedFeeCollectModule.sol, both _processCollectWithReferral and _processCollect can be removed from all the collect module and placed into a single library which all collect modules can utilize

Zer0dot commented 2 years ago
  1. Is invalid because this adds a vulnerability that allows the comment to comment on itself.
  2. This actually increased gas, and anyway it's better for visibility.
  3. Same as 2
  4. Inheritance was already getting quite confusing, although this is valid and a good find! We won't be taking any action here.