code-423n4 / 2021-11-nested-findings

1 stars 1 forks source link

Accessing the same storage value multiple times #211

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pauliax

Vulnerability details

Impact

There are places where the same storage variable is accessed multiple times in the same function. It would be more gas efficient to cache these variables and re-use them where necessary. E.g. function createRecord accesses records[_nftId].reserve 2 times in a require statement. function _transferToReserveAndStore accesses "reserve" 4 times. function isResolverCached accesses addressCache[name] 2 times.

Also, can save some gas here if you use local variables instead:

  emit BurnPartUpdated(burnPercentage);
  emit ReserveUpdated(nstReserve);
  emit FeeSplitterUpdated(feeSplitter);
  emit BurnPartUpdated(burnPercentage);

There might be more places where this suggestion can be applied. Consider caching repeated storage access to save some gas.

adrien-supizet commented 2 years ago

duplicate #102