sujithsomraaj / lifi-emergency-pause-facet-v1.2.0

1 day review - 1 / 09
0 stars 0 forks source link

Optimize `_isEmergencyPauseFacet` function #6

Open sujithsomraaj opened 2 months ago

sujithsomraaj commented 2 months ago

Context: EmergencyPauseFacet.sol#L159

Description: The _isEmergencyPauseFacet internal function is used to compare if the facet address is equal to the emergency pause facet. The function is used only in a single instance, so it can be optimized to avoid extra memory.

function _getAllFacetFunctionSelectorsToBeRemoved()
  internal
  view
  returns (IDiamondLoupe.Facet[] memory toBeRemoved)
{
...
if (allFacets[i].facetAddress != _emergencyPauseFacetAddress) {
...
}
[PASS] test_DiamondOwnerCanPauseDiamond() (gas: 490820) --> BEFORE OPTIMIZATION
[PASS] test_DiamondOwnerCanPauseDiamond() (gas: 490536) --> AFTER OPTIMIZATION

Recommendation: Optimize code by removing the _isEmergencyPauseFacet.

LI.FI: Fixed in 7ea4c75b2049fbe173b145eed91a7b0b048eb786

Researcher: Confirmed.

0xDEnYO commented 2 months ago

Makes sense. Fix:

https://github.com/lifinance/contracts/commit/7ea4c75b2049fbe173b145eed91a7b0b048eb786